IBM Rational Software Modeler
Release 6.0

com.ibm.xtools.ras.profile.management.artifact.filter
Class AbstractArtifactAttributeFilterImpl

java.lang.Object
  extended bycom.ibm.xtools.ras.profile.management.artifact.filter.AbstractCaseSensitiveFilterImpl
      extended bycom.ibm.xtools.ras.profile.management.artifact.filter.AbstractArtifactAttributeFilterImpl
All Implemented Interfaces:
IArtifactAttributeFilter, IArtifactFilter, ICaseSensitiveArtifactFilter

public abstract class AbstractArtifactAttributeFilterImpl
extends AbstractCaseSensitiveFilterImpl
implements IArtifactAttributeFilter

Abstract class that provides the ability to filter on the String attribute of an Artifact. The class provides all functionality related to the matching algorithm and case sensitivity. The derived client class need only focus on overriding the abstract ArtifactAttributeFilterImpl.getArtifactAttribute(Artifact) method.

See Also:
IArtifactFilter, ICaseSensitiveArtifactFilter

Constructor Summary
AbstractArtifactAttributeFilterImpl(String methodName)
          Constructs the AbstractArtifactAttributeFilterImpl with the name of the method to invoke on the Artifact
AbstractArtifactAttributeFilterImpl(String methodName, Object filterObject)
          Constructs the AbstractArtifactAttributeFilterImpl with the name of the method to invoke on the Artifact
AbstractArtifactAttributeFilterImpl(String methodName, Object filterObject, boolean caseSensitive)
          Constructs the AbstractArtifactAttributeFilterImpl with name of the method to invoke on the Artifact and a case sensitivity indicator.
 
Method Summary
protected abstract  boolean compare(Object theAttribute, Object filterObject)
          Compares the attribute of the current Artifact being filtered against the filter object.
protected abstract  boolean compareIgnoreCase(Object theAttribute, Object filterObject)
          Compares the attribute of the current Artifact being filtered against the filter object.
protected  Object getArtifactAttribute(Artifact theArtifact)
          Retrieves the attribute from the Artifact using the method that was looked up through reflection.
protected  Class getArtifactClass()
          This is the class that will be used to look up the method name to invoke on the Artifact.
 Object getFilterObject()
          Retrieves the Object that is used to compare against during the filtering process.
 String getMethodName()
          Retrieves the name of the method that will be invoked on the Artifact that is used to retrieve an attribute of the Artifact during filtering.
 boolean matches(Artifact theArtifact)
          Determines if the attribute filter string matches the Artifact propety returned by a call to ArtifactAttributeFilterImpl.getArtifactAttribute(Artifact).
 void setFilterObject(Object filterObject)
          Sets the Object that is used to compare against during the filtering process.
 void setMethodName(String methodName)
          Sets the name of the method that will be invoked on the Artifact that is used to retrieve an attribute of the Artifact during filtering.
 
Methods inherited from class com.ibm.xtools.ras.profile.management.artifact.filter.AbstractCaseSensitiveFilterImpl
isCaseSensitive, setCaseSensitive
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ibm.xtools.ras.profile.management.artifact.filter.ICaseSensitiveArtifactFilter
isCaseSensitive, setCaseSensitive
 

Constructor Detail

AbstractArtifactAttributeFilterImpl

public AbstractArtifactAttributeFilterImpl(String methodName)
                                    throws SecurityException,
                                           NoSuchMethodException,
                                           NullPointerException
Constructs the AbstractArtifactAttributeFilterImpl with the name of the method to invoke on the Artifact

Parameters:
methodName - the name of the method to invoke on the Artifact
Throws:
NoSuchMethodException - - if a matching method is not found or if the method name is "" or "".
NullPointerException - - if method name is null
SecurityException - - if access to the information is denied.

AbstractArtifactAttributeFilterImpl

public AbstractArtifactAttributeFilterImpl(String methodName,
                                           Object filterObject)
                                    throws SecurityException,
                                           NoSuchMethodException,
                                           NullPointerException
Constructs the AbstractArtifactAttributeFilterImpl with the name of the method to invoke on the Artifact

Parameters:
methodName - the name of the method to invoke on the Artifact
filterObject - the Object that is used to compare against during the filtering process. It can be null
Throws:
NoSuchMethodException - - if a matching method is not found or if the method name is "" or "".
NullPointerException - - if method name is null
SecurityException - - if access to the information is denied.

AbstractArtifactAttributeFilterImpl

public AbstractArtifactAttributeFilterImpl(String methodName,
                                           Object filterObject,
                                           boolean caseSensitive)
                                    throws SecurityException,
                                           NoSuchMethodException,
                                           NullPointerException
