com.openharbor.beck
Class ObjectOHXPathMap.Policy

java.lang.Object
  extended bycom.openharbor.beck.ObjectOHXPathMap.Policy
Enclosing class:
ObjectOHXPathMap

public static class ObjectOHXPathMap.Policy
extends java.lang.Object

Controls the behavior of an ObjectOHXPathMap. This class is not thread-safe; an instance should not be used by multiple threads.


Constructor Summary
ObjectOHXPathMap.Policy()
           
 
Method Summary
 OHXPathElement getPathElement(java.lang.Object parent, java.lang.Object child, XMLName elementName)
          Compute an OHXPathElement for a given XML element.
 boolean isPossibleReferent(java.lang.Object candidate)
          Whether a given object's XPath is desired.
 void restrictReferentClass(java.util.Collection classes)
          Subsequently, isPossibleReferent(candidate)==true only if the given Collection contains the candidate's class, or a base class or interface of the object's class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectOHXPathMap.Policy

public ObjectOHXPathMap.Policy()
Method Detail

isPossibleReferent

public boolean isPossibleReferent(java.lang.Object candidate)
Whether a given object's XPath is desired. This implementation checks whether the candidate's class is restricted. Extensions may override this method to implement other restrictions.

Returns:
false to prevent mapping the given Object.

restrictReferentClass

public void restrictReferentClass(java.util.Collection classes)
                           throws java.lang.ClassCastException
Subsequently, isPossibleReferent(candidate)==true only if the given Collection contains the candidate's class, or a base class or interface of the object's class.

Parameters:
classes - contains the Class objects that will restrict the map keys
Throws:
java.lang.ClassCastException - the given Collection contains a non-Class

getPathElement

public OHXPathElement getPathElement(java.lang.Object parent,
                                     java.lang.Object child,
                                     XMLName elementName)
Compute an OHXPathElement for a given XML element. This implementation simply names the element, which is sufficient if it has no sibling elements of the same name.