ibis.ipl
Class StaticProperties

java.lang.Object
  extended byibis.ipl.StaticProperties

public class StaticProperties
extends java.lang.Object

Container for the properties of an Ibis or a PortType. A property consists of a name (key), and its value, a set of strings. for instance: name: serialization, value: {sun}. The properties are static, that is, once a property is set, its value cannot be changed. The value of a property is usually given as a string, which is then split into words (a word separator is one of " ,\t\n\r\f"). These words can be queried as well, by means of the isProp(String, String) method. For instance, isProp("communication", "OneToMany") could be a query to find out if multicast is supported (or required, when a porttype is created).


Constructor Summary
StaticProperties()
          Creates an empty property set.
StaticProperties(StaticProperties sp)
          Creates an empty property set with the specified defaults.
 
Method Summary
 void add(java.lang.String key, java.lang.String value)
          Adds a key/value pair to the properties.
 java.lang.Object clone()
          Creates and returns a clone of this.
 StaticProperties combine(StaticProperties p)
          Combines the properties with the specified properties, giving preference to the latter.
 StaticProperties combineWithUserProps()
          Combines the specified properties with system properties as specified by the user, giving preference to the latter.
 StaticProperties copy()
          Returns a copy of the properties.
 boolean equals(java.lang.Object other)
          Returns true if other represents the same property set.
 java.lang.String find(java.lang.String key)
          Returns the value associated with the specified key, or null.
 java.util.Set findSet(java.lang.String key)
          Returns the value associated with the specified key, as a set.
 java.lang.String getProperty(java.lang.String key)
          Returns the value associated with the specified key, or null.
 int hashCode()
          Returns the hashcode of this property set.
 boolean isProp(java.lang.String cat, java.lang.String prop)
          Returns true if the specified property category has the specified property set.
 void load(java.io.InputStream in)
          Reads the properties from the specified InputStream.
 boolean matchProperties(StaticProperties sp)
          Matches the current properties with the static properties supplied.
 StaticProperties merge(StaticProperties p)
          Merges the properties with the specified properties.
 java.util.Set propertyNames()
          Returns the set of property names.
 int size()
          Returns the number of property names in this property set.
 java.lang.String toString()
          Returns all key/value pairs as a string.
 StaticProperties unmatchedProperties(StaticProperties sp)
          Matches the current properties with the static properties supplied.
static StaticProperties userProperties()
          Returns the static properties as derived from the system properties provided by the user running the application.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StaticProperties

public StaticProperties()
Creates an empty property set.


StaticProperties

public StaticProperties(StaticProperties sp)
Creates an empty property set with the specified defaults.

Method Detail

propertyNames

public java.util.Set propertyNames()
Returns the set of property names.

Returns:
the set of property names.

size

public int size()
Returns the number of property names in this property set.

Returns:
the number of property names.

userProperties

public static StaticProperties userProperties()
Returns the static properties as derived from the system properties provided by the user running the application.

Returns:
the user-provided static properties.

combineWithUserProps

public StaticProperties combineWithUserProps()
Combines the specified properties with system properties as specified by the user, giving preference to the latter.

Returns:
the combined static properties.

combine

public StaticProperties combine(StaticProperties p)
Combines the properties with the specified properties, giving preference to the latter. This means: choose the specified property if it is "more specific" or conflicts with "this" properties.

Parameters:
p - the properties to combine with.
Returns:
the combined static properties.

merge

public StaticProperties merge(StaticProperties p)
Merges the properties with the specified properties. Merging means that the result is a union, in contrast to what combine(StaticProperties) does.

Parameters:
p - the properties to merge with.
Returns:
the merged static properties.

matchProperties

public boolean matchProperties(StaticProperties sp)
Matches the current properties with the static properties supplied. We have a match if the current properties are a subset of the specified properties.

Parameters:
sp - the static properties to be matched with.
Returns:
true if we have a match, false otherwise.

unmatchedProperties

public StaticProperties unmatchedProperties(StaticProperties sp)
Matches the current properties with the static properties supplied. We have a match if the current properties are a subset of the specified properties.

Parameters:
sp - the static properties to be matched with.
Returns:
the properties that don't match.

add

public void add(java.lang.String key,
                java.lang.String value)
Adds a key/value pair to the properties. If the key is already bound, an IbisRuntimeException is thrown. If either the key or the value is null, a NullPointer is thrown.

Parameters:
key - the key to be bound.
value - the value to bind to the key.
Throws:
IbisRuntimeException - is thrown when the key is already bound.
java.lang.NullPointerException - is thrown when either key or value is null.

getProperty

public java.lang.String getProperty(java.lang.String key)
Returns the value associated with the specified key, or null. This is a synonym for find(String)

Returns:
the value associated with the specified key.

find

public java.lang.String find(java.lang.String key)
Returns the value associated with the specified key, or null.

Returns:
the value associated with the specified key.

findSet

public java.util.Set findSet(java.lang.String key)
Returns the value associated with the specified key, as a set.

Returns:
the value associated with the specified key.

isProp

public boolean isProp(java.lang.String cat,
                      java.lang.String prop)
Returns true if the specified property category has the specified property set.

Parameters:
cat - the property category.
prop - the property.
Returns:
true if the property is set, false otherwise.

clone

public java.lang.Object clone()
Creates and returns a clone of this.

Returns:
a clone.

toString

public java.lang.String toString()
Returns all key/value pairs as a string. The format is: a newline-separated list of key = value pairs.

Returns:
the key/value pairs as a string, or an empty string if there are no key/value pairs.

load

public void load(java.io.InputStream in)
          throws java.io.IOException
Reads the properties from the specified InputStream.

Parameters:
in - the InputStream.
Throws:
java.io.IOException - is thrown when an IO error occurs.

copy

public StaticProperties copy()
Returns a copy of the properties.

Returns:
the copy.

equals

public boolean equals(java.lang.Object other)
Returns true if other represents the same property set.

Parameters:
other - the object to compare with.
Returns:
true if equal.

hashCode

public int hashCode()
Returns the hashcode of this property set.

Returns:
the hashcode.


The Ibis project