Class BundleFile<FILE,EX extends Exception>

java.lang.Object
de.codecamp.messages.shared.bundle.BundleFile<FILE,EX>
Type Parameters:
FILE - the file reference
EX - the exception type
All Implemented Interfaces:
Comparable<BundleFile<FILE,EX>>

public class BundleFile<FILE,EX extends Exception> extends Object implements Comparable<BundleFile<FILE,EX>>
Represents one file (i.e. one locale) of a message bundle.
  • Constructor Details

  • Method Details

    • getLocation

      public FILE getLocation()
    • getDisplayPath

      public String getDisplayPath()
    • getBundleName

      public String getBundleName()
    • getLocale

      public Locale getLocale()
    • isReadOnly

      public boolean isReadOnly()
    • isEmpty

      public boolean isEmpty()
    • getKeys

      public Set<String> getKeys()
    • hasMessageKey

      public boolean hasMessageKey(String messageKey)
    • isMessageEmpty

      public boolean isMessageEmpty(String messageKey)
    • hasMessage

      public boolean hasMessage(String messageKey)
    • getMessage

      public String getMessage(String messageKey)
    • setMessage

      public void setMessage(String messageKey, String message)
    • removeMessage

      public String removeMessage(String messageKey)
    • getComment

      public String getComment(String messageKey)
    • setComment

      public void setComment(String messageKey, String comment)
    • findLineNumberOfKey

      public Integer findLineNumberOfKey(String messageKey)
      Finds the line number of the given message key in the bundle file.
      Parameters:
      messageKey - the message key
      Returns:
      the line number or null
      Throws:
      BundleException - an error during bundle operations
    • findLineNumberOfKeys

      public Map<String,Integer> findLineNumberOfKeys(Collection<String> messageKeys)
      Finds the line numbers of the given message keys in the bundle file.
      Parameters:
      messageKeys - the message keys
      Returns:
      the line number per message key
      Throws:
      BundleException - an error during bundle operations
    • exists

      public boolean exists()
    • needsSaving

      public boolean needsSaving()
    • needsSorting

      public boolean needsSorting()
    • save

      public boolean save()
      Saves the bundle file, if there are unsaved changes.
      Returns:
      whether the file was saved
      Throws:
      BundleException - an error during bundle operations
    • save

      public boolean save(boolean force)
      Saves the bundle file.
      Parameters:
      force - whether to save even without unsaved changes
      Returns:
      whether the file was saved
      Throws:
      BundleException - an error during bundle operations
    • ensureLoaded

      protected void ensureLoaded()
      Ensures that the file has been loaded.
      Throws:
      BundleException - an error during bundle operations
    • delete

      public void delete()
      Deletes the bundle file.
      Throws:
      BundleException - an error during bundle operations
    • compareTo

      public int compareTo(BundleFile<FILE,EX> o)
      Specified by:
      compareTo in interface Comparable<FILE>