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.slc.sli.modeling.xmi.reader.XmiReader.java
protected static final List<TaggedValue> readTaggedValueGroup(final XMLStreamReader reader) { final List<TaggedValue> taggedValues = new LinkedList<TaggedValue>(); try {/*from w w w. j a v a 2 s . c o m*/ if (match(XmiElementName.MODEL_ELEMENT_DOT_TAGGED_VALUE, reader)) { while (reader.hasNext()) { reader.next(); switch (reader.getEventType()) { case XMLStreamConstants.START_ELEMENT: { if ("TaggedValue".equals(reader.getLocalName())) { taggedValues.add(assertNotNull(readTaggedValue(reader))); break; } else { throw new AssertionError(reader.getLocalName()); } } case XMLStreamConstants.END_ELEMENT: { if (match(XmiElementName.MODEL_ELEMENT_DOT_TAGGED_VALUE, reader)) { return taggedValues; } else { throw new AssertionError(reader.getLocalName()); } } case XMLStreamConstants.CHARACTERS: { // Ignore. break; } default: { throw new AssertionError(reader.getEventType()); } } } } else { throw new AssertionError(reader.getLocalName()); } } catch (final XMLStreamException e) { LOG.warn(e.getMessage()); } throw new AssertionError(); }
From source file:org.slc.sli.modeling.xmi.reader.XmiReader.java
protected static final Identifier readTaggedValueType(final XMLStreamReader reader) throws XMLStreamException { assertName(XmiElementName.TAGGED_VALUE_DOT_TYPE, reader); Identifier reference = null;//w w w . ja v a2 s . c o m while (reader.hasNext()) { reader.next(); switch (reader.getEventType()) { case XMLStreamConstants.START_ELEMENT: { if (match(XmiElementName.TAG_DEFINITION, reader)) { reference = assertNotNull(readIdentifier(reader)); } else { throw new AssertionError(reader.getLocalName()); } break; } case XMLStreamConstants.END_ELEMENT: { assertName(XmiElementName.TAGGED_VALUE_DOT_TYPE, reader); return assertNotNull(reference); } case XMLStreamConstants.CHARACTERS: { // Ignore. break; } default: { throw new AssertionError(reader.getEventType()); } } } throw new AssertionError(); }
From source file:org.slc.sli.modeling.xmi.reader.XmiReader.java
protected static final Model readXMI(final XMLStreamReader reader) { try {//from www . ja va2 s . c o m if ("XMI".equals(reader.getLocalName())) { Model model = null; while (reader.hasNext()) { reader.next(); switch (reader.getEventType()) { case XMLStreamConstants.START_ELEMENT: { if ("XMI.header".equals(reader.getLocalName())) { skipElement(reader, false); break; } else if ("XMI.content".equals(reader.getLocalName())) { model = readContent(reader); if (model == null) { throw new IllegalStateException(); } break; } else { throw new XmiRuntimeException("Expecting Foo element, got: " + reader.getLocalName()); } } case XMLStreamConstants.END_ELEMENT: { if ("XMI".equals(reader.getLocalName())) { if (model == null) { throw new IllegalStateException(); } return model; } else { throw new AssertionError(reader.getLocalName()); } } case XMLStreamConstants.CHARACTERS: { // Ignore. break; } default: { throw new AssertionError(reader.getEventType()); } } } } else { throw new AssertionError(reader.getLocalName()); } } catch (final XMLStreamException e) { LOG.warn(e.getMessage()); } return null; }
From source file:org.slc.sli.modeling.xmi.reader.XmiReader.java
/** * Skips (recursively) over the element in question. Also useful during development. * * @param reader// w w w. ja va 2 s. c o m * The StAX {@link XMLStreamReader}. */ protected static final void skipElement(final XMLStreamReader reader, final boolean check) throws XMLStreamException { if (check) { throw new AssertionError(reader.getName()); } final String localName = reader.getLocalName(); while (reader.hasNext()) { reader.next(); switch (reader.getEventType()) { case XMLStreamConstants.START_ELEMENT: { skipElement(reader, check); break; } case XMLStreamConstants.END_ELEMENT: { if (localName.equals(reader.getLocalName())) { return; } else { throw new AssertionError(reader.getLocalName()); } } case XMLStreamConstants.CHARACTERS: { // Ignore. break; } default: { throw new AssertionError(reader.getEventType()); } } } throw new AssertionError(); }
From source file:org.springmodules.remoting.xmlrpc.stax.AbstractStaxXmlRpcParser.java
/** * Creates a new <code>java.util.List</code> from the current element being * read in the specified <code>StreamReader</code>. * //from w w w . ja va 2 s. com * @param reader * the <code>StreamReader</code>. * @return the new array of <code>java.util.List</code>s. * @throws XmlRpcInvalidPayloadException * if the element contains an unknown child. Only one "data" element * is allowed inside an "array" element. * @see #parseDataElement(XMLStreamReader) */ protected final XmlRpcArray parseArrayElement(XMLStreamReader reader) throws XMLStreamException { while (reader.hasNext()) { int event = reader.next(); switch (event) { case XMLStreamConstants.START_ELEMENT: String localName = reader.getLocalName(); if (XmlRpcElementNames.DATA.equals(localName)) { return parseDataElement(reader); } XmlRpcParsingUtils.handleUnexpectedElementFound(localName); } } // we should not reach this point. return null; }
From source file:org.springmodules.remoting.xmlrpc.stax.AbstractStaxXmlRpcParser.java
/** * Creates a new <code>java.util.List</code> from the current element being * read in the specified <code>StreamReader</code>. * /* w w w. j a va2s . co m*/ * @param reader * the <code>StreamReader</code>. * @return the new array of <code>java.util.List</code>s. * @see #parseValueElement(XMLStreamReader) */ protected final XmlRpcArray parseDataElement(XMLStreamReader reader) throws XMLStreamException { XmlRpcArray array = new XmlRpcArray(); while (reader.hasNext()) { int event = reader.next(); String localName = null; switch (event) { case XMLStreamConstants.START_ELEMENT: localName = reader.getLocalName(); if (XmlRpcElementNames.VALUE.equals(localName)) { XmlRpcElement element = parseValueElement(reader); array.add(element); } break; case XMLStreamConstants.END_ELEMENT: localName = reader.getLocalName(); if (XmlRpcElementNames.DATA.equals(localName) || XmlRpcElementNames.ARRAY.equals(localName)) { return array; } } } // we should not reach this point. return null; }
From source file:org.springmodules.remoting.xmlrpc.stax.AbstractStaxXmlRpcParser.java
/** * Creates a new Object from the current element being read in the specified * <code>StreamReader</code>. * // w w w .j av a2s . co m * @param reader * the <code>StreamReader</code>. * @return the created Object. * @throws XmlRpcInvalidPayloadException * if the element contains an unknown child. * @see #parseValueElement(XMLStreamReader) */ protected final XmlRpcElement parseParameterElement(XMLStreamReader reader) throws XMLStreamException { while (reader.hasNext()) { int event = reader.next(); switch (event) { case XMLStreamConstants.START_ELEMENT: String localName = reader.getLocalName(); if (XmlRpcElementNames.VALUE.equals(localName)) { return parseValueElement(reader); } XmlRpcParsingUtils.handleUnexpectedElementFound(localName); } } // we should not reach this point. return null; }
From source file:org.springmodules.remoting.xmlrpc.stax.AbstractStaxXmlRpcParser.java
/** * Parses the given <code>XMLStreamReader</code> containing parameters for a * XML-RPC request/response./*from w w w .j ava2s.c o m*/ * * @param reader * the <code>StreamReader</code>. * @return the parameters of the XML-RPC request/response. */ protected final XmlRpcElement[] parseParametersElement(XMLStreamReader reader) throws XMLStreamException { List parameters = new ArrayList(); while (reader.hasNext()) { int event = reader.next(); String localName = null; switch (event) { case XMLStreamConstants.START_ELEMENT: localName = reader.getLocalName(); if (XmlRpcElementNames.PARAM.equals(localName)) { XmlRpcElement parameter = parseParameterElement(reader); parameters.add(parameter); } else { XmlRpcParsingUtils.handleUnexpectedElementFound(localName); } break; case XMLStreamConstants.END_ELEMENT: localName = reader.getLocalName(); if (XmlRpcElementNames.PARAMS.equals(localName)) { return (XmlRpcElement[]) parameters.toArray(new XmlRpcElement[parameters.size()]); } } } // we should not reach this point. return null; }
From source file:org.springmodules.remoting.xmlrpc.stax.AbstractStaxXmlRpcParser.java
/** * Creates a new <code>java.util.Map</code> from the current element being * read in the specified <code>StreamReader</code>. * //w w w .jav a 2s .c o m * @param reader * the <code>StreamReader</code>. * @return the new array of <code>java.util.Map</code>s. * @see #parseMemberElement(XMLStreamReader) */ protected final XmlRpcStruct parseStructElement(XMLStreamReader reader) throws XMLStreamException { XmlRpcStruct struct = new XmlRpcStruct(); while (reader.hasNext()) { int event = reader.next(); String localName = null; switch (event) { case XMLStreamConstants.START_ELEMENT: localName = reader.getLocalName(); if (XmlRpcElementNames.MEMBER.equals(localName)) { XmlRpcMember member = parseMemberElement(reader); struct.add(member); } break; case XMLStreamConstants.END_ELEMENT: localName = reader.getLocalName(); if (XmlRpcElementNames.STRUCT.equals(localName)) { return struct; } } } // we should not reach this point. return null; }
From source file:org.springmodules.remoting.xmlrpc.stax.AbstractStaxXmlRpcParser.java
/** * Creates a new <code>StructMember</code> from the current element being * read in the specified <code>StreamReader</code>. * //from ww w . j a va 2 s . co m * @param reader * the <code>StreamReader</code>. * @return the new <code>StructMember</code>. * @throws XmlRpcInvalidPayloadException * if the element contains an unknown child. Only one "name" element * and one "value" element are allowed inside an "member" element. * @see #parseValueElement(XMLStreamReader) */ protected final XmlRpcMember parseMemberElement(XMLStreamReader reader) throws XMLStreamException { String name = null; XmlRpcElement value = null; while (reader.hasNext()) { int event = reader.next(); String localName = null; switch (event) { case XMLStreamConstants.START_ELEMENT: localName = reader.getLocalName(); if (XmlRpcElementNames.NAME.equals(localName)) { name = reader.getElementText(); } else if (XmlRpcElementNames.VALUE.equals(localName)) { value = parseValueElement(reader); } else { XmlRpcParsingUtils.handleUnexpectedElementFound(localName); } break; case XMLStreamConstants.END_ELEMENT: localName = reader.getLocalName(); if (XmlRpcElementNames.MEMBER.equals(localName)) { if (!StringUtils.hasText(name)) { throw new XmlRpcInvalidPayloadException("The struct member should have a name"); } return new XmlRpcMember(name, value); } } } // we should never reach this point. return null; }