/** * Get a QName for a given fingerprint. * * @param fingerprint a code identifying an expanded QName, e.g. of an element or attribute * @return a qName containing the URI and local name corresponding to the supplied fingerprint. * There will be no prefix */ public StructuredQName getStructuredQName(int fingerprint) { return getUnprefixedQName(fingerprint); }
/** * Get a QName for a given fingerprint. * * @param fingerprint a code identifying an expanded QName, e.g. of an element or attribute * @return a qName containing the URI and local name corresponding to the supplied fingerprint. * There will be no prefix */ public StructuredQName getStructuredQName(int fingerprint) { return getUnprefixedQName(fingerprint); }
/** * Get the EQName form of a name, given its name code or fingerprint * * @param nameCode the integer name code or fingerprint of a name in the name pool * @return the name in the form Q{}local for a name in no namespace, or Q{uri}local for * a name in a namespace */ public String getEQName(int nameCode) { return getUnprefixedQName(nameCode).getEQName(); }
/** * Get the EQName form of a name, given its name code or fingerprint * * @param nameCode the integer name code or fingerprint of a name in the name pool * @return the name in the form Q{}local for a name in no namespace, or Q{uri}local for * a name in a namespace */ public String getEQName(int nameCode) { return getUnprefixedQName(nameCode).getEQName(); }
/** * Get the local part of a name, given its name code or fingerprint * * @param nameCode the integer name code or fingerprint of the name * @return the local part of the name represented by this name code or fingerprint */ public String getLocalName(int nameCode) { return getUnprefixedQName(nameCode).getLocalPart(); }
/** * Get the Clark form of a name, given its name code or fingerprint * * @param nameCode the integer name code or fingerprint of a name in the name pool * @return the local name if the name is in the null namespace, or "{uri}local" * otherwise. The name is always interned. */ public String getClarkName(int nameCode) { return getUnprefixedQName(nameCode).getClarkName(); }
/** * Get the namespace-URI of a name, given its name code or fingerprint * * @param nameCode the name code or fingerprint of a name * @return the namespace URI corresponding to this name code. Returns "" for the * no-namespace. * @throws IllegalArgumentException if the nameCode is not known to the NamePool. */ /*@NotNull*/ public String getURI(int nameCode) { return getUnprefixedQName(nameCode).getURI(); }
/** * Get the Clark form of a name, given its name code or fingerprint * * @param nameCode the integer name code or fingerprint of a name in the name pool * @return the local name if the name is in the null namespace, or "{uri}local" * otherwise. The name is always interned. */ public String getClarkName(int nameCode) { return getUnprefixedQName(nameCode).getClarkName(); }
/** * Get the local part of a name, given its name code or fingerprint * * @param nameCode the integer name code or fingerprint of the name * @return the local part of the name represented by this name code or fingerprint */ public String getLocalName(int nameCode) { return getUnprefixedQName(nameCode).getLocalPart(); }
private void computeUriAndLocal() { if (uri == null || localName == null) { StructuredQName name = namePool.getUnprefixedQName(fingerprint); uri = name.getURI(); localName = name.getLocalPart(); } }
/** * Get the name in the form of a StructuredQName * * @return the name in the form of a StructuredQName */ public StructuredQName getStructuredQName() { StructuredQName qn = pool.getUnprefixedQName(fingerprint); if (prefix.isEmpty()) { return qn; } else { return new StructuredQName(prefix, qn.getURI(), qn.getLocalPart()); } }
/** * Get the name in the form of a StructuredQName * * @return the name in the form of a StructuredQName */ public StructuredQName getStructuredQName() { StructuredQName qn = pool.getUnprefixedQName(fingerprint); if (prefix.isEmpty()) { return qn; } else { return new StructuredQName(prefix, qn.getURI(), qn.getLocalPart()); } }
/** * Get the namespace-URI of a name, given its name code or fingerprint * * @param nameCode the name code or fingerprint of a name * @return the namespace URI corresponding to this name code. Returns "" for the * no-namespace. * @throws IllegalArgumentException if the nameCode is not known to the NamePool. */ /*@NotNull*/ public String getURI(int nameCode) { int fp = nameCode & FP_MASK; if ((fp & USER_DEFINED_MASK) == 0) { return StandardNames.getURI(fp); } return getUnprefixedQName(fp).getURI(); }
/** * Get the string value of a given attribute of this node * * @param uri the namespace URI of the attribute name. Supply the empty string for an attribute * that is in no namespace * @param local the local part of the attribute name. * @return the attribute value if it exists, or null if it does not exist. Always returns null * if this node is not an element. * @since 9.4 */ @Override public String getAttributeValue(/*@NotNull*/ String uri, /*@NotNull*/ String local) { int a = tree.alpha[nodeNr]; if (a < 0) { return null; } NamePool pool = getNamePool(); while (a < tree.numberOfAttributes && tree.attParent[a] == nodeNr) { int nc = tree.attCode[a]; // Avoid allocating a name code for an ad-hoc request StructuredQName name = pool.getUnprefixedQName(nc); if (name.getLocalPart().equals(local) && name.hasURI(uri)) { return tree.attValue[a].toString(); } a++; } return null; }
public void addRule(NodeTestPattern pattern, Stripper.StripRuleTarget action, int precedence, int minImportPrecedence) throws XPathException { NodeTest test = pattern.getNodeTest(); double priority = test.getDefaultPriority(); Rule newRule = new Rule(pattern, action, precedence, minImportPrecedence, priority, sequence++); int prio = priority == 0 ? 2 : priority == -0.25 ? 1 : 0; newRule.setRank((precedence << 18) + (prio << 16) + sequence); if (test instanceof NodeKindTest) { newRule.setAlwaysMatches(true); anyElementRule = addRuleToList(newRule, anyElementRule, true); } else if (test instanceof NameTest) { newRule.setAlwaysMatches(true); int fp = test.getFingerprint(); NamePool pool = ((NameTest) test).getNamePool(); FingerprintedQName key = new FingerprintedQName(pool.getUnprefixedQName(fp), pool); Rule chain = namedElementRules.get(key); namedElementRules.put(key, addRuleToList(newRule, chain, true)); } else { unnamedElementRuleChain = addRuleToList(newRule, unnamedElementRuleChain, false); } }