com.ricebridge.xmlman.in
Class TargetPath

java.lang.Object
  extended bycom.ricebridge.xmlman.in.TargetPath

public class TargetPath
extends Object

Represents an XPath expression parsing plan.

For example, /root/foo is represented as two parts, root followed by foo. When root is matched, descend to foo, which becomes the search part. When foo is matched, the target is hit.

To avoid left-over data values from previous records, on the start of a new element, clear all predicate paths and sub paths, but leave other path values alone as they will hold the most recent values.


Field Summary
 int iInstanceNum
           
 
Constructor Summary
TargetPath()
          Create an empty TargetPath.
TargetPath(PathSpec pPathSpec)
          Create a TargetPath from a PathSpec created by the ExprWalker class.
TargetPath(PathSpec pPathSpec, boolean pNamespaceAware)
          Create a TargetPath from a PathSpec created by the ExprWalker class, and set the namespace awareness.
 
Method Summary
 void activate(int pDepth, DocContext pDocContext)
          Activate this path and its precursors (subpaths are activated on target match).
 boolean active(DocContext pDocContext)
          Indicate that this path is active for the specified document context.
 void addSubPath(TargetPath pTargetPath)
          Add a subpath to this path.
 void addTrigger(DocContext pDocContext, Trigger pTrigger)
          Add a Trigger to be executed when this path matches.
 void clear(DocContext pDocContext)
          Clear the data value of this path.
 void deactivate(DocContext pDocContext)
          Deactivate this path, its subpaths and precursors.
 NameInfo getAttrNameInfo()
          Get the target attribute name.
 com.ricebridge.xmlman.tp.Context getContext(DocContext pDocContext)
          Get the current Jaxen Context of this path.
 boolean getDefaultActivation()
          Get the default activation state of this path.
 String getDocContextName()
          Get the document context name of the data value that this path targets.
 int getInstanceNum()
          Get the instance number of this path, for debugging.
 int getMatchCount(DocContext pDocContext)
          Get the number of times this path has matched.
 String getName()
          Get the name of this path - normally the XPath expression.
 int getNumParts()
          Get this number of parts in this path.
 TargetPath getParentPath()
          Get the parent path of which this path is a subpath.
 PathPart getPathPartAt(int pPartIndex)
          Get the part at the specified index.
 SubPathManager getSubPathManager()
          Get the SubPathManager containing the subpaths of this path.
 TextInfo getTextInfo()
          Get the text target description.
 Object getValue(DocContext pDocContext)
          Get the current data field value of this path.
 boolean handleEndPoint(EndPoint pEndPoint, DocContext pDocContext)
          Handle an EndPoint event.
 List handleStartPoint(StartPoint pStartPoint, DocContext pDocContext)
          Handle a StartPoint event.
 boolean hasAbsoluteParent()
          This is a subpath of an absolute path.
 boolean hasAttribute()
          The target is an attribute.
 boolean hasNamespace()
          The target is a namespace.
 boolean hasParentPath()
          This is a subpath of another path.
 boolean hasPathPartAt(int pPartIndex)
          Check for a part.
 boolean hasTextInfo()
          The target is a text node.
 boolean isAbsolute()
          This is an absolute path.
 boolean isMatch(StartPoint pStartPoint, PathContext pPathContext, int pDepth)
          Check if this path matches the start element tag.
 boolean isTopLevel()
          This is a top level path, this is, it is a data field path that should be activated when a record is matched.
static String makeDocContextName(String pDocContextPrefix, String pPathName)
          Create document context name from the record path name.
 void pushContext(int pDepth, boolean pReplicate, DocContext pDocContext)
          Push the current path context onto the path context stack.
 void removeTrigger(DocContext pDocContext, Trigger pTrigger)
          Remove a match Trigger.
 boolean requiresClear(DocContext pDocContext)
          Indicate that this path is marked for data field clearing.
 boolean requiresDeactivation(DocContext pDocContext)
          Indicate that this path is marked for deactivation.
 void reset(DocContext pDocContext)
          Reset this path for a new document.
 void resolveTextInfo()
          If the target is not defined, then make the target the element text.
 void setDefaultActivation(boolean pDefaultActivation)
          Set the default activation state of this path.
 void setDocContextPrefix(String pDocContextPrefix)
          Set the document context prefix for this path and its subpaths.
 void setFullRequiresClear(DocContext pDocContext, boolean pRequiresClear, String pReason)
          Mark this path for data field clearing, and also its subpaths.
 void setIsRecord(boolean pIsRecord)
          This will be a record path.
 void setRequiresDeactivation(DocContext pDocContext, boolean pRequiresDeactivation)
          Mark this path for deactivation by PointHandler.
 void setTextInfo(TextInfo pTextInfo)
          Set the text target description.
 List splitOnDescend()
          Paths with descendant axes must be split at these points so that the preceding part can continue to match subelements.
 String toString()
          Debugging description.
 String toString(boolean pIncludeInstanceNum)
          Debugging description, including TargetPath instance number,
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

iInstanceNum

public int iInstanceNum
Constructor Detail

TargetPath

public TargetPath()
Create an empty TargetPath.


TargetPath

public TargetPath(PathSpec pPathSpec)
Create a TargetPath from a PathSpec created by the ExprWalker class.


