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

项目:woodstox    文件:WEntityDeclaration.java   
@Override
public boolean equals(Object o)
{
    if (o == this) return true;
    if (o == null) return false;

    if (!(o instanceof EntityDeclaration)) return false;

    EntityDeclaration other = (EntityDeclaration) o;
    return stringsWithNullsEqual(getName(), other.getName())
        && stringsWithNullsEqual(getBaseURI(), other.getBaseURI())
        && stringsWithNullsEqual(getNotationName(), other.getNotationName())
        && stringsWithNullsEqual(getPublicId(), other.getPublicId())
        && stringsWithNullsEqual(getReplacementText(), other.getReplacementText())
        && stringsWithNullsEqual(getSystemId(), other.getSystemId())
        ;
}
项目:openjdk-jdk10    文件:SupportDTDTest.java   
void DisplayEntities(DTD event) {
    List entities = event.getEntities();
    if (entities == null) {
        _hasEntityDelaration = false;
        print("No entity found.");
    } else {
        _hasEntityDelaration = true;
        for (int i = 0; i < entities.size(); i++) {
            EntityDeclaration entity = (EntityDeclaration) entities.get(i);
            print(entity.getName());
        }
    }

}
项目:openjdk-jdk10    文件:Issue48Test.java   
/**
 * DTDEvent instances constructed via event reader are missing the notation
 * and entity declaration information
 */
