List of usage examples for javax.xml.stream XMLStreamReader next
public int next() throws XMLStreamException;
From source file:org.apache.ddlutils.io.DatabaseIO.java
/** * Reads index column elements from the XML stream reader and adds them to the given * index object./* w w w .j a va 2 s .c o m*/ * * @param xmlReader The reader * @param index The index object */ private void readIndexColumnElements(XMLStreamReader xmlReader, Index index) throws XMLStreamException, IOException { int eventType = XMLStreamReader.START_ELEMENT; while (eventType != XMLStreamReader.END_ELEMENT) { eventType = xmlReader.next(); if (eventType == XMLStreamReader.START_ELEMENT) { QName elemQName = xmlReader.getName(); if (isSameAs(elemQName, QNAME_ELEMENT_INDEX_COLUMN)) { index.addColumn(readIndexColumnElement(xmlReader)); } else { readOverElement(xmlReader); } } } }
From source file:org.apache.ddlutils.io.DatabaseIO.java
/** * Reads unique index column elements from the XML stream reader and adds them to the given * index object./* ww w . j ava 2 s.c o m*/ * * @param xmlReader The reader * @param index The index object */ private void readUniqueColumnElements(XMLStreamReader xmlReader, Index index) throws XMLStreamException, IOException { int eventType = XMLStreamReader.START_ELEMENT; while (eventType != XMLStreamReader.END_ELEMENT) { eventType = xmlReader.next(); if (eventType == XMLStreamReader.START_ELEMENT) { QName elemQName = xmlReader.getName(); if (isSameAs(elemQName, QNAME_ELEMENT_UNIQUE_COLUMN)) { index.addColumn(readIndexColumnElement(xmlReader)); } else { readOverElement(xmlReader); } } } }
From source file:org.apache.ddlutils.io.DatabaseIO.java
/** * Consumes the rest of the current element. This assumes that the current XML stream * event type is not START_ELEMENT./*w ww. j av a 2s . com*/ * * @param reader The xml reader */ private void consumeRestOfElement(XMLStreamReader reader) throws XMLStreamException { int eventType = reader.getEventType(); while ((eventType != XMLStreamReader.END_ELEMENT) && (eventType != XMLStreamReader.END_DOCUMENT)) { eventType = reader.next(); } }
From source file:org.apache.ddlutils.io.DatabaseIO.java
/** * Reads over the current element. This assumes that the current XML stream event type is * START_ELEMENT.//from ww w . j av a 2 s . com * * @param reader The xml reader */ private void readOverElement(XMLStreamReader reader) throws XMLStreamException { int depth = 1; while (depth > 0) { int eventType = reader.next(); if (eventType == XMLStreamReader.START_ELEMENT) { depth++; } else if (eventType == XMLStreamReader.END_ELEMENT) { depth--; } } }
From source file:org.apache.ddlutils.io.DataReader.java
/** * Reads the data from the given XML stream reader. * //from ww w . j ava2 s .c o m * @param xmlReader The reader */ private void read(XMLStreamReader xmlReader) throws DdlUtilsXMLException { try { while (xmlReader.getEventType() != XMLStreamReader.START_ELEMENT) { if (xmlReader.next() == XMLStreamReader.END_DOCUMENT) { return; } } readDocument(xmlReader); } catch (XMLStreamException ex) { throw new DdlUtilsXMLException(ex); } }
From source file:org.apache.ddlutils.io.DataReader.java
/** * Reads the xml document from the given xml stream reader. * //from w w w . j ava 2 s .c o m * @param xmlReader The reader */ private void readDocument(XMLStreamReader xmlReader) throws XMLStreamException, DdlUtilsXMLException { // we ignore the top-level tag since we don't know about its name int eventType = XMLStreamReader.START_ELEMENT; while (eventType != XMLStreamReader.END_ELEMENT) { eventType = xmlReader.next(); if (eventType == XMLStreamReader.START_ELEMENT) { readBean(xmlReader); } } }
From source file:org.apache.ddlutils.io.DataReader.java
/** * Reads all relevant sub elements that match the columns specified by the given table object from the xml reader into the given bean. * /* w w w.j ava 2s .c o m*/ * @param xmlReader The reader * @param data Where to store the values */ private void readColumnSubElements(XMLStreamReader xmlReader, Map data) throws XMLStreamException, DdlUtilsXMLException { int eventType = XMLStreamReader.START_ELEMENT; while (eventType != XMLStreamReader.END_ELEMENT) { eventType = xmlReader.next(); if (eventType == XMLStreamReader.START_ELEMENT) { readColumnSubElement(xmlReader, data); } } }
From source file:org.apache.ddlutils.io.DataReader.java
/** * Reads the next column sub element that matches a column specified by the given table object from the xml reader into the given bean. * //from w w w.ja va 2 s . c o m * @param xmlReader The reader * @param data Where to store the values */ private void readColumnSubElement(XMLStreamReader xmlReader, Map data) throws XMLStreamException, DdlUtilsXMLException { QName elemQName = xmlReader.getName(); Map attributes = new HashMap(); boolean usesBase64 = false; for (int idx = 0; idx < xmlReader.getAttributeCount(); idx++) { QName attrQName = xmlReader.getAttributeName(idx); String value = xmlReader.getAttributeValue(idx); if (DatabaseIO.BASE64_ATTR_NAME.equals(attrQName.getLocalPart())) { if ("true".equalsIgnoreCase(value)) { usesBase64 = true; } } else { attributes.put(attrQName.getLocalPart(), value); } } int eventType = XMLStreamReader.START_ELEMENT; StringBuffer content = new StringBuffer(); while (eventType != XMLStreamReader.END_ELEMENT) { eventType = xmlReader.next(); if (eventType == XMLStreamReader.START_ELEMENT) { readColumnDataSubElement(xmlReader, attributes); } else if ((eventType == XMLStreamReader.CHARACTERS) || (eventType == XMLStreamReader.CDATA) || (eventType == XMLStreamReader.SPACE) || (eventType == XMLStreamReader.ENTITY_REFERENCE)) { content.append(xmlReader.getText()); } } String value = content.toString().trim(); if (usesBase64) { value = new String(Base64.decodeBase64(value.getBytes())); } String name = elemQName.getLocalPart(); if ("table-name".equals(name)) { data.put("table-name", value); } else { if ("column".equals(name)) { name = (String) attributes.get("column-name"); } if (attributes.containsKey("column-value")) { value = (String) attributes.get("column-value"); } data.put(name, value); } consumeRestOfElement(xmlReader); }
From source file:org.apache.ddlutils.io.DataReaderKeys.java
private void readDocument(XMLStreamReader xmlReader) throws XMLStreamException, DdlUtilsXMLException { // we ignore the top-level tag since we don't know about its name int eventType = XMLStreamReader.START_ELEMENT; while (eventType != XMLStreamReader.END_ELEMENT) { eventType = xmlReader.next(); if (eventType == XMLStreamReader.START_ELEMENT) { Identity id = readBean(xmlReader); if (id != null) { //check to see if keymap has the table already Set keyset = (Set) keymap.get(id.getTable().getName()); if (keyset != null) { keyset.add(id);/*from w ww . j a va 2 s.co m*/ } else { //add the table Set newset = new HashSet(); newset.add(id); keymap.put(id.getTable().getName(), newset); } } } } }
From source file:org.apache.ddlutils.io.DataReaderKeys.java
private void readColumnSubElements(XMLStreamReader xmlReader, DynaBean bean, Table table) throws XMLStreamException, DdlUtilsXMLException { int eventType = XMLStreamReader.START_ELEMENT; while (eventType != XMLStreamReader.END_ELEMENT) { eventType = xmlReader.next(); if (eventType == XMLStreamReader.START_ELEMENT) { readColumnSubElement(xmlReader, bean, table); }/*from w w w. j a v a 2s.c om*/ } }