com.sun.org.apache.xml.internal.serializer.SerializationHandler Java Examples

The following examples show how to use com.sun.org.apache.xml.internal.serializer.SerializationHandler. 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: SAX2DTM2.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Copy the String value of a Text node to a SerializationHandler
 */
protected final void copyTextNode(final int nodeID, SerializationHandler handler)
    throws SAXException
{
    if (nodeID != DTM.NULL) {
        int dataIndex = m_dataOrQName.elementAt(nodeID);
        if (dataIndex >= 0) {
            m_chars.sendSAXcharacters(handler,
                                      dataIndex >>> TEXT_LENGTH_BITS,
                                      dataIndex & TEXT_LENGTH_MAX);
        } else {
            m_chars.sendSAXcharacters(handler, m_data.elementAt(-dataIndex),
                                      m_data.elementAt(-dataIndex+1));
        }
    }
}
 
Example #2
Source File: SAX2DTM2.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Copy the String value of a Text node to a SerializationHandler
 */
protected final void copyTextNode(final int nodeID, SerializationHandler handler)
    throws SAXException
{
    if (nodeID != DTM.NULL) {
        int dataIndex = m_dataOrQName.elementAt(nodeID);
        if (dataIndex >= 0) {
            m_chars.sendSAXcharacters(handler,
                                      dataIndex >>> TEXT_LENGTH_BITS,
                                      dataIndex & TEXT_LENGTH_MAX);
        } else {
            m_chars.sendSAXcharacters(handler, m_data.elementAt(-dataIndex),
                                      m_data.elementAt(-dataIndex+1));
        }
    }
}
 
Example #3
Source File: SimpleResultTreeImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
public void copy(DTMAxisIterator nodes, SerializationHandler handler)
    throws TransletException
{
    int node;
    while ((node = nodes.next()) != DTM.NULL)
    {
        copy(node, handler);
    }
}
 
Example #4
Source File: MultiDOM.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void copy(final int node, SerializationHandler handler)
    throws TransletException
{
    if (node != DTM.NULL) {
        _adapters[node >>> DTMManager.IDENT_DTM_NODE_BITS].copy(node, handler);
    }
}
 
Example #5
Source File: SAXImpl.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Copy the string value of a node directly to an output handler
 */
public void characters(final int node, SerializationHandler handler)
    throws TransletException
{
    if (node != DTM.NULL) {
        try {
            dispatchCharactersEvents(node, handler, false);
        } catch (SAXException e) {
            throw new TransletException(e);
        }
    }
}
 
Example #6
Source File: DOMAdapter.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
public void characters(final int textNode, SerializationHandler handler)
  throws TransletException
{
    if (_enhancedDOM != null) {
        _enhancedDOM.characters(textNode, handler);
    }
    else {
        _dom.characters(textNode, handler);
    }
}
 
Example #7
Source File: SimpleResultTreeImpl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void copy(DTMAxisIterator nodes, SerializationHandler handler)
    throws TransletException
{
    int node;
    while ((node = nodes.next()) != DTM.NULL)
    {
        copy(node, handler);
    }
}
 
Example #8
Source File: SAX2DTM2.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Copy  attribute nodes from an element .
 *
 * @param nodeID The Element node identity
 * @param handler The SerializationHandler
 */
protected final void copyAttributes(final int nodeID, SerializationHandler handler)
    throws SAXException{

   for(int current = getFirstAttributeIdentity(nodeID); current != DTM.NULL; current = getNextAttributeIdentity(current)){
        int eType = _exptype2(current);
        copyAttribute(current, eType, handler);
   }
}
 
Example #9
Source File: AdaptiveResultTreeImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void copy(final int node, SerializationHandler handler)
    throws TransletException
{
    if (_dom != null) {
        _dom.copy(node, handler);
    }
    else {
        super.copy(node, handler);
    }
}
 
Example #10
Source File: SAX2DTM2.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Copy  attribute nodes from an element .
 *
 * @param nodeID The Element node identity
 * @param handler The SerializationHandler
 */
protected final void copyAttributes(final int nodeID, SerializationHandler handler)
    throws SAXException{

   for(int current = getFirstAttributeIdentity(nodeID); current != DTM.NULL; current = getNextAttributeIdentity(current)){
        int eType = _exptype2(current);
        copyAttribute(current, eType, handler);
   }
}
 
