Class PropertiesHelper
- java.lang.Object
-
- org.jabylon.properties.types.impl.PropertiesHelper
-
- All Implemented Interfaces:
PropertyConverter
public class PropertiesHelper extends Object implements PropertyConverter
- Author:
- joe
-
-
Constructor Summary
Constructors Constructor Description PropertiesHelper()PropertiesHelper(boolean unicodeEscaping)PropertiesHelper(boolean unicodeEscaping, org.eclipse.emf.common.util.URI uri)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static org.eclipse.emf.ecore.resource.ContentHandler.ByteOrderMarkcheckForBom(InputStream inputStream)returns the BOM if available.protected StringderiveEncoding(org.eclipse.emf.ecore.resource.ContentHandler.ByteOrderMark bom)StringgetLicenseHeader()protected booleanisComment(String line)protected booleanisFilled(Property property)booleanisUnicodeEscaping()PropertyFileload(InputStream in, String encoding)loads the given input stream and transform it into aPropertyFileprotected StringparseComment(String line)extracts the comment from the given linePropertyreadProperty(BufferedReader reader)protected String[]split(String propertyValue)splits the property line into a key and value partintwrite(OutputStream out, PropertyFile file, String encoding)serializes the givenPropertyFileinto the output steamprotected voidwriteComment(Writer writer, String comment)protected voidwriteCommentAndAnnotations(Writer writer, Property property)voidwriteLicenseHeader(Writer writer, String licenseHeader)voidwriteProperty(Writer writer, Property property)
-
-
-
Constructor Detail
-
PropertiesHelper
public PropertiesHelper()
-
PropertiesHelper
public PropertiesHelper(boolean unicodeEscaping)
-
PropertiesHelper
public PropertiesHelper(boolean unicodeEscaping, org.eclipse.emf.common.util.URI uri)- Parameters:
unicodeEscaping-uri- can be used to log the path of invalid files if supplied
-
-
Method Detail
-
readProperty
public Property readProperty(BufferedReader reader) throws IOException
- Throws:
IOException
-
parseComment
protected String parseComment(String line)
extracts the comment from the given line- Parameters:
line-- Returns:
- the comment content
-
split
protected String[] split(String propertyValue)
splits the property line into a key and value part- Parameters:
propertyValue-- Returns:
-
isComment
protected boolean isComment(String line)
-
writeProperty
public void writeProperty(Writer writer, Property property) throws IOException
- Throws:
IOException
-
writeCommentAndAnnotations
protected void writeCommentAndAnnotations(Writer writer, Property property) throws IOException
- Throws:
IOException
-
writeComment
protected void writeComment(Writer writer, String comment) throws IOException
- Throws:
IOException
-
checkForBom
public static org.eclipse.emf.ecore.resource.ContentHandler.ByteOrderMark checkForBom(InputStream inputStream) throws IOException
returns the BOM if available. If no BOM was found the stream is reset to its original state- Parameters:
inputStream- must support mark/rest, or an IllegalArgumentException is thrown- Returns:
- Throws:
IOException
-
getLicenseHeader
public String getLicenseHeader()
-
writeLicenseHeader
public void writeLicenseHeader(Writer writer, String licenseHeader) throws IOException
- Throws:
IOException
-
write
public int write(OutputStream out, PropertyFile file, String encoding) throws IOException
Description copied from interface:PropertyConverterserializes the givenPropertyFileinto the output steamThe implementation is expected to close the stream upon completion
The implementation is free to optimize the output by removing empty translations.
- Specified by:
writein interfacePropertyConverterencoding- hint about which encoding to use- Returns:
- number of translated (non-empty) keys
- Throws:
IOException
-
isFilled
protected boolean isFilled(Property property)
-
load
public PropertyFile load(InputStream in, String encoding) throws IOException
Description copied from interface:PropertyConverterloads the given input stream and transform it into aPropertyFileThe implementation is expected to close the stream upon completion
- Specified by:
loadin interfacePropertyConverterencoding- hint about which encoding to use- Returns:
- Throws:
IOException
-
deriveEncoding
protected String deriveEncoding(org.eclipse.emf.ecore.resource.ContentHandler.ByteOrderMark bom)
-
isUnicodeEscaping
public boolean isUnicodeEscaping()
-
-