Java 类javax.xml.stream.events.EndDocument 实例源码

项目:ali-idea-plugin    文件:AbstractList.java   
protected void init(InputStream is) throws XMLStreamException {
    XMLInputFactory factory = XMLInputFactory.newInstance();
    reader = factory.createXMLEventReader(is);
    while(true) {
        XMLEvent event = reader.nextEvent();
        if(event instanceof EndDocument) {
            reader.close();
            break;
        }
        if(event instanceof StartElement) {
            onStartElement((StartElement)event);
        }
        if(event instanceof EndElement) {
            onEndElement((EndElement)event);
        }
    }
}
项目:ali-idea-plugin    文件:ProjectListService.java   
@Override
protected Map<Integer, List<String>> doGetValue(String entityType) {
    Map<Integer, List<String>> map = new HashMap<Integer, List<String>>();
    try {
        InputStream is = restService.getForStream("customization/entities/{0}/lists", entityType);
        XMLInputFactory factory = XMLInputFactory.newInstance();
        XMLEventReader reader = factory.createXMLEventReader(is);
        int listId = 0;
        while(true) {
            XMLEvent event = reader.nextEvent();
            if(event instanceof EndDocument) {
                reader.close();
                break;
            }
            if(event instanceof StartElement) {
                String localPart = ((StartElement) event).getName().getLocalPart();
                if("Id".equals(localPart)) {
                    listId = Integer.valueOf(AbstractList.readNextValue(reader));
                    map.put(listId, new ArrayList<String>());
                } else if("Item".equals(localPart)) {
                    String value = ((StartElement) event).getAttributeByName(new QName(null, "value")).getValue();
                    map.get(listId).add(value);
                }
            }
        }
    } catch(XMLStreamException e) {
        // return what was read so far
    }
    return map;
}
项目:openjdk-jdk10    文件:Issue41Test.java   
@Test
public void testEvents() {
    XMLEventFactory f = XMLEventFactory.newInstance();
    final String contents = "test <some> text & more! [[]] --";
    final String prefix = "prefix";
    final String uri = "http://foo";
    final String localName = "elem";

    try {
        StartDocument sd = f.createStartDocument();
        writeAsEncodedUnicode(sd);

        Comment c = f.createComment("some comments");
        writeAsEncodedUnicode(c);

        StartElement se = f.createStartElement(prefix, uri, localName);

        ProcessingInstruction pi = f.createProcessingInstruction("target", "data");
        writeAsEncodedUnicode(pi);

        Namespace ns = f.createNamespace(prefix, uri);
        writeAsEncodedUnicode(ns);

        Characters characters = f.createCharacters(contents);
        writeAsEncodedUnicode(characters);
        // CData
        Characters cdata = f.createCData(contents);
        writeAsEncodedUnicode(cdata);

        // Attribute
        QName attrName = new QName("http://test.com", "attr", "ns");
        Attribute attr = f.createAttribute(attrName, "value");
        writeAsEncodedUnicode(attr);

        // prefix, uri, localName
        EndElement ee = f.createEndElement(prefix, uri, localName);
        writeAsEncodedUnicode(ee);

        EndDocument ed = f.createEndDocument();
        writeAsEncodedUnicode(ed);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }

}
项目:openjdk-jdk10    文件:XMLEventFactoryWrapper.java   
@Override
public EndDocument createEndDocument() {
    return defaultImpl.createEndDocument();
}
项目:openjdk-jdk10    文件:XMLEventFactoryImpl.java   
@Override
public EndDocument createEndDocument() {
    return null;
}
项目:openjdk9    文件:Issue41Test.java   
@Test
public void testEvents() {
    XMLEventFactory f = XMLEventFactory.newInstance();
    final String contents = "test <some> text & more! [[]] --";
    final String prefix = "prefix";
    final String uri = "http://foo";
    final String localName = "elem";

    try {
        StartDocument sd = f.createStartDocument();
        writeAsEncodedUnicode(sd);

        Comment c = f.createComment("some comments");
        writeAsEncodedUnicode(c);

        StartElement se = f.createStartElement(prefix, uri, localName);

        ProcessingInstruction pi = f.createProcessingInstruction("target", "data");
        writeAsEncodedUnicode(pi);

        Namespace ns = f.createNamespace(prefix, uri);
        writeAsEncodedUnicode(ns);

        Characters characters = f.createCharacters(contents);
        writeAsEncodedUnicode(characters);
        // CData
        Characters cdata = f.createCData(contents);
        writeAsEncodedUnicode(cdata);

        // Attribute
        QName attrName = new QName("http://test.com", "attr", "ns");
        Attribute attr = f.createAttribute(attrName, "value");
        writeAsEncodedUnicode(attr);

        // prefix, uri, localName
        EndElement ee = f.createEndElement(prefix, uri, localName);
        writeAsEncodedUnicode(ee);

        EndDocument ed = f.createEndDocument();
        writeAsEncodedUnicode(ed);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }

}
项目:openjdk9    文件:XMLEventFactoryImpl.java   
@Override
public EndDocument createEndDocument() {
    return null;
}
项目:javify    文件:XMLEventFactoryImpl.java   
public EndDocument createEndDocument()
{
  return new EndDocumentImpl(location);
}
项目:jvm-stm    文件:XMLEventFactoryImpl.java   
public EndDocument createEndDocument()
{
  return new EndDocumentImpl(location);
}
项目:werval    文件:XMLEventFactoryImpl.java   
@Override
public EndDocument createEndDocument()
{
    return delegate.createEndDocument();
}
项目:JamVM-PH    文件:XMLEventFactoryImpl.java   
public EndDocument createEndDocument()
{
  return new EndDocumentImpl(location);
}
项目:SplitCharater    文件:XMLEventFactoryImpl.java   
public EndDocument createEndDocument() {
    return new EndDocumentImpl(fLocation);
}
项目:SplitCharater    文件:StAXEventResultBuilder.java   
public void endDocument(EndDocument event) throws XMLStreamException {
    fEventWriter.add(event);
    fEventWriter.flush();
}
项目:SplitCharater    文件:StAXStreamResultBuilder.java   
public void endDocument(EndDocument event) throws XMLStreamException {
    fStreamWriter.writeEndDocument();
    fStreamWriter.flush();
}
项目:classpath    文件:XMLEventFactoryImpl.java   
public EndDocument createEndDocument()
{
  return new EndDocumentImpl(location);
}
项目:HTMLtoc    文件:Transformer.java   
protected void index(XMLEvent event) throws XMLStreamException
 {
  final Location location = event.getLocation();
  try
  {
   if (event instanceof EndDocument)
   {
    if (null != context)
     trackContext(event);
    if (null != formatter)
    {
     formatter.end();
     conveyFormatted();
    }
    for (XMLEvent resumed : deferred)
     super.add(resumed);
    super.add(event);
   }
   else if (event instanceof EndElement && null != context && context.isEmpty())
   {
    EndElement close = (EndElement)event;
    if (!((StartElement)origin).getName().equals(close.getName()))
     throw new IllegalStateException("Unclosed " + describeEvent(origin) + ' '
         + describeLocation(origin.getLocation()));
    endContext();
    if (null != formatter)
    {
     formatter.closeItem(event);
     conveyFormatted();
    }
    deferred.add(event);
   }
   else if (null == context)
   {
    String id = null;
    if (null != formatter && formatter.accept(event))
    {
     event = assignIdToElement((StartElement)event);
     id = ((StartElement)event).getAttributeByName(ID_ATTR_QNAME).getValue();
    }
    deferred.add(event);
    if (null != id)
    {
     XMLEventFactory eventFactory = getXMLEventFactory();
     Set<Attribute> attrs = Collections.singleton(
eventFactory.createAttribute("name", id)
     );
     deferred.add(eventFactory.createStartElement(
DEFAULT_NS_PREFIX,
NULL_NS_URI,
"a",
attrs.iterator(),
Collections.EMPTY_SET.iterator()));
     deferred.add(eventFactory.createCharacters(" "));
     deferred.add(eventFactory.createEndElement(DEFAULT_NS_PREFIX, NULL_NS_URI, "a"));
     if (null != formatter)
     {
      formatter.openItem(event, id);
      conveyFormatted();
     }
     enterContext(event);
    }
   }
   else // null != context
   {
    trackContext(event);
    deferred.add(event);
    if (null != formatter)
    {
     formatter.addContent(event);
     conveyFormatted();
    }
   }
  }
  catch (RuntimeException error)
  {
   throw new XMLStreamException(error.getLocalizedMessage(), location, error);
  }
 }
项目:javify    文件:XMLEventFactory.java   
/**
 * Create an end-document event.
 */
public abstract EndDocument createEndDocument();
项目:jvm-stm    文件:XMLEventFactory.java   
/**
 * Create an end-document event.
 */
public abstract EndDocument createEndDocument();
项目:JamVM-PH    文件:XMLEventFactory.java   
/**
 * Create an end-document event.
 */
public abstract EndDocument createEndDocument();
项目:classpath    文件:XMLEventFactory.java   
/**
 * Create an end-document event.
 */
public abstract EndDocument createEndDocument();
项目:SplitCharater    文件:StAXDocumentHandler.java   
public void endDocument(EndDocument event) throws XMLStreamException;