Example #11
Source File: MultiDOM.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void copy(DTMAxisIterator nodes, SerializationHandler handler)
        throws TransletException
{
    int node;
    while ((node = nodes.next()) != DTM.NULL) {
        _adapters[node >>> DTMManager.IDENT_DTM_NODE_BITS].copy(node, handler);
    }
}
 
Example #12
Source File: SAX2DTM2.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Copy an Attribute node to a SerializationHandler
 *
 * @param nodeID The node identity
 * @param exptype The expanded type of the Element node
 * @param handler The SerializationHandler
 */
protected final void copyAttribute(int nodeID, int exptype,
    SerializationHandler handler)
    throws SAXException
{
    /*
        final String uri = getNamespaceName(node);
        if (uri.length() != 0) {
            final String prefix = getPrefix(node);
            handler.namespaceAfterStartElement(prefix, uri);
        }
        handler.addAttribute(getNodeName(node), getNodeValue(node));
    */
    final ExtendedType extType = m_extendedTypes[exptype];
    final String uri = extType.getNamespace();
    final String localName = extType.getLocalName();

    String prefix = null;
    String qname = null;
    int dataIndex = _dataOrQName(nodeID);
    int valueIndex = dataIndex;
        if (dataIndex <= 0) {
            int prefixIndex = m_data.elementAt(-dataIndex);
            valueIndex = m_data.elementAt(-dataIndex+1);
            qname = m_valuesOrPrefixes.indexToString(prefixIndex);
            int colonIndex = qname.indexOf(':');
            if (colonIndex > 0) {
                prefix = qname.substring(0, colonIndex);
            }
        }
        if (uri.length() != 0) {
            handler.namespaceAfterStartElement(prefix, uri);
        }

    String nodeName = (prefix != null) ? qname : localName;
    String nodeValue = (String)m_values.elementAt(valueIndex);

    handler.addAttribute(uri, localName, nodeName, "CDATA", nodeValue);
}
 
Example #13
Source File: SAXImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Copy a node-set to an output handler
 */
public void copy(DTMAxisIterator nodes, SerializationHandler handler)
    throws TransletException
{
    int node;
    while ((node = nodes.next()) != DTM.NULL) {
        copy(node, handler);
    }
}
 
Example #14
Source File: SAXImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Copy the string value of a node directly to an output handler
 */
public void characters(final int node, SerializationHandler handler)
    throws TransletException
{
    if (node != DTM.NULL) {
        try {
            dispatchCharactersEvents(node, handler, false);
        } catch (SAXException e) {
            throw new TransletException(e);
        }
    }
}
 
Example #15
Source File: AbstractTranslet.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Calls transform() with a given output handler
 */
public final void transform(DOM document, SerializationHandler handler)
    throws TransletException {
    try {
        transform(document, document.getIterator(), handler);
    } finally {
        _keyIndexes = null;
    }
}
 
Example #16
Source File: BasisLibrary.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public static void copy(Object obj,
                        SerializationHandler handler,
                        int node,
                        DOM dom) {
    try {
        if (obj instanceof DTMAxisIterator)
  {
            DTMAxisIterator iter = (DTMAxisIterator) obj;
            dom.copy(iter.reset(), handler);
        }
        else if (obj instanceof Node) {
            dom.copy(((Node) obj).node, handler);
        }
        else if (obj instanceof DOM) {
            //((DOM)obj).copy(((com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBase)((DOMAdapter)obj).getDOMImpl()).getDocument(), handler);
            DOM newDom = (DOM)obj;
            newDom.copy(newDom.getDocument(), handler);
        }
        else {
            String string = obj.toString();         // or call stringF()
            final int length = string.length();
            if (length > _characterArray.length)
                _characterArray = new char[length];
            string.getChars(0, length, _characterArray, 0);
            handler.characters(_characterArray, 0, length);
        }
    }
    catch (SAXException e) {
        runTimeError(RUN_TIME_COPY_ERR);
    }
}
 
Example #17
Source File: MultiDOM.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public String shallowCopy(final int node, SerializationHandler handler)
        throws TransletException
{
    if (node == DTM.NULL) {
        return "";
    }
    return _adapters[node >>> DTMManager.IDENT_DTM_NODE_BITS].shallowCopy(node, handler);
}
 
