java类javax.xml.stream.events.EndDocument的实例源码

AbstractList.java 文件源码 项目:ali-idea-plugin 阅读 29 收藏 0 点赞 0 评论 0
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);
        }
    }
}
ProjectListService.java 文件源码 项目:ali-idea-plugin 阅读 22 收藏 0 点赞 0 评论 0
@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;
}
Issue41Test.java 文件源码 项目:openjdk-jdk10 阅读 21 收藏 0 点赞 0 评论 0
@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());
    }

}
XMLEventFactoryWrapper.java 文件源码 项目:openjdk-jdk10 阅读 23 收藏 0 点赞 0 评论 0
@Override
public EndDocument createEndDocument() {
    return defaultImpl.createEndDocument();
}
XMLEventFactoryImpl.java 文件源码 项目:openjdk-jdk10 阅读 26 收藏 0 点赞 0 评论 0
@Override
public EndDocument createEndDocument() {
    return null;
}
Issue41Test.java 文件源码 项目:openjdk9 阅读 23 收藏 0 点赞 0 评论 0
@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());
    }

}
XMLEventFactoryImpl.java 文件源码 项目:openjdk9 阅读 26 收藏 0 点赞 0 评论 0
@Override
public EndDocument createEndDocument() {
    return null;
}
XMLEventFactoryImpl.java 文件源码 项目:javify 阅读 29 收藏 0 点赞 0 评论 0
public EndDocument createEndDocument()
{
  return new EndDocumentImpl(location);
}
XMLEventFactoryImpl.java 文件源码 项目:jvm-stm 阅读 20 收藏 0 点赞 0 评论 0
public EndDocument createEndDocument()
{
  return new EndDocumentImpl(location);
}
XMLEventFactoryImpl.java 文件源码 项目:werval 阅读 22 收藏 0 点赞 0 评论 0
@Override
public EndDocument createEndDocument()
{
    return delegate.createEndDocument();
}
XMLEventFactoryImpl.java 文件源码 项目:JamVM-PH 阅读 25 收藏 0 点赞 0 评论 0
public EndDocument createEndDocument()
{
  return new EndDocumentImpl(location);
}
XMLEventFactoryImpl.java 文件源码 项目:SplitCharater 阅读 23 收藏 0 点赞 0 评论 0
public EndDocument createEndDocument() {
    return new EndDocumentImpl(fLocation);
}
StAXEventResultBuilder.java 文件源码 项目:SplitCharater 阅读 23 收藏 0 点赞 0 评论 0
public void endDocument(EndDocument event) throws XMLStreamException {
    fEventWriter.add(event);
    fEventWriter.flush();
}
StAXStreamResultBuilder.java 文件源码 项目:SplitCharater 阅读 22 收藏 0 点赞 0 评论 0
public void endDocument(EndDocument event) throws XMLStreamException {
    fStreamWriter.writeEndDocument();
    fStreamWriter.flush();
}
XMLEventFactoryImpl.java 文件源码 项目:classpath 阅读 30 收藏 0 点赞 0 评论 0
public EndDocument createEndDocument()
{
  return new EndDocumentImpl(location);
}
Transformer.java 文件源码 项目:HTMLtoc 阅读 29 收藏 0 点赞 0 评论 0
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);
  }
 }
XMLEventFactory.java 文件源码 项目:javify 阅读 23 收藏 0 点赞 0 评论 0
/**
 * Create an end-document event.
 */
public abstract EndDocument createEndDocument();
XMLEventFactory.java 文件源码 项目:jvm-stm 阅读 24 收藏 0 点赞 0 评论 0
/**
 * Create an end-document event.
 */
public abstract EndDocument createEndDocument();
XMLEventFactory.java 文件源码 项目:JamVM-PH 阅读 33 收藏 0 点赞 0 评论 0
/**
 * Create an end-document event.
 */
public abstract EndDocument createEndDocument();
XMLEventFactory.java 文件源码 项目:classpath 阅读 23 收藏 0 点赞 0 评论 0
/**
 * Create an end-document event.
 */
public abstract EndDocument createEndDocument();
StAXDocumentHandler.java 文件源码 项目:SplitCharater 阅读 22 收藏 0 点赞 0 评论 0
public void endDocument(EndDocument event) throws XMLStreamException;


问题


面经


文章

微信
公众号

扫码关注公众号