@Override
public String getText() {
XMLSecEvent xmlSecEvent = getCurrentEvent();
switch (xmlSecEvent.getEventType()) {
case ENTITY_REFERENCE:
return ((EntityReference) xmlSecEvent).getDeclaration().getReplacementText();
case DTD:
return ((DTD) xmlSecEvent).getDocumentTypeDeclaration();
case COMMENT:
return ((Comment) xmlSecEvent).getText();
case CDATA:
case SPACE:
case CHARACTERS:
return xmlSecEvent.asCharacters().getData();
default:
throw new IllegalStateException("Current state not TEXT");
}
}
java类javax.xml.stream.events.EntityReference的实例源码
XMLSecurityStreamReader.java 文件源码
项目:xmlsec-gost
阅读 20
收藏 0
点赞 0
评论 0
XMLSecurityStreamReader.java 文件源码
项目:xmlsec-gost
阅读 22
收藏 0
点赞 0
评论 0
@Override
public char[] getTextCharacters() {
XMLSecEvent xmlSecEvent = getCurrentEvent();
switch (xmlSecEvent.getEventType()) {
case ENTITY_REFERENCE:
return ((EntityReference) xmlSecEvent).getDeclaration().getReplacementText().toCharArray();
case DTD:
return ((DTD) xmlSecEvent).getDocumentTypeDeclaration().toCharArray();
case COMMENT:
return ((Comment) xmlSecEvent).getText().toCharArray();
case CDATA:
case SPACE:
case CHARACTERS:
return xmlSecEvent.asCharacters().getText();
default:
throw new IllegalStateException("Current state not TEXT");
}
}
XMLSecurityStreamReader.java 文件源码
项目:xmlsec-gost
阅读 20
收藏 0
点赞 0
评论 0
@Override
public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length) throws XMLStreamException {
XMLSecEvent xmlSecEvent = getCurrentEvent();
switch (xmlSecEvent.getEventType()) {
case ENTITY_REFERENCE:
((EntityReference) xmlSecEvent).getDeclaration().getReplacementText().getChars(sourceStart, sourceStart + length, target, targetStart);
return length;
case DTD:
((DTD) xmlSecEvent).getDocumentTypeDeclaration().getChars(sourceStart, sourceStart + length, target, targetStart);
return length;
case COMMENT:
((Comment) xmlSecEvent).getText().getChars(sourceStart, sourceStart + length, target, targetStart);
return length;
case CDATA:
case SPACE:
case CHARACTERS:
xmlSecEvent.asCharacters().getData().getChars(sourceStart, sourceStart + length, target, targetStart);
return length;
default:
throw new IllegalStateException("Current state not TEXT");
}
}
XMLSecurityStreamReader.java 文件源码
项目:xmlsec-gost
阅读 19
收藏 0
点赞 0
评论 0
@Override
public int getTextLength() {
XMLSecEvent xmlSecEvent = getCurrentEvent();
switch (xmlSecEvent.getEventType()) {
case ENTITY_REFERENCE:
return ((EntityReference) xmlSecEvent).getDeclaration().getReplacementText().length();
case DTD:
return ((DTD) xmlSecEvent).getDocumentTypeDeclaration().length();
case COMMENT:
return ((Comment) xmlSecEvent).getText().length();
case CDATA:
case SPACE:
case CHARACTERS:
return xmlSecEvent.asCharacters().getData().length();
default:
throw new IllegalStateException("Current state not TEXT");
}
}
Bug6555001.java 文件源码
项目:openjdk-jdk10
阅读 18
收藏 0
点赞 0
评论 0
@Test
public void testReplacing() throws Exception {
JAXPTestUtilities.tryRunWithTmpPermission(() -> {
XMLInputFactory factory = XMLInputFactory.newInstance();
factory.setProperty("javax.xml.stream.isReplacingEntityReferences", true);
StringReader sr = new StringReader(XML);
XMLEventReader reader = factory.createXMLEventReader(sr);
boolean sawUndef = false;
boolean sawDef = false;
while (reader.hasNext()) {
XMLEvent event = reader.nextEvent();
// System.out.println("Event: " + event);
if (event.isEntityReference()) {
EntityReference ref = (EntityReference) event;
if ("def".equals(ref.getName())) {
sawDef = true;
} else if ("undef".equals(ref.getName())) {
sawUndef = true;
} else {
throw new IllegalArgumentException("Unexpected entity name");
}
}
}
Assert.assertEquals(false, sawDef);
Assert.assertEquals(true, sawUndef);
reader.close();
}, new FilePermission("/tmp/this/does/not/exist/but/that/is/ok", "read"));
}
Bug6555001.java 文件源码
项目:openjdk-jdk10
阅读 29
收藏 0
点赞 0
评论 0
@Test
public void testNotReplacing() throws Exception {
JAXPTestUtilities.tryRunWithTmpPermission(() -> {
XMLInputFactory factory = XMLInputFactory.newInstance();
factory.setProperty("javax.xml.stream.isReplacingEntityReferences", false);
StringReader sr = new StringReader(XML);
XMLEventReader reader = factory.createXMLEventReader(sr);
boolean sawUndef = false;
boolean sawDef = false;
while (reader.hasNext()) {
XMLEvent event = reader.nextEvent();
// System.out.println("Event: " + event);
if (event.isEntityReference()) {
EntityReference ref = (EntityReference) event;
if ("def".equals(ref.getName())) {
sawDef = true;
} else if ("undef".equals(ref.getName())) {
sawUndef = true;
} else {
throw new IllegalArgumentException("Unexpected entity name");
}
}
}
Assert.assertEquals(true, sawDef);
Assert.assertEquals(true, sawUndef);
reader.close();
}, new FilePermission("/tmp/this/does/not/exist/but/that/is/ok", "read"));
}
Bug6555001.java 文件源码
项目:openjdk9
阅读 20
收藏 0
点赞 0
评论 0
@Test
public void testReplacing() throws Exception {
XMLInputFactory factory = XMLInputFactory.newInstance();
factory.setProperty("javax.xml.stream.isReplacingEntityReferences", true);
StringReader sr = new StringReader(XML);
XMLEventReader reader = factory.createXMLEventReader(sr);
boolean sawUndef = false;
boolean sawDef = false;
while (reader.hasNext()) {
XMLEvent event = reader.nextEvent();
// System.out.println("Event: " + event);
if (event.isEntityReference()) {
EntityReference ref = (EntityReference) event;
if ("def".equals(ref.getName())) {
sawDef = true;
} else if ("undef".equals(ref.getName())) {
sawUndef = true;
} else {
throw new IllegalArgumentException("Unexpected entity name");
}
}
}
Assert.assertEquals(false, sawDef);
Assert.assertEquals(true, sawUndef);
reader.close();
}
Bug6555001.java 文件源码
项目:openjdk9
阅读 20
收藏 0
点赞 0
评论 0
@Test
public void testNotReplacing() throws Exception {
XMLInputFactory factory = XMLInputFactory.newInstance();
factory.setProperty("javax.xml.stream.isReplacingEntityReferences", false);
StringReader sr = new StringReader(XML);
XMLEventReader reader = factory.createXMLEventReader(sr);
boolean sawUndef = false;
boolean sawDef = false;
while (reader.hasNext()) {
XMLEvent event = reader.nextEvent();
// System.out.println("Event: " + event);
if (event.isEntityReference()) {
EntityReference ref = (EntityReference) event;
if ("def".equals(ref.getName())) {
sawDef = true;
} else if ("undef".equals(ref.getName())) {
sawUndef = true;
} else {
throw new IllegalArgumentException("Unexpected entity name");
}
}
}
Assert.assertEquals(true, sawDef);
Assert.assertEquals(true, sawUndef);
reader.close();
}
StaxEventXMLReader.java 文件源码
项目:spring4-understanding
阅读 23
收藏 0
点赞 0
评论 0
private void handleEntityReference(EntityReference reference) throws SAXException {
if (getLexicalHandler() != null) {
getLexicalHandler().startEntity(reference.getName());
}
if (getLexicalHandler() != null) {
getLexicalHandler().endEntity(reference.getName());
}
}
StaxEventXMLReader.java 文件源码
项目:spring
阅读 24
收藏 0
点赞 0
评论 0
private void handleEntityReference(EntityReference reference) throws SAXException {
if (getLexicalHandler() != null) {
getLexicalHandler().startEntity(reference.getName());
}
if (getLexicalHandler() != null) {
getLexicalHandler().endEntity(reference.getName());
}
}
StaxEventXMLReader.java 文件源码
项目:class-guard
阅读 24
收藏 0
点赞 0
评论 0
private void handleEntityReference(EntityReference reference) throws SAXException {
if (getLexicalHandler() != null) {
getLexicalHandler().startEntity(reference.getName());
}
if (getLexicalHandler() != null) {
getLexicalHandler().endEntity(reference.getName());
}
}
BaseXMLEventReader.java 文件源码
项目:lams
阅读 23
收藏 0
点赞 0
评论 0
@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();
}
XMLEventFactoryImpl.java 文件源码
项目:openjdk-jdk10
阅读 24
收藏 0
点赞 0
评论 0
@Override
public EntityReference createEntityReference(String name, EntityDeclaration entityDeclaration) {
EntityReferenceEvent event = new EntityReferenceEvent(name, entityDeclaration);
if(location != null)event.setLocation(location);
return event;
}
XMLEventFactoryWrapper.java 文件源码
项目:openjdk-jdk10
阅读 26
收藏 0
点赞 0
评论 0
@Override
public EntityReference createEntityReference(String name, EntityDeclaration declaration) {
return defaultImpl.createEntityReference(name, declaration);
}
XMLEventFactoryImpl.java 文件源码
项目:openjdk-jdk10
阅读 24
收藏 0
点赞 0
评论 0
@Override
public EntityReference createEntityReference(String name, EntityDeclaration declaration) {
return null;
}
XMLEventFactoryImpl.java 文件源码
项目:openjdk9
阅读 23
收藏 0
点赞 0
评论 0
@Override
public EntityReference createEntityReference(String name, EntityDeclaration declaration) {
return null;
}
StaxEventXMLReader.java 文件源码
项目:spring4-understanding
阅读 23
收藏 0
点赞 0
评论 0
@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();
}
}
StaxEventXMLReader.java 文件源码
项目:spring
阅读 20
收藏 0
点赞 0
评论 0
@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();
}
}
XMLEventFactoryImpl.java 文件源码
项目:javify
阅读 17
收藏 0
点赞 0
评论 0
public EntityReference createEntityReference(String name,
EntityDeclaration declaration)
{
return new EntityReferenceImpl(location, declaration, name);
}
XMLEventFactoryImpl.java 文件源码
项目:jvm-stm
阅读 19
收藏 0
点赞 0
评论 0
public EntityReference createEntityReference(String name,
EntityDeclaration declaration)
{
return new EntityReferenceImpl(location, declaration, name);
}
StaxEventXMLReader.java 文件源码
项目:class-guard
阅读 24
收藏 0
点赞 0
评论 0
@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();
}
}
XMLEventFactoryImpl.java 文件源码
项目:werval
阅读 20
收藏 0
点赞 0
评论 0
@Override
public EntityReference createEntityReference( String name, EntityDeclaration declaration )
{
return delegate.createEntityReference( name, declaration );
}
XMLEventFactoryImpl.java 文件源码
项目:JamVM-PH
阅读 22
收藏 0
点赞 0
评论 0
public EntityReference createEntityReference(String name,
EntityDeclaration declaration)
{
return new EntityReferenceImpl(location, declaration, name);
}
XMLEventFactoryImpl.java 文件源码
项目:SplitCharater
阅读 18
收藏 0
点赞 0
评论 0
public EntityReference createEntityReference(String name,
EntityDeclaration declaration) {
return new EntityReferenceImpl(name, declaration, fLocation);
}
StAXEventResultBuilder.java 文件源码
项目:SplitCharater
阅读 19
收藏 0
点赞 0
评论 0
public void entityReference(EntityReference event)
throws XMLStreamException {
fEventWriter.add(event);
}
XMLEventFactoryImpl.java 文件源码
项目:classpath
阅读 23
收藏 0
点赞 0
评论 0
public EntityReference createEntityReference(String name,
EntityDeclaration declaration)
{
return new EntityReferenceImpl(location, declaration, name);
}
XMLEventFactory.java 文件源码
项目:javify
阅读 20
收藏 0
点赞 0
评论 0
/**
* Create an entity reference event.
*/
public abstract EntityReference createEntityReference(String name,
EntityDeclaration declaration);
XMLEventFactory.java 文件源码
项目:jvm-stm
阅读 30
收藏 0
点赞 0
评论 0
/**
* Create an entity reference event.
*/
public abstract EntityReference createEntityReference(String name,
EntityDeclaration declaration);
XMLEventFactory.java 文件源码
项目:JamVM-PH
阅读 23
收藏 0
点赞 0
评论 0
/**
* Create an entity reference event.
*/
public abstract EntityReference createEntityReference(String name,
EntityDeclaration declaration);
StAXStreamResultBuilder.java 文件源码
项目:SplitCharater
阅读 24
收藏 0
点赞 0
评论 0
public void entityReference(EntityReference event) throws XMLStreamException {
fStreamWriter.writeEntityRef(event.getName());
}