Package javax.xml.stream.events

Examples of javax.xml.stream.events.EndElement


                  stack.push(refEntity);
               }

               break;
            case XMLStreamConstants.END_ELEMENT :
               EndElement endElement = event.asEndElement();
               localName = endElement.getName().getLocalPart();

               if (localName.equals(REFERENCE_ELEMENT))
               {
                  RefEntity refEntity = stack.pop();
                  importedRefs.put(refEntity.getKey(), refEntity.getValue());
View Full Code Here


                return;
            }
            case XMLEvent.END_ELEMENT: {
                List<Namespace> declaredNs = this.namespaces.get(depth);
                depth--;
                EndElement endElement = xmlEvent.asEndElement();

                QName name = endElement.getName();
                String prefix = endElement.getName().getPrefix();
                if(null == prefix || prefix.length() == 0) {
                    contentHandler.endElement(name.getNamespaceURI(), name.getLocalPart(), name.getLocalPart());
                } else {
                    contentHandler.endElement(name.getNamespaceURI(), name.getLocalPart(), prefix + XMLConstants.COLON + name.getLocalPart());
                }
View Full Code Here

    writer = new UnopenedElementClosingEventWriter(wrappedWriter, ioWriter, unopenedElements);
  }
   
    @Test
    public void testEndUnopenedElements() throws Exception {
      EndElement endElementB = eventFactory.createEndElement(unopenedB, null);
      writer.add(endElementB);

      EndElement endElementA = eventFactory.createEndElement(unopenedA, null);
      writer.add(endElementA);

      verify(wrappedWriter, Mockito.never()).add(endElementB);
      verify(wrappedWriter, Mockito.never()).add(endElementA);
      verify(wrappedWriter, Mockito.times(2)).flush();
View Full Code Here

      verify(ioWriter, Mockito.times(2)).flush();
    }
   
    @Test
    public void testEndUnopenedElementRemovesFromList() throws Exception {
      EndElement endElement = eventFactory.createEndElement(unopenedB, null);
      writer.add(endElement);
     
      verify(wrappedWriter, Mockito.never()).add(endElement);
      verify(wrappedWriter).flush();
      verify(ioWriter).write("</unopened-b>");
View Full Code Here

      Assert.assertEquals(2, unopenedElements.size());     
    }   
   
    @Test
    public void testOtherEndElement() throws Exception {
      EndElement endElement = eventFactory.createEndElement(other, null);
      writer.add(endElement);
     
      verify(wrappedWriter).add(endElement);
    }      
View Full Code Here

      verify(wrappedWriter).add(event);
   
   
    @Test (expected = DataAccessResourceFailureException.class)
    public void testIOException() throws Exception {
      EndElement endElementB = eventFactory.createEndElement(unopenedB, null);
      Mockito.doThrow(new IOException("Simulated IOException")).when(ioWriter).write("</unopened-b>");
      writer.add(endElementB);
    }
View Full Code Here

                        osmRelation.addTag(tag);
                    }
                }

            } else if (xmlEvent.isEndElement()) {
                EndElement element = xmlEvent.asEndElement();
                if (osmNode != null && element.getName().equals(qNode)) {
                    map.addNode(osmNode);
                    osmNode = null;
                else if (osmWay != null && element.getName().equals(qWay)) {
                    map.addWay(osmWay);
                    osmWay = null;
                else if (osmRelation != null && element.getName().equals(qRelation)) {
                    map.addRelation(osmRelation);
                    osmRelation = null;
                }
            }
        }
View Full Code Here

            String attributeName, String attributeValue) throws XMLStreamException {
        Attribute newAttribute = xmlEventFactory.createAttribute(attributeName, attributeValue);
        Set attributes = new HashSet();
        attributes.add(newAttribute);

        EndElement oldEvent = event.asEndElement();
        StartElement newStartEvent = xmlEventFactory.createStartElement(new QName(elementName),
                attributes.iterator(), oldEvent.getNamespaces());

        writer.add(newStartEvent);
        return xmlEventFactory.createEndElement(newStartEvent.getName(), newStartEvent.getNamespaces());
    }
View Full Code Here

            String attributeName, String attributeValue) throws XMLStreamException {
        Attribute newAttribute = xmlEventFactory.createAttribute(attributeName, attributeValue);
        Set attributes = new HashSet();
        attributes.add(newAttribute);

        EndElement oldEvent = event.asEndElement();
        StartElement newStartEvent = xmlEventFactory.createStartElement(new QName(elementName),
                attributes.iterator(), oldEvent.getNamespaces());

        writer.add(newStartEvent);
        return xmlEventFactory.createEndElement(newStartEvent.getName(), newStartEvent.getNamespaces());
    }
View Full Code Here

              for (final AttributeEntry entry : tag) {
                attrs.add(eventFactory.createAttribute(entry.getKey(), entry.getValue()));
              }
              StartElement newStart = eventFactory.createStartElement(QName.valueOf(tag.getName()), attrs.iterator(),
                      null);
              EndElement newEnd = eventFactory.createEndElement(newStart.getName(), null);

              writer.add(newStart);
              writer.add(newEnd);
            }
          }
View Full Code Here

TOP

Related Classes of javax.xml.stream.events.EndElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.