Example #18
Source File: SAX2DTM2.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Copy an Attribute node to a SerializationHandler
 *
 * @param nodeID The node identity
 * @param exptype The expanded type of the Element node
 * @param handler The SerializationHandler
 */
protected final void copyAttribute(int nodeID, int exptype,
    SerializationHandler handler)
    throws SAXException
{
    /*
        final String uri = getNamespaceName(node);
        if (uri.length() != 0) {
            final String prefix = getPrefix(node);
            handler.namespaceAfterStartElement(prefix, uri);
        }
        handler.addAttribute(getNodeName(node), getNodeValue(node));
    */
    final ExtendedType extType = m_extendedTypes[exptype];
    final String uri = extType.getNamespace();
    final String localName = extType.getLocalName();

    String prefix = null;
    String qname = null;
    int dataIndex = _dataOrQName(nodeID);
    int valueIndex = dataIndex;
        if (dataIndex <= 0) {
            int prefixIndex = m_data.elementAt(-dataIndex);
            valueIndex = m_data.elementAt(-dataIndex+1);
            qname = m_valuesOrPrefixes.indexToString(prefixIndex);
            int colonIndex = qname.indexOf(':');
            if (colonIndex > 0) {
                prefix = qname.substring(0, colonIndex);
            }
        }
        if (uri.length() != 0) {
            handler.namespaceAfterStartElement(prefix, uri);
        }

    String nodeName = (prefix != null) ? qname : localName;
    String nodeValue = (String)m_values.elementAt(valueIndex);

    handler.addAttribute(uri, localName, nodeName, "CDATA", nodeValue);
}
 
Example #19
Source File: SAX2DTM2.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Copy  attribute nodes from an element .
 *
 * @param nodeID The Element node identity
 * @param handler The SerializationHandler
 */
protected final void copyAttributes(final int nodeID, SerializationHandler handler)
    throws SAXException{

   for(int current = getFirstAttributeIdentity(nodeID); current != DTM.NULL; current = getNextAttributeIdentity(current)){
        int eType = _exptype2(current);
        copyAttribute(current, eType, handler);
   }
}
 
Example #20
Source File: SimpleResultTreeImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void copy(DTMAxisIterator nodes, SerializationHandler handler)
    throws TransletException
{
    int node;
    while ((node = nodes.next()) != DTM.NULL)
    {
        copy(node, handler);
    }
}
 
Example #21
Source File: SAXImpl.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
/**
 * Copies a processing instruction node to an output handler
 */
private void copyPI(final int node, SerializationHandler handler)
    throws TransletException
{
    final String target = getNodeName(node);
    final String value = getStringValueX(node);

    try {
        handler.processingInstruction(target, value);
    } catch (Exception e) {
        throw new TransletException(e);
    }
}
 
Example #22
Source File: DOMAdapter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public String shallowCopy(final int node, SerializationHandler handler)
    throws TransletException
{
    if (_enhancedDOM != null) {
        return _enhancedDOM.shallowCopy(node, handler);
    }
    else {
        return _dom.shallowCopy(node, handler);
    }
}
 
Example #23
Source File: SAXImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Copy the string value of a node directly to an output handler
 */
public void characters(final int node, SerializationHandler handler)
    throws TransletException
{
    if (node != DTM.NULL) {
        try {
            dispatchCharactersEvents(node, handler, false);
        } catch (SAXException e) {
            throw new TransletException(e);
        }
    }
}
 
Example #24
Source File: SAX2DTM2.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Copy an Element node to a SerializationHandler.
 *
 * @param nodeID The node identity
 * @param exptype The expanded type of the Element node
 * @param handler The SerializationHandler
 * @return The qualified name of the Element node.
 */
protected final String copyElement(int nodeID, int exptype,
                           SerializationHandler handler)
    throws SAXException
{
    final ExtendedType extType = m_extendedTypes[exptype];
    String uri = extType.getNamespace();
    String name = extType.getLocalName();

    if (uri.length() == 0) {
        handler.startElement(name);
        return name;
    } else {
        int qnameIndex = m_dataOrQName.elementAt(nodeID);

        if (qnameIndex == 0) {
            handler.startElement(name);
            handler.namespaceAfterStartElement(EMPTY_STR, uri);
            return name;
        }

        if (qnameIndex < 0) {
            qnameIndex = -qnameIndex;
            qnameIndex = m_data.elementAt(qnameIndex);
        }

        String qName = m_valuesOrPrefixes.indexToString(qnameIndex);
        handler.startElement(qName);
        int prefixIndex = qName.indexOf(':');
        String prefix;
        if (prefixIndex > 0) {
            prefix = qName.substring(0, prefixIndex);
        } else {
            prefix = null;
        }
        handler.namespaceAfterStartElement(prefix, uri);
        return qName;
    }
}
 
