artefaktur
software engineer &        architecture

 
 
 
 

class Properties

Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   Namespace Members   Compound Members   Related Pages  

acdk::util::Properties Class Reference

#include <Properties.h>

Inheritance diagram for acdk::util::Properties:

acdk::util::HashMap acdk::io::Serializable acdk::lang::Cloneable acdk::util::AbstractMap acdk::lang::Cloneable acdk::io::Serializable acdk::lang::Object acdk::util::Map acdk::lang::ObjectBase acdk::lang::dmi::StdDispatch acdk::make::TaskCfgFile List of all members.

Detailed Description

API: Java with extension<br/>.

Author:
Roger Rene Kommer (mailto:kommer@artefaktur.com)
Version:
Revision
1.24
Date:
Date
2005/04/09 19:26:57


Public Member Functions

 Properties (IN(RProperties) def=Nil)
RString getProperty (IN(RString) key)
 see RString getProperty(IN(RString) key, IN(RString) defaultValue, bool withDefaults = true);

RString getProperty (IN(RString) key, IN(RString) defaultValue, bool withDefaults=true)
 retrieve a property as String

RMap getMapProperty (IN(RString) keyStart, bool withDefaults=true)
 ACDK extension return a list of properties as map If keyStart is "my.prop" and the properties contains the values my.prop.a=A my.prop.b=B my.prop.c=C this method returns a map a => A b => B c => C.

void setPropertyMap (IN(RString) keyStart, IN(RMap) map)
 set the map of value/keys in current Property Before inserting all entries with starting keyStart + "." will be deleted

RStringArray getArrayProperty (IN(RString) keyStart, int start=0, bool withDefaults=true)
 ADCK extension return a list of property values a array if keyStart is "my.prop" and start = 1 (default is 0) and the properties contains following values: my.prop.1=A my.prop.2=C my.prop.3=B my.prop.5=X this method returns a string array containing "A", "C", "B" if no element was found returns an empty array.

void setArrayProperty (IN(RString) keyStart, IN(RStringArray) values, int start=0)
 set the array of string in the current properties map Before inserting all entries with starting keyStart + "." will be deleted

RString eval (IN(RString) expr, bool recursive=false)
 this method replaces with corresponding values in this properties.

void list (IN(acdk::io::RPrintWriter) out, bool withDefaults=true)
 writes the elements into the printwriter

void load (IN(acdk::io::RReader) in)
 Load a properties file using java literal decoding.

RIterator propertyNames (bool withDefaults=true)
 get a iterator for all keys of this properties

RObject setProperty (IN(RString) key, IN(RString) value)
 set the property value

void store (IN(acdk::io::RWriter) out, IN(RString) header, bool withDefaults=true)
RProperties defaults ()
void setDefaults (IN(RProperties) defaults)
void mergeProperties (IN(RProperties) props)
 merge existant properties with new properties.

void addPropertyChangeListener (IN(RPropertiesChangeListener) listener)
 add a new listener

void removePropertyChangeListener (IN(RPropertiesChangeListener) listener)
 remove a previous added listener

virtual RObject clone ()
 Interface from cloneable.

virtual RObject clone (sys::Allocator *alloc)

Static Public Member Functions

RProperties loadProperties (IN(RString) name)
 try to load properties file on given name.


Protected Member Functions

void _deleteKeys (IN(RString) keyStart)
 deletes all entries with keys starting with keyStart in this properties

void _notifyListener (PropertiesChangeAction action, IN(RString) key, IN(RObject) obj)
 used internally to notify listener

void _notifyListener2 (PropertiesChangeAction action, IN(RString) key, IN(RObject) obj)

Static Protected Member Functions

RString _format (IN(RString) key, IN(RString) value)

Protected Attributes

RProperties _defaults
RPropertiesChangeListenerArray _listener

Friends

class PropertiesIterator

Constructor & Destructor Documentation

acdk::util::Properties::Properties IN(RProperties)  def = Nil  ) 
 


Member Function Documentation

void acdk::util::Properties::_deleteKeys IN(RString)  keyStart  )  [protected]
 

deletes all entries with keys starting with keyStart in this properties

RString acdk::util::Properties::_format IN(RString)  key,
IN(RString)  value
[static, protected]
 

void acdk::util::Properties::_notifyListener PropertiesChangeAction  action,
IN(RString)  key,
IN(RObject)  obj
[inline, protected]
 

used internally to notify listener

void acdk::util::Properties::_notifyListener2 PropertiesChangeAction  action,
IN(RString)  key,
IN(RObject)  obj
[protected]
 

void acdk::util::Properties::addPropertyChangeListener IN(RPropertiesChangeListener)  listener  ) 
 

add a new listener

virtual RObject acdk::util::Properties::clone sys::Allocator *  alloc  )  [virtual]
 

