org.knime.core.data
Class DataColumnProperties

java.lang.Object
  extended by org.knime.core.data.DataColumnProperties
All Implemented Interfaces:
Cloneable

public final class DataColumnProperties
extends Object
implements Cloneable

Property map that contains annotations assigned to a column. This class implements a slim, read only version of java's Properties class, whereby all related methods delegate to the underlying property object. This class is used by the DataColumnSpec.

Author:
Bernd Wiswedel, University of Konstanz
See Also:
Properties, DataColumnSpec.getProperties()

Constructor Summary
DataColumnProperties()
          Creates an empty DataColumnProperties object.
DataColumnProperties(Map<String,String> content)
          Creates a properties object containing the (key, value) pairs from the argument.
 
Method Summary
 DataColumnProperties cloneAndOverwrite(Map<String,String> newProperties)
          Creates a new instance which carries all properties from this object and adds the newProperties.
 boolean containsProperty(String key)
          Tests if this properties object contains a given key.
 boolean equals(Object obj)
          Compares a given object on equality.
 String getProperty(String key)
          Get the property value for the given key or null if key does not exist.
 String getProperty(String key, String defaultValue)
          Get the property assigned to key or - if this property does not exist - the defaultValue.
 int hashCode()
          Hash code based on underlying Properties class.
static DataColumnProperties load(ConfigRO config)
          Reads all properties (key-value pairs) from the given ConfigRO and returns a new DataColumnProperties object.
 Enumeration<String> properties()
          Get an enumeration on all keys in this property object.
 void save(ConfigWO config)
          Saves all key-value pairs to the given ConfigWO.
 int size()
          Get the number of properties in this object.
 String toString()
          Returns a string containing key=value pairs, separated by ", ".
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataColumnProperties

public DataColumnProperties()
Creates an empty DataColumnProperties object.


DataColumnProperties

public DataColumnProperties(Map<String,String> content)
Creates a properties object containing the (key, value) pairs from the argument. The argument must not be null (but may be empty). Any subsequent change to the argument is not reflected in this object.

Parameters:
content - a map with key-value pairs
Throws:
NullPointerException - if the argument is null
Method Detail

containsProperty

public boolean containsProperty(String key)
Tests if this properties object contains a given key.

Parameters:
key - the key to check
Returns:
true if key is contained in this property object, false otherwise
Throws:
NullPointerException - if the key is null
See Also:
Hashtable.containsKey(Object)

getProperty

public String getProperty(String key,
                          String defaultValue)
Get the property assigned to key or - if this property does not exist - the defaultValue.

Parameters:
key - request-key
defaultValue - the value to be returned if key is not contained in this property object
Returns:
the property value for the given key or the defaultValue
Throws:
NullPointerException - if key is null
See Also:
Properties.getProperty(String, String)

getProperty

public String getProperty(String key)
Get the property value for the given key or null if key does not exist.

Parameters:
key - request key
Returns:
the value which is mapped to the given key or null if key is not contained
Throws:
NullPointerException - if argument is null
See Also:
Properties.getProperty(String)

size

public int size()
Get the number of properties in this object.

Returns:
the number of stored properties
See Also:
Hashtable.size()

properties

public Enumeration<String> properties()
Get an enumeration on all keys in this property object.

Returns:
an enumeration on the keys
See Also:
Properties.propertyNames()

cloneAndOverwrite

public DataColumnProperties cloneAndOverwrite(Map<String,String> newProperties)
Creates a new instance which carries all properties from this object and adds the newProperties. If there is a key conflict the newProperties overwrite the old ones. This serves as a convenient way to add new properties to a DataColumnProperties object.

Parameters:
newProperties - the new properties to add
Returns:
a (almost) clone of this object with additional properties
Throws:
NullPointerException - if the argument is null

toString

public String toString()
Returns a string containing key=value pairs, separated by ", ".

Overrides:
toString in class Object
See Also:
Hashtable.toString()

equals

public boolean equals(Object obj)
Compares a given object on equality. It will be equal if it is also a DataColumnProperties object and contains the equal key value pairs.

Overrides:
equals in class Object
Parameters:
obj - to compare to
Returns:
true if the given object is equal to this property object

hashCode

public int hashCode()
Hash code based on underlying Properties class.

Overrides:
hashCode in class Object
See Also:
Hashtable.hashCode()

save

public void save(ConfigWO config)
Saves all key-value pairs to the given ConfigWO.

Note: This implementation adds the pairs directly to the argument, make sure to provide an empty subconfig!

Parameters:
config - write properties into this object

load

public static DataColumnProperties load(ConfigRO config)
                                 throws InvalidSettingsException
Reads all properties (key-value pairs) from the given ConfigRO and returns a new DataColumnProperties object.

Parameters:
config - to read properties from
Returns:
a new property object
Throws:
InvalidSettingsException - if the keys entry is not available or a value is not available for a given key


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.