@Test
public void testDTDEvent() {
    String XML = "<?xml version='1.0' ?>" + "<!DOCTYPE root [\n" + "<!ENTITY intEnt 'internal'>\n" + "<!ENTITY extParsedEnt SYSTEM 'url:dummy'>\n"
            + "<!NOTATION notation PUBLIC 'notation-public-id'>\n" + "<!NOTATION notation2 SYSTEM 'url:dummy'>\n"
            + "<!ENTITY extUnparsedEnt SYSTEM 'url:dummy2' NDATA notation>\n" + "]>" + "<root />";

    try {
        XMLEventReader er = getReader(XML);
        XMLEvent evt = er.nextEvent(); // StartDocument
        evt = er.nextEvent(); // DTD
        if (evt.getEventType() != XMLStreamConstants.DTD) {
            Assert.fail("Expected DTD event");
        }
        DTD dtd = (DTD) evt;
        List entities = dtd.getEntities();
        if (entities == null) {
            Assert.fail("No entity found. Expected 3.");
        } else {
            Assert.assertEquals(entities.size(), 3);
        }
        // Let's also verify they are all of right type...
        testListElems(entities, EntityDeclaration.class);

        List notations = dtd.getNotations();
        if (notations == null) {
            Assert.fail("No notation found. Expected 2.");
        } else {
            Assert.assertEquals(notations.size(), 2);
        }
        // Let's also verify they are all of right type...
        testListElems(notations, NotationDeclaration.class);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
}
项目:openjdk9    文件:SupportDTDTest.java   
void DisplayEntities(DTD event) {
    List entities = event.getEntities();
    if (entities == null) {
        _hasEntityDelaration = false;
        print("No entity found.");
    } else {
        _hasEntityDelaration = true;
        for (int i = 0; i < entities.size(); i++) {
            EntityDeclaration entity = (EntityDeclaration) entities.get(i);
            print(entity.getName());
        }
    }

}
项目:openjdk9    文件:Issue48Test.java   
/**
 * DTDEvent instances constructed via event reader are missing the notation
 * and entity declaration information
 */
@Test
public void testDTDEvent() {
    String XML = "<?xml version='1.0' ?>" + "<!DOCTYPE root [\n" + "<!ENTITY intEnt 'internal'>\n" + "<!ENTITY extParsedEnt SYSTEM 'url:dummy'>\n"
            + "<!NOTATION notation PUBLIC 'notation-public-id'>\n" + "<!NOTATION notation2 SYSTEM 'url:dummy'>\n"
            + "<!ENTITY extUnparsedEnt SYSTEM 'url:dummy2' NDATA notation>\n" + "]>" + "<root />";

    try {
        XMLEventReader er = getReader(XML);
        XMLEvent evt = er.nextEvent(); // StartDocument
        evt = er.nextEvent(); // DTD
        if (evt.getEventType() != XMLStreamConstants.DTD) {
            Assert.fail("Expected DTD event");
        }
        DTD dtd = (DTD) evt;
        List entities = dtd.getEntities();
        if (entities == null) {
            Assert.fail("No entity found. Expected 3.");
        } else {
            Assert.assertEquals(entities.size(), 3);
        }
        // Let's also verify they are all of right type...
        testListElems(entities, EntityDeclaration.class);

        List notations = dtd.getNotations();
        if (notations == null) {
            Assert.fail("No notation found. Expected 2.");
        } else {
            Assert.assertEquals(notations.size(), 2);
        }
        // Let's also verify they are all of right type...
        testListElems(notations, NotationDeclaration.class);
    } catch (Exception e) {
        Assert.fail(e.getMessage());
    }
}
项目:javify    文件:EntityReferenceImpl.java   
protected EntityReferenceImpl(Location location,
                              EntityDeclaration decl,
                              String name)
{
  super(location);
  this.decl = decl;
  this.name = name;
}
项目:jvm-stm    文件:EntityReferenceImpl.java   
protected EntityReferenceImpl(Location location,
                              EntityDeclaration decl,
                              String name)
{
  super(location);
  this.decl = decl;
  this.name = name;
}
项目:woodstox    文件:WDTD.java   
@Override
public List<EntityDeclaration> getEntities()
{
    if (mEntities == null && (mSubset != null)) {
        /* Better make a copy, so that caller can not modify list
         * DTD has, which may be shared (since DTD subset instances
         * are cached and reused)
         */
        mEntities = new ArrayList<EntityDeclaration>(mSubset.getGeneralEntityList());
    }
    return mEntities;
}
项目:woodstox    文件:TestDoctypeDecl.java   
public void testSimpleEntity()
    throws XMLStreamException
{
    XMLStreamReader sr = getReader(UNPARSED_ENTITY_XML, true);
    assertTokenType(DTD, sr.next());
    List<?> l = (List<?>) sr.getProperty("javax.xml.stream.entities");
    assertNotNull(l);
    assertEquals(1, l.size());
    EntityDeclaration ed = (EntityDeclaration) l.get(0);
    assertEquals("unp", ed.getName());
    assertEquals("mynot", ed.getNotationName());

    sr.close();
}
项目:JamVM-PH    文件:EntityReferenceImpl.java   
protected EntityReferenceImpl(Location location,
                              EntityDeclaration decl,
                              String name)
{
  super(location);
  this.decl = decl;
  this.name = name;
}
项目:SplitCharater    文件:StAXValidatorHelper.java   
public boolean isEntityUnparsed(String name) {
    if (fEntities != null) {
        EntityDeclaration entityDecl = (EntityDeclaration) fEntities.get(name);
        // If the entity is associated with a notation then it must be an unparsed entity.
        if (entityDecl != null) {
            return (entityDecl.getNotationName() != null);
        }
    }
    return false;
}
项目:SplitCharater    文件:StAXValidatorHelper.java   
/** Copies entity declarations into a hash map. */
final void processEntityDeclarations(List entityDecls) {
    int size = (entityDecls != null) ? entityDecls.size() : 0;
    if (size > 0) {
        if (fEntities == null) {
            fEntities = new HashMap();
        }
        for (int i = 0; i < size; ++i) {
            EntityDeclaration decl = (EntityDeclaration) entityDecls.get(i);
            fEntities.put(decl.getName(), decl);
        }
    }
}
项目:classpath    文件:EntityReferenceImpl.java   
protected EntityReferenceImpl(Location location,
                              EntityDeclaration decl,
                              String name)
{
  super(location);
  this.decl = decl;
  this.name = name;
}
项目:lams    文件:BaseXMLEventReader.java   
@Override
public final String getElementText() throws XMLStreamException {
    XMLEvent event = this.previousEvent;
    if (event == null) {
        throw new XMLStreamException("Must be on START_ELEMENT to read next text, element was null");
    }
    if (!event.isStartElement()) {
        throw new XMLStreamException("Must be on START_ELEMENT to read next text", event.getLocation());
    }

    final StringBuilder text = new StringBuilder();
    while (!event.isEndDocument()) {
        switch (event.getEventType()) {
            case XMLStreamConstants.CHARACTERS:
            case XMLStreamConstants.SPACE:
            case XMLStreamConstants.CDATA: {
                final Characters characters = event.asCharacters();
                text.append(characters.getData());
                break;
            }
            case XMLStreamConstants.ENTITY_REFERENCE: {
                final EntityReference entityReference = (EntityReference)event;
                final EntityDeclaration declaration = entityReference.getDeclaration();
                text.append(declaration.getReplacementText());
                break;
            }
            case XMLStreamConstants.COMMENT:
            case XMLStreamConstants.PROCESSING_INSTRUCTION: {
                //Ignore
                break;
            }
            default: {
                throw new XMLStreamException("Unexpected event type '" + XMLStreamConstantsUtils.getEventName(event.getEventType()) + "' encountered. Found event: " + event, event.getLocation());
            }
        }

        event = this.nextEvent();
    }

    return text.toString();
}
项目:OpenJSharp    文件:EntityReferenceEvent.java   
public EntityReferenceEvent(String entityName , EntityDeclaration entityDeclaration) {
    init();
    _entityName = entityName;
    _entityDeclaration = entityDeclaration;
}
项目:OpenJSharp    文件:EntityReferenceEvent.java   
/**
* Return the declaration of this entity.
*/
 public EntityDeclaration getDeclaration(){
     return _entityDeclaration ;
 }
项目:OpenJSharp    文件:EntityReferenceEvent.java   
public void setDeclaration(EntityDeclaration declaration) {
    _entityDeclaration = declaration ;
}
项目:OpenJSharp    文件:EntityReferenceEvent.java   
public EntityReferenceEvent(String entityName , EntityDeclaration entityDeclaration) {
    init();
    fEntityName = entityName;
    fEntityDeclaration = entityDeclaration ;
}
项目:OpenJSharp    文件:EntityReferenceEvent.java   
public EntityDeclaration getDeclaration(){
    return fEntityDeclaration ;
}
项目:OpenJSharp    文件:XMLEventFactoryImpl.java   
public javax.xml.stream.events.EntityReference createEntityReference(String name, EntityDeclaration entityDeclaration) {
    EntityReferenceEvent event =  new EntityReferenceEvent(name, entityDeclaration);
    if(location != null)event.setLocation(location);
    return event;
}
项目:openjdk-jdk10    文件:EntityReferenceEvent.java   
public EntityReferenceEvent(String entityName , EntityDeclaration entityDeclaration) {
    init();
    _entityName = entityName;
    _entityDeclaration = entityDeclaration;
}
项目:openjdk-jdk10    文件:EntityReferenceEvent.java   
/**
* Return the declaration of this entity.
*/
 public EntityDeclaration getDeclaration(){
     return _entityDeclaration ;
 }
项目:openjdk-jdk10    文件:EntityReferenceEvent.java   
public void setDeclaration(EntityDeclaration declaration) {
    _entityDeclaration = declaration ;
}
项目:openjdk-jdk10    文件:EntityReferenceEvent.java   
public EntityReferenceEvent(String entityName , EntityDeclaration entityDeclaration) {
    init();
    fEntityName = entityName;
    fEntityDeclaration = entityDeclaration ;
}
项目:openjdk-jdk10    文件:EntityReferenceEvent.java   
public EntityDeclaration getDeclaration(){
    return fEntityDeclaration ;
}
项目:openjdk-jdk10    文件:DTDEvent.java   
public void setEntities(List<EntityDeclaration> entites) {
    fEntities = entites;
}
项目:openjdk-jdk10    文件:DTDEvent.java   
@Override
public List<EntityDeclaration> getEntities() {
    return fEntities;
}
项目:openjdk-jdk10    文件:XMLEventFactoryImpl.java   
@Override
public EntityReference createEntityReference(String name, EntityDeclaration entityDeclaration) {
    EntityReferenceEvent event =  new EntityReferenceEvent(name, entityDeclaration);
    if(location != null)event.setLocation(location);
    return event;
}
项目:openjdk-jdk10    文件:XMLEventFactoryWrapper.java   
@Override
public EntityReference createEntityReference(String name, EntityDeclaration declaration) {
    return defaultImpl.createEntityReference(name, declaration);
}
项目:openjdk-jdk10    文件:XMLEventFactoryImpl.java   
@Override
public EntityReference createEntityReference(String name, EntityDeclaration declaration) {
    return null;
}
项目:openjdk9    文件:EntityReferenceEvent.java   
public EntityReferenceEvent(String entityName , EntityDeclaration entityDeclaration) {
    init();
    _entityName = entityName;
    _entityDeclaration = entityDeclaration;
}
项目:openjdk9    文件:EntityReferenceEvent.java   
/**
* Return the declaration of this entity.
*/
 public EntityDeclaration getDeclaration(){
     return _entityDeclaration ;
 }
项目:openjdk9    文件:EntityReferenceEvent.java   
public void setDeclaration(EntityDeclaration declaration) {
    _entityDeclaration = declaration ;
}
项目:openjdk9    文件:EntityReferenceEvent.java   
public EntityReferenceEvent(String entityName , EntityDeclaration entityDeclaration) {
    init();
    fEntityName = entityName;
    fEntityDeclaration = entityDeclaration ;
}
项目:openjdk9    文件:EntityReferenceEvent.java   
public EntityDeclaration getDeclaration(){
    return fEntityDeclaration ;
}
项目:openjdk9    文件:XMLEventFactoryImpl.java   
public javax.xml.stream.events.EntityReference createEntityReference(String name, EntityDeclaration entityDeclaration) {
    EntityReferenceEvent event =  new EntityReferenceEvent(name, entityDeclaration);
    if(location != null)event.setLocation(location);
    return event;
}
项目:openjdk9    文件:XMLEventFactoryImpl.java   
@Override
public EntityReference createEntityReference(String name, EntityDeclaration declaration) {
    return null;
}
项目:spring4-understanding    文件:StaxEventXMLReader.java   
@Override
protected void parseInternal() throws SAXException, XMLStreamException {
    boolean documentStarted = false;
    boolean documentEnded = false;
    int elementDepth = 0;
    while (this.reader.hasNext() && elementDepth >= 0) {
        XMLEvent event = this.reader.nextEvent();
        if (!event.isStartDocument() && !event.isEndDocument() && !documentStarted) {
            handleStartDocument(event);
            documentStarted = true;
        }
        switch (event.getEventType()) {
            case XMLStreamConstants.START_DOCUMENT:
                handleStartDocument(event);
                documentStarted = true;
                break;
            case XMLStreamConstants.START_ELEMENT:
                elementDepth++;
                handleStartElement(event.asStartElement());
                break;
            case XMLStreamConstants.END_ELEMENT:
                elementDepth--;
                if (elementDepth >= 0) {
                    handleEndElement(event.asEndElement());
                }
                break;
            case XMLStreamConstants.PROCESSING_INSTRUCTION:
                handleProcessingInstruction((ProcessingInstruction) event);
                break;
            case XMLStreamConstants.CHARACTERS:
            case XMLStreamConstants.SPACE:
            case XMLStreamConstants.CDATA:
                handleCharacters(event.asCharacters());
                break;
            case XMLStreamConstants.END_DOCUMENT:
                handleEndDocument();
                documentEnded = true;
                break;
            case XMLStreamConstants.NOTATION_DECLARATION:
                handleNotationDeclaration((NotationDeclaration) event);
                break;
            case XMLStreamConstants.ENTITY_DECLARATION:
                handleEntityDeclaration((EntityDeclaration) event);
                break;
            case XMLStreamConstants.COMMENT:
                handleComment((Comment) event);
                break;
            case XMLStreamConstants.DTD:
                handleDtd((DTD) event);
                break;
            case XMLStreamConstants.ENTITY_REFERENCE:
                handleEntityReference((EntityReference) event);
                break;
        }
    }
    if (documentStarted && !documentEnded) {
        handleEndDocument();
    }

}
项目:spring4-understanding    文件:StaxEventXMLReader.java   
private void handleEntityDeclaration(EntityDeclaration entityDeclaration) throws SAXException {
    if (getDTDHandler() != null) {
        getDTDHandler().unparsedEntityDecl(entityDeclaration.getName(), entityDeclaration.getPublicId(),
                entityDeclaration.getSystemId(), entityDeclaration.getNotationName());
    }
}
项目:xmlsec-gost    文件:XMLSecEntityReferenceImpl.java   
public XMLSecEntityReferenceImpl(String name, EntityDeclaration entityDeclaration, XMLSecStartElement parentXmlSecStartElement) {
    this.name = name;
    this.entityDeclaration = entityDeclaration;
    setParentXMLSecStartElement(parentXmlSecStartElement);
}