it.geosolutions.tools.io.file
Class MultiPropertyFile
java.lang.Object
it.geosolutions.tools.io.file.MultiPropertyFile
public class MultiPropertyFile
- extends java.lang.Object
Reads a property file, where a single property may be defined more than once.
The internal value representation for a given propertyname will be
- a String if the property was defined once only
- a List of Strings if the property was defined more than once.
Empty lines will not be taken into account.
Lines starting with a '#' will be considered as comments and will not be taken into account.
If the file read procedure fails, the valid properties will still be accessibile.
Before accessing any accessor, the read() method must be called.
- Author:
- ETj (etj at geo-solutions.it)
|
Method Summary |
boolean |
exist(java.lang.String propertyName)
|
java.util.List<java.lang.String> |
getList(java.lang.String propertyName)
|
java.util.Set<java.lang.String> |
getPropertyNames()
|
java.util.Map<java.lang.String,java.lang.Object> |
getRawMap()
|
java.lang.String |
getString(java.lang.String propertyName)
|
java.lang.Object |
getValue(java.lang.String propertyName)
|
boolean |
isMultiValue(java.lang.String propertyName)
|
boolean |
isSingleValue(java.lang.String propertyName)
|
boolean |
read()
Process the file. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MultiPropertyFile
public MultiPropertyFile(java.io.File file)
MultiPropertyFile
public MultiPropertyFile(java.io.InputStream in)
read
public boolean read()
- Process the file.
The return value tells if the processing was successful.
Even in a case of a failed parsing, the valid properties will be accessibile.
At the end of the read procedure the InputStream will be closed.
- Returns:
- true if the parsing was successful.
exist
public boolean exist(java.lang.String propertyName)
throws java.lang.IllegalStateException
- Returns:
- true if the given propertyName is defined
- Throws:
java.lang.IllegalStateException - if read() has not been yet invoked.
isMultiValue
public boolean isMultiValue(java.lang.String propertyName)
throws java.lang.IllegalStateException
- Returns:
- true if the given propertyName is bound to multiple values.
- Throws:
java.lang.IllegalStateException - if read() has not been yet invoked.
isSingleValue
public boolean isSingleValue(java.lang.String propertyName)
throws java.lang.IllegalStateException
- Returns:
- true if the given propertyName is bound to a single value.
- Throws:
java.lang.IllegalStateException - if read() has not been yet invoked.
getValue
public java.lang.Object getValue(java.lang.String propertyName)
throws java.lang.IllegalStateException
- Returns:
- the value for the given propertyName. It may be a String or a List of Strings.
- Throws:
java.lang.IllegalStateException - if read() has not been yet invoked.
getString
public java.lang.String getString(java.lang.String propertyName)
throws java.lang.IllegalStateException,
java.lang.ClassCastException
- Returns:
- the value for the given propertyName, already cast to a String single value.
- Throws:
java.lang.IllegalStateException - if read() has not been yet invoked.
java.lang.ClassCastException - if the propertyis bound to multiple values.
getList
public java.util.List<java.lang.String> getList(java.lang.String propertyName)
throws java.lang.IllegalStateException,
java.lang.ClassCastException
- Returns:
- the value for the given propertyName, already cast to a List of Strings.
- Throws:
java.lang.IllegalStateException - if read() has not been yet invoked.
java.lang.ClassCastException - if the property is bound to a single value.
getPropertyNames
public java.util.Set<java.lang.String> getPropertyNames()
throws java.lang.IllegalStateException
- Returns:
- the Set of the defined properties. The Set is unmodifiable.
- Throws:
java.lang.IllegalStateException - if read() has not been yet invoked.
getRawMap
public java.util.Map<java.lang.String,java.lang.Object> getRawMap()
throws java.lang.IllegalStateException
- Returns:
- the raw property Map. The Map is unmodifiable.
- Throws:
java.lang.IllegalStateException - if read() has not been yet invoked.
Copyright © 2011-2012 GeoSolutions. All Rights Reserved.