com.ibm.rational.rpe.common.utils
Class PropertyUtils

java.lang.Object
  extended by com.ibm.rational.rpe.common.utils.PropertyUtils

public class PropertyUtils
extends java.lang.Object

Utility methods for manipulating Property objects


Constructor Summary
PropertyUtils()
           
 
Method Summary
static Property clone(Property source)
          Creates a clone of the source property
static Property cloneSameValue(Property source)
          Creates a clone of this property, but assigns the same value to it
static boolean compareProperties(java.util.Collection<Property> properties1, java.util.Collection<Property> properties2)
          Compares the two property collections
static boolean compareProperties(Property prop1, Property prop2)
          Compares the two properties
static java.lang.String extractSystemVariables(java.lang.String prop)
          Extract external variable in properties, such as path or URI properties.
static Property findCreateProperty(Feature context, java.lang.String propname)
          Searches the context feature for a property named propname.
static Property findFirstProperty(Feature context, java.lang.String featurePath, java.lang.String propertyName)
          Deprecated. 
static java.util.List<Property> findPropertiesByName(Feature context, java.lang.String name)
          Searches the context feature for properties with the given name.
static java.util.List<Property> findPropertiesByType(Feature context, java.lang.String type)
          Deprecated. 
static Property findProperty(java.util.Collection<Property> properties, java.lang.String name)
          Searches the properties collection for a property with the given name
static Property findProperty(Feature context, java.lang.String name)
          Searches the context feature for a property with the given name.
static Property findProperty(java.util.List<Property> properties, java.lang.String name)
          Finds the property that is named name in the properties collection.
static Property findPropertyDeep(Feature context, java.lang.String name)
          Searches the context feature for a property with the given name.
static java.lang.String getPropertyRawValue(Property prop, java.lang.String emptyValue)
           
static boolean hasPropertiesWithType(Feature context, java.lang.String type)
          Searches the context feature for properties with the given type.
static Property makeProperty(java.lang.String proptag, java.lang.String valtag, java.lang.String valcontent)
          Shortcut for creating a property with the given tag and value
static boolean removeFeature(Feature context, Feature removed)
          Deprecated. 
static boolean removeProperty(Feature context, Property property)
          Deprecated. 
static boolean removeProperty(Feature context, java.lang.String name)
          Removes the first occurrence of a property with name name from the context feature.
static void setProperty(Feature context, java.lang.String propname, Value value)
          Searches the context feature for a property named propname and sets its value to value.
static void setPropertyValue(Property prop, Value value)
          Deprecated. 
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyUtils

public PropertyUtils()
Method Detail

makeProperty

public static Property makeProperty(java.lang.String proptag,
                                    java.lang.String valtag,
                                    java.lang.String valcontent)
Shortcut for creating a property with the given tag and value

Parameters:
proptag - - the tag (name) of the newly created property
valtag - - the tag of the value ( can be null)
valcontent - - the content of the value ( can be null)
Returns:

clone

public static Property clone(Property source)
Creates a clone of the source property

Parameters:
source -
Returns:

cloneSameValue

public static Property cloneSameValue(Property source)
Creates a clone of this property, but assigns the same value to it

Parameters:
source -
Returns:

findProperty

public static Property findProperty(java.util.Collection<Property> properties,
                                    java.lang.String name)
Searches the properties collection for a property with the given name

Parameters:
properties -
name -
Returns:

findProperty

public static Property findProperty(Feature context,
                                    java.lang.String name)
Searches the context feature for a property with the given name. Only the top-level properties of the context feature are searched. This is an alias for Feature.getProperty(String).

Parameters:
properties -
name -
Returns:

findPropertyDeep

public static Property findPropertyDeep(Feature context,
                                        java.lang.String name)
Searches the context feature for a property with the given name. The search is recursive.

Parameters:
properties -
name -
Returns:

findFirstProperty

@Deprecated
public static Property findFirstProperty(Feature context,
                                                    java.lang.String featurePath,
                                                    java.lang.String propertyName)
Deprecated. 

Deprecated. Do not use.


findPropertiesByType

@Deprecated
public static java.util.List<Property> findPropertiesByType(Feature context,
                                                                       java.lang.String type)
Deprecated. 

Deprecated. Do not use.


hasPropertiesWithType

public static boolean hasPropertiesWithType(Feature context,
                                            java.lang.String type)
Searches the context feature for properties with the given type. The search is not recursive.

Parameters:
context - - the feature to be searched
type - - the type to search for
Returns:
true if at least one property in the has the give type

findPropertiesByName

public static java.util.List<Property> findPropertiesByName(Feature context,
                                                            java.lang.String name)
Searches the context feature for properties with the given name. The search is not recursive.

Parameters:
context - - the feature to be searched
name - - the name to search for
Returns:
the collection of properties with the given name

compareProperties

public static boolean compareProperties(Property prop1,
                                        Property prop2)
Compares the two properties

Parameters:
prop1 -
prop2 -
Returns:
true if the two properties are equal

compareProperties

public static boolean compareProperties(java.util.Collection<Property> properties1,
                                        java.util.Collection<Property> properties2)
Compares the two property collections

Parameters:
prop1 -
prop2 -
Returns:
true if the properties in the two collections are equal. The order of the properties in the given collections is important. Example: { p1, p2} is not equal with {p2, p1}

findProperty

public static Property findProperty(java.util.List<Property> properties,
                                    java.lang.String name)
Finds the property that is named name in the properties collection.

Parameters:
properties -
name -
Returns:
the first property in the properties list named name or null if such a property is not found.

removeProperty

public static boolean removeProperty(Feature context,
                                     java.lang.String name)
Removes the first occurrence of a property with name name from the context feature.

Parameters:
context -
name -
Returns:

removeProperty

@Deprecated
public static boolean removeProperty(Feature context,
                                                Property property)
Deprecated. 

Deprecated. Do not use.


removeFeature

@Deprecated
public static boolean removeFeature(Feature context,
                                               Feature removed)
Deprecated. 

Deprecated. Do not use.


setProperty

public static void setProperty(Feature context,
                               java.lang.String propname,
                               Value value)
Searches the context feature for a property named propname and sets its value to value. If no such property is found, a new property is created and its value is set to value

Parameters:
context -
propname -
value -

findCreateProperty

public static Property findCreateProperty(Feature context,
                                          java.lang.String propname)
Searches the context feature for a property named propname. If no such property is found, a new property is created and added to the context.

Parameters:
context - the feature where the property is to be searched for
propname - the name of the searched property
Returns:
a property with this name in the given context

getPropertyRawValue

public static java.lang.String getPropertyRawValue(Property prop,
                                                   java.lang.String emptyValue)
Parameters:
prop -
emptyValue -
Returns:
the value of the property if not null, the emptyValue otherwise

setPropertyValue

@Deprecated
public static void setPropertyValue(Property prop,
                                               Value value)
Deprecated. 

Deprecated. Do not use.


extractSystemVariables

public static java.lang.String extractSystemVariables(java.lang.String prop)
Extract external variable in properties, such as path or URI properties. Surround the external variable by ${}, like ${OUTPUT_PATH} The supported external variable name must be at least one word, characters a-zA-Z_0-9. Whitespace characters ( \t\n\x0B\f\r) are not supported in the external variable name.

Parameters:
prop - the value. Can be null
Returns:
the input value in which all variable names have been expanded