本文整理汇总了Java中net.sf.saxon.pattern.NameTest类的典型用法代码示例。如果您正苦于以下问题:Java NameTest类的具体用法?Java NameTest怎么用?Java NameTest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NameTest类属于net.sf.saxon.pattern包,在下文中一共展示了NameTest类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getArgumentTypes
import net.sf.saxon.pattern.NameTest; //导入依赖的package包/类
@Override
public SequenceType[] getArgumentTypes() {
// 1/ element(http:request)
final int one = StaticProperty.EXACTLY_ONE;
final int kind = Type.ELEMENT;
final String uri = HttpConstants.HTTP_CLIENT_NS_URI;
final NamePool pool = myConfig.getNamePool();
final ItemType itype = new NameTest(kind, uri, "request", pool);
SequenceType stype1 = SequenceType.makeSequenceType(itype, one); // 2/ xs:string?
SequenceType stype2 = SequenceType.OPTIONAL_STRING; // 3/ item()*
SequenceType stype3 = SequenceType.ANY_SEQUENCE; // 1/, 2/ and 3/
return new SequenceType[] { stype1, stype2, stype3 };
}
示例2: getAttribute
import net.sf.saxon.pattern.NameTest; //导入依赖的package包/类
@Override
public String getAttribute(String local_name) throws HttpClientException {
// get the attribute
NamePool pool = myNode.getConfiguration().getNamePool();
NodeTest pred = new NameTest(Type.ATTRIBUTE, "", local_name, pool);
AxisIterator attrs = myNode.iterateAxis(AxisInfo.ATTRIBUTE, pred);
NodeInfo a = (NodeInfo) attrs.next();
// return its string value, or null if there is no such attribute
if (a == null) {
return null;
} else {
return a.getStringValue();
}
}
示例3: DescendantAxisIterator
import net.sf.saxon.pattern.NameTest; //导入依赖的package包/类
public DescendantAxisIterator(NodeWrapper start, boolean includeSelf, boolean following, NodeTest test) {
this.start = start;
this.includeSelf = includeSelf;
this.following = following;
this.moveToNextSibling = following;
if (!following) anchor = start.node;
if (!includeSelf) currNode = start.node;
if (test == AnyNodeTest.getInstance()) { // performance hack
test = null; // mark as AnyNodeTest
}
else if (test instanceof NameTest) {
NameTest nt = (NameTest) test;
if (nt.getPrimitiveType() == Type.ELEMENT) { // performance hack
// mark as element name test
NamePool pool = getNamePool();
this.testLocalName = pool.getLocalName(nt.getFingerprint());
this.testURI = pool.getURI(nt.getFingerprint());
}
}
else if (test instanceof NodeKindTest) {
if (test.getPrimitiveType() == Type.ELEMENT) { // performance hack
// mark as element type test
this.testLocalName = "";
this.testURI = null;
}
}
this.nodeTest = test;
this.position = 0;
}
示例4: PrecedingAxisIterator
import net.sf.saxon.pattern.NameTest; //导入依赖的package包/类
public PrecedingAxisIterator(NodeWrapper start, boolean includeAncestors, NodeTest test) {
this.start = start;
this.includeAncestors = includeAncestors;
this.currNode = start.node;
if (includeAncestors)
nextAncestor = null;
else
nextAncestor = start.node.getParent();
if (test == AnyNodeTest.getInstance()) { // performance hack
test = null; // mark as AnyNodeTest
}
else if (test instanceof NameTest) {
NameTest nt = (NameTest) test;
if (nt.getPrimitiveType() == Type.ELEMENT) { // performance hack
// mark as element name test
NamePool pool = getNamePool();
this.testLocalName = pool.getLocalName(nt.getFingerprint());
this.testURI = pool.getURI(nt.getFingerprint());
}
}
else if (test instanceof NodeKindTest) {
if (test.getPrimitiveType() == Type.ELEMENT) { // performance hack
// mark as element type test
this.testLocalName = "";
this.testURI = null;
}
}
this.nodeTest = test;
this.position = 0;
}
示例5: AttributeEnumeration
import net.sf.saxon.pattern.NameTest; //导入依赖的package包/类
/**
* Constructor
* @param node the element whose attributes are required. This may be any type of node,
* but if it is not an element the enumeration will be empty
* @param nodeTest condition to be applied to the names of the attributes selected
*/
public AttributeEnumeration(NodeImpl node, NodeTest nodeTest)
{
this.nodeTest = nodeTest;
if (node.getNodeKind() == Type.ELEMENT)
{
element = (ElementImpl)node;
if (element.attrNames == null)
return;
if (nodeTest instanceof NameTest)
{
NameTest test = (NameTest)nodeTest;
int fingerprint = test.getFingerprint();
for (int i = 0; i < element.attrNames.length; i++)
{
if ((element.attrNames[i] & 0xfffff) == fingerprint) {
next = new AttributeImpl(element, i);
return;
}
}
next = null;
}
else {
length = element.attrNames.length;
advance();
}
}
else { // if it's not an element, or if we're not looking for attributes,
// then there's nothing to find
next = null;
index = 0;
length = 0;
}
}
示例6: iterateAxis
import net.sf.saxon.pattern.NameTest; //导入依赖的package包/类
/**
* Return an enumeration over the nodes reached by the given axis from this node
*
* @param axisNumber The axis to be iterated over
* @param nodeTest A pattern to be matched by the returned nodes
* @return an AxisIterator that scans the nodes reached by the axis in turn.
*/
public AxisIterator iterateAxis(byte axisNumber, NodeTest nodeTest)
{
switch (axisNumber)
{
case Axis.ANCESTOR:
return new AncestorEnumeration(this, nodeTest, false);
case Axis.ANCESTOR_OR_SELF:
return new AncestorEnumeration(this, nodeTest, true);
case Axis.ATTRIBUTE:
if (this.getNodeKind() != Type.ELEMENT)
{
return EmptyIterator.getInstance();
}
return new AttributeEnumeration(this, nodeTest);
case Axis.CHILD:
if (this instanceof ParentNodeImpl)
{
return ((ParentNodeImpl)this).enumerateChildren(nodeTest);
}
else {
return EmptyIterator.getInstance();
}
case Axis.DESCENDANT:
if (getNodeKind() == Type.DOCUMENT &&
nodeTest instanceof NameTest &&
nodeTest.getPrimitiveType() == Type.ELEMENT)
{
return ((LazyDocument)this).getAllElements(nodeTest.getFingerprint());
}
else if (hasChildNodes()) {
return new DescendantEnumeration(this, nodeTest, false);
}
else {
return EmptyIterator.getInstance();
}
case Axis.DESCENDANT_OR_SELF:
return new DescendantEnumeration(this, nodeTest, true);
case Axis.FOLLOWING:
return new FollowingEnumeration(this, nodeTest);
case Axis.FOLLOWING_SIBLING:
return new FollowingSiblingEnumeration(this, nodeTest);
case Axis.NAMESPACE:
if (this.getNodeKind() != Type.ELEMENT)
{
return EmptyIterator.getInstance();
}
return NamespaceIterator.makeIterator(this, nodeTest);
case Axis.PARENT:
NodeInfo parent = getParent();
if (parent == null) {
return EmptyIterator.getInstance();
}
return Navigator.filteredSingleton(parent, nodeTest);
case Axis.PRECEDING:
return new PrecedingEnumeration(this, nodeTest);
case Axis.PRECEDING_SIBLING:
return new PrecedingSiblingEnumeration(this, nodeTest);
case Axis.SELF:
return Navigator.filteredSingleton(this, nodeTest);
case Axis.PRECEDING_OR_ANCESTOR:
return new PrecedingOrAncestorEnumeration(this, nodeTest);
default:
throw new IllegalArgumentException("Unknown axis number " + axisNumber);
}
}
示例7: ProxyAttributeEnumeration
import net.sf.saxon.pattern.NameTest; //导入依赖的package包/类
/**
* Constructor
* @param element the element whose attributes are required. This may be any type of node,
* but if it is not an element the enumeration will be empty
* @param nodeTest condition to be applied to the names of the attributes selected
*/
public ProxyAttributeEnumeration(ProxyElement element, NodeTest nodeTest)
{
this.nodeTest = nodeTest;
if (element.attrNames == null)
return;
if (nodeTest instanceof NameTest)
{
NameTest test = (NameTest)nodeTest;
int fingerprint = test.getFingerprint();
for (int i = 0; i < element.attrNames.length; i++)
{
if ((element.attrNames[i] & 0xfffff) == fingerprint) {
next = new ProxyAttributeImpl(element, i);
return;
}
}
next = null;
}
else {
length = element.attrNames.length;
advance();
}
}