com.sun.xml.internal.txw2.TxwException Java Examples

The following examples show how to use com.sun.xml.internal.txw2.TxwException. 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: DomSerializer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public DomSerializer(DOMResult domResult) {
    Node node = domResult.getNode();

    if (node == null) {
        try {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            dbf.setNamespaceAware(true);
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.newDocument();
            domResult.setNode(doc);
            serializer = new SaxSerializer(new Dom2SaxAdapter(doc),null,false);
        } catch (ParserConfigurationException pce) {
            throw new TxwException(pce);
        }
    } else {
        serializer = new SaxSerializer(new Dom2SaxAdapter(node),null,false);
    }
}
 
Example #2
Source File: SaxSerializer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public void endStartTag(String uri, String localName, String prefix) {
    try {
        while (prefixBindings.size() != 0) {
            writer.startPrefixMapping(prefixBindings.pop(), // prefix
                    prefixBindings.pop()   // uri
            );
        }

        writer.startElement(uri,
                localName,
                getQName(prefix, localName),
                attrs);

        attrs.clear();
    } catch (SAXException e) {
        throw new TxwException(e);
    }
}
 
Example #3
Source File: DomSerializer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public DomSerializer(DOMResult domResult) {
    Node node = domResult.getNode();

    if (node == null) {
        try {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            dbf.setNamespaceAware(true);
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.newDocument();
            domResult.setNode(doc);
            serializer = new SaxSerializer(new Dom2SaxAdapter(doc),null,false);
        } catch (ParserConfigurationException pce) {
            throw new TxwException(pce);
        }
    } else {
        serializer = new SaxSerializer(new Dom2SaxAdapter(node),null,false);
    }
}
 
Example #4
Source File: SaxSerializer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void endStartTag(String uri, String localName, String prefix) {
    try {
        while (prefixBindings.size() != 0) {
            writer.startPrefixMapping(prefixBindings.pop(), // prefix
                    prefixBindings.pop()   // uri
            );
        }

        writer.startElement(uri,
                localName,
                getQName(prefix, localName),
                attrs);

        attrs.clear();
    } catch (SAXException e) {
        throw new TxwException(e);
    }
}
 
Example #5
Source File: SaxSerializer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void endStartTag(String uri, String localName, String prefix) {
    try {
        while (prefixBindings.size() != 0) {
            writer.startPrefixMapping(prefixBindings.pop(), // prefix
                    prefixBindings.pop()   // uri
            );
        }

        writer.startElement(uri,
                localName,
                getQName(prefix, localName),
                attrs);

        attrs.clear();
    } catch (SAXException e) {
        throw new TxwException(e);
    }
}
 
Example #6
Source File: DomSerializer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public DomSerializer(DOMResult domResult) {
    Node node = domResult.getNode();

    if (node == null) {
        try {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            dbf.setNamespaceAware(true);
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.newDocument();
            domResult.setNode(doc);
            serializer = new SaxSerializer(new Dom2SaxAdapter(doc),null,false);
        } catch (ParserConfigurationException pce) {
            throw new TxwException(pce);
        }
    } else {
        serializer = new SaxSerializer(new Dom2SaxAdapter(node),null,false);
    }
}
 
Example #7
Source File: DomSerializer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public DomSerializer(DOMResult domResult) {
    Node node = domResult.getNode();

    if (node == null) {
        try {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            dbf.setNamespaceAware(true);
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.newDocument();
            domResult.setNode(doc);
            serializer = new SaxSerializer(new Dom2SaxAdapter(doc),null,false);
        } catch (ParserConfigurationException pce) {
            throw new TxwException(pce);
        }
    } else {
        serializer = new SaxSerializer(new Dom2SaxAdapter(node),null,false);
    }
}
 