Example #25
Source File: SAX2DTM2.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Copy an Attribute node to a SerializationHandler
 *
 * @param nodeID The node identity
 * @param exptype The expanded type of the Element node
 * @param handler The SerializationHandler
 */
protected final void copyAttribute(int nodeID, int exptype,
    SerializationHandler handler)
    throws SAXException
{
    /*
        final String uri = getNamespaceName(node);
        if (uri.length() != 0) {
            final String prefix = getPrefix(node);
            handler.namespaceAfterStartElement(prefix, uri);
        }
        handler.addAttribute(getNodeName(node), getNodeValue(node));
    */
    final ExtendedType extType = m_extendedTypes[exptype];
    final String uri = extType.getNamespace();
    final String localName = extType.getLocalName();

    String prefix = null;
    String qname = null;
    int dataIndex = _dataOrQName(nodeID);
    int valueIndex = dataIndex;
        if (dataIndex <= 0) {
            int prefixIndex = m_data.elementAt(-dataIndex);
            valueIndex = m_data.elementAt(-dataIndex+1);
            qname = m_valuesOrPrefixes.indexToString(prefixIndex);
            int colonIndex = qname.indexOf(':');
            if (colonIndex > 0) {
                prefix = qname.substring(0, colonIndex);
            }
        }
        if (uri.length() != 0) {
            handler.namespaceAfterStartElement(prefix, uri);
        }

    String nodeName = (prefix != null) ? qname : localName;
    String nodeValue = (String)m_values.elementAt(valueIndex);

    handler.addAttribute(uri, localName, nodeName, "CDATA", nodeValue);
}
 
Example #26
Source File: SAXImpl.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Copies a processing instruction node to an output handler
 */
private void copyPI(final int node, SerializationHandler handler)
    throws TransletException
{
    final String target = getNodeName(node);
    final String value = getStringValueX(node);

    try {
        handler.processingInstruction(target, value);
    } catch (Exception e) {
        throw new TransletException(e);
    }
}
 
Example #27
Source File: DOMAdapter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public String shallowCopy(final int node, SerializationHandler handler)
    throws TransletException
{
    if (_enhancedDOM != null) {
        return _enhancedDOM.shallowCopy(node, handler);
    }
    else {
        return _dom.shallowCopy(node, handler);
    }
}
 
Example #28
Source File: AdaptiveResultTreeImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void copy(DTMAxisIterator nodes, SerializationHandler handler)
    throws TransletException
{
    if (_dom != null) {
        _dom.copy(nodes, handler);
    }
    else {
        super.copy(nodes, handler);
    }
}
 
Example #29
Source File: SimpleResultTreeImpl.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Dispatch the character content of a node to an output handler.
 *
 * The escape setting should be taken care of when outputting to
 * a handler.
 */
public void characters(final int node, SerializationHandler handler)
    throws TransletException
{
    int nodeID = getNodeIdent(node);
    if (nodeID == RTF_ROOT || nodeID == RTF_TEXT) {
        boolean escapeBit = false;
        boolean oldEscapeSetting = false;

        try {
            for (int i = 0; i < _size; i++) {

                if (_dontEscape != null) {
                    escapeBit = _dontEscape.getBit(i);
                    if (escapeBit) {
                        oldEscapeSetting = handler.setEscaping(false);
                    }
                }

                handler.characters(_textArray[i]);

                if (escapeBit) {
                    handler.setEscaping(oldEscapeSetting);
                }
            }
        } catch (SAXException e) {
            throw new TransletException(e);
        }
    }
}
 
Example #30
Source File: SAXImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Copy the string value of a node directly to an output handler
 */
public void characters(final int node, SerializationHandler handler)
    throws TransletException
{
    if (node != DTM.NULL) {
        try {
            dispatchCharactersEvents(node, handler, false);
        } catch (SAXException e) {
            throw new TransletException(e);
        }
    }
}