public final class PropertiesExtensions extends 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 String[] |
PROPERTIES_DELIMITERS
The Constant PROPERTIES_DELIMITERS contains all valid delimiters for properties files.
|
static String |
SEARCH_FILE_PATTERN
The Constant SEARCH_FILE_PATTERN is a regex for searching java and html files.
|
| Constructor and Description |
|---|
PropertiesExtensions() |
| Modifier and Type | Method and Description |
|---|---|
static void |
export(Properties properties,
OutputStream outputStream)
Exports the given
InputStream that represents a properties file to the given
properties OutputStream that represents the output file. |
static void |
export(Properties properties,
OutputStream outputStream,
InputStream inputStream,
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(Properties properties,
OutputStream outputStream,
String comment)
Exports the given
InputStream that represents a properties file to the given
properties OutputStream that represents the output file. |
static Map<String,List<String>> |
findRedundantValues(Properties properties)
Finds redundant values from the given Properties object and saves it to a Map.
|
static Optional<Integer> |
getInteger(Properties properties,
String propertiesKey)
Try to get a number from the given properties key from the given properties.
|
static Map<String,List<String>> |
getMatchedPrefixLists(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 List<String> |
getPropertyParameters(String propertyValue)
Finds the property parameters from the given propertyValue.
|
static Properties |
loadProperties(File propertiesFile)
Load a Properties-object from the given File-object.
|
static Properties |
loadProperties(File propertiesFile,
boolean loadFromXML)
Load a Properties-object from the given File-object.
|
static List<KeyValuePair<String,String>> |
toKeyValuePairs(Properties properties)
Transforms the given
Properties to a list of KeyValuePair's. |
static void |
toProperties(File properties,
File xml,
String comment)
Converts the given xml file to the given properties file.
|
static void |
toProperties(OutputStream properties,
InputStream xml,
String comment)
Converts the given xml InputStream to the given properties OutputStream.
|
static void |
toProperties(OutputStream outputStream,
InputStream inputStream,
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(OutputStream outputStream,
InputStream inputStream,
String comment)
Converts the given properties InputStream to the given properties
OutputStream that
represents the output file. |
static void |
toXml(File properties,
File xml,
String comment,
String encoding)
Converts the given properties file to the given xml file.
|
static void |
toXml(InputStream properties,
OutputStream xml,
String comment,
String encoding)
Converts the given properties InputStream to the given xml OutputStream.
|
public static final String SEARCH_FILE_PATTERN
public static final String[] PROPERTIES_DELIMITERS
public static Map<String,List<String>> findRedundantValues(Properties properties)
properties - The Properties to check.public static Map<String,List<String>> getMatchedPrefixLists(Properties properties)
properties - the en propertiespublic static List<String> getPropertyParameters(String propertyValue)
propertyValue - the property valuepublic static Properties loadProperties(File propertiesFile) throws IOException
propertiesFile - the properties fileIOException - Signals that an I/O exception has occurred.public static Properties loadProperties(File propertiesFile, boolean loadFromXML) throws IOException
propertiesFile - the properties fileloadFromXML - the load from XMLIOException - Signals that an I/O exception has occurred.public static List<KeyValuePair<String,String>> toKeyValuePairs(Properties properties)
Properties to a list of KeyValuePair's.properties - the propertiesKeyValuePair's.public static void toProperties(File properties, File xml, String comment) throws IOException
properties - the properties file. The xml file does not have to exist.xml - the xml file with the properties to convert.comment - the commentIOException - Signals that an I/O exception has occurred.public static void toProperties(OutputStream properties, InputStream xml, String comment) throws IOException
properties - the properties file. The xml file does not have to exist.xml - the xml file with the properties to convert.comment - the commentIOException - Signals that an I/O exception has occurred.public static void toPropertiesFile(OutputStream outputStream, InputStream inputStream, String comment) throws 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 commentIOException - Signals that an I/O exception has occurred.public static void toProperties(OutputStream outputStream, InputStream inputStream, String comment, boolean xmlFile) throws 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 fileIOException - Signals that an I/O exception has occurred.public static void export(Properties properties, OutputStream outputStream, InputStream inputStream, String comment, boolean loadFromXML, boolean storeToXML) throws 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.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 fileIOException - Signals that an I/O exception has occurred.public static void export(Properties properties, OutputStream outputStream) throws 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.IOException - Signals that an I/O exception has occurred.public static void export(Properties properties, OutputStream outputStream, String comment) throws 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 commentIOException - Signals that an I/O exception has occurred.public static void toXml(File properties, File xml, String comment, String encoding) throws 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.IOException - Signals that an I/O exception has occurred.public static void toXml(InputStream properties, OutputStream xml, String comment, String encoding) throws IOException
properties - the properties InputStream.xml - the xml OutputStream to write in.comment - the commentencoding - the encoding for the xml file.IOException - Signals that an I/O exception has occurred.public static Optional<Integer> getInteger(Properties properties, String propertiesKey)
Optional will be returned and a log message will be logged.properties - the propertiespropertiesKey - the properties keyCopyright © 2015–2018 Alpha Ro Group UG (haftungsbeschrÀngt). All rights reserved.