TargetPath

public TargetPath(PathSpec pPathSpec,
                  boolean pNamespaceAware)
Create a TargetPath from a PathSpec created by the ExprWalker class, and set the namespace awareness.

Method Detail

splitOnDescend

public List splitOnDescend()
Paths with descendant axes must be split at these points so that the preceding part can continue to match subelements.


resolveTextInfo

public void resolveTextInfo()
If the target is not defined, then make the target the element text.


setIsRecord

public void setIsRecord(boolean pIsRecord)
This will be a record path.


hasParentPath

public boolean hasParentPath()
This is a subpath of another path.


getParentPath

public TargetPath getParentPath()
Get the parent path of which this path is a subpath.


hasAttribute

public boolean hasAttribute()
The target is an attribute.


getAttrNameInfo

public NameInfo getAttrNameInfo()
Get the target attribute name.


hasTextInfo

public boolean hasTextInfo()
The target is a text node.


setTextInfo

public void setTextInfo(TextInfo pTextInfo)
Set the text target description.


getTextInfo

public TextInfo getTextInfo()
Get the text target description.


hasNamespace

public boolean hasNamespace()
The target is a namespace.


isAbsolute

public boolean isAbsolute()
This is an absolute path.


hasAbsoluteParent

public boolean hasAbsoluteParent()
This is a subpath of an absolute path.


isTopLevel

public boolean isTopLevel()
This is a top level path, this is, it is a data field path that should be activated when a record is matched.


setDocContextPrefix

public void setDocContextPrefix(String pDocContextPrefix)
Set the document context prefix for this path and its subpaths.


addTrigger

public void addTrigger(DocContext pDocContext,
                       Trigger pTrigger)
Add a Trigger to be executed when this path matches.


removeTrigger

public void removeTrigger(DocContext pDocContext,
                          Trigger pTrigger)
Remove a match Trigger.


addSubPath

public void addSubPath(TargetPath pTargetPath)
Add a subpath to this path.


getName

public String getName()
Get the name of this path - normally the XPath expression.


getDocContextName

public String getDocContextName()
Get the document context name of the data value that this path targets.


active

public boolean active(DocContext pDocContext)
Indicate that this path is active for the specified document context.


activate

public void activate(int pDepth,
                     DocContext pDocContext)
Activate this path and its precursors (subpaths are activated on target match).


deactivate

public void deactivate(DocContext pDocContext)
Deactivate this path, its subpaths and precursors.


setRequiresDeactivation

public void setRequiresDeactivation(DocContext pDocContext,
                                    boolean pRequiresDeactivation)
Mark this path for deactivation by PointHandler.


requiresDeactivation

public boolean requiresDeactivation(DocContext pDocContext)
Indicate that this path is marked for deactivation.


setFullRequiresClear

public void setFullRequiresClear(DocContext pDocContext,
                                 boolean pRequiresClear,
                                 String pReason)
Mark this path for data field clearing, and also its subpaths.


requiresClear

public boolean requiresClear(DocContext pDocContext)
Indicate that this path is marked for data field clearing.


reset

public void reset(DocContext pDocContext)
Reset this path for a new document.


clear

public void clear(DocContext pDocContext)
Clear the data value of this path.


setDefaultActivation

public void setDefaultActivation(boolean pDefaultActivation)
Set the default activation state of this path.


getDefaultActivation

public boolean getDefaultActivation()
Get the default activation state of this path.


handleStartPoint

public List handleStartPoint(StartPoint pStartPoint,
                             DocContext pDocContext)
Handle a StartPoint event.

Returns:
List of TextAppender objects

handleEndPoint

public boolean handleEndPoint(EndPoint pEndPoint,
                              DocContext pDocContext)
Handle an EndPoint event.

Returns:
true if target element end tag

isMatch

public boolean isMatch(StartPoint pStartPoint,
                       PathContext pPathContext,
                       int pDepth)
Check if this path matches the start element tag.


getValue

public Object getValue(DocContext pDocContext)
Get the current data field value of this path.


getContext

public com.ricebridge.xmlman.tp.Context getContext(DocContext pDocContext)
Get the current Jaxen Context of this path.


getNumParts

public int getNumParts()
Get this number of parts in this path.


hasPathPartAt

public boolean hasPathPartAt(int pPartIndex)
Check for a part.


getPathPartAt

public PathPart getPathPartAt(int pPartIndex)
Get the part at the specified index.


getMatchCount

public int getMatchCount(DocContext pDocContext)
Get the number of times this path has matched.


getInstanceNum

public int getInstanceNum()
Get the instance number of this path, for debugging.


getSubPathManager

public SubPathManager getSubPathManager()
Get the SubPathManager containing the subpaths of this path.


toString

public String toString()
Debugging description.


toString

public String toString(boolean pIncludeInstanceNum)
Debugging description, including TargetPath instance number,


pushContext

public void pushContext(int pDepth,
                        boolean pReplicate,
                        DocContext pDocContext)
Push the current path context onto the path context stack.

Used to manage descendant axes.


makeDocContextName

public static String makeDocContextName(String pDocContextPrefix,
                                        String pPathName)
Create document context name from the record path name.



Copyright © 2004-2005 Ricebridge