Diffusion .NET Classic API - Core and Common  5.9.4
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
PushTechnology.DiffusionCore.PropertyHandler.JavaProperties Class Reference

The JavaProperties class loads and saves Java style properties from a Stream. This version uses C# friendly names and implements the most important features of the Java Properties class in Sun Java version 1.5.0 with some methods omitted (e.g. the loadFrom/storeToXML methods as C# provides simple alternatives and any More...

Inheritance diagram for PushTechnology.DiffusionCore.PropertyHandler.JavaProperties:

Classes

class  LineReader
 A private class to read lines from the input stream in the special escaped ".properties" format. More...
 

Public Member Functions

 JavaProperties ()
 Creates an empty property list with no default values. More...
 
 JavaProperties (JavaProperties defaults)
 Creates an empty property list with the specified defaults. More...
 
void Load (Stream inStream)
 Reads a property list (key and element pairs) from the input stream. The stream is assumed to be using the ISO 8859-1 character encoding; that is each byte is one Latin1 character. Characters not in Latin1, and certain special characters, can be represented in keys and elements using escape sequences. More...
 
void Store (Stream output, string comments)
 Writes this property list (key and element pairs) in this JavaProperties table to the output stream in a format suitable for loading into a JavaProperties table using the load method. The stream is written using the ISO 8859-1 character encoding. More...
 
string GetProperty (string key)
 Searches for the property with the specified key in this property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns More...
 
string GetProperty (string key, string defaultValue)
 Searches for the property with the specified key in this property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns the default value argument if the property is not found. More...
 
Object SetProperty (string key, string newValue)
 Adds a string key/value property pair to the underlying Hashtable. Enforces use of strings for property keys and values. More...
 
IEnumerator PropertyNames ()
 Returns an enumeration of all the keys in this property list, including distinct keys in the default property list if a key of the same name has not already been found from the main properties list. More...
 

Protected Attributes

JavaProperties defaults
 A property list that contains default values for any keys not found in this property list. More...
 

Detailed Description

The JavaProperties class loads and saves Java style properties from a Stream. This version uses C# friendly names and implements the most important features of the Java Properties class in Sun Java version 1.5.0 with some methods omitted (e.g. the loadFrom/storeToXML methods as C# provides simple alternatives and any

NOTE: An important detail to remember is that non-string keys and values were usually ignored in the Java version - I have used 'ToString()' to allow them to be handled more easily.

See http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html for full details.

Constructor & Destructor Documentation

PushTechnology.DiffusionCore.PropertyHandler.JavaProperties.JavaProperties ( )

Creates an empty property list with no default values.

PushTechnology.DiffusionCore.PropertyHandler.JavaProperties.JavaProperties ( JavaProperties  defaults)

Creates an empty property list with the specified defaults.

Parameters
defaultsAn instance of JavaProperties containing default values for the properties.

Member Function Documentation

string PushTechnology.DiffusionCore.PropertyHandler.JavaProperties.GetProperty ( string  key)

Searches for the property with the specified key in this property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns

null if the property is not found.

Parameters
keyThe property key.
Returns
The value in this property list with the specified key.
string PushTechnology.DiffusionCore.PropertyHandler.JavaProperties.GetProperty ( string  key,
string  defaultValue 
)

Searches for the property with the specified key in this property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns the default value argument if the property is not found.

Parameters
keyThe hashtable key.
defaultValueA default value.
Returns
The value in this property list with the specified key value.
void PushTechnology.DiffusionCore.PropertyHandler.JavaProperties.Load ( Stream  inStream)

Reads a property list (key and element pairs) from the input stream. The stream is assumed to be using the ISO 8859-1 character encoding; that is each byte is one Latin1 character. Characters not in Latin1, and certain special characters, can be represented in keys and elements using escape sequences.

See http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html#load(java.io.InputStream)

Parameters
inStreamThe input stream to read properties from.
IEnumerator PushTechnology.DiffusionCore.PropertyHandler.JavaProperties.PropertyNames ( )

Returns an enumeration of all the keys in this property list, including distinct keys in the default property list if a key of the same name has not already been found from the main properties list.

Returns
An enumeration of all the keys in this property list, including the keys in the default property list.
Object PushTechnology.DiffusionCore.PropertyHandler.JavaProperties.SetProperty ( string  key,
string  newValue 
)

Adds a string key/value property pair to the underlying Hashtable. Enforces use of strings for property keys and values.

Parameters
keythe property name to use as the key.
newValuethe value of the property.
Returns
an Object - which should be a string if properties have been used property.
void PushTechnology.DiffusionCore.PropertyHandler.JavaProperties.Store ( Stream  output,
string  comments 
)

Writes this property list (key and element pairs) in this JavaProperties table to the output stream in a format suitable for loading into a JavaProperties table using the load method. The stream is written using the ISO 8859-1 character encoding.

Parameters
outputAn output stream.
commentsA description of the property list to add to the top of the properties file.

Member Data Documentation

JavaProperties PushTechnology.DiffusionCore.PropertyHandler.JavaProperties.defaults
protected

A property list that contains default values for any keys not found in this property list.