org.tm4j.topicmap.utils.testers
Class TypeTester

java.lang.Object
  extended byorg.tm4j.topicmap.utils.testers.TypeTester
All Implemented Interfaces:
uk.co.jezuk.mango.Predicate

public class TypeTester
extends java.lang.Object
implements uk.co.jezuk.mango.Predicate

A Predicate which returns true if the object passed in is a topic map object which is typed by one or more topics and if one or more of the typing topics is found in the list of allowed types or if the subject or subject indicator of one or more of the typing topics is found in the list of allowed subject or subject indicators.


Constructor Summary
TypeTester()
           
TypeTester(Locator subjOrInd)
          Convenience method to create a tester that tests for objects of a single type.
TypeTester(Topic type)
          Convenience method to create a tester that tests for objects of a single type.
 
Method Summary
 void addAllowedType(Locator subjectOrIndicator)
          Adds a Locator to the list of allowed subject or subjectIndicators.
 void addAllowedType(Topic t)
          Adds a topic to the list of allowed typing topics.
protected  boolean isAllowed(Topic t)
          Determines whether or not the specified topic is allowed through this test.
 void removeAllowedType(Locator subjectOrIndicator)
          Removes a Locator from the list of allowed subject or subjectIndicators.
 void removeAllowedType(Topic t)
          Removes a topic from the list of allowed typing topics.
 boolean test(java.lang.Object o)
          Performs the test.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeTester

public TypeTester()

TypeTester

public TypeTester(Topic type)
Convenience method to create a tester that tests for objects of a single type.

Parameters:
type - The type to test for.

TypeTester

public TypeTester(Locator subjOrInd)
Convenience method to create a tester that tests for objects of a single type.

Parameters:
subjOrInd - The subject or subject indicator of the type to test for.
Method Detail

addAllowedType

public void addAllowedType(Topic t)
Adds a topic to the list of allowed typing topics.

Parameters:
t - The topic to add

addAllowedType

public void addAllowedType(Locator subjectOrIndicator)
Adds a Locator to the list of allowed subject or subjectIndicators.

Parameters:
subjectOrIndicator - The Locator to be allowed if it is a subject or subjectIndicator of the typing topic.

removeAllowedType

public void removeAllowedType(Topic t)
Removes a topic from the list of allowed typing topics.

Parameters:
t - the topic to remove
See Also:
addAllowedType(Topic)

removeAllowedType

public void removeAllowedType(Locator subjectOrIndicator)
Removes a Locator from the list of allowed subject or subjectIndicators.

Parameters:
subjectOrIndicator - The Locator to remove.
See Also:
addAllowedType(Locator)

test

public boolean test(java.lang.Object o)
Performs the test.

Specified by:
test in interface uk.co.jezuk.mango.Predicate
Parameters:
o - The object to be tested.
Returns:
True if the object is a Topic, Association, Member or Occurrence and if there is one or more type-specifying topic for that object which is in the list of allowed types, or if there is one or more type-specifying topic for that object which has a subject or subject indicator which is in the list of allowed subjects or indicators. For the purposes of this method, the topic returned by Member.getRoleSpec() is considered to be a type-specifying topic.

isAllowed

protected boolean isAllowed(Topic t)
Determines whether or not the specified topic is allowed through this test.