com.ibm.rational.rpe.common.data
Class Feature

java.lang.Object
  extended by com.ibm.rational.rpe.common.data.Feature
All Implemented Interfaces:
Visitable

public class Feature
extends java.lang.Object
implements Visitable

A Feature is a collection of Property and other Feature objects.


Constructor Summary
Feature()
           
Feature(java.lang.String id, java.lang.String tag)
          Creates a new feature with the given id and tag
 
Method Summary
 void addFeature(Feature feature)
          Adds the provided feature as a direct child feature of the current feature.
 void addFeature(int location, Feature feature)
          Adds the given feature to the current feature at the given position.
 void addFeatures(java.util.Collection<Feature> other)
          Adds all of the features from the provided collection to this feature as direct children.
 void addProperties(java.util.Collection<Property> properties)
          Adds all of the properties from the provided collection to this feature as direct children
 void addProperty(Property property)
          Adds the property to this feature as a direct child property
 void addPropertyAfter(Property property, Property other)
          Deprecated. 
 void addPropertyBefore(Property property, Property other)
          Deprecated. 
 void copyContent(Feature other)
          Copies the content of the other feature to this one.
 Feature copyOf()
          Returns a copy of this feature and all of its children.
 java.util.List<Feature> getFeatures()
          Returns an unmodifiable collection of Features.
 java.lang.String getId()
          Returns the tag of this feature
 Feature getNewInstance()
          Creates and returns a new feature instance.
 java.util.List<Property> getProperties()
          Returns an unmodifiable collection of properties.
 Property getProperty(java.lang.String name)
          Returns the property with this name if it is found as a direct child of this feature.
 Property getPropertyFast(java.lang.String name)
          Searches for a property with this name in the first child feature of the current feature.
 java.lang.String getTag()
          Returns the tag of this feature
 java.lang.String getType()
          Returns the tag attribute of this feature
 void removeAll(java.util.Collection<Feature> deleted)
          Removes all of the features provided in the collection argument from this feature.
 void removeAllFeatures()
          Removes all the direct child features.
 void removeAllProperties()
          Removes all the direct child properties.
 boolean removeFeature(Feature feature)
          Removes the given feature from the children of this feature.
 boolean removeProperty(Property prop)
          Removes the given property from this feature, if found.
 void setId(java.lang.String id)
          Sets the id of this feature
 void setTag(java.lang.String tag)
          Sets the tag of this feature
 void setType(java.lang.String type)
          Sets the type attribute of this feature
 void sort(java.util.Comparator<Feature> featureComparator, java.util.Comparator<Property> propertyComparator, boolean deep)
          Sorts the features and the properties of this feature by using the provided comparators.
 void visit(Visitable parent, com.ibm.rational.rpe.common.template.visitor.Visitor v)
          Implementation of .
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Feature

public Feature()

Feature

public Feature(java.lang.String id,
               java.lang.String tag)
Creates a new feature with the given id and tag

Method Detail

getNewInstance

public Feature getNewInstance()
Creates and returns a new feature instance. Use this method to create new instances from derived classes.


getPropertyFast

public Property getPropertyFast(java.lang.String name)
Searches for a property with this name in the first child feature of the current feature. If not found, the property is searched for among the direct child properties.

Parameters:
name - - the name of the property to look for *
Returns:
the property with this name of null, if no such property exists

getProperty

public Property getProperty(java.lang.String name)
Returns the property with this name if it is found as a direct child of this feature.

Parameters:
name - - the name of the property to look for *
Returns:
the property with this name of null if no such property exists

setTag

public void setTag(java.lang.String tag)
Sets the tag of this feature


getTag

public java.lang.String getTag()
Returns the tag of this feature


setId

public void setId(java.lang.String id)
Sets the id of this feature


getId

public java.lang.String getId()
Returns the tag of this feature


setType

public void setType(java.lang.String type)
Sets the type attribute of this feature


getType

public java.lang.String getType()
Returns the tag attribute of this feature


addProperty

public void addProperty(Property property)
Adds the property to this feature as a direct child property


addProperties

public void addProperties(java.util.Collection<Property> properties)
Adds all of the properties from the provided collection to this feature as direct children


addPropertyBefore

@Deprecated
public void addPropertyBefore(Property property,
                                         Property other)
Deprecated. 

Deprecated.

Parameters:
property -
other -

addPropertyAfter

@Deprecated
public void addPropertyAfter(Property property,
                                        Property other)
Deprecated. 

Deprecated.

Parameters:
property -
other -

getProperties

public java.util.List<Property> getProperties()
Returns an unmodifiable collection of properties. The result is never null. The return type is to be changed to Collection.


removeProperty

public boolean removeProperty(Property prop)
Removes the given property from this feature, if found.

Parameters:
prop -
Returns:

addFeature

public void addFeature(Feature feature)
Adds the provided feature as a direct child feature of the current feature.

Parameters:
feature -

addFeatures

public void addFeatures(java.util.Collection<Feature> other)
Adds all of the features from the provided collection to this feature as direct children.


addFeature

public void addFeature(int location,
                       Feature feature)
Adds the given feature to the current feature at the given position. Throws an exception if the location is invalid, which is lower than 0 or greater then the collection's size.


removeFeature

public boolean removeFeature(Feature feature)
Removes the given feature from the children of this feature.


removeAll

public void removeAll(java.util.Collection<Feature> deleted)
Removes all of the features provided in the collection argument from this feature.


getFeatures

public java.util.List<Feature> getFeatures()
Returns an unmodifiable collection of Features. The result is never null. The return type is to be changed to Collection.


copyOf

public Feature copyOf()
Returns a copy of this feature and all of its children. The properties in the new feature are not cloned, they are the same objects as the ones in this instance.


copyContent

public void copyContent(Feature other)
Copies the content of the other feature to this one. Unlike clones, no duplicates are created for the child properties and features.

Parameters:
other -

visit

public void visit(Visitable parent,
                  com.ibm.rational.rpe.common.template.visitor.Visitor v)
Implementation of . Visits this feature and all its children features and properties.

Specified by:
visit in interface Visitable
Parameters:
parent - - (optional) the parent visitable object that triggered the visit of this object
v - - the visitor

removeAllProperties

public void removeAllProperties()
Removes all the direct child properties.


removeAllFeatures

public void removeAllFeatures()
Removes all the direct child features.


sort

public void sort(java.util.Comparator<Feature> featureComparator,
                 java.util.Comparator<Property> propertyComparator,
                 boolean deep)
Sorts the features and the properties of this feature by using the provided comparators. If deep is set to true, then the child features are sorted recursively.

Parameters:
featureComparator -
propertyComparator -
deep -