public final class PropertiesExtensions
extends java.lang.Object
PropertiesExtensions provides methods loading properties and other related
operations for properties like find redundant values or getting all available languages from a
bundle.| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
PROPERTIES_COMMENT_PATTERN
The constant PROPERTIES_COMMENT_PATTERN is the regex pattern for find comments in properties
file
|
static java.lang.String[] |
PROPERTIES_DELIMITERS
The constant PROPERTIES_DELIMITERS contains all valid delimiters for properties files
|
static java.lang.String |
SEARCH_FILE_PATTERN
The constant SEARCH_FILE_PATTERN is a regex for searching java and html files
|
| Modifier and Type | Method and Description |
|---|---|
static void |
export(java.util.Properties properties,
java.io.OutputStream outputStream)
Exports the given
InputStream that represents a properties file to the given
properties OutputStream that represents the output file. |
static void |
export(java.util.Properties properties,
java.io.OutputStream outputStream,
java.io.InputStream inputStream,
java.lang.String comment,
boolean loadFromXML,
boolean storeToXML)
Exports the given
InputStream that represents a properties file to the given
properties OutputStream that represents the output file. |
static void |
export(java.util.Properties properties,
java.io.OutputStream outputStream,
java.lang.String comment)
Exports the given
InputStream that represents a properties file to the given
properties OutputStream that represents the output file. |
static java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
findRedundantValues(java.util.Properties properties)
Finds redundant values from the given Properties object and saves it to a Map.
|
static java.util.Optional<java.lang.Integer> |
getInteger(java.util.Properties properties,
java.lang.String propertiesKey)
Try to get a number from the given properties key from the given properties.
|
static java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getMatchedPrefixLists(java.util.Properties properties)
Finds all keys with the same key prefixes from the given Properties and saves them to a Map
with the prefix as a key and holds a List with the whole keys the starts with the same key
prefix.
|
static java.util.List<java.lang.String> |
getPropertyParameters(java.lang.String propertyValue)
Finds the property parameters from the given propertyValue.
|
static java.util.Properties |
loadProperties(java.io.File propertiesFile)
Load a Properties-object from the given File-object.
|
static java.util.Properties |
loadProperties(java.io.File propertiesFile,
boolean loadFromXML)
Load a Properties-object from the given File-object.
|
static void |
toProperties(java.io.File properties,
java.io.File xml,
java.lang.String comment)
Converts the given xml file to the given properties file.
|
static void |
toProperties(java.io.OutputStream properties,
java.io.InputStream xml,
java.lang.String comment)
Converts the given xml InputStream to the given properties OutputStream.
|
static void |
toProperties(java.io.OutputStream outputStream,
java.io.InputStream inputStream,
java.lang.String comment,
boolean xmlFile)
Exports the given
InputStream that represents a properties file to the given
properties OutputStream that represents the output file. |
static void |
toPropertiesFile(java.io.OutputStream outputStream,
java.io.InputStream inputStream,
java.lang.String comment)
Converts the given properties InputStream to the given properties
OutputStream that
represents the output file. |
static void |
toXml(java.io.File properties,
java.io.File xml,
java.lang.String comment,
java.lang.String encoding)
Converts the given properties file to the given xml file.
|
static void |
toXml(java.io.InputStream properties,
java.io.OutputStream xml,
java.lang.String comment,
java.lang.String encoding)
Converts the given properties InputStream to the given xml OutputStream.
|
public static final java.lang.String PROPERTIES_COMMENT_PATTERN
public static final java.lang.String[] PROPERTIES_DELIMITERS
public static final java.lang.String SEARCH_FILE_PATTERN
public static void export(java.util.Properties properties,
java.io.OutputStream outputStream)
throws java.io.IOException
InputStream that represents a properties file to the given
properties OutputStream that represents the output file. The flag xmlFile tells if
the output shell be an xml file or a properties file.properties - the properties to storeoutputStream - the stream from the output properties file. If the file does not exists a new file
will be created.java.io.IOException - Signals that an I/O exception has occurred.public static void export(java.util.Properties properties,
java.io.OutputStream outputStream,
java.io.InputStream inputStream,
java.lang.String comment,
boolean loadFromXML,
boolean storeToXML)
throws java.io.IOException
InputStream that represents a properties file to the given
properties OutputStream that represents the output file.properties - the properties to storeoutputStream - the stream from the output properties file. If the file does not exists a new file
will be created.inputStream - the input streamcomment - the commentloadFromXML - the flag that tells if the input shell be loaded from a XML file if true otherwise
it will be loaded from a properties filestoreToXML - the flag that tells if the output shell be stored to a XML file if true otherwise
it will be stored to a properties filejava.io.IOException - Signals that an I/O exception has occurred.public static void export(java.util.Properties properties,
java.io.OutputStream outputStream,
java.lang.String comment)
throws java.io.IOException
InputStream that represents a properties file to the given
properties OutputStream that represents the output file. The flag xmlFile tells if
the output shell be an xml file or a properties file.properties - the properties to storeoutputStream - the stream from the output properties file. If the file does not exists a new file
will be created.comment - the commentjava.io.IOException - Signals that an I/O exception has occurred.public static java.util.Map<java.lang.String,java.util.List<java.lang.String>> findRedundantValues(java.util.Properties properties)
properties - The Properties to check.public static java.util.Optional<java.lang.Integer> getInteger(java.util.Properties properties,
java.lang.String propertiesKey)
Optional will be returned and a log message will be logged.properties - the propertiespropertiesKey - the properties keypublic static java.util.Map<java.lang.String,java.util.List<java.lang.String>> getMatchedPrefixLists(java.util.Properties properties)
properties - the en propertiespublic static java.util.List<java.lang.String> getPropertyParameters(java.lang.String propertyValue)
propertyValue - the property valuepublic static java.util.Properties loadProperties(java.io.File propertiesFile)
throws java.io.IOException
propertiesFile - the properties filejava.io.IOException - Signals that an I/O exception has occurred.public static java.util.Properties loadProperties(java.io.File propertiesFile,
boolean loadFromXML)
throws java.io.IOException
propertiesFile - the properties fileloadFromXML - the load from XMLjava.io.IOException - Signals that an I/O exception has occurred.public static void toProperties(java.io.File properties,
java.io.File xml,
java.lang.String comment)
throws java.io.IOException
properties - the properties file. The xml file does not have to exist.xml - the xml file with the properties to convert.comment - the commentjava.io.IOException - Signals that an I/O exception has occurred.public static void toProperties(java.io.OutputStream properties,
java.io.InputStream xml,
java.lang.String comment)
throws java.io.IOException
properties - the properties file. The xml file does not have to exist.xml - the xml file with the properties to convert.comment - the commentjava.io.IOException - Signals that an I/O exception has occurred.public static void toProperties(java.io.OutputStream outputStream,
java.io.InputStream inputStream,
java.lang.String comment,
boolean xmlFile)
throws java.io.IOException
InputStream that represents a properties file to the given
properties OutputStream that represents the output file. The flag xmlFile tells if
the output shell be an xml file or a properties file.outputStream - the stream from the output properties file. If the file does not exists a new file
will be created.inputStream - the stream from input file with the properties to convertcomment - the commentxmlFile - the flag that tells if the output shell be an xml file if true otherwise it will
be an properties filejava.io.IOException - Signals that an I/O exception has occurred.public static void toPropertiesFile(java.io.OutputStream outputStream,
java.io.InputStream inputStream,
java.lang.String comment)
throws java.io.IOException
OutputStream that
represents the output file.outputStream - the properties file. The xml file does not have to exist.inputStream - the xml file with the properties to convert.comment - the commentjava.io.IOException - Signals that an I/O exception has occurred.public static void toXml(java.io.File properties,
java.io.File xml,
java.lang.String comment,
java.lang.String encoding)
throws java.io.IOException
properties - the properties file.xml - the xml file to write in. The xml file does not have to exist.comment - the commentencoding - the encoding for the xml file.java.io.IOException - Signals that an I/O exception has occurred.public static void toXml(java.io.InputStream properties,
java.io.OutputStream xml,
java.lang.String comment,
java.lang.String encoding)
throws java.io.IOException
properties - the properties InputStream.xml - the xml OutputStream to write in.comment - the commentencoding - the encoding for the xml file.java.io.IOException - Signals that an I/O exception has occurred.