Java Code Examples for org.w3c.dom.traversal.NodeFilter#SHOW_ATTRIBUTE

The following examples show how to use org.w3c.dom.traversal.NodeFilter#SHOW_ATTRIBUTE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XMLSerializer.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example 2
Source File: XMLSerializer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example 3
Source File: XMLSerializer.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example 4
Source File: XMLSerializer.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example 5
Source File: DomTreeWalker.java    From htmlunit with Apache License 2.0 5 votes vote down vote up
/**
 * Given a {@link Node}, return the appropriate constant for whatToShow.
 *
 * @param node the node
 * @return the whatToShow constant for the type of specified node
 */
static int getFlagForNode(final Node node) {
    switch (node.getNodeType()) {
        case Node.ELEMENT_NODE:
            return NodeFilter.SHOW_ELEMENT;
        case Node.ATTRIBUTE_NODE:
            return NodeFilter.SHOW_ATTRIBUTE;
        case Node.TEXT_NODE:
            return NodeFilter.SHOW_TEXT;
        case Node.CDATA_SECTION_NODE:
            return NodeFilter.SHOW_CDATA_SECTION;
        case Node.ENTITY_REFERENCE_NODE:
            return NodeFilter.SHOW_ENTITY_REFERENCE;
        case Node.ENTITY_NODE:
            return NodeFilter.SHOW_ENTITY;
        case Node.PROCESSING_INSTRUCTION_NODE:
            return NodeFilter.SHOW_PROCESSING_INSTRUCTION;
        case Node.COMMENT_NODE:
            return NodeFilter.SHOW_COMMENT;
        case Node.DOCUMENT_NODE:
            return NodeFilter.SHOW_DOCUMENT;
        case Node.DOCUMENT_TYPE_NODE:
            return NodeFilter.SHOW_DOCUMENT_TYPE;
        case Node.DOCUMENT_FRAGMENT_NODE:
            return NodeFilter.SHOW_DOCUMENT_FRAGMENT;
        case Node.NOTATION_NODE:
            return NodeFilter.SHOW_NOTATION;
        default:
            return 0;
    }
}
 
Example 6
Source File: DomTreeWalker.java    From HtmlUnit-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Given a {@link Node}, return the appropriate constant for whatToShow.
 *
 * @param node the node
 * @return the whatToShow constant for the type of specified node
 */
static int getFlagForNode(final Node node) {
    switch (node.getNodeType()) {
        case Node.ELEMENT_NODE:
            return NodeFilter.SHOW_ELEMENT;
        case Node.ATTRIBUTE_NODE:
            return NodeFilter.SHOW_ATTRIBUTE;
        case Node.TEXT_NODE:
            return NodeFilter.SHOW_TEXT;
        case Node.CDATA_SECTION_NODE:
            return NodeFilter.SHOW_CDATA_SECTION;
        case Node.ENTITY_REFERENCE_NODE:
            return NodeFilter.SHOW_ENTITY_REFERENCE;
        case Node.ENTITY_NODE:
            return NodeFilter.SHOW_ENTITY;
        case Node.PROCESSING_INSTRUCTION_NODE:
            return NodeFilter.SHOW_PROCESSING_INSTRUCTION;
        case Node.COMMENT_NODE:
            return NodeFilter.SHOW_COMMENT;
        case Node.DOCUMENT_NODE:
            return NodeFilter.SHOW_DOCUMENT;
        case Node.DOCUMENT_TYPE_NODE:
            return NodeFilter.SHOW_DOCUMENT_TYPE;
        case Node.DOCUMENT_FRAGMENT_NODE:
            return NodeFilter.SHOW_DOCUMENT_FRAGMENT;
        case Node.NOTATION_NODE:
            return NodeFilter.SHOW_NOTATION;
        default:
            return 0;
    }
}
 
Example 7
Source File: XMLSerializer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example 8
Source File: XMLSerializer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example 9
Source File: XMLSerializer.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example 10
Source File: XMLSerializer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example 11
Source File: XMLSerializer.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example 12
Source File: XMLSerializer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
    }
}
 
Example 13
Source File: XMLSerializer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
    }
}