List of usage examples for javax.xml.stream XMLStreamException XMLStreamException
public XMLStreamException(Throwable th)
From source file:org.apache.axis2.databinding.utils.ConverterUtil.java
public static Object getAnyTypeObject(XMLStreamReader xmlStreamReader, Class extensionMapperClass) throws XMLStreamException { Object returnObject = null;/*from w ww.j a v a2 s.co m*/ // make sure reader is at the first element. while (!xmlStreamReader.isStartElement()) { xmlStreamReader.next(); } // first check whether this element is null or not String nillableValue = xmlStreamReader.getAttributeValue(Constants.XSI_NAMESPACE, "nil"); if ("true".equals(nillableValue) || "1".equals(nillableValue)) { returnObject = null; xmlStreamReader.next(); } else { String attributeType = xmlStreamReader.getAttributeValue(Constants.XSI_NAMESPACE, "type"); if (attributeType != null) { String attributeTypePrefix = ""; if (attributeType.indexOf(":") > -1) { attributeTypePrefix = attributeType.substring(0, attributeType.indexOf(":")); attributeType = attributeType.substring(attributeType.indexOf(":") + 1); } NamespaceContext namespaceContext = xmlStreamReader.getNamespaceContext(); String attributeNameSpace = namespaceContext.getNamespaceURI(attributeTypePrefix); if (Constants.XSD_NAMESPACE.equals(attributeNameSpace)) { if ("base64Binary".equals(attributeType)) { returnObject = XMLStreamReaderUtils.getDataHandlerFromElement(xmlStreamReader); } else { String attribValue = xmlStreamReader.getElementText(); if (attribValue != null) { if (attributeType.equals("string")) { returnObject = attribValue; } else if (attributeType.equals("int")) { returnObject = new Integer(attribValue); } else if (attributeType.equals("QName")) { String namespacePrefix = null; String localPart = null; if (attribValue.indexOf(":") > -1) { namespacePrefix = attribValue.substring(0, attribValue.indexOf(":")); localPart = attribValue.substring(attribValue.indexOf(":") + 1); returnObject = new QName(namespaceContext.getNamespaceURI(namespacePrefix), localPart); } } else if ("boolean".equals(attributeType)) { returnObject = new Boolean(attribValue); } else if ("anyURI".equals(attributeType)) { try { returnObject = new URI(attribValue); } catch (URI.MalformedURIException e) { throw new XMLStreamException("Invalid URI"); } } else if ("date".equals(attributeType)) { returnObject = ConverterUtil.convertToDate(attribValue); } else if ("dateTime".equals(attributeType)) { returnObject = ConverterUtil.convertToDateTime(attribValue); } else if ("time".equals(attributeType)) { returnObject = ConverterUtil.convertToTime(attribValue); } else if ("byte".equals(attributeType)) { returnObject = new Byte(attribValue); } else if ("short".equals(attributeType)) { returnObject = new Short(attribValue); } else if ("float".equals(attributeType)) { returnObject = new Float(attribValue); } else if ("long".equals(attributeType)) { returnObject = new Long(attribValue); } else if ("double".equals(attributeType)) { returnObject = new Double(attribValue); } else if ("decimal".equals(attributeType)) { returnObject = new BigDecimal(attribValue); } else if ("unsignedLong".equals(attributeType)) { returnObject = new UnsignedLong(attribValue); } else if ("unsignedInt".equals(attributeType)) { returnObject = new UnsignedInt(attribValue); } else if ("unsignedShort".equals(attributeType)) { returnObject = new UnsignedShort(attribValue); } else if ("unsignedByte".equals(attributeType)) { returnObject = new UnsignedByte(attribValue); } else if ("positiveInteger".equals(attributeType)) { returnObject = new PositiveInteger(attribValue); } else if ("negativeInteger".equals(attributeType)) { returnObject = new NegativeInteger(attribValue); } else if ("nonNegativeInteger".equals(attributeType)) { returnObject = new NonNegativeInteger(attribValue); } else if ("nonPositiveInteger".equals(attributeType)) { returnObject = new NonPositiveInteger(attribValue); } else { throw new ADBException("Unknown type ==> " + attributeType); } } else { throw new ADBException("Attribute value is null"); } } } else { try { Method getObjectMethod = extensionMapperClass.getMethod("getTypeObject", new Class[] { String.class, String.class, XMLStreamReader.class }); returnObject = getObjectMethod.invoke(null, new Object[] { attributeNameSpace, attributeType, xmlStreamReader }); } catch (NoSuchMethodException e) { throw new ADBException( "Can not find the getTypeObject method in the " + "extension mapper class ", e); } catch (IllegalAccessException e) { throw new ADBException( "Can not access the getTypeObject method in the " + "extension mapper class ", e); } catch (InvocationTargetException e) { throw new ADBException( "Can not invoke the getTypeObject method in the " + "extension mapper class ", e); } } } else { throw new ADBException("Any type element type has not been given"); } } return returnObject; }
From source file:org.apache.axis2.dataretrieval.DataRetrievalUtil.java
private static InputStream getInputStream(ClassLoader classLoader, String file) throws XMLStreamException { InputStream servicexmlStream = classLoader.getResourceAsStream(file); if (servicexmlStream == null) { String message = "File does not exist in the Service Repository! File=" + file; if (log.isDebugEnabled()) { log.debug(message);//from www .ja v a 2s. co m } throw new XMLStreamException(message); } return servicexmlStream; }
From source file:org.apache.axis2.datasource.jaxb.JAXBDataSource.java
public XMLStreamReader getReader() throws XMLStreamException { try {//from www.ja va 2 s .co m String encoding = "utf-8"; InputStream is = new ByteArrayInputStream(getXMLBytes(encoding)); return StAXUtils.createXMLStreamReader(is, encoding); } catch (UnsupportedEncodingException e) { throw new XMLStreamException(e); } }
From source file:org.apache.axis2.datasource.jaxb.JAXBDataSource.java
public void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException { try {//from w w w .j a v a 2 s . c o m context.marshal(jaxb, xmlWriter); } catch (JAXBException je) { if (log.isDebugEnabled()) { try { log.debug( "JAXBContext for marshal failure:" + context.getJAXBContext(context.getClassLoader())); } catch (Exception e) { } } throw new XMLStreamException(je); } }
From source file:org.apache.axis2.format.WrappedTextNodeStreamReader.java
public int next() throws XMLStreamException { // Determine next event type based on current event type. If current event type // is START_ELEMENT or CHARACTERS, pull new data from the reader. switch (eventType) { case START_DOCUMENT: eventType = START_ELEMENT;/* www . j a v a 2 s. co m*/ break; case START_ELEMENT: charData = new char[chunkSize]; // No break here! case CHARACTERS: try { charDataLength = reader.read(charData); } catch (IOException ex) { throw new XMLStreamException(ex); } if (charDataLength == -1) { charData = null; eventType = END_ELEMENT; } else { eventType = CHARACTERS; } break; case END_ELEMENT: eventType = END_DOCUMENT; break; default: throw new IllegalStateException(); } return eventType; }
From source file:org.apache.axis2.format.WrappedTextNodeStreamReader.java
public int nextTag() throws XMLStreamException { // We don't have white space, comments or processing instructions throw new XMLStreamException("Current event is not white space"); }
From source file:org.apache.axis2.format.WrappedTextNodeStreamReader.java
public void require(int type, String namespaceURI, String localName) throws XMLStreamException { if (type != eventType || (namespaceURI != null && !namespaceURI.equals(getNamespaceURI())) || (localName != null && !namespaceURI.equals(getLocalName()))) { throw new XMLStreamException("Unexpected event type"); }//w w w. j av a2 s . c o m }
From source file:org.apache.axis2.format.WrappedTextNodeStreamReader.java
public void close() throws XMLStreamException { // Javadoc says that this method should not close the underlying input source, // but we need to close the reader somewhere. try {//from w ww. j a v a2s. c o m reader.close(); } catch (IOException ex) { throw new XMLStreamException(ex); } }
From source file:org.apache.axis2.format.WrappedTextNodeStreamReader.java
public String getElementText() throws XMLStreamException { if (eventType == START_ELEMENT) { // Actually the purpose of this class is to avoid storing // the character data entirely in memory, but if the caller // wants a String, we don't have the choice... try {//from w w w. j a v a 2s.com String result = IOUtils.toString(reader); eventType = END_ELEMENT; return result; } catch (IOException ex) { throw new XMLStreamException(ex); } } else { throw new XMLStreamException("Current event is not a START_ELEMENT"); } }
From source file:org.apache.axis2.jaxws.message.databinding.impl.DataSourceBlockImpl.java
protected Object _getBOFromReader(XMLStreamReader reader, Object busContext) throws XMLStreamException, WebServiceException { Reader2Writer r2w = new Reader2Writer(reader); try {//w ww .ja v a2 s . c om return new ByteArrayDataSource(r2w.getAsString(), "application/octet-stream"); } catch (IOException e) { throw new XMLStreamException(e); } }