Example #8
Source File: DomSerializer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public DomSerializer(DOMResult domResult) {
    Node node = domResult.getNode();

    if (node == null) {
        try {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            dbf.setNamespaceAware(true);
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.newDocument();
            domResult.setNode(doc);
            serializer = new SaxSerializer(new Dom2SaxAdapter(doc),null,false);
        } catch (ParserConfigurationException pce) {
            throw new TxwException(pce);
        }
    } else {
        serializer = new SaxSerializer(new Dom2SaxAdapter(node),null,false);
    }
}
 
Example #9
Source File: SaxSerializer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void endStartTag(String uri, String localName, String prefix) {
    try {
        while (prefixBindings.size() != 0) {
            writer.startPrefixMapping(prefixBindings.pop(), // prefix
                    prefixBindings.pop()   // uri
            );
        }

        writer.startElement(uri,
                localName,
                getQName(prefix, localName),
                attrs);

        attrs.clear();
    } catch (SAXException e) {
        throw new TxwException(e);
    }
}
 
Example #10
Source File: SaxSerializer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public void endStartTag(String uri, String localName, String prefix) {
    try {
        while (prefixBindings.size() != 0) {
            writer.startPrefixMapping(prefixBindings.pop(), // prefix
                    prefixBindings.pop()   // uri
            );
        }

        writer.startElement(uri,
                localName,
                getQName(prefix, localName),
                attrs);

        attrs.clear();
    } catch (SAXException e) {
        throw new TxwException(e);
    }
}
 
Example #11
Source File: StreamSerializer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public StreamSerializer(StreamResult streamResult) {
    // if this method opened a stream, let it close it
    final OutputStream[] autoClose = new OutputStream[1];

    if (streamResult.getWriter() != null)
        writer = createWriter(streamResult.getWriter());
    else if (streamResult.getOutputStream() != null)
        writer = createWriter(streamResult.getOutputStream());
    else if (streamResult.getSystemId() != null) {
        String fileURL = streamResult.getSystemId();

        fileURL = convertURL(fileURL);

        try {
            FileOutputStream fos = new FileOutputStream(fileURL);
            autoClose[0] = fos;
            writer = createWriter(fos);
        } catch (IOException e) {
            throw new TxwException(e);
        }
    } else
        throw new IllegalArgumentException();

    // now delegate to the SaxSerializer
    serializer = new SaxSerializer(writer,writer,false) {
        public void endDocument() {
            super.endDocument();
            if(autoClose[0]!=null) {
                try {
                    autoClose[0].close();
                } catch (IOException e) {
                    throw new TxwException(e);
                }
                autoClose[0] = null;
            }
        }
    };
}
 
Example #12
Source File: StreamSerializer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void flush() {
    serializer.flush();
    try {
        writer.flush();
    } catch (IOException e) {
        throw new TxwException(e);
    }
}
 
Example #13
Source File: StaxSerializer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void flush() {
    try {
        out.flush();
    } catch (XMLStreamException e) {
        throw new TxwException(e);
    }
}
 
Example #14
Source File: SaxSerializer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void startDocument() {
    try {
        writer.startDocument();
    } catch (SAXException e) {
        throw new TxwException(e);
    }
}
 
Example #15
Source File: StreamSerializer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void flush() {
    serializer.flush();
    try {
        writer.flush();
    } catch (IOException e) {
        throw new TxwException(e);
    }
}
 
Example #16
Source File: SaxSerializer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void endTag() {
    try {
        writer.endElement(elementBindings.pop(), // uri
                elementBindings.pop(), // localName
                elementBindings.pop()  // qname
        );
    } catch (SAXException e) {
        throw new TxwException(e);
    }
}
 