Constructs the AbstractArtifactAttributeFilterImpl with name of the method to invoke on the Artifact and a case sensitivity indicator.

Parameters:
methodName - the name of the method to invoke on the Artifact
filterObject - the Object that is used to compare against during the filtering process. It can be null
caseSensitive - indicates if the filter should operate in a case sensitive manner
Throws:
NoSuchMethodException - - if a matching method is not found or if the method name is "" or "".
NullPointerException - - if method name is null
SecurityException - - if access to the information is denied.
Method Detail

getMethodName

public String getMethodName()
Description copied from interface: IArtifactAttributeFilter
Retrieves the name of the method that will be invoked on the Artifact that is used to retrieve an attribute of the Artifact during filtering.

Specified by:
getMethodName in interface IArtifactAttributeFilter
Returns:
the name of the method that will be invoked on the Artifact

setMethodName

public void setMethodName(String methodName)
                   throws SecurityException,
                          NoSuchMethodException,
                          NullPointerException
Description copied from interface: IArtifactAttributeFilter
Sets the name of the method that will be invoked on the Artifact that is used to retrieve an attribute of the Artifact during filtering. This should be the name of a public method that does not take any parameters. It should also return some form of an Object.

Specified by:
setMethodName in interface IArtifactAttributeFilter
Parameters:
methodName - the name of the method that will be invoked on the Artifact
Throws:
NoSuchMethodException - - if a matching method is not found or if the method name is "" or "".
NullPointerException - - if method name is null
SecurityException - - if access to the information is denied.

getFilterObject

public Object getFilterObject()
Description copied from interface: IArtifactAttributeFilter
Retrieves the Object that is used to compare against during the filtering process.

Specified by:
getFilterObject in interface IArtifactAttributeFilter
Returns:
the Object that is used to compare against during the filtering process.

setFilterObject

public void setFilterObject(Object filterObject)
Description copied from interface: IArtifactAttributeFilter
Sets the Object that is used to compare against during the filtering process. This Object can be null providing the ability to filter for Artifact instances that have a particular attribute set to null.

Specified by:
setFilterObject in interface IArtifactAttributeFilter
Parameters:
filterObject - the Object that is used to compare against during the filtering process. It can be null

getArtifactClass

protected Class getArtifactClass()
This is the class that will be used to look up the method name to invoke on the Artifact. This can be overridden by derived classes to provided access to methods that are only available on a derived object. This method should be used cautiously however since there is no guarantee that all Artifact instances that pass through the filter will be of the derived type. If this method is overridden then ArtifactAttributeFilterImpl.getArtifactAttribute(Artifact) should probably be as well. It's in this method where the invocation actually occurs.

Returns:
the Class of the Artifact

matches

public boolean matches(Artifact theArtifact)
Determines if the attribute filter string matches the Artifact propety returned by a call to ArtifactAttributeFilterImpl.getArtifactAttribute(Artifact). This methods also supports the null case. If getArtifactAttribute() returns null, a comparison is made to also see if the filter string is null. This allows the client to filter for Artifact instances that have null String attributes.

Specified by:
matches in interface IArtifactFilter
Parameters:
theArtifact - to compare against the filter criteria
Returns:
true if the Artifact matches the filter criteria
See Also:
IArtifactFilter.matches(com.ibm.xtools.ras.profile.defauld.defaultprofile.Artifact)

getArtifactAttribute

protected Object getArtifactAttribute(Artifact theArtifact)
Retrieves the attribute from the Artifact using the method that was looked up through reflection. If the attribute doesn't exist or the invocation of the client specified method fails, null is returned.

Parameters:
theArtifact - to retrieve the attribute from
Returns:
the attribute as an Object or null.

compare

protected abstract boolean compare(Object theAttribute,
                                   Object filterObject)
Compares the attribute of the current Artifact being filtered against the filter object. If appropriate the comparison should be down in a case sensitive manner.

Parameters:
theAttribute - of the current Artifact in the filtering process.
filterObject - the Object to compare against.
Returns:
true if the two objects are equal

compareIgnoreCase

protected abstract boolean compareIgnoreCase(Object theAttribute,
                                             Object filterObject)
Compares the attribute of the current Artifact being filtered against the filter object. If appropriate the comparison should be down in a manner that ignores case.

Parameters:
theAttribute - of the current Artifact in the filtering process.
filterObject - the Object to compare against.
Returns:
true if the two objects are equal

IBM Rational Software Modeler
Release 6.0


Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2004. All rights reserved.