it.geosolutions.tools.io.file
Class MultiPropertyFile
java.lang.Object
it.geosolutions.tools.io.file.MultiPropertyFile
public class MultiPropertyFile
- extends 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)
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MultiPropertyFile
public MultiPropertyFile(File file)
MultiPropertyFile
public MultiPropertyFile(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(String propertyName)
throws IllegalStateException
- Returns:
- true if the given propertyName is defined
- Throws:
IllegalStateException
- if read()
has not been yet invoked.
isMultiValue
public boolean isMultiValue(String propertyName)
throws IllegalStateException
- Returns:
- true if the given propertyName is bound to multiple values.
- Throws:
IllegalStateException
- if read()
has not been yet invoked.
isSingleValue
public boolean isSingleValue(String propertyName)
throws IllegalStateException
- Returns:
- true if the given propertyName is bound to a single value.
- Throws:
IllegalStateException
- if read()
has not been yet invoked.
getValue
public Object getValue(String propertyName)
throws IllegalStateException
- Returns:
- the value for the given propertyName. It may be a String or a List of Strings.
- Throws:
IllegalStateException
- if read()
has not been yet invoked.
getString
public String getString(String propertyName)
throws IllegalStateException,
ClassCastException
- Returns:
- the value for the given propertyName, already cast to a String single value.
- Throws:
IllegalStateException
- if read()
has not been yet invoked.
ClassCastException
- if the propertyis bound to multiple values.
getList
public List<String> getList(String propertyName)
throws IllegalStateException,
ClassCastException
- Returns:
- the value for the given propertyName, already cast to a List of Strings.
- Throws:
IllegalStateException
- if read()
has not been yet invoked.
ClassCastException
- if the property is bound to a single value.
getPropertyNames
public Set<String> getPropertyNames()
throws IllegalStateException
- Returns:
- the Set of the defined properties. The Set is unmodifiable.
- Throws:
IllegalStateException
- if read()
has not been yet invoked.
getRawMap
public Map<String,Object> getRawMap()
throws IllegalStateException
- Returns:
- the raw property Map. The Map is unmodifiable.
- Throws:
IllegalStateException
- if read()
has not been yet invoked.
Copyright © 2011-2012 GeoSolutions. All Rights Reserved.