C# Class Kajabity.Tools.Java.JavaProperties

Hold Java style properties as key-value pairs and allow them to be loaded from or saved to a ".properties" file. The file is stored with character set ISO-8859-1 which extends US-ASCII (the characters 0-127 are the same) and forms the first part of the Unicode character set. Within the application string are Unicode - but all values outside the basic US-ASCII set are escaped.
Inheritance: System.Collections.Hashtable
Afficher le fichier Open project: Kajabity/Kajabity-Tools Class Usage Examples

Protected Properties

Свойство Type Description
defaults System.Collections.Hashtable

Private Properties

Свойство Type Description
AsString string

Méthodes publiques

Méthode Description
GetProperty ( string key ) : string

Get the value for the specified key value. If the key is not found, then return the default value - and if still not found, return null.

GetProperty ( string key, string defaultValue ) : string

Get the value for the specified key value. If the key is not found, then return the default value - and if still not found, return defaultValue.

JavaProperties ( ) : System

An empty constructor that doesn't set the defaults.

JavaProperties ( Hashtable defaults ) : System

Use this constructor to provide a set of default values. The default values are kept separate to the ones in this instant.

Load ( Stream streamIn ) : void

Load Java Properties from a stream expecting the format as described in JavaPropertyReader.

Load ( Stream streamIn, Encoding encoding ) : void

Load Java Properties from a stream with the specified encoding and expecting the format as described in JavaPropertyReader.

PropertyNames ( ) : IEnumerator

Returns an enumerator of all the properties available in this instance - including the defaults.

SetProperty ( string key, string newValue ) : string

Set the value for a property key. The old value is returned - if any.

Store ( Stream streamOut, string comments ) : void

Store the contents of this collection of properties to the stream in the format used for Java ".properties" files using an instance of JavaPropertyWriter. The keys and values will be minimally escaped to ensure special characters are read back in properly. Keys are not sorted. The file will begin with a comment identifying the date - and an additional comment may be included.

Private Methods

Méthode Description
AsString ( Object o ) : string

A utility method to safely convert an Object to a string.

Method Details

GetProperty() public méthode

Get the value for the specified key value. If the key is not found, then return the default value - and if still not found, return null.
public GetProperty ( string key ) : string
key string The key whose value should be returned.
Résultat string

GetProperty() public méthode

Get the value for the specified key value. If the key is not found, then return the default value - and if still not found, return defaultValue.
public GetProperty ( string key, string defaultValue ) : string
key string The key whose value should be returned.
defaultValue string The default value if the key is not found.
Résultat string

JavaProperties() public méthode

An empty constructor that doesn't set the defaults.
public JavaProperties ( ) : System
Résultat System

JavaProperties() public méthode

Use this constructor to provide a set of default values. The default values are kept separate to the ones in this instant.
public JavaProperties ( Hashtable defaults ) : System
defaults System.Collections.Hashtable A Hashtable that holds a set of defafult key value pairs to /// return when the requested key has not been set.
Résultat System

Load() public méthode

Load Java Properties from a stream expecting the format as described in JavaPropertyReader.
If the stream source is invalid.
public Load ( Stream streamIn ) : void
streamIn Stream An input stream to read properties from.
Résultat void

Load() public méthode

Load Java Properties from a stream with the specified encoding and expecting the format as described in JavaPropertyReader.
public Load ( Stream streamIn, Encoding encoding ) : void
streamIn Stream An input stream to read properties from.
encoding System.Text.Encoding The stream's encoding.
Résultat void

PropertyNames() public méthode

Returns an enumerator of all the properties available in this instance - including the defaults.
public PropertyNames ( ) : IEnumerator
Résultat IEnumerator

SetProperty() public méthode

Set the value for a property key. The old value is returned - if any.
public SetProperty ( string key, string newValue ) : string
key string The key whose value is to be set.
newValue string The new value off the key.
Résultat string

Store() public méthode

Store the contents of this collection of properties to the stream in the format used for Java ".properties" files using an instance of JavaPropertyWriter. The keys and values will be minimally escaped to ensure special characters are read back in properly. Keys are not sorted. The file will begin with a comment identifying the date - and an additional comment may be included.
public Store ( Stream streamOut, string comments ) : void
streamOut Stream An output stream to write the properties to.
comments string Optional additional comment to include at the head of the output.
Résultat void

Property Details

defaults protected_oe property

A reference to an optional set of default properties - these values are returned if the value has not been loaded from a ".properties" file or set programatically.
protected Hashtable,System.Collections defaults
Résultat System.Collections.Hashtable