List of usage examples for javax.xml.stream XMLStreamException XMLStreamException
public XMLStreamException(Throwable th)
From source file:davmail.exchange.ews.EWSMethod.java
protected String getTagContent(XMLStreamReader reader) throws XMLStreamException { String tagLocalName = reader.getLocalName(); while (reader.hasNext() && !(reader.getEventType() == XMLStreamConstants.END_ELEMENT)) { reader.next();// ww w . j ava 2 s . c o m if (reader.getEventType() == XMLStreamConstants.CHARACTERS) { return reader.getText(); } } // empty tag if (reader.hasNext()) { return null; } else { throw new XMLStreamException("End element for " + tagLocalName + " not found"); } }
From source file:de.uni_koblenz.jgralab.utilities.rsa2tg.Rsa2Tg.java
/** * Finalizes the created {@link SchemaGraph} by creating missing links * between several objects./* w w w . j a v a 2 s .c om*/ * * @throws XMLStreamException * @throws GraphIOException */ @Override public void endDocument() throws XMLStreamException { // finalizes processing by creating missing links assert schema != null; assert graphClass != null; // The qualified name of the GraphClass should be set. if (graphClass.get_qualifiedName() == null) { throw new ProcessingException(getParser(), getFilename(), "No <<graphclass>> defined in schema '" + schema.get_packagePrefix() + "." + schema.get_name() + "'"); } // Checks whether each enum domain has at least one literal checkEnumDomains(); // Now the RSA XMI file has been processed, pending actions to link // elements can be performed linkGeneralizations(); linkRecordDomainComponents(); linkAttributeDomains(); removeIgnoredPackages(); if (isUseNavigability()) { correctEdgeDirection(); } // the following depends on correct subsets relations between incidences attachConstraints(); // the following depends on correct edge directions and edgeclass // generalizations checkSubsettingOfAllIncidenceClasses(); // delete derived GraphElementClasses for (GraphElementClass gec : derivedGraphElementClasses) { assert gec.isValid(); Edge current = gec.getFirstIncidence(); while (current != null) { Edge next = current.getNextIncidence(); if (current.isInstanceOf(Annotates.EC)) { Vertex comment = next.getThat(); if (comment.getDegree() == 1) { comment.delete(); } } current = next; } gec.delete(); } createEdgeClassNames(); checkAttributes(); if (isRemoveUnusedDomains()) { removeUnusedDomains(); } if (!isRemoveComments()) { attachComments(); } if (!isKeepEmptyPackages()) { removeEmptyPackages(); } // preliminaryVertices must be empty at this time of processing, // otherwise there is an error... if (!preliminaryVertices.isEmpty()) { System.err.println("Remaining preliminary vertices (" + preliminaryVertices.size() + "):"); for (Vertex v : preliminaryVertices) { System.err.println(attributedElement2String(v)); } throw new ProcessingException(getFilename(), "There are still vertices left over. "); } if (!suppressOutput) { try { writeOutput(); } catch (GraphIOException e) { throw new XMLStreamException(e); } } }
From source file:de.uni_koblenz.jgralab.utilities.rsa.Rsa2Tg.java
/** * Finalizes the created {@link SchemaGraph} by creating missing links * between several objects.// w w w .j av a 2 s .c o m * * @throws XMLStreamException * @throws GraphIOException */ @Override public void endDocument() throws XMLStreamException { // finalizes processing by creating missing links assert schema != null; assert graphClass != null; // The qualified name of the GraphClass should be set. if (graphClass.get_qualifiedName() == null) { throw new ProcessingException(getFileName(), "No <<graphclass>> defined in schema '" + schema.get_packagePrefix() + "." + schema.get_name() + "'"); } // Checks whether each enum domain has at least one literal checkEnumDomains(); // replace old edges of compositions with an incident associationClass // with proper MayBeNestedIn edges tidyUpMayBeNestedInAtAssociationClasses(); // transform the VertexClasses with an edge stereotype to EdgeClasses convertToEdgeClasses(); // Now the RSA XMI file has been processed, pending actions to link // elements can be performed linkGeneralizations(); linkRecordDomainComponents(); linkAttributeDomains(); deleteCompositionsWhichRepresentsNoBinaryEdgeClass(); removeIgnoredPackages(); if (isUseNavigability()) { correctEdgeDirection(); } // the following depends on correct subsets relations between incidences attachConstraints(); // the following depends on correct edge directions and edgeclass // generalizations createSubsetsAndRedefinesRelations(); createMayBeNestedIn(); // convert EdgeClass to BinaryEdgeClass where possible convertEdgeClassesToBinaryEdgeClasses(); createEdgeClassNames(); if (isRemoveUnusedDomains()) { removeUnusedDomains(); } attachComments(); if (!isKeepEmptyPackages()) { removeEmptyPackages(); } // preliminaryVertices must be empty at this time of processing, // otherwise there is an error... if (!preliminaryVertices.isEmpty()) { System.err.println("Remaining preliminary vertices (" + preliminaryVertices.size() + "):"); for (Vertex v : preliminaryVertices) { System.err.println(attributedElement2String(v)); } throw new ProcessingException(getFileName(), "There are still vertices left over. "); } if (!suppressOutput) { try { writeOutput(); } catch (GraphIOException e) { throw new XMLStreamException(e); } } }
From source file:org.apache.axiom.om.ds.OMDataSourceExtBase.java
public void serialize(OutputStream output, OMOutputFormat format) throws XMLStreamException { if (DEBUG_ENABLED) { log.debug("serialize output=" + output + " format=" + format); }// ww w . ja va2 s . c o m try { // Write bytes to the output stream output.write(getXMLBytes(format.getCharSetEncoding())); } catch (IOException e) { throw new XMLStreamException(e); } }
From source file:org.apache.axiom.om.ds.OMDataSourceExtBase.java
public void serialize(Writer writer, OMOutputFormat format) throws XMLStreamException { if (DEBUG_ENABLED) { log.debug("serialize writer=" + writer + " format=" + format); }/*from w w w . j av a 2 s.c om*/ try { // Convert the bytes into a String and write it to the Writer String text = new String(getXMLBytes(format.getCharSetEncoding())); writer.write(text); } catch (UnsupportedEncodingException e) { throw new XMLStreamException(e); } catch (IOException e) { throw new XMLStreamException(e); } }
From source file:org.apache.axiom.om.ds.ParserInputStreamDataSource.java
public void serialize(OutputStream output, OMOutputFormat format) throws XMLStreamException { if (log.isDebugEnabled()) { log.debug("Entry ParserInputStreamDataSource.serialize(OutputStream, OMOutputFormat"); }//from w w w . ja va2s. com String encoding = (format != null) ? format.getCharSetEncoding() : null; try { if (!data.encoding.equalsIgnoreCase(encoding)) { byte[] bytes = getXMLBytes(encoding); output.write(bytes); } else { // Write the input stream to the output stream InputStream is = data.readParserInputStream(); if (is != null) { BufferUtils.inputStream2OutputStream(is, output); } } if (log.isDebugEnabled()) { log.debug("Exit ParserInputStreamDataSource.serialize(OutputStream, OMOutputFormat"); } } catch (UnsupportedEncodingException e) { throw new XMLStreamException(e); } catch (IOException e) { throw new XMLStreamException(e); } }
From source file:org.apache.axiom.om.impl.llom.OMStAXWrapper.java
/** * Method next./*from ww w. j a v a 2s .c o m*/ * * @return Returns int. * @throws XMLStreamException */ public int next() throws XMLStreamException { switch (state) { case DOCUMENT_COMPLETE: throw new XMLStreamException("End of the document reached"); case COMPLETED: state = DOCUMENT_COMPLETE; currentEvent = END_DOCUMENT; break; case SWITCH_AT_NEXT: state = SWITCHED; // load the parser try { parser = (XMLStreamReader) builder.getParser(); } catch (Exception e) { throw new XMLStreamException("problem accessing the parser. " + e.getMessage(), e); } // We should throw an END_DOCUMENT if ((currentEvent == START_DOCUMENT) && (currentEvent == parser.getEventType())) { currentEvent = parser.next(); } else { currentEvent = parser.getEventType(); } updateCompleteStatus(); break; case NAVIGABLE: currentEvent = generateEvents(currentNode); updateCompleteStatus(); updateLastNode(); break; case SWITCHED: if (parser.hasNext()) { currentEvent = parser.next(); } updateCompleteStatus(); break; default: throw new OMStreamingException("unsuppported state!"); } return currentEvent; }
From source file:org.apache.axiom.om.impl.llom.OMStAXWrapper.java
/** * This is a very important method. It keeps the navigator one step ahead and pushes it one * event ahead. If the nextNode is null then navigable is set to false. At the same time the * parser and builder are set up for the upcoming event generation. * * @throws XMLStreamException//from w w w .ja va 2s .co m */ private void updateLastNode() throws XMLStreamException { // Detect XOP:Include element and don't advance if processing // the end tag. if (xopInclude != null && xopIncludeText == currentNode && xopIncludeStart) { lastNode = xopIncludeText; return; } lastNode = currentNode; currentNode = nextNode; try { updateNextNode(); } catch (Exception e) { throw new XMLStreamException(e); } }
From source file:org.apache.axiom.om.impl.MTOMXMLStreamWriter.java
/** * Creates a new MTOMXMLStreamWriter with specified encoding. * * @param outStream/*from w w w .ja v a 2 s . co m*/ * @param format * @throws XMLStreamException * @throws FactoryConfigurationError * @see OMOutputFormat#DEFAULT_CHAR_SET_ENCODING */ public MTOMXMLStreamWriter(OutputStream outStream, OMOutputFormat format) throws XMLStreamException, FactoryConfigurationError { if (isDebugEnabled) { log.debug("Creating MTOMXMLStreamWriter"); log.debug("OutputStream =" + outStream.getClass()); log.debug("OMFormat = " + format.toString()); } if (isTraceEnabled) { log.trace("Call Stack =" + CommonUtils.callStackToString()); } this.format = format; this.outStream = outStream; String encoding = format.getCharSetEncoding(); if (encoding == null) { //Default encoding is UTF-8 format.setCharSetEncoding(encoding = OMOutputFormat.DEFAULT_CHAR_SET_ENCODING); } optimizationPolicy = new OptimizationPolicyImpl(format); if (format.isOptimized()) { multipartWriter = new OMMultipartWriter(outStream, format); try { rootPartOutputStream = multipartWriter.writeRootPart(); } catch (IOException ex) { throw new XMLStreamException(ex); } ContentIDGenerator contentIDGenerator = new ContentIDGenerator() { public String generateContentID(String existingContentID) { return existingContentID != null ? existingContentID : getNextContentId(); } }; xmlWriter = new XOPEncodingStreamWriter(StAXUtils .createXMLStreamWriter(format.getStAXWriterConfiguration(), rootPartOutputStream, encoding), contentIDGenerator, optimizationPolicy); } else { xmlWriter = StAXUtils.createXMLStreamWriter(format.getStAXWriterConfiguration(), outStream, format.getCharSetEncoding()); } xmlStreamWriterFilter = format.getXmlStreamWriterFilter(); if (xmlStreamWriterFilter != null) { if (log.isDebugEnabled()) { log.debug("Installing XMLStreamWriterFilter " + xmlStreamWriterFilter); } xmlStreamWriterFilter.setDelegate(xmlWriter); xmlWriter = xmlStreamWriterFilter; } }
From source file:org.apache.axiom.om.impl.SwitchingWrapper.java
/** * This is a very important method. It keeps the navigator one step ahead and pushes it one * event ahead. If the nextNode is null then navigable is set to false. At the same time the * parser and builder are set up for the upcoming event generation. * * @throws XMLStreamException/*from w w w . j a v a 2 s. com*/ */ private void updateLastNode() throws XMLStreamException { lastNode = currentNode; attributeCount = -1; namespaceCount = -1; currentNode = nextNode; try { updateNextNode(); } catch (Exception e) { throw new XMLStreamException(e); } }