Java Doc for ExtendedProperties.java in  » Library » Apache-common-Collections » org » apache » commons » collections » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Library » Apache common Collections » org.apache.commons.collections 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.util.Hashtable
   org.apache.commons.collections.ExtendedProperties

ExtendedProperties
public class ExtendedProperties extends Hashtable (Code)
This class extends normal Java properties by adding the possibility to use the same key many times concatenating the value strings instead of overwriting them.

Please consider using the PropertiesConfiguration class in Commons-Configuration as soon as it is released.

The Extended Properties syntax is explained here:

  • Each property has the syntax key = value
  • The key may use any character but the equal sign '='.
  • value may be separated on different lines if a backslash is placed at the end of the line that continues below.
  • If value is a list of strings, each token is separated by a comma ','.
  • Commas in each token are escaped placing a backslash right before the comma.
  • Backslashes are escaped by using two consecutive backslashes i.e. \\
  • If a key is used more than once, the values are appended as if they were on the same line separated with commas.
  • Blank lines and lines starting with character '#' are skipped.
  • If a property is named "include" (or whatever is defined by setInclude() and getInclude() and the value of that property is the full path to a file on disk, that file will be included into the ConfigurationsRepository. You can also pull in files relative to the parent configuration file. So if you have something like the following: include = additional.properties Then "additional.properties" is expected to be in the same directory as the parent configuration file. Duplicate name values will be replaced, so be careful.

Here is an example of a valid extended properties file:

 # lines starting with # are comments
 # This is the simplest property
 key = value
 # A long property may be separated on multiple lines
 longvalue = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \
 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 # This is a property with many tokens
 tokens_on_a_line = first token, second token
 # This sequence generates exactly the same result
 tokens_on_multiple_lines = first token
 tokens_on_multiple_lines = second token
 # commas may be escaped in tokens
 commas.escaped = Hi\, what'up?
 

NOTE: this class has not been written for performance nor low memory usage. In fact, it's way slower than it could be and generates too much memory garbage. But since performance is not an issue during intialization (and there is not much time to improve it), I wrote it this way. If you don't like it, go ahead and tune it up!
since:
   Commons Collections 1.0
version:
   $Revision: 405927 $ $Date: 2006-05-12 23:57:03 +0100 (Fri, 12 May 2006) $
author:
   Stefano Mazzocchi
author:
   Jon S. Stevens
author:
   Dave Bryson
author:
   Jason van Zyl
author:
   Geir Magnusson Jr.
author:
   Leon Messerschmidt
author:
   Kent Johnson
author:
   Daniel Rall
author:
   Ilkka Priha
author:
   Janek Bogucki
author:
   Mohan Kishore
author:
   Stephen Colebourne
author:
   Shinobu Kawai
author:
   Henning P. Schmiedehausen


Inner Class :static class PropertiesReader extends LineNumberReader
Inner Class :static class PropertiesTokenizer extends StringTokenizer

Field Summary
final protected static  StringEND_TOKEN
    
final protected static  StringSTART_TOKEN
    
protected  StringbasePath
     Base path of the configuration file used to create this ExtendedProperties object.
protected  Stringfile
     The file connected to this repository (holding comments and such).
protected  StringfileSeparator
     File separator.
protected static  Stringinclude
     This is the name of the property that can point to other properties file for including other properties files.
protected  booleanisInitialized
     Has this configuration been intialized.
protected  ArrayListkeysAsListed
     These are the keys in the order they listed in the configuration file.

Constructor Summary
public  ExtendedProperties()
     Creates an empty extended properties object.
public  ExtendedProperties(String file)
     Creates and loads the extended properties from the specified file.
public  ExtendedProperties(String file, String defaultFile)
     Creates and loads the extended properties from the specified file.

Method Summary
public  voidaddProperty(String key, Object value)
     Add a property to the configuration.
public  voidclearProperty(String key)
     Clear a property in the configuration.
public  voidcombine(ExtendedProperties props)
     Combines an existing Hashtable with this Hashtable.
public static  ExtendedPropertiesconvertProperties(Properties props)
     Convert a standard properties class into a configuration class.
public  voiddisplay()
     Display the configuration for debugging purposes to System.out.
public  booleangetBoolean(String key)
     Get a boolean associated with the given configuration key.
Parameters:
  key - The configuration key.
public  booleangetBoolean(String key, boolean defaultValue)
     Get a boolean associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
public  BooleangetBoolean(String key, Boolean defaultValue)
     Get a boolean associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
public  bytegetByte(String key)
     Get a byte associated with the given configuration key.
Parameters:
  key - The configuration key.
public  bytegetByte(String key, byte defaultValue)
     Get a byte associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
public  BytegetByte(String key, Byte defaultValue)
     Get a byte associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
public  doublegetDouble(String key)
     Get a double associated with the given configuration key.
Parameters:
  key - The configuration key.
public  doublegetDouble(String key, double defaultValue)
     Get a double associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
public  DoublegetDouble(String key, Double defaultValue)
     Get a double associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
public  floatgetFloat(String key)
     Get a float associated with the given configuration key.
Parameters:
  key - The configuration key.
public  floatgetFloat(String key, float defaultValue)
     Get a float associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
public  FloatgetFloat(String key, Float defaultValue)
     Get a float associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
public  StringgetInclude()
     Gets the property value for including other properties files.
public  intgetInt(String name)
     The purpose of this method is to get the configuration resource with the given name as an integer.
Parameters:
  name - The resource name.
public  intgetInt(String name, int def)
     The purpose of this method is to get the configuration resource with the given name as an integer, or a default value.
Parameters:
  name - The resource name
Parameters:
  def - The default value of the resource.
public  intgetInteger(String key)
     Get a int associated with the given configuration key.
Parameters:
  key - The configuration key.
public  intgetInteger(String key, int defaultValue)
     Get a int associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
public  IntegergetInteger(String key, Integer defaultValue)
     Get a int associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
public  IteratorgetKeys()
     Get the list of the keys contained in the configuration repository.
public  IteratorgetKeys(String prefix)
     Get the list of the keys contained in the configuration repository that match the specified prefix.
public  ListgetList(String key)
     Get a List of strings associated with the given configuration key.

The list is a copy of the internal data of this object, and as such you may alter it freely.
Parameters:
  key - The configuration key.

public  ListgetList(String key, List defaultValue)
     Get a List of strings associated with the given configuration key.

The list is a copy of the internal data of this object, and as such you may alter it freely.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.

public  longgetLong(String key)
     Get a long associated with the given configuration key.
Parameters:
  key - The configuration key.
public  longgetLong(String key, long defaultValue)
     Get a long associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
public  LonggetLong(String key, Long defaultValue)
     Get a long associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
public  PropertiesgetProperties(String key)
     Get a list of properties associated with the given configuration key.
Parameters:
  key - The configuration key.
public  PropertiesgetProperties(String key, Properties defaults)
     Get a list of properties associated with the given configuration key.
Parameters:
  key - The configuration key.
public  ObjectgetProperty(String key)
     Gets a property from the configuration.
Parameters:
  key - property to retrieve value as object.
public  shortgetShort(String key)
     Get a short associated with the given configuration key.
Parameters:
  key - The configuration key.
public  shortgetShort(String key, short defaultValue)
     Get a short associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
public  ShortgetShort(String key, Short defaultValue)
     Get a short associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
public  StringgetString(String key)
     Get a string associated with the given configuration key.
Parameters:
  key - The configuration key.
public  StringgetString(String key, String defaultValue)
     Get a string associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.
public  String[]getStringArray(String key)
     Get an array of strings associated with the given configuration key.
Parameters:
  key - The configuration key.
public  VectorgetVector(String key)
     Get a Vector of strings associated with the given configuration key.
Parameters:
  key - The configuration key.
public  VectorgetVector(String key, Vector defaultValue)
     Get a Vector of strings associated with the given configuration key.

The list is a copy of the internal data of this object, and as such you may alter it freely.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value.

protected  Stringinterpolate(String base)
    
protected  StringinterpolateHelper(String base, List priorVariables)
     Recursive handler for multiple levels of interpolation. When called the first time, priorVariables should be null.
Parameters:
  base - string with the ${key} variables
Parameters:
  priorVariables - serves two purposes: to allow checking forloops, and creating a meaningful exception message should a loopoccur.
public  booleanisInitialized()
     Indicate to client code whether property resources have been initialized or not.
public  voidload(InputStream input)
     Load the properties from the given input stream.
public synchronized  voidload(InputStream input, String enc)
     Load the properties from the given input stream and using the specified encoding.
public synchronized  voidsave(OutputStream output, String header)
     Save the properties to the given output stream.
public  voidsetInclude(String inc)
     Sets the property value for including other properties files.
public  voidsetProperty(String key, Object value)
     Set a property, this will replace any previously set values.
public  ExtendedPropertiessubset(String prefix)
     Create an ExtendedProperties object that is a subset of this one.
public  StringtestBoolean(String value)
     Test whether the string represent by value maps to a boolean value or not.

Field Detail
END_TOKEN
final protected static String END_TOKEN(Code)



START_TOKEN
final protected static String START_TOKEN(Code)



basePath
protected String basePath(Code)
Base path of the configuration file used to create this ExtendedProperties object.



file
protected String file(Code)
The file connected to this repository (holding comments and such).



fileSeparator
protected String fileSeparator(Code)
File separator.



include
protected static String include(Code)
This is the name of the property that can point to other properties file for including other properties files.



isInitialized
protected boolean isInitialized(Code)
Has this configuration been intialized.



keysAsListed
protected ArrayList keysAsListed(Code)
These are the keys in the order they listed in the configuration file. This is useful when you wish to perform operations with configuration information in a particular order.




Constructor Detail
ExtendedProperties
public ExtendedProperties()(Code)
Creates an empty extended properties object.



ExtendedProperties
public ExtendedProperties(String file) throws IOException(Code)
Creates and loads the extended properties from the specified file.
Parameters:
  file - the filename to load
throws:
  IOException - if a file error occurs



ExtendedProperties
public ExtendedProperties(String file, String defaultFile) throws IOException(Code)
Creates and loads the extended properties from the specified file.
Parameters:
  file - the filename to load
Parameters:
  defaultFile - a second filename to load default values from
throws:
  IOException - if a file error occurs




Method Detail
addProperty
public void addProperty(String key, Object value)(Code)
Add a property to the configuration. If it already exists then the value stated here will be added to the configuration entry. For example, if resource.loader = file is already present in the configuration and you addProperty("resource.loader", "classpath") Then you will end up with a Vector like the following: ["file", "classpath"]
Parameters:
  key - the key to add
Parameters:
  value - the value to add



clearProperty
public void clearProperty(String key)(Code)
Clear a property in the configuration.
Parameters:
  key - the property key to remove along with corresponding value



combine
public void combine(ExtendedProperties props)(Code)
Combines an existing Hashtable with this Hashtable.

Warning: It will overwrite previous entries without warning.
Parameters:
  props - the properties to combine




convertProperties
public static ExtendedProperties convertProperties(Properties props)(Code)
Convert a standard properties class into a configuration class.

NOTE: From Commons Collections 3.2 this method will pick up any default parent Properties of the specified input object.
Parameters:
  props - the properties object to convert new ExtendedProperties created from props




display
public void display()(Code)
Display the configuration for debugging purposes to System.out.



getBoolean
public boolean getBoolean(String key)(Code)
Get a boolean associated with the given configuration key.
Parameters:
  key - The configuration key. The associated boolean.
throws:
  NoSuchElementException - is thrown if the key doesn'tmap to an existing object.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a Boolean.



getBoolean
public boolean getBoolean(String key, boolean defaultValue)(Code)
Get a boolean associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated boolean.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a Boolean.



getBoolean
public Boolean getBoolean(String key, Boolean defaultValue)(Code)
Get a boolean associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated boolean if key is found and has validformat, default value otherwise.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a Boolean.



getByte
public byte getByte(String key)(Code)
Get a byte associated with the given configuration key.
Parameters:
  key - The configuration key. The associated byte.
throws:
  NoSuchElementException - is thrown if the key doesn'tmap to an existing object.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a Byte.
throws:
  NumberFormatException - is thrown if the value mappedby the key has not a valid number format.



getByte
public byte getByte(String key, byte defaultValue)(Code)
Get a byte associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated byte.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a Byte.
throws:
  NumberFormatException - is thrown if the value mappedby the key has not a valid number format.



getByte
public Byte getByte(String key, Byte defaultValue)(Code)
Get a byte associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated byte if key is found and has validformat, default value otherwise.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a Byte.
throws:
  NumberFormatException - is thrown if the value mappedby the key has not a valid number format.



getDouble
public double getDouble(String key)(Code)
Get a double associated with the given configuration key.
Parameters:
  key - The configuration key. The associated double.
throws:
  NoSuchElementException - is thrown if the key doesn'tmap to an existing object.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a Double.
throws:
  NumberFormatException - is thrown if the value mappedby the key has not a valid number format.



getDouble
public double getDouble(String key, double defaultValue)(Code)
Get a double associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated double.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a Double.
throws:
  NumberFormatException - is thrown if the value mappedby the key has not a valid number format.



getDouble
public Double getDouble(String key, Double defaultValue)(Code)
Get a double associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated double if key is found and has validformat, default value otherwise.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a Double.
throws:
  NumberFormatException - is thrown if the value mappedby the key has not a valid number format.



getFloat
public float getFloat(String key)(Code)
Get a float associated with the given configuration key.
Parameters:
  key - The configuration key. The associated float.
throws:
  NoSuchElementException - is thrown if the key doesn'tmap to an existing object.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a Float.
throws:
  NumberFormatException - is thrown if the value mappedby the key has not a valid number format.



getFloat
public float getFloat(String key, float defaultValue)(Code)
Get a float associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated float.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a Float.
throws:
  NumberFormatException - is thrown if the value mappedby the key has not a valid number format.



getFloat
public Float getFloat(String key, Float defaultValue)(Code)
Get a float associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated float if key is found and has validformat, default value otherwise.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a Float.
throws:
  NumberFormatException - is thrown if the value mappedby the key has not a valid number format.



getInclude
public String getInclude()(Code)
Gets the property value for including other properties files. By default it is "include". A String.



getInt
public int getInt(String name)(Code)
The purpose of this method is to get the configuration resource with the given name as an integer.
Parameters:
  name - The resource name. The value of the resource as an integer.



getInt
public int getInt(String name, int def)(Code)
The purpose of this method is to get the configuration resource with the given name as an integer, or a default value.
Parameters:
  name - The resource name
Parameters:
  def - The default value of the resource. The value of the resource as an integer.



getInteger
public int getInteger(String key)(Code)
Get a int associated with the given configuration key.
Parameters:
  key - The configuration key. The associated int.
throws:
  NoSuchElementException - is thrown if the key doesn'tmap to an existing object.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a Integer.
throws:
  NumberFormatException - is thrown if the value mappedby the key has not a valid number format.



getInteger
public int getInteger(String key, int defaultValue)(Code)
Get a int associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated int.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a Integer.
throws:
  NumberFormatException - is thrown if the value mappedby the key has not a valid number format.



getInteger
public Integer getInteger(String key, Integer defaultValue)(Code)
Get a int associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated int if key is found and has validformat, default value otherwise.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a Integer.
throws:
  NumberFormatException - is thrown if the value mappedby the key has not a valid number format.



getKeys
public Iterator getKeys()(Code)
Get the list of the keys contained in the configuration repository. an Iterator over the keys



getKeys
public Iterator getKeys(String prefix)(Code)
Get the list of the keys contained in the configuration repository that match the specified prefix.
Parameters:
  prefix - the prefix to match an Iterator of keys that match the prefix



getList
public List getList(String key)(Code)
Get a List of strings associated with the given configuration key.

The list is a copy of the internal data of this object, and as such you may alter it freely.
Parameters:
  key - The configuration key. The associated List object.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a List.
since:
   Commons Collections 3.2




getList
public List getList(String key, List defaultValue)(Code)
Get a List of strings associated with the given configuration key.

The list is a copy of the internal data of this object, and as such you may alter it freely.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated List.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a List.
since:
   Commons Collections 3.2




getLong
public long getLong(String key)(Code)
Get a long associated with the given configuration key.
Parameters:
  key - The configuration key. The associated long.
throws:
  NoSuchElementException - is thrown if the key doesn'tmap to an existing object.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a Long.
throws:
  NumberFormatException - is thrown if the value mappedby the key has not a valid number format.



getLong
public long getLong(String key, long defaultValue)(Code)
Get a long associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated long.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a Long.
throws:
  NumberFormatException - is thrown if the value mappedby the key has not a valid number format.



getLong
public Long getLong(String key, Long defaultValue)(Code)
Get a long associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated long if key is found and has validformat, default value otherwise.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a Long.
throws:
  NumberFormatException - is thrown if the value mappedby the key has not a valid number format.



getProperties
public Properties getProperties(String key)(Code)
Get a list of properties associated with the given configuration key.
Parameters:
  key - The configuration key. The associated properties if key is found.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a String/List.
throws:
  IllegalArgumentException - if one of the tokens ismalformed (does not contain an equals sign).



getProperties
public Properties getProperties(String key, Properties defaults)(Code)
Get a list of properties associated with the given configuration key.
Parameters:
  key - The configuration key. The associated properties if key is found.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a String/List.
throws:
  IllegalArgumentException - if one of the tokens ismalformed (does not contain an equals sign).



getProperty
public Object getProperty(String key)(Code)
Gets a property from the configuration.
Parameters:
  key - property to retrieve value as object. Will return user value if exists,if not then default value if exists, otherwise null



getShort
public short getShort(String key)(Code)
Get a short associated with the given configuration key.
Parameters:
  key - The configuration key. The associated short.
throws:
  NoSuchElementException - is thrown if the key doesn'tmap to an existing object.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a Short.
throws:
  NumberFormatException - is thrown if the value mappedby the key has not a valid number format.



getShort
public short getShort(String key, short defaultValue)(Code)
Get a short associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated short.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a Short.
throws:
  NumberFormatException - is thrown if the value mappedby the key has not a valid number format.



getShort
public Short getShort(String key, Short defaultValue)(Code)
Get a short associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated short if key is found and has validformat, default value otherwise.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a Short.
throws:
  NumberFormatException - is thrown if the value mappedby the key has not a valid number format.



getString
public String getString(String key)(Code)
Get a string associated with the given configuration key.
Parameters:
  key - The configuration key. The associated string.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a String.



getString
public String getString(String key, String defaultValue)(Code)
Get a string associated with the given configuration key.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated string if key is found,default value otherwise.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a String.



getStringArray
public String[] getStringArray(String key)(Code)
Get an array of strings associated with the given configuration key.
Parameters:
  key - The configuration key. The associated string array if key is found.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a String/List.



getVector
public Vector getVector(String key)(Code)
Get a Vector of strings associated with the given configuration key.
Parameters:
  key - The configuration key. The associated Vector.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a Vector.



getVector
public Vector getVector(String key, Vector defaultValue)(Code)
Get a Vector of strings associated with the given configuration key.

The list is a copy of the internal data of this object, and as such you may alter it freely.
Parameters:
  key - The configuration key.
Parameters:
  defaultValue - The default value. The associated Vector.
throws:
  ClassCastException - is thrown if the key maps to anobject that is not a Vector.




interpolate
protected String interpolate(String base)(Code)
Interpolate key names to handle ${key} stuff
Parameters:
  base - string to interpolate returns the key name with the ${key} substituted



interpolateHelper
protected String interpolateHelper(String base, List priorVariables)(Code)
Recursive handler for multiple levels of interpolation. When called the first time, priorVariables should be null.
Parameters:
  base - string with the ${key} variables
Parameters:
  priorVariables - serves two purposes: to allow checking forloops, and creating a meaningful exception message should a loopoccur. It's 0'th element will be set to the value of base fromthe first call. All subsequent interpolated variables are addedafterward. the string with the interpolation taken care of



isInitialized
public boolean isInitialized()(Code)
Indicate to client code whether property resources have been initialized or not.



load
public void load(InputStream input) throws IOException(Code)
Load the properties from the given input stream.
Parameters:
  input - the InputStream to load from
throws:
  IOException - if an IO error occurs



load
public synchronized void load(InputStream input, String enc) throws IOException(Code)
Load the properties from the given input stream and using the specified encoding.
Parameters:
  input - the InputStream to load from
Parameters:
  enc - the encoding to use
throws:
  IOException - if an IO error occurs



save
public synchronized void save(OutputStream output, String header) throws IOException(Code)
Save the properties to the given output stream.

The stream is not closed, but it is flushed.
Parameters:
  output - an OutputStream, may be null
Parameters:
  header - a textual comment to act as a file header
throws:
  IOException - if an IO error occurs




setInclude
public void setInclude(String inc)(Code)
Sets the property value for including other properties files. By default it is "include".
Parameters:
  inc - A String.



setProperty
public void setProperty(String key, Object value)(Code)
Set a property, this will replace any previously set values. Set values is implicitly a call to clearProperty(key), addProperty(key,value).
Parameters:
  key - the key to set
Parameters:
  value - the value to set



subset
public ExtendedProperties subset(String prefix)(Code)
Create an ExtendedProperties object that is a subset of this one. Take into account duplicate keys by using the setProperty() in ExtendedProperties.
Parameters:
  prefix - the prefix to get a subset for a new independent ExtendedProperties



testBoolean
public String testBoolean(String value)(Code)
Test whether the string represent by value maps to a boolean value or not. We will allow true, on, and yes for a true boolean value, and false, off, and no for false boolean values. Case of value to test for boolean status is ignored.
Parameters:
  value - the value to test for boolean state true or false if the suppliedtext maps to a boolean value, or null otherwise.



Methods inherited from java.util.Hashtable
public synchronized void clear()(Code)(Java Doc)
public synchronized Object clone()(Code)(Java Doc)
public synchronized boolean contains(Object value)(Code)(Java Doc)
public synchronized boolean containsKey(Object key)(Code)(Java Doc)
public boolean containsValue(Object value)(Code)(Java Doc)
public synchronized Enumeration<V> elements()(Code)(Java Doc)
public Set<Map.Entry<K, V>> entrySet()(Code)(Java Doc)
public synchronized boolean equals(Object o)(Code)(Java Doc)
public synchronized V get(Object key)(Code)(Java Doc)
public synchronized int hashCode()(Code)(Java Doc)
public synchronized boolean isEmpty()(Code)(Java Doc)
public Set<K> keySet()(Code)(Java Doc)
public synchronized Enumeration<K> keys()(Code)(Java Doc)
public synchronized V put(K key, V value)(Code)(Java Doc)
public synchronized void putAll(Map<? extends K, ? extends V> t)(Code)(Java Doc)
protected void rehash()(Code)(Java Doc)
public synchronized V remove(Object key)(Code)(Java Doc)
public synchronized int size()(Code)(Java Doc)
public synchronized String toString()(Code)(Java Doc)
public Collection<V> values()(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.