Reimplemented from acdk::lang::Cloneable.

virtual RObject acdk::util::Properties::clone  )  [inline, virtual]
 

Interface from cloneable.

clone ignores all entries, where the key is not a string. clone only copy the reference, and do not clone the values itself clone will also clone Properties::_default.

Implements acdk::lang::Cloneable.

RProperties acdk::util::Properties::defaults  )  [inline]
 

RString acdk::util::Properties::eval IN(RString)  expr,
bool  recursive = false
 

this method replaces with corresponding values in this properties.

System::getProperties()->eval("$(ACDKHOME)/csf"); will expand for example to "/artefaktur/acdk/csf" if ACDKHOME=/artefaktur/acdk If expr is "$(KEY)", but this property has no value for KEY the original expr will be in the resulting string.

Parameters:
expr a string, which may contains
recursive call eval recursivelly, as long are in the evaluated string

RStringArray acdk::util::Properties::getArrayProperty IN(RString)  keyStart,
int  start = 0,
bool  withDefaults = true
 

ADCK extension return a list of property values a array if keyStart is "my.prop" and start = 1 (default is 0) and the properties contains following values: my.prop.1=A my.prop.2=C my.prop.3=B my.prop.5=X this method returns a string array containing "A", "C", "B" if no element was found returns an empty array.

RMap acdk::util::Properties::getMapProperty IN(RString)  keyStart,
bool  withDefaults = true
 

ACDK extension return a list of properties as map If keyStart is "my.prop" and the properties contains the values my.prop.a=A my.prop.b=B my.prop.c=C this method returns a map a => A b => B c => C.

If no element was found returns an empty map.

This method computes the Map every time it will be called, so don't use it in inner loops.

RString acdk::util::Properties::getProperty IN(RString)  key,
IN(RString)  defaultValue,
bool  withDefaults = true
 

retrieve a property as String

Parameters:
a key to the properties
defaultValue will be returned if the property entry cannot be found
withDefaults if true (default) the value will also be searched in the parent resp. default property set
Returns:
the found value or the param defaultValue if not found

RString acdk::util::Properties::getProperty IN(RString)  key  ) 
 

see RString getProperty(IN(RString) key, IN(RString) defaultValue, bool withDefaults = true);

void acdk::util::Properties::list IN(acdk::io::RPrintWriter)  out,
bool  withDefaults = true
 

writes the elements into the printwriter

void acdk::util::Properties::load IN(acdk::io::RReader)  in  ) 
 

Load a properties file using java literal decoding.

RProperties acdk::util::Properties::loadProperties IN(RString)  name  )  [static]
 

try to load properties file on given name.

The name "acdk.util.MyProps" tries to load $ACDKHOME/cfg/acdk/util/MyProps.properties"

Parameters:
name alternativally also acdk/util/MyProps notation is allowed
Returns:
Nil if not found

void acdk::util::Properties::mergeProperties IN(RProperties)  props  ) 
 

merge existant properties with new properties.

Property values with the same key from the new properties will be overwritten.

RIterator acdk::util::Properties::propertyNames bool  withDefaults = true  ) 
 

get a iterator for all keys of this properties

Parameters:
withDefaults if true (the default) also the names of parent resp. default property set will be returned

void acdk::util::Properties::removePropertyChangeListener IN(RPropertiesChangeListener)  listener  ) 
 

remove a previous added listener

Parameters:
listener this has to be the same instance as previously added

void acdk::util::Properties::setArrayProperty IN(RString)  keyStart,
IN(RStringArray)  values,
int  start = 0
 

set the array of string in the current properties map Before inserting all entries with starting keyStart + "." will be deleted

Parameters:
keyStart property key name
values new values. If this is Nil only the old entries will be deleted
start start number occour in the property keyname as keyStart.start
See also:
getArrayProperty

void acdk::util::Properties::setDefaults IN(RProperties)  defaults  )  [inline]
 

RObject acdk::util::Properties::setProperty IN(RString)  key,
IN(RString)  value
 

set the property value

void acdk::util::Properties::setPropertyMap IN(RString)  keyStart,
IN(RMap)  map
 

set the map of value/keys in current Property Before inserting all entries with starting keyStart + "." will be deleted

See also:
getMapProperty

void acdk::util::Properties::store IN(acdk::io::RWriter)  out,
IN(RString)  header,
bool  withDefaults = true
 


Friends And Related Function Documentation

friend class PropertiesIterator [friend]
 


Member Data Documentation

RProperties acdk::util::Properties::_defaults [protected]
 

RPropertiesChangeListenerArray acdk::util::Properties::_listener [protected]
 

 
Last modified 2005-05-08 18:33 by SYSTEM By Artefaktur, Ing. Bureau Kommer