List of usage examples for javax.xml.stream XMLStreamConstants START_ELEMENT
int START_ELEMENT
To view the source code for javax.xml.stream XMLStreamConstants START_ELEMENT.
Click Source Link
From source file:org.deegree.services.wps.execute.ExecuteResponseXMLWriter.java
private static void exportXMLOutput(XMLStreamWriter writer, ComplexOutputImpl output) throws XMLStreamException { // "wps:ComplexData" element writer.writeStartElement(WPS_NS, "ComplexData"); String mimeType = output.getRequestedMimeType(); if (mimeType != null) { writer.writeAttribute("mimeType", mimeType); }/*ww w. j a v a 2 s . co m*/ String schema = output.getRequestedSchema(); if (schema != null) { writer.writeAttribute("schema", schema); } // NOTE: Providing the encoding attribute doesn't make any sense for inline XML output (always defined by the // surrounding document) XMLStreamReader reader = output.getStreamReader(); // skip start document event // apadberg: the following line was necessary when Axiom 1.2.8 is used, // it is commented out because of revised behavior in Axiom 1.2.9 if (reader.getEventType() == XMLStreamConstants.START_DOCUMENT) { reader.next(); } if (reader.getEventType() == XMLStreamConstants.START_ELEMENT) { XMLAdapter.writeElement(writer, reader); } else { LOG.warn("No element in XMLOutput found, skipping it in response document."); } writer.writeEndElement(); }
From source file:org.eclipse.sw360.licenseinfo.parsers.AbstractCLIParser.java
protected <T> boolean hasThisXMLRootElement(AttachmentContent content, String rootElementNamespace, String rootElementName, User user, T context) throws TException { XMLInputFactory xmlif = XMLInputFactory.newFactory(); XMLStreamReader xmlStreamReader = null; InputStream attachmentStream = null; try {//from www . ja v a2 s. c o m attachmentStream = attachmentConnector.getAttachmentStream(content, user, context); xmlStreamReader = xmlif.createXMLStreamReader(attachmentStream); //skip to first element while (xmlStreamReader.hasNext() && xmlStreamReader.next() != XMLStreamConstants.START_ELEMENT) ; xmlStreamReader.require(XMLStreamConstants.START_ELEMENT, rootElementNamespace, rootElementName); return true; } catch (XMLStreamException | SW360Exception e) { return false; } finally { if (null != xmlStreamReader) { try { xmlStreamReader.close(); } catch (XMLStreamException e) { // ignore it } } closeQuietly(attachmentStream, log); } }
From source file:org.intermine.webservice.client.results.XMLTableResult.java
private List<String> getNextRow() { List<String> row = new ArrayList<String>(); boolean hasGotWholeRow = false; boolean hasGotWholeResultSet = false; String currentElemName = null; String errorMessage = null;/*from w w w. ja va2 s . c o m*/ String errorCause = null; String currentValue = null; try { while (xmlReader.hasNext()) { int eventType = xmlReader.getEventType(); switch (eventType) { case XMLStreamConstants.START_ELEMENT: currentElemName = xmlReader.getLocalName(); break; case XMLStreamConstants.END_ELEMENT: String elemName = xmlReader.getLocalName(); if ("Result".equals(elemName)) { hasGotWholeRow = true; } else if ("ResultSet".equals(elemName)) { hasGotWholeResultSet = true; } else if ("i".equals(elemName)) { row.add(currentValue); currentValue = null; } break; case XMLStreamConstants.CHARACTERS: if ("i".equals(currentElemName)) { String valueChunk = StringEscapeUtils.unescapeXml(xmlReader.getText()); if (currentValue == null) { currentValue = valueChunk; } else { currentValue += valueChunk; } } else if ("message".equals(currentElemName)) { errorMessage = xmlReader.getText(); } else if ("cause".equals(currentElemName)) { errorCause = xmlReader.getText(); } else { String data = xmlReader.getText(); if (!(data == null || "".equals(data.trim()))) { throw new ServiceException("Character data found in illegal place: " + currentElemName + ", '" + data + "'"); } } break; default: break; } xmlReader.next(); if (hasGotWholeRow) { break; } } } catch (XMLStreamException e) { throw new RuntimeException("Error parsing XML result response", e); } // Check to make sure we can return data if (errorMessage != null || errorCause != null) { throw new ResultException(errorMessage, errorCause); } if (!hasGotWholeRow && !hasGotWholeResultSet) { throw new TransferInterruptedException(); } if (row.isEmpty()) { return null; } else { return row; } }
From source file:org.jasig.schedassist.impl.caldav.xml.ReportResponseHandlerImpl.java
/** * Extracts a {@link List} of {@link Calendar}s from the {@link InputStream}, if present. * //from w w w .j av a 2s .co m * @param inputStream * @return a never null, but possibly empty {@link List} of {@link Calendar}s from the {@link InputStream} * @throws XmlParsingException in the event the stream could not be properly parsed */ public List<CalendarWithURI> extractCalendars(InputStream inputStream) { List<CalendarWithURI> results = new ArrayList<CalendarWithURI>(); ByteArrayOutputStream capturedContent = null; XMLInputFactory factory = XMLInputFactory.newInstance(); try { InputStream localReference = inputStream; if (log.isDebugEnabled()) { capturedContent = new ByteArrayOutputStream(); localReference = new TeeInputStream(inputStream, capturedContent); } BufferedInputStream buffered = new BufferedInputStream(localReference); buffered.mark(1); int firstbyte = buffered.read(); if (-1 == firstbyte) { // short circuit on empty stream return results; } buffered.reset(); XMLStreamReader parser = factory.createXMLStreamReader(buffered); String currentUri = null; String currentEtag = null; for (int eventType = parser.next(); eventType != XMLStreamConstants.END_DOCUMENT; eventType = parser .next()) { switch (eventType) { case XMLStreamConstants.START_ELEMENT: QName name = parser.getName(); if (isWebdavHrefElement(name)) { currentUri = parser.getElementText(); } else if (isWebdavEtagElement(name)) { currentEtag = parser.getElementText(); } else if (isCalendarDataElement(name)) { Calendar cal = extractCalendar(parser.getElementText()); if (cal != null) { CalendarWithURI withUri = new CalendarWithURI(cal, currentUri, currentEtag); results.add(withUri); } else if (log.isDebugEnabled()) { log.debug("extractCalendar returned null for " + currentUri + ", skipping"); } } break; } } if (log.isDebugEnabled()) { log.debug("extracted " + results.size() + " calendar from " + capturedContent.toString()); } } catch (XMLStreamException e) { if (capturedContent != null) { log.error("caught XMLStreamException in extractCalendars, captured content: " + capturedContent.toString(), e); } else { log.error("caught XMLStreamException in extractCalendars, no captured content available", e); } throw new XmlParsingException("caught XMLStreamException in extractCalendars", e); } catch (IOException e) { log.error("caught IOException in extractCalendars", e); throw new XmlParsingException("caught IOException in extractCalendars", e); } return results; }
From source file:org.mcisb.subliminal.SubliminalUtils.java
/** * /*from w ww . j a va 2 s .c o m*/ * @param elementName * @param is * @param onlyValues * @return Collection * @throws XMLStreamException * @throws UnsupportedEncodingException */ private static Collection<String> getElements(final String elementName, final InputStream is, final boolean onlyValues) throws XMLStreamException, UnsupportedEncodingException { final Collection<String> elements = new ArrayList<>(); final ByteArrayOutputStream os = new ByteArrayOutputStream(); final XMLEventReader reader = XMLInputFactory.newInstance() .createXMLEventReader(new InputStreamReader(is, Charset.defaultCharset().name())); final XMLEventWriter writer = XMLOutputFactory.newInstance() .createXMLEventWriter(new OutputStreamWriter(os, Charset.defaultCharset().name())); boolean read = false; String characters = null; while (reader.peek() != null) { final XMLEvent event = (XMLEvent) reader.next(); switch (event.getEventType()) { case XMLStreamConstants.START_DOCUMENT: case XMLStreamConstants.END_DOCUMENT: { // Ignore. break; } case XMLStreamConstants.START_ELEMENT: { read = read || elementName.equals(event.asStartElement().getName().getLocalPart()); if (read && !onlyValues) { writer.add(event); } break; } case XMLStreamConstants.ATTRIBUTE: { if (read && !onlyValues) { writer.add(event); } break; } case XMLStreamConstants.CHARACTERS: { if (read && !onlyValues) { writer.add(event); } characters = event.asCharacters().getData(); break; } case XMLStreamConstants.END_ELEMENT: { if (read && !onlyValues) { writer.add(event); } if (elementName.equals(event.asEndElement().getName().getLocalPart())) { writer.flush(); if (characters != null) { elements.add(characters); } os.reset(); read = false; } break; } default: { // Ignore break; } } } return elements; }
From source file:org.mule.module.xml.util.XMLUtils.java
public static void copy(XMLStreamReader reader, XMLStreamWriter writer, boolean fragment) throws XMLStreamException { // number of elements read in int read = 0; int event = reader.getEventType(); while (reader.hasNext()) { switch (event) { case XMLStreamConstants.START_ELEMENT: read++;/*from w w w . java2 s . c o m*/ writeStartElement(reader, writer); break; case XMLStreamConstants.END_ELEMENT: writer.writeEndElement(); read--; if (read <= 0 && !fragment) { return; } break; case XMLStreamConstants.CHARACTERS: writer.writeCharacters(reader.getText()); break; case XMLStreamConstants.START_DOCUMENT: case XMLStreamConstants.END_DOCUMENT: case XMLStreamConstants.ATTRIBUTE: case XMLStreamConstants.NAMESPACE: break; default: break; } event = reader.next(); } }
From source file:org.netbeans.jbatch.modeler.spec.core.Definitions.java
public static Definitions load(ModelerFile file, String definitionId) { File savedFile = file.getFile(); Definitions definition_Load = null;//www . j av a 2 s. c om boolean definitionExist = false; XMLStreamReader xsr = null; try { if (savedFile.length() != 0) { XMLInputFactory xif = XMLInputFactory.newFactory(); StreamSource xml = new StreamSource(savedFile); xsr = xif.createXMLStreamReader(xml); xsr.nextTag(); if (definitionId == null) { while (xsr.hasNext() && !definitionExist) { if (xsr.getEventType() == XMLStreamConstants.START_ELEMENT && xsr.getLocalName().equals("definitions") && xsr.getAttributeValue(null, "id") == null) { definitionExist = true; } else { xsr.next(); } } } else { while (xsr.hasNext() && !definitionExist) { if (xsr.getEventType() == XMLStreamConstants.START_ELEMENT && xsr.getLocalName().equals("definitions") && definitionId.equals(xsr.getAttributeValue(null, "id"))) { definitionExist = true; } else { xsr.next(); } } } } JAXBContext jobContext; Unmarshaller jobUnmarshaller; // if (jobContext == null) { jobContext = JAXBContext.newInstance(new Class<?>[] { ShapeDesign.class, Definitions.class }); // } // if (jobUnmarshaller == null) { jobUnmarshaller = jobContext.createUnmarshaller(); jobUnmarshaller.setEventHandler(new ValidateJAXB()); // } if (definitionExist) { definition_Load = jobUnmarshaller.unmarshal(xsr, Definitions.class).getValue();//new StreamSource(savedFile) } if (xsr != null) { xsr.close(); } } catch (XMLStreamException ex) { Exceptions.printStackTrace(ex); } catch (JAXBException ex) { // io.getOut().println("Exception: " + ex.toString()); ex.printStackTrace(); System.out.println("Document XML Not Exist"); } return definition_Load; }
From source file:org.netbeans.jbatch.modeler.spec.core.Definitions.java
public static void unload(ModelerFile file, List<String> definitionIdList) { File savedFile = file.getFile(); if (definitionIdList.isEmpty()) { return;//w w w . j ava2 s . co m } try { File cloneSavedFile = File.createTempFile("TMP", "job"); FileUtils.copyFile(savedFile, cloneSavedFile); BufferedReader br = new BufferedReader(new FileReader(savedFile)); String line = null; while ((line = br.readLine()) != null) { System.out.println("pre savedFile : " + line); } XMLOutputFactory xof = XMLOutputFactory.newFactory(); XMLStreamWriter xsw = xof.createXMLStreamWriter(new FileWriter(savedFile)); xsw.setDefaultNamespace("http://jbatchsuite.java.net"); xsw.writeStartDocument(); xsw.writeStartElement("jbatchnb", "root", "http://jbatchsuite.java.net"); xsw.writeNamespace("jbatch", "http://xmlns.jcp.org/xml/ns/javaee"); xsw.writeNamespace("jbatchnb", "http://jbatchsuite.java.net"); xsw.writeNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"); xsw.writeNamespace("java", "http://jcp.org/en/jsr/detail?id=270"); xsw.writeNamespace("nbm", "http://nbmodeler.java.net"); if (cloneSavedFile.length() != 0) { try { XMLInputFactory xif = XMLInputFactory.newFactory(); StreamSource xml = new StreamSource(cloneSavedFile); XMLStreamReader xsr = xif.createXMLStreamReader(xml); xsr.nextTag(); while (xsr.getEventType() == XMLStreamConstants.START_ELEMENT) { // Def Y N // Tag N(D) Y(D) // ________________ // T T // ---------------- // // Def Y N // Tag Y(S) N(S) // ________________ // S S // ---------------- // // Def Y N // Tag Y(D) N(S) // ________________ // T S // ---------------- // // (D) => Different // (S) => Same // Y => Id Exist // N => Def Id is null // T => Transform // S => Skip if (xsr.getLocalName().equals("definitions")) { // if (definitionId == null) { // if (xsr.getAttributeValue(null, "id") != null) { // transformXMLStream(xsr, xsw); // } // } else { if (xsr.getAttributeValue(null, "id") == null) { System.out.println("transformXMLStream " + null); transformXMLStream(xsr, xsw); } else { if (!definitionIdList.contains(xsr.getAttributeValue(null, "id"))) { System.out.println("transformXMLStream " + xsr.getAttributeValue(null, "id")); transformXMLStream(xsr, xsw); } else { System.out.println("skipXMLStream " + xsr.getAttributeValue(null, "id")); skipXMLStream(xsr); } } // } } System.out.println( "pre xsr.getEventType() : " + xsr.getEventType() + " " + xsr.getLocalName()); xsr.nextTag(); System.out.println( "post xsr.getEventType() : " + xsr.getEventType() + " " + xsr.getLocalName()); } } catch (XMLStreamException ex) { Exceptions.printStackTrace(ex); } } xsw.writeEndDocument(); xsw.close(); br = new BufferedReader(new FileReader(savedFile)); line = null; while ((line = br.readLine()) != null) { System.out.println("post savedFile : " + line); } } catch (IOException ex) { Exceptions.printStackTrace(ex); } catch (XMLStreamException ex) { Exceptions.printStackTrace(ex); } }
From source file:org.netbeans.jbatch.modeler.specification.model.job.util.JobUtil.java
public void saveModelerFile(ModelerFile modelerFile) { Definitions definitions = (Definitions) modelerFile.getDefinitionElement(); try {/*from ww w.j a v a 2s . c o m*/ updateBatchDiagram(modelerFile); List<String> closeDefinitionIdList = closeDiagram(modelerFile, definitions.getGarbageDefinitions()); List<String> definitionIdList = new ArrayList<String>(closeDefinitionIdList); // definitionIdList.addAll(definitions.getGarbageDefinitions()); definitionIdList.add(definitions.getId()); File savedFile = modelerFile.getFile(); BufferedReader br = new BufferedReader(new FileReader(savedFile)); String line = null; while ((line = br.readLine()) != null) { System.out.println("savedFile : " + line); } File cloneSavedFile = File.createTempFile("TMP", "job"); FileUtils.copyFile(savedFile, cloneSavedFile); // br = new BufferedReader(new FileReader(cloneSavedFile)); // line = null; // while ((line = br.readLine()) != null) { // System.out.println("line2 : " + line); // } XMLOutputFactory xof = XMLOutputFactory.newFactory(); XMLStreamWriter xsw = xof.createXMLStreamWriter(new FileWriter(savedFile)); xsw.setDefaultNamespace("http://jbatchsuite.java.net"); xsw.writeStartDocument(); xsw.writeStartElement("jbatchnb", "root", "http://jbatchsuite.java.net"); xsw.writeNamespace("jbatch", "http://xmlns.jcp.org/xml/ns/javaee"); xsw.writeNamespace("jbatchnb", "http://jbatchsuite.java.net"); xsw.writeNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"); xsw.writeNamespace("java", "http://jcp.org/en/jsr/detail?id=270"); xsw.writeNamespace("nbm", "http://nbmodeler.java.net"); // br = new BufferedReader(new FileReader(savedFile)); // line = null; // while ((line = br.readLine()) != null) { // System.out.println("line3 : " + line); // } if (cloneSavedFile.length() != 0) { try { XMLInputFactory xif = XMLInputFactory.newFactory(); StreamSource xml = new StreamSource(cloneSavedFile); XMLStreamReader xsr = xif.createXMLStreamReader(xml); xsr.nextTag(); while (xsr.getEventType() == XMLStreamConstants.START_ELEMENT) { // Def Y N // Tag N(D) Y(D) // ________________ // T T // ---------------- // // Def Y N // Tag Y(S) N(S) // ________________ // S S // ---------------- // // Def Y N // Tag Y(D) N(S) // ________________ // T S // ---------------- // // (D) => Different // (S) => Same // Y => Id Exist // N => Id is null // T => Transform // S => Skip if (xsr.getLocalName().equals("definitions")) { // if (definitions.getId() == null) { // if (xsr.getAttributeValue(null, "id") != null) { // transformXMLStream(xsr, xsw); // } else { // skipXMLStream(xsr); // } // } else { if (xsr.getAttributeValue(null, "id") == null) { if (definitions.getId() == null) { skipXMLStream(xsr); } else { transformXMLStream(xsr, xsw); } } else { if (!definitionIdList.contains(xsr.getAttributeValue(null, "id"))) { transformXMLStream(xsr, xsw); } else { skipXMLStream(xsr); } } // } } xsr.nextTag(); } } catch (XMLStreamException ex) { Exceptions.printStackTrace(ex); } } JAXBElement<Definitions> je = new JAXBElement<Definitions>( new QName("http://jbatchsuite.java.net", "definitions", "jbatchnb"), Definitions.class, definitions); if (jobContext == null) { jobContext = JAXBContext.newInstance(new Class<?>[] { ShapeDesign.class, Definitions.class }); } if (jobMarshaller == null) { jobMarshaller = jobContext.createMarshaller(); } // output pretty printed jobMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); jobMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE); // jobMarshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, "http://www.omg.org/spec/Batch/20100524/MODEL http://www.omg.org/spec/Batch/2.0/20100501/Batch20.xsd"); jobMarshaller.setEventHandler(new ValidateJAXB()); jobMarshaller.marshal(je, System.out); jobMarshaller.marshal(je, xsw); // xsw.writeEndElement(); xsw.writeEndDocument(); xsw.close(); // StringWriter sw = new StringWriter(); // jobMarshaller.marshal(file.getDefinitionElement(), sw); // FileUtils.writeStringToFile(savedFile, sw.toString().replaceFirst("xmlns:ns[A-Za-z\\d]{0,3}=\"http://www.omg.org/spec/Batch/20100524/MODEL\"", // "xmlns=\"http://www.omg.org/spec/Batch/20100524/MODEL\"")); } catch (JAXBException ex) { Exceptions.printStackTrace(ex); } catch (IOException ex) { Exceptions.printStackTrace(ex); } catch (XMLStreamException ex) { Exceptions.printStackTrace(ex); } }
From source file:org.openanzo.services.serialization.XMLBackupReader.java
/** * Parse the data within the reader, passing the results to the IRepositoryHandler * //from ww w. ja v a2 s . c o m * @param reader * reader containing the data * @param handler * Handler which will handle the elements within the data * @throws AnzoException */ private void parseBackup(Reader reader, final IBackupHandler handler) throws AnzoException { try { XMLStreamReader parser = XMLFactoryFinder.getXMLInputFactory().createXMLStreamReader(reader); for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next()) { switch (event) { case XMLStreamConstants.START_ELEMENT: if (SerializationConstants.namedGraph.equals(parser.getLocalName())) { graphUri = parser.getAttributeValue(null, SerializationConstants.namedGraphUri); String meta = parser.getAttributeValue(null, SerializationConstants.metadataGraphUri); String uuidString = parser.getAttributeValue(null, SerializationConstants.namedGraphUUID); namedGraphUri = Constants.valueFactory.createURI(graphUri); metaURI = Constants.valueFactory.createURI(meta); uuid = Constants.valueFactory.createURI(uuidString); revisioned = Boolean .parseBoolean(parser.getAttributeValue(null, SerializationConstants.revisioned)); } else if (SerializationConstants.revisions.equals(parser.getLocalName())) { revisions = new ArrayList<BackupRevision>(); } else if (SerializationConstants.revisionInfo.equals(parser.getLocalName())) { long revision = Long .parseLong(parser.getAttributeValue(null, SerializationConstants.revision)); Long start = Long.valueOf(parser.getAttributeValue(null, SerializationConstants.start)); String endString = parser.getAttributeValue(null, SerializationConstants.end); Long end = (endString != null) ? Long.valueOf(endString) : -1; lastModified = Constants.valueFactory .createURI(parser.getAttributeValue(null, SerializationConstants.lastModifiedBy)); revisions.add(new BackupRevision(revision, start, end, lastModified)); } else if (SerializationConstants.statement.equals(parser.getLocalName())) { if (processGraph) { if (revisioned) { String startString = parser.getAttributeValue(null, SerializationConstants.start); String endString = parser.getAttributeValue(null, SerializationConstants.end); if (startString != null) start = Long.valueOf(startString); if (endString != null) end = Long.valueOf(endString); } } } else if (SerializationConstants.statements.equals(parser.getLocalName())) { if (processGraph) { metadata = !parser.getAttributeValue(null, SerializationConstants.namedGraphUri) .equals(graphUri); } } else if (SerializationConstants.subject.equals(parser.getLocalName())) { if (processGraph) { nodeType = parser.getAttributeValue(null, SerializationConstants.subjectType); } } else if (SerializationConstants.predicate.equals(parser.getLocalName())) { } else if (SerializationConstants.object.equals(parser.getLocalName())) { if (processGraph) { nodeType = parser.getAttributeValue(null, SerializationConstants.objectType); language = parser.getAttributeValue(null, SerializationConstants.language); datatype = parser.getAttributeValue(null, SerializationConstants.dataType); } } else if (SerializationConstants.namedGraphUri.equals(parser.getLocalName())) { } break; case XMLStreamConstants.END_ELEMENT: if (SerializationConstants.namedGraph.equals(parser.getLocalName())) { graphUri = null; namedGraphUri = null; metaURI = null; uuid = null; revisioned = true; revisions = null; } else if (SerializationConstants.revisionInfo.equals(parser.getLocalName())) { } else if (SerializationConstants.revisions.equals(parser.getLocalName())) { processGraph = handler.handleNamedGraph(revisioned, namedGraphUri, metaURI, uuid, revisions); revisions = null; } else if (SerializationConstants.statement.equals(parser.getLocalName())) { if (processGraph) { handler.handleStatement(metadata, revisioned, Constants.valueFactory.createStatement(currentSubject, currentPredicate, currentObject, currentNamedGraphURI), start, end); start = null; end = null; } } else if (SerializationConstants.subject.equals(parser.getLocalName())) { if (processGraph) { if (NodeType.BNODE.name().equals(nodeType)) { currentSubject = Constants.valueFactory.createBNode(currentValue); } else { currentSubject = Constants.valueFactory.createURI(currentValue); } currentValue = null; nodeType = null; } } else if (SerializationConstants.predicate.equals(parser.getLocalName())) { if (processGraph) { currentPredicate = Constants.valueFactory.createURI(currentValue); currentValue = null; } } else if (SerializationConstants.object.equals(parser.getLocalName())) { if (processGraph) { if (NodeType.BNODE.name().equals(nodeType)) { currentObject = Constants.valueFactory.createBNode(currentValue); } else if (NodeType.URI.name().equals(nodeType)) { currentObject = Constants.valueFactory.createURI(currentValue); } else if (NodeType.LITERAL.name().equals(nodeType)) { if (currentValue == null) { currentValue = ""; } else if (Base64 .isArrayByteBase64(currentValue.getBytes(Constants.byteEncoding))) { currentValue = new String( Base64.decodeBase64(currentValue.getBytes(Constants.byteEncoding)), Constants.byteEncoding); } if (datatype != null) { currentObject = Constants.valueFactory.createLiteral(currentValue, Constants.valueFactory.createURI(datatype)); } else if (language != null) { currentObject = Constants.valueFactory.createLiteral(currentValue, language); } else { currentObject = Constants.valueFactory.createLiteral(currentValue); } } currentValue = null; nodeType = null; language = null; datatype = null; } } else if (SerializationConstants.namedGraphUri.equals(parser.getLocalName())) { if (processGraph) { currentNamedGraphURI = Constants.valueFactory.createURI(currentValue); currentValue = null; } } break; case XMLStreamConstants.CHARACTERS: if (parser.hasText()) currentValue = parser.getText(); break; case XMLStreamConstants.CDATA: if (parser.hasText()) currentValue = parser.getText(); break; } } parser.close(); } catch (XMLStreamException ex) { throw new AnzoException(ExceptionConstants.IO.READ_ERROR, ex, ex.getMessage()); } catch (UnsupportedEncodingException uee) { throw new AnzoException(ExceptionConstants.IO.ENCODING_ERROR, uee); } }