Java 类org.w3c.dom.traversal.NodeFilter 实例源码
项目:convertigo-engine
文件:TwsTreeWalker.java
/** Internal function.
* Return the parent Node, from the input node
* after applying filter, whatToshow.
* The current node is not consulted or set.
*/
Node getParentNode(Node node) {
if (node == null || isSameNode(node, fRoot)) return null;
Node newNode = node.getParentNode();
if (newNode == null) return null;
int accept = acceptNode(newNode);
if (accept == NodeFilter.FILTER_ACCEPT)
return newNode;
else
//if (accept == NodeFilter.SKIP_NODE) // and REJECT too.
{
return getParentNode(newNode);
}
}
项目:OpenJSharp
文件:TreeWalkerImpl.java
/** Internal function.
* Return the parent Node, from the input node
* after applying filter, whatToshow.
* The current node is not consulted or set.
*/
Node getParentNode(Node node) {
if (node == null || node == fRoot) return null;
Node newNode = node.getParentNode();
if (newNode == null) return null;
int accept = acceptNode(newNode);
if (accept == NodeFilter.FILTER_ACCEPT)
return newNode;
else
//if (accept == NodeFilter.SKIP_NODE) // and REJECT too.
{
return getParentNode(newNode);
}
}
项目:openjdk-jdk10
文件:DocumentImpl.java
/**
* Create and return a NodeIterator. The NodeIterator is
* added to a list of NodeIterators so that it can be
* removed to free up the DOM Nodes it references.
*
* @param root The root of the iterator.
* @param whatToShow The whatToShow mask.
* @param filter The NodeFilter installed. Null means no filter.
* @param entityReferenceExpansion true to expand the contents of
* EntityReference nodes
* @since WD-DOM-Level-2-19990923
*/
public NodeIterator createNodeIterator(Node root,
int whatToShow,
NodeFilter filter,
boolean entityReferenceExpansion)
{
if (root == null) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
}
NodeIterator iterator = new NodeIteratorImpl(this,
root,
whatToShow,
filter,
entityReferenceExpansion);
if (iterators == null) {
iterators = new ArrayList<>();
}
iterators.add(iterator);
return iterator;
}
项目:openjdk-jdk10
文件:TreeWalkerImpl.java
/** Internal function.
* Return the parent Node, from the input node
* after applying filter, whatToshow.
* The current node is not consulted or set.
*/
Node getParentNode(Node node) {
if (node == null || node == fRoot) return null;
Node newNode = node.getParentNode();
if (newNode == null) return null;
int accept = acceptNode(newNode);
if (accept == NodeFilter.FILTER_ACCEPT)
return newNode;
else
//if (accept == NodeFilter.SKIP_NODE) // and REJECT too.
{
return getParentNode(newNode);
}
}
项目:openjdk-jdk10
文件:DOM3TreeWalker.java
/**
* Serializes a Comment Node.
*
* @param node The Comment Node to serialize
*/
protected void serializeComment(Comment node) throws SAXException {
// comments=true
if ((fFeatures & COMMENTS) != 0) {
String data = node.getData();
// well-formed=true
if ((fFeatures & WELLFORMED) != 0) {
isCommentWellFormed(data);
}
if (fLexicalHandler != null) {
// apply the LSSerializer filter after the operations requested by the
// DOMConfiguration parameters have been applied
if (!applyFilter(node, NodeFilter.SHOW_COMMENT)) {
return;
}
fLexicalHandler.comment(data.toCharArray(), 0, data.length());
}
}
}
项目:openjdk-jdk10
文件:DOM3TreeWalker.java
/**
* Serializes an ProcessingInstruction Node.
*
* @param node The ProcessingInstruction Node to serialize
*/
protected void serializePI(ProcessingInstruction node)
throws SAXException {
ProcessingInstruction pi = node;
String name = pi.getNodeName();
// well-formed=true
if ((fFeatures & WELLFORMED) != 0) {
isPIWellFormed(node);
}
// apply the LSSerializer filter
if (!applyFilter(node, NodeFilter.SHOW_PROCESSING_INSTRUCTION)) {
return;
}
// String data = pi.getData();
if (name.equals("xslt-next-is-raw")) {
fNextIsRaw = true;
} else {
this.fSerializer.processingInstruction(name, pi.getData());
}
}
项目:openjdk9
文件:DocumentImpl.java
/**
* Create and return a NodeIterator. The NodeIterator is
* added to a list of NodeIterators so that it can be
* removed to free up the DOM Nodes it references.
*
* @param root The root of the iterator.
* @param whatToShow The whatToShow mask.
* @param filter The NodeFilter installed. Null means no filter.
* @param entityReferenceExpansion true to expand the contents of
* EntityReference nodes
* @since WD-DOM-Level-2-19990923
*/
public NodeIterator createNodeIterator(Node root,
int whatToShow,
NodeFilter filter,
boolean entityReferenceExpansion)
{
if (root == null) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
}
NodeIterator iterator = new NodeIteratorImpl(this,
root,
whatToShow,
filter,
entityReferenceExpansion);
if (iterators == null) {
iterators = new ArrayList<>();
}
iterators.add(iterator);
return iterator;
}
项目:openjdk9
文件:TreeWalkerImpl.java
/** Internal function.
* Return the parent Node, from the input node
* after applying filter, whatToshow.
* The current node is not consulted or set.
*/
Node getParentNode(Node node) {
if (node == null || node == fRoot) return null;
Node newNode = node.getParentNode();
if (newNode == null) return null;
int accept = acceptNode(newNode);
if (accept == NodeFilter.FILTER_ACCEPT)
return newNode;
else
//if (accept == NodeFilter.SKIP_NODE) // and REJECT too.
{
return getParentNode(newNode);
}
}
项目:openjdk9
文件:DOM3TreeWalker.java
/**
* Serializes a Comment Node.
*
* @param node The Comment Node to serialize
*/
protected void serializeComment(Comment node) throws SAXException {
// comments=true
if ((fFeatures & COMMENTS) != 0) {
String data = node.getData();
// well-formed=true
if ((fFeatures & WELLFORMED) != 0) {
isCommentWellFormed(data);
}
if (fLexicalHandler != null) {
// apply the LSSerializer filter after the operations requested by the
// DOMConfiguration parameters have been applied
if (!applyFilter(node, NodeFilter.SHOW_COMMENT)) {
return;
}
fLexicalHandler.comment(data.toCharArray(), 0, data.length());
}
}
}
项目:openjdk9
文件:DOM3TreeWalker.java
/**
* Serializes an ProcessingInstruction Node.
*
* @param node The ProcessingInstruction Node to serialize
*/
protected void serializePI(ProcessingInstruction node)
throws SAXException {
ProcessingInstruction pi = node;
String name = pi.getNodeName();
// well-formed=true
if ((fFeatures & WELLFORMED) != 0) {
isPIWellFormed(node);
}
// apply the LSSerializer filter
if (!applyFilter(node, NodeFilter.SHOW_PROCESSING_INSTRUCTION)) {
return;
}
// String data = pi.getData();
if (name.equals("xslt-next-is-raw")) {
fNextIsRaw = true;
} else {
this.fSerializer.processingInstruction(name, pi.getData());
}
}
项目:citrus-admin
文件:RemoveSpringBeanFilter.java
/**
* {@inheritDoc}
*/
public short accept(Element element) {
if (isEqualById(element, elementId)) {
if (element.getNextSibling() != null && element.getNextSibling().getNodeType() == Node.TEXT_NODE) {
element.getParentNode().removeChild(element.getNextSibling());
}
markChildElementsForDeletion(element);
return NodeFilter.FILTER_REJECT;
}
if (shouldDeleteNode(element)) {
return NodeFilter.FILTER_REJECT;
}
return NodeFilter.FILTER_ACCEPT;
}
项目:citrus-admin
文件:UpdateSpringBeanFilter.java
/**
* {@inheritDoc}
*/
public short accept(Element element) {
if (added == null && (isEqualById(element, elementId))) {
if (element.getNextSibling() != null) {
added = element.getParentNode().insertBefore(element.getOwnerDocument().importNode(beanDefinition, true), element.getNextSibling());
} else {
added = element.getParentNode().appendChild(element.getOwnerDocument().importNode(beanDefinition, true));
}
updatedBeans++;
}
if (element.equals(added)) {
return NodeFilter.FILTER_ACCEPT;
}
return super.accept(element);
}
项目:jnieasy
文件:TreeWalkerImpl.java
/** Internal function.
* Return the parent Node, from the input node
* after applying filter, whatToshow.
* The current node is not consulted or set.
*/
Node getParentNode(Node node) {
if (node == null || isSameNode(node, fRoot)) return null;
Node newNode = node.getParentNode();
if (newNode == null) return null;
int accept = acceptNode(newNode);
if (accept == NodeFilter.FILTER_ACCEPT)
return newNode;
else
//if (accept == NodeFilter.SKIP_NODE) // and REJECT too.
{
return getParentNode(newNode);
}
}
项目:Push2Display
文件:TraversalSupport.java
/**
* Creates a new node iterator.
*/
public NodeIterator createNodeIterator(AbstractDocument doc,
Node root,
int whatToShow,
NodeFilter filter,
boolean entityReferenceExpansion)
throws DOMException {
if (root == null) {
throw doc.createDOMException
(DOMException.NOT_SUPPORTED_ERR, "null.root", null);
}
NodeIterator result = new DOMNodeIterator(doc, root, whatToShow,
filter,
entityReferenceExpansion);
if (iterators == null) {
iterators = new LinkedList();
}
iterators.add(result);
return result;
}
项目:Push2Display
文件:DOMTreeWalker.java
/**
* Returns the first child of the given node.
*/
protected Node firstChild(Node n) {
if (n.getNodeType() == Node.ENTITY_REFERENCE_NODE &&
!expandEntityReferences) {
return null;
}
Node result = n.getFirstChild();
if (result == null) {
return null;
}
switch (acceptNode(result)) {
case NodeFilter.FILTER_ACCEPT:
return result;
case NodeFilter.FILTER_SKIP:
Node t = firstChild(result);
if (t != null) {
return t;
}
// Fall through
default: // NodeFilter.FILTER_REJECT
return nextSibling(result, n);
}
}
项目:Push2Display
文件:DOMTreeWalker.java
/**
* Returns the last child of the given node.
*/
protected Node lastChild(Node n) {
if (n.getNodeType() == Node.ENTITY_REFERENCE_NODE &&
!expandEntityReferences) {
return null;
}
Node result = n.getLastChild();
if (result == null) {
return null;
}
switch (acceptNode(result)) {
case NodeFilter.FILTER_ACCEPT:
return result;
case NodeFilter.FILTER_SKIP:
Node t = lastChild(result);
if (t != null) {
return t;
}
// Fall through
default: // NodeFilter.FILTER_REJECT
return previousSibling(result, n);
}
}
项目:javify
文件:GnomeDocument.java
public Element getElementById(String elementId)
{
Element element = xmljGetElementById(elementId);
if (element == null)
{
TreeWalker walker = createTreeWalker(this, NodeFilter.SHOW_ELEMENT,
null, false);
for (Node node = walker.nextNode(); node != null;
node = walker.nextNode())
{
GnomeElement e = (GnomeElement) node;
if (e.userIdAttrs != null)
{
for (Iterator i = e.userIdAttrs.iterator(); i.hasNext(); )
{
Attr attr = (Attr) i.next();
if (attr.getNodeValue().equals(elementId))
{
return e;
}
}
}
}
}
return element;
}
项目:convertigo-engine
文件:TwsTreeWalker.java
/** Public constructor */
public TwsTreeWalker(Node root,
int whatToShow,
NodeFilter nodeFilter,
boolean entityReferenceExpansion) {
fCurrentNode = root;
fRoot = root;
fUseIsSameNode = useIsSameNode(root);
fWhatToShow = whatToShow;
fNodeFilter = nodeFilter;
fEntityReferenceExpansion = entityReferenceExpansion;
}
项目:convertigo-engine
文件:TwsTreeWalker.java
/** Internal function.
* Return the previousSibling Node, from the input node
* after applying filter, whatToshow.
* NEVER TRAVERSES ABOVE THE SPECIFIED ROOT NODE.
* The current node is not consulted or set.
*/
Node getPreviousSibling(Node node, Node root) {
if (node == null || isSameNode(node, root)) return null;
Node newNode = node.getPreviousSibling();
if (newNode == null) {
newNode = node.getParentNode();
if (newNode == null || isSameNode(newNode, root)) return null;
int parentAccept = acceptNode(newNode);
if (parentAccept==NodeFilter.FILTER_SKIP) {
return getPreviousSibling(newNode, root);
}
return null;
}
int accept = acceptNode(newNode);
if (accept == NodeFilter.FILTER_ACCEPT)
return newNode;
else
if (accept == NodeFilter.FILTER_SKIP) {
Node fChild = getLastChild(newNode);
if (fChild == null) {
return getPreviousSibling(newNode, root);
}
return fChild;
}
else
//if (accept == NodeFilter.REJECT_NODE)
{
return getPreviousSibling(newNode, root);
}
}
项目:convertigo-engine
文件:TwsTreeWalker.java
/** Internal function.
* Return the first child Node, from the input node
* after applying filter, whatToshow.
* The current node is not consulted or set.
*/
Node getFirstChild(Node node) {
if (node == null) return null;
if ( !fEntityReferenceExpansion
&& node.getNodeType() == Node.ENTITY_REFERENCE_NODE)
return null;
Node newNode = node.getFirstChild();
if (newNode == null) return null;
int accept = acceptNode(newNode);
if (accept == NodeFilter.FILTER_ACCEPT)
return newNode;
else
if (accept == NodeFilter.FILTER_SKIP
&& newNode.hasChildNodes())
{
Node fChild = getFirstChild(newNode);
if (fChild == null) {
return getNextSibling(newNode, node);
}
return fChild;
}
else
//if (accept == NodeFilter.REJECT_NODE)
{
return getNextSibling(newNode, node);
}
}
项目:convertigo-engine
文件:TwsTreeWalker.java
/** Internal function.
* Return the last child Node, from the input node
* after applying filter, whatToshow.
* The current node is not consulted or set.
*/
Node getLastChild(Node node) {
if (node == null) return null;
if ( !fEntityReferenceExpansion
&& node.getNodeType() == Node.ENTITY_REFERENCE_NODE)
return null;
Node newNode = node.getLastChild();
if (newNode == null) return null;
int accept = acceptNode(newNode);
if (accept == NodeFilter.FILTER_ACCEPT)
return newNode;
else
if (accept == NodeFilter.FILTER_SKIP
&& newNode.hasChildNodes())
{
Node lChild = getLastChild(newNode);
if (lChild == null) {
return getPreviousSibling(newNode, node);
}
return lChild;
}
else
//if (accept == NodeFilter.REJECT_NODE)
{
return getPreviousSibling(newNode, node);
}
}
项目:convertigo-engine
文件:TwsTreeWalker.java
/** Internal function.
* The node whatToShow and the filter are combined into one result. */
short acceptNode(Node node) {
/***
7.1.2.4. Filters and whatToShow flags
Iterator and TreeWalker apply whatToShow flags before applying Filters. If a node is rejected by the
active whatToShow flags, a Filter will not be called to evaluate that node. When a node is rejected by
the active whatToShow flags, children of that node will still be considered, and Filters may be called to
evaluate them.
***/
if (fNodeFilter == null) {
if ( ( fWhatToShow & (1 << node.getNodeType()-1)) != 0) {
return NodeFilter.FILTER_ACCEPT;
} else {
return NodeFilter.FILTER_SKIP;
}
} else {
if ((fWhatToShow & (1 << node.getNodeType()-1)) != 0 ) {
return fNodeFilter.acceptNode(node);
} else {
// What to show has failed. See above excerpt from spec.
// Equivalent to FILTER_SKIP.
return NodeFilter.FILTER_SKIP;
}
}
}
项目:convertigo-engine
文件:TwsCachedXPathAPI.java
@Override
public NodeFilter getFilter() {
return new NodeFilter() {
@Override
public short acceptNode(Node arg0) {
return 0;
}
};
}
项目:convertigo-engine
文件:Sequence.java
private static void buildOutputDom(Element root, OutputFilter outputFilter) {
try {
TreeWalker walker = new TwsTreeWalker(root, NodeFilter.SHOW_ELEMENT, outputFilter, false);
traverseLevel(walker,null,"");
outputFilter.doOutPut();
}
finally {
if (outputFilter != null) {
outputFilter.map.clear();
}
}
}
项目:OpenJSharp
文件:NodeIteratorImpl.java
/** Public constructor */
public NodeIteratorImpl( DocumentImpl document,
Node root,
int whatToShow,
NodeFilter nodeFilter,
boolean entityReferenceExpansion) {
fDocument = document;
fRoot = root;
fCurrentNode = null;
fWhatToShow = whatToShow;
fNodeFilter = nodeFilter;
fEntityReferenceExpansion = entityReferenceExpansion;
}
项目:OpenJSharp
文件:NodeIteratorImpl.java
/** The node is accepted if it passes the whatToShow and the filter. */
boolean acceptNode(Node node) {
if (fNodeFilter == null) {
return ( fWhatToShow & (1 << node.getNodeType()-1)) != 0 ;
} else {
return ((fWhatToShow & (1 << node.getNodeType()-1)) != 0 )
&& fNodeFilter.acceptNode(node) == NodeFilter.FILTER_ACCEPT;
}
}
项目:OpenJSharp
文件:DocumentImpl.java
/**
* Create and return a TreeWalker.
*
* @param root The root of the iterator.
* @param whatToShow The whatToShow mask.
* @param filter The NodeFilter installed. Null means no filter.
* @param entityReferenceExpansion true to expand the contents of
* EntityReference nodes
* @since WD-DOM-Level-2-19990923
*/
public TreeWalker createTreeWalker(Node root,
int whatToShow,
NodeFilter filter,
boolean entityReferenceExpansion)
{
if (root == null) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
}
return new TreeWalkerImpl(root, whatToShow, filter,
entityReferenceExpansion);
}
项目:OpenJSharp
文件:TreeWalkerImpl.java
/** Public constructor */
public TreeWalkerImpl(Node root,
int whatToShow,
NodeFilter nodeFilter,
boolean entityReferenceExpansion) {
fCurrentNode = root;
fRoot = root;
fWhatToShow = whatToShow;
fNodeFilter = nodeFilter;
fEntityReferenceExpansion = entityReferenceExpansion;
}
项目:OpenJSharp
文件:TreeWalkerImpl.java
/** Internal function.
* Return the nextSibling Node, from the input node
* after applying filter, whatToshow.
* NEVER TRAVERSES ABOVE THE SPECIFIED ROOT NODE.
* The current node is not consulted or set.
*/
Node getNextSibling(Node node, Node root) {
if (node == null || node == root) return null;
Node newNode = node.getNextSibling();
if (newNode == null) {
newNode = node.getParentNode();
if (newNode == null || newNode == root) return null;
int parentAccept = acceptNode(newNode);
if (parentAccept==NodeFilter.FILTER_SKIP) {
return getNextSibling(newNode, root);
}
return null;
}
int accept = acceptNode(newNode);
if (accept == NodeFilter.FILTER_ACCEPT)
return newNode;
else
if (accept == NodeFilter.FILTER_SKIP) {
Node fChild = getFirstChild(newNode);
if (fChild == null) {
return getNextSibling(newNode, root);
}
return fChild;
}
else
//if (accept == NodeFilter.REJECT_NODE)
{
return getNextSibling(newNode, root);
}
}
项目:OpenJSharp
文件:TreeWalkerImpl.java
/** Internal function.
* Return the previousSibling Node, from the input node
* after applying filter, whatToshow.
* NEVER TRAVERSES ABOVE THE SPECIFIED ROOT NODE.
* The current node is not consulted or set.
*/
Node getPreviousSibling(Node node, Node root) {
if (node == null || node == root) return null;
Node newNode = node.getPreviousSibling();
if (newNode == null) {
newNode = node.getParentNode();
if (newNode == null || newNode == root) return null;
int parentAccept = acceptNode(newNode);
if (parentAccept==NodeFilter.FILTER_SKIP) {
return getPreviousSibling(newNode, root);
}
return null;
}
int accept = acceptNode(newNode);
if (accept == NodeFilter.FILTER_ACCEPT)
return newNode;
else
if (accept == NodeFilter.FILTER_SKIP) {
Node fChild = getLastChild(newNode);
if (fChild == null) {
return getPreviousSibling(newNode, root);
}
return fChild;
}
else
//if (accept == NodeFilter.REJECT_NODE)
{
return getPreviousSibling(newNode, root);
}
}
项目:OpenJSharp
文件:TreeWalkerImpl.java
/** Internal function.
* Return the first child Node, from the input node
* after applying filter, whatToshow.
* The current node is not consulted or set.
*/
Node getFirstChild(Node node) {
if (node == null) return null;
if ( !fEntityReferenceExpansion
&& node.getNodeType() == Node.ENTITY_REFERENCE_NODE)
return null;
Node newNode = node.getFirstChild();
if (newNode == null) return null;
int accept = acceptNode(newNode);
if (accept == NodeFilter.FILTER_ACCEPT)
return newNode;
else
if (accept == NodeFilter.FILTER_SKIP
&& newNode.hasChildNodes())
{
Node fChild = getFirstChild(newNode);
if (fChild == null) {
return getNextSibling(newNode, node);
}
return fChild;
}
else
//if (accept == NodeFilter.REJECT_NODE)
{
return getNextSibling(newNode, node);
}
}
项目:OpenJSharp
文件:TreeWalkerImpl.java
/** Internal function.
* Return the last child Node, from the input node
* after applying filter, whatToshow.
* The current node is not consulted or set.
*/
Node getLastChild(Node node) {
if (node == null) return null;
if ( !fEntityReferenceExpansion
&& node.getNodeType() == Node.ENTITY_REFERENCE_NODE)
return null;
Node newNode = node.getLastChild();
if (newNode == null) return null;
int accept = acceptNode(newNode);
if (accept == NodeFilter.FILTER_ACCEPT)
return newNode;
else
if (accept == NodeFilter.FILTER_SKIP
&& newNode.hasChildNodes())
{
Node lChild = getLastChild(newNode);
if (lChild == null) {
return getPreviousSibling(newNode, node);
}
return lChild;
}
else
//if (accept == NodeFilter.REJECT_NODE)
{
return getPreviousSibling(newNode, node);
}
}
项目:OpenJSharp
文件:TreeWalkerImpl.java
/** Internal function.
* The node whatToShow and the filter are combined into one result. */
short acceptNode(Node node) {
/***
7.1.2.4. Filters and whatToShow flags
Iterator and TreeWalker apply whatToShow flags before applying Filters. If a node is rejected by the
active whatToShow flags, a Filter will not be called to evaluate that node. When a node is rejected by
the active whatToShow flags, children of that node will still be considered, and Filters may be called to
evaluate them.
***/
if (fNodeFilter == null) {
if ( ( fWhatToShow & (1 << node.getNodeType()-1)) != 0) {
return NodeFilter.FILTER_ACCEPT;
} else {
return NodeFilter.FILTER_SKIP;
}
} else {
if ((fWhatToShow & (1 << node.getNodeType()-1)) != 0 ) {
return fNodeFilter.acceptNode(node);
} else {
// What to show has failed. See above excerpt from spec.
// Equivalent to FILTER_SKIP.
return NodeFilter.FILTER_SKIP;
}
}
}
项目:OpenJSharp
文件:XMLSerializer.java
/**
* Prints attribute.
* NOTE: xml:space attribute modifies output format
*
* @param name
* @param value
* @param isSpecified
* @exception IOException
*/
private void printAttribute (String name, String value, boolean isSpecified, Attr attr) throws IOException{
if (isSpecified || (features & DOMSerializerImpl.DISCARDDEFAULT) == 0) {
if (fDOMFilter !=null &&
(fDOMFilter.getWhatToShow() & NodeFilter.SHOW_ATTRIBUTE)!= 0) {
short code = fDOMFilter.acceptNode(attr);
switch (code) {
case NodeFilter.FILTER_REJECT:
case NodeFilter.FILTER_SKIP: {
return;
}
default: {
// fall through
}
}
}
_printer.printSpace();
_printer.printText( name );
_printer.printText( "=\"" );
printEscaped( value );
_printer.printText( '"' );
}
// If the attribute xml:space exists, determine whether
// to preserve spaces in this and child nodes based on
// its value.
if (name.equals( "xml:space" )) {
if (value.equals( "preserve" ))
fPreserveSpace = true;
else
fPreserveSpace = _format.getPreserveSpace();
}
}
项目:openjdk-jdk10
文件:NodeIteratorImpl.java
/** Public constructor */
public NodeIteratorImpl( DocumentImpl document,
Node root,
int whatToShow,
NodeFilter nodeFilter,
boolean entityReferenceExpansion) {
fDocument = document;
fRoot = root;
fCurrentNode = null;
fWhatToShow = whatToShow;
fNodeFilter = nodeFilter;
fEntityReferenceExpansion = entityReferenceExpansion;
}
项目:openjdk-jdk10
文件:NodeIteratorImpl.java
/** The node is accepted if it passes the whatToShow and the filter. */
boolean acceptNode(Node node) {
if (fNodeFilter == null) {
return ( fWhatToShow & (1 << node.getNodeType()-1)) != 0 ;
} else {
return ((fWhatToShow & (1 << node.getNodeType()-1)) != 0 )
&& fNodeFilter.acceptNode(node) == NodeFilter.FILTER_ACCEPT;
}
}
项目:openjdk-jdk10
文件:DocumentImpl.java
/**
* Create and return a TreeWalker.
*
* @param root The root of the iterator.
* @param whatToShow The whatToShow mask.
* @param filter The NodeFilter installed. Null means no filter.
* @param entityReferenceExpansion true to expand the contents of
* EntityReference nodes
* @since WD-DOM-Level-2-19990923
*/
public TreeWalker createTreeWalker(Node root,
int whatToShow,
NodeFilter filter,
boolean entityReferenceExpansion)
{
if (root == null) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", null);
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
}
return new TreeWalkerImpl(root, whatToShow, filter,
entityReferenceExpansion);
}
项目:openjdk-jdk10
文件:TreeWalkerImpl.java
/** Public constructor */
public TreeWalkerImpl(Node root,
int whatToShow,
NodeFilter nodeFilter,
boolean entityReferenceExpansion) {
fCurrentNode = root;
fRoot = root;
fWhatToShow = whatToShow;
fNodeFilter = nodeFilter;
fEntityReferenceExpansion = entityReferenceExpansion;
}
项目:openjdk-jdk10
文件:TreeWalkerImpl.java
/** Internal function.
* Return the nextSibling Node, from the input node
* after applying filter, whatToshow.
* NEVER TRAVERSES ABOVE THE SPECIFIED ROOT NODE.
* The current node is not consulted or set.
*/
Node getNextSibling(Node node, Node root) {
if (node == null || node == root) return null;
Node newNode = node.getNextSibling();
if (newNode == null) {
newNode = node.getParentNode();
if (newNode == null || newNode == root) return null;
int parentAccept = acceptNode(newNode);
if (parentAccept==NodeFilter.FILTER_SKIP) {
return getNextSibling(newNode, root);
}
return null;
}
int accept = acceptNode(newNode);
if (accept == NodeFilter.FILTER_ACCEPT)
return newNode;
else
if (accept == NodeFilter.FILTER_SKIP) {
Node fChild = getFirstChild(newNode);
if (fChild == null) {
return getNextSibling(newNode, root);
}
return fChild;
}
else
//if (accept == NodeFilter.REJECT_NODE)
{
return getNextSibling(newNode, root);
}
}
项目:openjdk-jdk10
文件:TreeWalkerImpl.java
/** Internal function.
* Return the previousSibling Node, from the input node
* after applying filter, whatToshow.
* NEVER TRAVERSES ABOVE THE SPECIFIED ROOT NODE.
* The current node is not consulted or set.
*/
Node getPreviousSibling(Node node, Node root) {
if (node == null || node == root) return null;
Node newNode = node.getPreviousSibling();
if (newNode == null) {
newNode = node.getParentNode();
if (newNode == null || newNode == root) return null;
int parentAccept = acceptNode(newNode);
if (parentAccept==NodeFilter.FILTER_SKIP) {
return getPreviousSibling(newNode, root);
}
return null;
}
int accept = acceptNode(newNode);
if (accept == NodeFilter.FILTER_ACCEPT)
return newNode;
else
if (accept == NodeFilter.FILTER_SKIP) {
Node fChild = getLastChild(newNode);
if (fChild == null) {
return getPreviousSibling(newNode, root);
}
return fChild;
}
else
//if (accept == NodeFilter.REJECT_NODE)
{
return getPreviousSibling(newNode, root);
}
}