Example #17
Source File: StreamSerializer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public StreamSerializer(StreamResult streamResult) {
    // if this method opened a stream, let it close it
    final OutputStream[] autoClose = new OutputStream[1];

    if (streamResult.getWriter() != null)
        writer = createWriter(streamResult.getWriter());
    else if (streamResult.getOutputStream() != null)
        writer = createWriter(streamResult.getOutputStream());
    else if (streamResult.getSystemId() != null) {
        String fileURL = streamResult.getSystemId();

        fileURL = convertURL(fileURL);

        try {
            FileOutputStream fos = new FileOutputStream(fileURL);
            autoClose[0] = fos;
            writer = createWriter(fos);
        } catch (IOException e) {
            throw new TxwException(e);
        }
    } else
        throw new IllegalArgumentException();

    // now delegate to the SaxSerializer
    serializer = new SaxSerializer(writer,writer,false) {
        public void endDocument() {
            super.endDocument();
            if(autoClose[0]!=null) {
                try {
                    autoClose[0].close();
                } catch (IOException e) {
                    throw new TxwException(e);
                }
                autoClose[0] = null;
            }
        }
    };
}
 
Example #18
Source File: StaxSerializer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void endDocument() {
    try {
        out.writeEndDocument();
        out.flush();
    } catch (XMLStreamException e) {
        throw new TxwException(e);
    }
}
 
Example #19
Source File: StaxSerializer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void flush() {
    try {
        out.flush();
    } catch (XMLStreamException e) {
        throw new TxwException(e);
    }
}
 
Example #20
Source File: StaxSerializer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void endDocument() {
    try {
        out.writeEndDocument();
        out.flush();
    } catch (XMLStreamException e) {
        throw new TxwException(e);
    }
}
 
Example #21
Source File: StaxSerializer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void cdata(StringBuilder text) {
    try {
        out.writeCData(text.toString());
    } catch (XMLStreamException e) {
        throw new TxwException(e);
    }
}
 
Example #22
Source File: StaxSerializer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void endTag() {
    try {
        out.writeEndElement();
    } catch (XMLStreamException e) {
        throw new TxwException(e);
    }
}
 
Example #23
Source File: StaxSerializer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void writeXmlns(String prefix, String uri) {
    try {
        if (prefix.length() == 0) {
            out.setDefaultNamespace(uri);
        } else {
            out.setPrefix(prefix, uri);
        }

        // this method handles "", null, and "xmlns" prefixes properly
        out.writeNamespace(prefix, uri);
    } catch (XMLStreamException e) {
        throw new TxwException(e);
    }
}
 
Example #24
Source File: StaxSerializer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void writeAttribute(String uri, String localName, String prefix, StringBuilder value) {
    try {
        out.writeAttribute(prefix, uri, localName, value.toString());
    } catch (XMLStreamException e) {
        throw new TxwException(e);
    }
}
 
Example #25
Source File: StaxSerializer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void beginStartTag(String uri, String localName, String prefix) {
    try {
        out.writeStartElement(prefix, localName, uri);
    } catch (XMLStreamException e) {
        throw new TxwException(e);
    }
}
 
Example #26
Source File: StaxSerializer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void startDocument() {
    try {
        out.writeStartDocument();
    } catch (XMLStreamException e) {
        throw new TxwException(e);
    }
}
 
Example #27
Source File: SaxSerializer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void endDocument() {
    try {
        writer.endDocument();
    } catch (SAXException e) {
        throw new TxwException(e);
    }
}
 
Example #28
Source File: SaxSerializer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void cdata(StringBuilder text) {
    if(lexical==null)
        throw new UnsupportedOperationException("LexicalHandler is needed to write PCDATA");

    try {
        lexical.startCDATA();
        text(text);
        lexical.endCDATA();
    } catch (SAXException e) {
        throw new TxwException(e);
    }
}
 
Example #29
Source File: SaxSerializer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void endTag() {
    try {
        writer.endElement(elementBindings.pop(), // uri
                elementBindings.pop(), // localName
                elementBindings.pop()  // qname
        );
    } catch (SAXException e) {
        throw new TxwException(e);
    }
}
 
Example #30
Source File: SaxSerializer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void startDocument() {
    try {
        writer.startDocument();
    } catch (SAXException e) {
        throw new TxwException(e);
    }
}