List of usage examples for javax.xml.stream XMLStreamReader hasNext
public boolean hasNext() throws XMLStreamException;
From source file:org.slc.sli.modeling.xmi.reader.XmiReader.java
protected static final Range readMultiplicityRange(final XMLStreamReader reader) throws XMLStreamException { assertName(XmiElementName.MULTIPLICITY_RANGE, reader); final Identifier id = getId(reader); final Occurs lowerBound = getOccurs(reader, XmiAttributeName.LOWER); final Occurs upperBound = getOccurs(reader, XmiAttributeName.UPPER); while (reader.hasNext()) { reader.next();// ww w. j a v a 2s.com switch (reader.getEventType()) { case XMLStreamConstants.START_ELEMENT: { skipElement(reader, false); break; } case XMLStreamConstants.END_ELEMENT: { assertName(XmiElementName.MULTIPLICITY_RANGE, reader); return new Range(id, lowerBound, upperBound, EMPTY_TAGGED_VALUE_LIST); } 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
/** * The UML:Namespace.ownedElement is simply a list of model elements that can belong in a * name-space.//from w w w .j av a2 s .co m * * It has no identity of its own and is only present in the serialization format. */ protected static final List<NamespaceOwnedElement> readNamespaceOwnedElement(final XMLStreamReader reader) throws XMLStreamException { assertName(XmiElementName.NAMESPACE_DOT_OWNED_ELEMENT, reader); final List<NamespaceOwnedElement> ownedElements = new LinkedList<NamespaceOwnedElement>(); while (reader.hasNext()) { reader.next(); switch (reader.getEventType()) { case XMLStreamConstants.START_ELEMENT: { if (match(XmiElementName.CLASS, reader)) { ownedElements.add(assertNotNull(readClassType(reader.getName(), reader))); } else if (match(XmiElementName.ASSOCIATION_CLASS, reader)) { ownedElements.add(assertNotNull(readClassType(reader.getName(), reader))); } else if (match(XmiElementName.ASSOCIATION, reader)) { ownedElements.add(assertNotNull(readClassType(reader.getName(), reader))); } else if (match(XmiElementName.DATA_TYPE, reader)) { ownedElements.add(assertNotNull(readDataType(reader))); } else if (match(XmiElementName.ENUMERATION, reader)) { ownedElements.add(assertNotNull(readEnumeration(reader))); } else if (match(XmiElementName.TAG_DEFINITION, reader)) { ownedElements.add(assertNotNull(readTagDefinition(reader))); } else if (match(XmiElementName.GENERALIZATION, reader)) { ownedElements.add(assertNotNull(readGeneralization(reader))); } else if (match(XmiElementName.COMMENT, reader)) { skipElement(reader, false); } else if (match(XmiElementName.PACKAGE, reader)) { ownedElements.add(assertNotNull(readPackage(reader))); } else { throw new AssertionError(reader.getName()); // skipElement(reader); } break; } case XMLStreamConstants.END_ELEMENT: { assertName(XmiElementName.NAMESPACE_DOT_OWNED_ELEMENT, reader); return Collections.unmodifiableList(ownedElements); } 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 UmlPackage readPackage(final XMLStreamReader reader) throws XMLStreamException { assertName(XmiElementName.PACKAGE, reader); final List<TaggedValue> taggedValues = new LinkedList<TaggedValue>(); final Identifier id = getId(reader); final String name = assertNotNull(getName(reader, null, XmiAttributeName.NAME)); List<NamespaceOwnedElement> ownedElements = EMPTY_NAMESPACE_OWNED_ELEMENTS; while (reader.hasNext()) { reader.next();//from w w w. j a v a 2 s.c o m switch (reader.getEventType()) { case XMLStreamConstants.START_ELEMENT: { if (match(XmiElementName.NAMESPACE_DOT_OWNED_ELEMENT, reader)) { ownedElements = readNamespaceOwnedElement(reader); } else if (match(XmiElementName.MODEL_ELEMENT_DOT_TAGGED_VALUE, reader)) { taggedValues.addAll(readTaggedValueGroup(reader)); } else { throw new AssertionError(reader.getLocalName()); // skipElement(reader); } break; } case XMLStreamConstants.END_ELEMENT: { assertName(XmiElementName.PACKAGE, reader); return new UmlPackage(name, id, taggedValues, ownedElements); } 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 Multiplicity readStructuralFeatureDotMultiplicity(final XMLStreamReader reader) throws XMLStreamException { assertName(XmiElementName.STRUCTURAL_FEATURE_DOT_MULTIPLICITY, reader); Multiplicity multiplicity = null;// w ww .j av a 2 s. co m while (reader.hasNext()) { reader.next(); switch (reader.getEventType()) { case XMLStreamConstants.START_ELEMENT: { if (match(XmiElementName.MULTIPLICITY, reader)) { multiplicity = assertNotNull(readMultiplicity(reader)); } else { throw new AssertionError(reader.getLocalName()); // skipElement(reader); } break; } case XMLStreamConstants.END_ELEMENT: { assertName(XmiElementName.STRUCTURAL_FEATURE_DOT_MULTIPLICITY, reader); return assertNotNull(multiplicity); } 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 TagDefinition readTagDefinition(final XMLStreamReader reader) throws XMLStreamException { assertName(XmiElementName.TAG_DEFINITION, reader); final List<TaggedValue> taggedValues = new LinkedList<TaggedValue>(); final Identifier id = getId(reader); final String name = assertNotNull(getName(reader, null, XmiAttributeName.NAME)); Multiplicity multiplicity = null;/*from ww w . ja va2 s . c o m*/ while (reader.hasNext()) { reader.next(); switch (reader.getEventType()) { case XMLStreamConstants.START_ELEMENT: { if (match(XmiElementName.TAG_DEFINITION_DOT_MULTIPLICITY, reader)) { multiplicity = assertNotNull(readTagDefinitionMultiplicity(reader)); } else if (match(XmiElementName.MODEL_ELEMENT_DOT_TAGGED_VALUE, reader)) { skipElement(reader, false); } else { skipElement(reader, true); } break; } case XMLStreamConstants.END_ELEMENT: { assertName(XmiElementName.TAG_DEFINITION, reader); return new TagDefinition(id, taggedValues, name, multiplicity); } 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 Multiplicity readTagDefinitionMultiplicity(final XMLStreamReader reader) throws XMLStreamException { assertName(XmiElementName.TAG_DEFINITION_DOT_MULTIPLICITY, reader); Multiplicity multiplicity = null;/*from ww w. j a v a2 s .c o m*/ while (reader.hasNext()) { reader.next(); switch (reader.getEventType()) { case XMLStreamConstants.START_ELEMENT: { if (match(XmiElementName.MULTIPLICITY, reader)) { multiplicity = assertNotNull(readMultiplicity(reader)); } else { throw new AssertionError(reader.getLocalName()); // skipElement(reader); } break; } case XMLStreamConstants.END_ELEMENT: { assertName(XmiElementName.TAG_DEFINITION_DOT_MULTIPLICITY, reader); return assertNotNull(multiplicity); } 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 TaggedValue readTaggedValue(final XMLStreamReader reader) throws XMLStreamException { assertName(XmiElementName.TAGGED_VALUE, reader); final Identifier id = getId(reader); String dataValue = ""; Identifier tagDefinition = null;/* w w w . j a va2 s .c o m*/ while (reader.hasNext()) { reader.next(); switch (reader.getEventType()) { case XMLStreamConstants.START_ELEMENT: { if (match(XmiElementName.TAGGED_VALUE_DOT_DATA_VALUE, reader)) { dataValue = assertNotNull(readTaggedValueData(reader)); } else if (match(XmiElementName.TAGGED_VALUE_DOT_TYPE, reader)) { tagDefinition = assertNotNull(readTaggedValueType(reader)); } else { throw new AssertionError(reader.getLocalName()); } break; } case XMLStreamConstants.END_ELEMENT: { assertName(XmiElementName.TAGGED_VALUE, reader); return new TaggedValue(id, EMPTY_TAGGED_VALUE_LIST, dataValue, tagDefinition); } 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 String readTaggedValueData(final XMLStreamReader reader) throws XMLStreamException { assertName(XmiElementName.TAGGED_VALUE_DOT_DATA_VALUE, reader); final StringBuilder sb = new StringBuilder(); while (reader.hasNext()) { reader.next();// www . j av a 2s. com switch (reader.getEventType()) { case XMLStreamConstants.START_ELEMENT: { throw new AssertionError(reader.getLocalName()); } case XMLStreamConstants.END_ELEMENT: { assertName(XmiElementName.TAGGED_VALUE_DOT_DATA_VALUE, reader); return collapseWhitespace(sb.toString()); } case XMLStreamConstants.CHARACTERS: { sb.append(reader.getText()); break; } default: { throw new AssertionError(reader.getEventType()); } } } throw new AssertionError(); }
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 .ja 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;//ww w. ja v a 2 s. c om 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(); }