List of usage examples for javax.xml.stream XMLStreamException XMLStreamException
public XMLStreamException(Throwable th)
From source file:org.apache.axis2.jaxws.message.databinding.impl.DataSourceBlockImpl.java
public void serialize(OutputStream output, OMOutputFormat format) throws XMLStreamException { try {/* w ww . j a v a2s . com*/ BufferUtils.inputStream2OutputStream(((DataSource) busObject).getInputStream(), output); } catch (IOException e) { throw new XMLStreamException(e); } }
From source file:org.apache.axis2.jaxws.message.util.impl.XMLStreamReaderFromDOM.java
public int next() throws XMLStreamException { if (!hasNext()) { throw new XMLStreamException(Messages.getMessage("XMLSRErr2")); }//from w w w. j a va 2 s .c o m getNext(); cursor = nextCursor; event = nextEvent; return event; }
From source file:org.apache.axis2.jaxws.message.util.impl.XMLStreamReaderFromDOM.java
public void require(int event, String namespace, String localPart) throws XMLStreamException { try {// w w w .j av a 2 s .co m if (event != this.event) { throw new XMLStreamException( Messages.getMessage("XMLSRErr3", String.valueOf(event), String.valueOf(this.event))); } if (namespace != null && !namespace.equals(cursor.getNamespaceURI())) { throw new XMLStreamException( Messages.getMessage("XMLSRErr3", namespace, this.cursor.getNamespaceURI())); } if (localPart != null && !localPart.equals(cursor.getLocalName())) { throw new XMLStreamException( Messages.getMessage("XMLSRErr3", localPart, this.cursor.getLocalName())); } } catch (XMLStreamException e) { throw e; } catch (Exception e) { throw new XMLStreamException(e); } }
From source file:org.apache.axis2.jaxws.message.util.impl.XMLStreamReaderFromDOM.java
public String getElementText() throws XMLStreamException { if (event == XMLStreamReader.START_ELEMENT) { next();/*w w w . j a v a 2 s . co m*/ StringBuffer buffer = new StringBuffer(); while (event != XMLStreamReader.END_ELEMENT) { if (event == XMLStreamReader.CHARACTERS || event == XMLStreamReader.CDATA || event == XMLStreamReader.SPACE || event == XMLStreamReader.ENTITY_REFERENCE) { buffer.append(getText()); } else if (event == XMLStreamReader.PROCESSING_INSTRUCTION || event == XMLStreamReader.COMMENT) { // whitespace } else { throw new XMLStreamException(Messages.getMessage("XMLSRErr4", "getElementText()")); } next(); } return buffer.toString(); } throw new XMLStreamException(Messages.getMessage("XMLSRErr4", "getElementText()")); }
From source file:org.apache.axis2.jaxws.message.util.impl.XMLStreamReaderFromDOM.java
public int nextTag() throws XMLStreamException { next();/*from w w w .j av a 2s . c o m*/ while (event == XMLStreamReader.CHARACTERS && isWhiteSpace() || event == XMLStreamReader.CDATA && isWhiteSpace() || event == XMLStreamReader.SPACE || event == XMLStreamReader.PROCESSING_INSTRUCTION || event == XMLStreamReader.COMMENT) { event = next(); } if (event == XMLStreamReader.START_ELEMENT || event == XMLStreamReader.END_ELEMENT) { return event; } throw new XMLStreamException(Messages.getMessage("XMLSRErr4", "nextTag()")); }
From source file:org.apache.axis2.json.gson.GsonXMLStreamReader.java
public int next() throws XMLStreamException { if (hasNext()) { try {//w w w . j a v a2 s. c o m stateTransition(); } catch (IOException e) { throw new XMLStreamException("I/O error while reading JSON input Stream"); } return getEventType(); } else { throw new NoSuchElementException("There is no any next event"); } }
From source file:org.apache.axis2.json.gson.GsonXMLStreamReader.java
public boolean hasNext() throws XMLStreamException { try {//w w w .j a va 2s .com tokenType = jsonReader.peek(); if (tokenType == JsonToken.END_DOCUMENT) { return false; } else { return true; } } catch (IOException e) { throw new XMLStreamException("Unexpected end of json stream"); } }
From source file:org.apache.axis2.json.gson.GsonXMLStreamReader.java
private void removeStackObj() throws XMLStreamException { if (!stackObj.empty()) { if (topNestedArrayObj == null) { stackObj.pop();/*from w w w.j a v a2 s .co m*/ } else { if (stackObj.peek().equals(topNestedArrayObj)) { topNestedArrayObj = null; processedJsonObject.clear(); stackObj.pop(); } else { processedJsonObject.push(stackObj.pop()); } } if (!stackObj.empty()) { localName = stackObj.peek().getName(); } else { localName = ""; } } else { System.out.println("stackObj is empty"); throw new XMLStreamException("Error while processing input JSON stream, JSON request may not valid ," + " it may has more end object characters "); } }
From source file:org.apache.axis2.json.gson.GsonXMLStreamReader.java
private void nextName() throws IOException, XMLStreamException { String name = jsonReader.nextName(); boolean isElementExists = false; if (!miniList.isEmpty()) { while (!isElementExists && (miniListPointer < miniList.size() || skipMiniListElement)) { if (miniListPointer >= miniList.size()) { skipMiniListElement = false; miniListPointer = 0;/*from w w w . j a v a 2s. c o m*/ } JsonObject jsonObject = miniList.get(miniListPointer); if (jsonObject.getName().equals(name)) { isElementExists = true; namespace = jsonObject.getNamespaceUri(); stackObj.push(jsonObject); miniList.remove(miniListPointer); if (miniListPointer > 0) skipMiniListElement = true; } else { ++miniListPointer; } if (miniListPointer > miniList.size() && isElementExists) { throw new XMLStreamException( JsonConstant.IN_JSON_MESSAGE_NOT_VALID + name + " does not exist in schema"); } } } else { if (!schemaList.isEmpty()) { while (!isElementExists && (schemaListPointer < schemaList.size() || skipSchemaListElement)) { if (schemaListPointer >= schemaList.size()) { skipSchemaListElement = false; schemaListPointer = 0; } JsonObject jsonObject = schemaList.get(schemaListPointer); if (jsonObject.getName().equals(name)) { isElementExists = true; namespace = jsonObject.getNamespaceUri(); stackObj.push(jsonObject); schemaList.remove(schemaListPointer); if (schemaListPointer > 0) skipSchemaListElement = true; } else { ++schemaListPointer; } } if (schemaListPointer > schemaList.size() && !isElementExists) { throw new XMLStreamException( JsonConstant.IN_JSON_MESSAGE_NOT_VALID + name + " does not exist in schema"); } } } localName = name; value = null; }
From source file:org.apache.axis2.json.gson.GsonXMLStreamWriter.java
/** * Writes a start tag to the output. All writeStartElement methods * open a new scope in the internal namespace context. Writing the * corresponding EndElement causes the scope to be closed. * * @param localName local name of the tag, may not be null * @throws javax.xml.stream.XMLStreamException *//*from ww w . ja va 2 s. c o m*/ public void writeStartElement(String localName) throws XMLStreamException { if (!isProcessed) { try { process(); } catch (IOException e) { throw new XMLStreamException("Error occours while write first begin object "); } } JsonObject stackObj = null; try { if (miniStack.isEmpty()) { if (!queue.isEmpty()) { JsonObject queObj = queue.peek(); //if suspected element is not empty if (potentialEmpty && potentialEmptyElement == queObj) { potentialEmpty = false; potentialEmptyElement = null; } if (!queObj.getName().equals(localName) && queObj.getMinOccurs() == 0 && (stack.isEmpty() || !stack.peek().getName().equals(localName))) { queue.poll(); queObj = queue.peek(); } if (queObj.getName().equals(localName)) { if (flushObject != null) { if (topNestedArrayObj != null && flushObject.getType() == JSONType.NESTED_ARRAY && flushObject.getName().equals(topNestedArrayObj.getName())) { topNestedArrayObj = null; processedJsonObjects.clear(); } popStack(); writeEndJson(flushObject); flushObject = null; } if (topNestedArrayObj != null && (queObj.getType() == JSONType.NESTED_ARRAY || queObj.getType() == JSONType.NESTED_OBJECT)) { processedJsonObjects.push(queObj); } writeStartJson(queObj); stack.push(queue.poll()); JsonObject nextObj = queue.peek(); //Checks the child of the element is empty if (nextObj != null && nextObj.getMinOccurs() == 0) { potentialEmpty = true; potentialEmptyElement = nextObj; } } else if (!stack.isEmpty()) { stackObj = stack.peek(); if (stackObj.getName().equals(localName)) { if (stackObj.getType() == JSONType.NESTED_ARRAY) { fillMiniStack(stackObj); jsonWriter.beginObject(); processedJsonObjects.push(stackObj); } flushObject = null; } else { throw new XMLStreamException("Invalid Staring element"); } } } else { if (!stack.isEmpty()) { stackObj = stack.peek(); if (stackObj.getName().equals(localName)) { flushObject = null; if (stackObj.getType() == JSONType.NESTED_ARRAY) { fillMiniStack(stackObj); jsonWriter.beginObject(); processedJsonObjects.push(stackObj); } } else { throw new XMLStreamException("Invalid Staring element"); } } else { throw new XMLStreamException("Invalid Starting element"); } } } else { JsonObject queObj = miniStack.peek(); if (queObj.getName().equals(localName)) { if (flushObject != null) { popStack(); writeEndJson(flushObject); flushObject = null; } if (topNestedArrayObj != null && (queObj.getType() == JSONType.NESTED_OBJECT || queObj.getType() == JSONType.NESTED_ARRAY)) { processedJsonObjects.push(queObj); } writeStartJson(queObj); stack.push(miniStack.pop()); } else if (!stack.isEmpty()) { stackObj = stack.peek(); if (stackObj.getName().equals(localName)) { flushObject = null; if (stackObj.getType() == JSONType.NESTED_ARRAY) { fillMiniStack(stackObj); jsonWriter.beginObject(); processedJsonObjects.push(stackObj); } } else { throw new XMLStreamException("Invalid Staring element"); } } } } catch (IOException e) { throw new XMLStreamException(" Json Writer throw an error"); } }