com.edustructures.sifworks.tools.mapping
Class XPathRule

java.lang.Object
  extended by com.edustructures.sifworks.tools.mapping.Rule
      extended by com.edustructures.sifworks.tools.mapping.XPathRule

public class XPathRule
extends Rule

A Rule class to evaluate XPath-like queries as defined by the SIFDTD.lookupByXPath method

Version:
1.0

Constructor Summary
XPathRule(java.lang.String definition)
          Constructor
 
Method Summary
 Rule copy(FieldMapping newParent)
          Produces a duplicate of this Rule object
 org.apache.commons.jxpath.ri.model.NodePointer createPath(SIFXPathContext context, SIFVersion version)
          Builds out the path specified by this XPath rule and returns the final Element in the path
 SIFSimpleType evaluate(SIFXPathContext xpathContext, SIFVersion version)
          Evaluates this rule against a SIFDataObject and returns the text value of the element or attribute that satisfied the query.
 java.lang.String getPathExpression()
           
 java.lang.String getValueExpression()
           
 java.lang.String getXPath()
           
 ElementDef lookupTargetDef(ElementDef parent)
          Looks up the ElementDef that this XPathRule points to by XPath
 java.lang.String toString()
          Render this Rule as an XML element
 void toXML(org.w3c.dom.Node parent)
          Render this XPathRule as an XML DOM Node
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XPathRule

public XPathRule(java.lang.String definition)
Constructor

Parameters:
definition - An XPath-like query (e.g. "@RefId", "StudentAddress/Address[@Type='H','M']/Street/Line1") to evaluate against the SIFDataObject passed to the evaluate method
Method Detail

copy

public Rule copy(FieldMapping newParent)
Produces a duplicate of this Rule object

Specified by:
copy in class Rule
Parameters:
newParent - The FieldMapping to copy this rule to
Returns:
A "deep copy" of this Rule object

toXML

public void toXML(org.w3c.dom.Node parent)
Render this XPathRule as an XML DOM Node

Specified by:
toXML in class Rule
Parameters:
parent - The XML node to write to

toString

public java.lang.String toString()
Render this Rule as an XML element

Overrides:
toString in class java.lang.Object
Returns:
The XPath expression this rule represents

getXPath

public java.lang.String getXPath()
Returns:
The XPath expression this rule represents

getValueExpression

public java.lang.String getValueExpression()
Returns:

getPathExpression

public java.lang.String getPathExpression()

evaluate

public SIFSimpleType evaluate(SIFXPathContext xpathContext,
                              SIFVersion version)
                       throws ADKSchemaException
Description copied from class: Rule
Evaluates this rule against a SIFDataObject and returns the text value of the element or attribute that satisfied the query.

Specified by:
evaluate in class Rule
Parameters:
xpathContext - The SIFXPathContext instance to use for object traversal
version - The SIF Version that is in effect
Returns:
The SimpleType representing the value of the element or attribute that satisfied the query, or null if no match found
Throws:
ADKSchemaException - If the xpath expression cannot be resolved

createPath

public org.apache.commons.jxpath.ri.model.NodePointer createPath(SIFXPathContext context,
                                                                 SIFVersion version)
Builds out the path specified by this XPath rule and returns the final Element in the path

Parameters:
context -
version -
Returns:
The newly-created element. If the Element already exists, however, the return value will be null

lookupTargetDef

public ElementDef lookupTargetDef(ElementDef parent)
Looks up the ElementDef that this XPathRule points to by XPath

Parameters:
parent - The parent object metadata object, representing the root of the path
Returns:
The ElementDef that this XPathRule points to


Copyright © 2001-2007 Edustructures LLC. All Rights Reserved. SIFWorks® and ADK® are registered trademarks of Edustructures LLC. SIF™ and Schools Interoperability Framework are trademarks of the Schools Interoperability Framework Association.