C# Класс 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.
Наследование: System.Collections.Hashtable
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
defaults System.Collections.Hashtable

Private Properties

Свойство Тип Описание
AsString string

Открытые методы

Метод Описание
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.

Приватные методы

Метод Описание
AsString ( Object o ) : string

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

Описание методов

GetProperty() публичный Метод

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.
Результат string

GetProperty() публичный Метод

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.
Результат string

JavaProperties() публичный Метод

An empty constructor that doesn't set the defaults.
public JavaProperties ( ) : System
Результат System

JavaProperties() публичный Метод

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.
Результат System

Load() публичный Метод

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.
Результат void

Load() публичный Метод

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.
Результат void

PropertyNames() публичный Метод

Returns an enumerator of all the properties available in this instance - including the defaults.
public PropertyNames ( ) : IEnumerator
Результат IEnumerator

SetProperty() публичный Метод

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.
Результат string

Store() публичный Метод

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.
Результат void

Описание свойств

defaults защищенное свойство

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
Результат System.Collections.Hashtable