Class AbstractPropertiesFileEditor<T>

java.lang.Object
com.e1c.langtool.storage.properties.AbstractPropertiesFileEditor<T>
Type Parameters:
T - the type of data model
All Implemented Interfaces:
IFileEditor<T>
Direct Known Subclasses:
PropertiesContextFileEditor, PropertiesDictionaryFileEditor

public abstract class AbstractPropertiesFileEditor<T> extends Object implements IFileEditor<T>
The abstract file editor for JAVA-properties file format.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
     
    protected final org.eclipse.core.resources.IFile
     
    protected static final String
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractPropertiesFileEditor(org.eclipse.core.resources.IFile file)
    Instantiates a new abstract properties file editor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Delete storage file, associated with this object.
    org.eclipse.core.resources.IFile
    Gets the file that was loaded.
    boolean
    Checks if the file is dirty.
    void
    Load from the resource file.
    void
    load(Reader reader)
     
    protected String
    loadConvert(char[] in, int off, int len, char[] convtBuf)
     
    protected abstract void
    loadInternal(com.e1c.langtool.storage.properties.LineReader lr)
    Load content form line reader.
    void
    Mark the file as dirty.
    byte[]
    save(com.google.common.hash.HashFunction hashFunction, org.eclipse.core.runtime.IProgressMonitor monitor)
    Store translations to the file.
    void
    save(org.eclipse.core.runtime.IProgressMonitor monitor)
    Store translations to the file.
    protected String
    saveConvert(String theString, boolean escapeSpaceAndDot)
    Convert string on saving to the file.
    void
    Store to output stream.
    void
    store(Writer writer)
     
    protected abstract void
    storeInternal(BufferedWriter bw, boolean escUnicode)
    Store data to buffer writer.
    protected static void
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.e1c.langtool.storage.IFileEditor

    getData, isEmpty
  • Field Details

    • FILE_COMMENT_PREFIX

      protected static final String FILE_COMMENT_PREFIX
      See Also:
    • file

      protected final org.eclipse.core.resources.IFile file
    • dirty

      protected volatile boolean dirty
  • Constructor Details

    • AbstractPropertiesFileEditor

      protected AbstractPropertiesFileEditor(org.eclipse.core.resources.IFile file)
      Instantiates a new abstract properties file editor.
      Parameters:
      file - the file, cannot be null.
  • Method Details

    • getFile

      public org.eclipse.core.resources.IFile getFile()
      Description copied from interface: IFileEditor
      Gets the file that was loaded.
      Specified by:
      getFile in interface IFileEditor<T>
      Returns:
      the file
    • delete

      public void delete()
      Description copied from interface: IFileEditor
      Delete storage file, associated with this object.
      Specified by:
      delete in interface IFileEditor<T>
    • isDirty

      public boolean isDirty()
      Description copied from interface: IFileEditor
      Checks if the file is dirty.
      Specified by:
      isDirty in interface IFileEditor<T>
      Returns:
      the boolean
    • markDirty

      public void markDirty()
      Description copied from interface: IFileEditor
      Mark the file as dirty.
      Specified by:
      markDirty in interface IFileEditor<T>
    • save

      public byte[] save(com.google.common.hash.HashFunction hashFunction, org.eclipse.core.runtime.IProgressMonitor monitor) throws IOException
      Description copied from interface: IFileEditor
      Store translations to the file.
      Specified by:
      save in interface IFileEditor<T>
      monitor - the monitor
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • save

      public void save(org.eclipse.core.runtime.IProgressMonitor monitor) throws IOException
      Description copied from interface: IFileEditor
      Store translations to the file.
      Specified by:
      save in interface IFileEditor<T>
      Parameters:
      monitor - the monitor
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • store

      public void store(Writer writer) throws IOException
      Throws:
      IOException
    • storeInternal

      protected abstract void storeInternal(BufferedWriter bw, boolean escUnicode) throws IOException
      Store data to buffer writer.
      Parameters:
      bw - the buffer writer
      escUnicode - the escape unicode symbols
      Throws:
      IOException - Signals that an I/O exception has occurred.
      See Also:
    • store

      public void store(OutputStream out) throws IOException
      Store to output stream.
      Parameters:
      out - the output stream
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • load

      public void load()
      Description copied from interface: IFileEditor
      Load from the resource file.
      Specified by:
      load in interface IFileEditor<T>
    • load

      public void load(Reader reader) throws IOException
      Throws:
      IOException
    • loadInternal

      protected abstract void loadInternal(com.e1c.langtool.storage.properties.LineReader lr) throws IOException
      Load content form line reader.
      Parameters:
      lr - the line reader
      Throws:
      IOException - Signals that an I/O exception has occurred.
      See Also:
    • loadConvert

      protected String loadConvert(char[] in, int off, int len, char[] convtBuf)
    • saveConvert

      protected String saveConvert(String theString, boolean escapeSpaceAndDot)
      Convert string on saving to the file.
      Parameters:
      theString - the the string to convert
      escapeSpaceAndDot - the escape space and dot
      Returns:
      the converted string
    • writeComments

      protected static void writeComments(BufferedWriter bw, String comments) throws IOException
      Throws:
      IOException