feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
@@ -0,0 +1,161 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.stream.events;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.events.Attribute;
|
||||
import java.io.Writer;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
|
||||
|
||||
//xxx: AttributeEvent is not really a first order event. Should we be renaming the class to AttributeImpl for consistent
|
||||
//naming convention.
|
||||
|
||||
/**
|
||||
* Implementation of Attribute Event.
|
||||
*
|
||||
*@author Neeraj Bajaj, Sun Microsystems
|
||||
*@author K.Venugopal, Sun Microsystems
|
||||
*
|
||||
*/
|
||||
|
||||
public class AttributeImpl extends DummyEvent implements Attribute
|
||||
|
||||
{
|
||||
//attribute value
|
||||
private String fValue;
|
||||
private String fNonNormalizedvalue;
|
||||
|
||||
//name of the attribute
|
||||
private QName fQName;
|
||||
//attribute type
|
||||
private String fAttributeType = "CDATA";
|
||||
|
||||
|
||||
//A flag indicating whether this attribute was actually specified in the start-tag
|
||||
//of its element or was defaulted from the schema.
|
||||
private boolean fIsSpecified;
|
||||
|
||||
public AttributeImpl(){
|
||||
init();
|
||||
}
|
||||
public AttributeImpl(String name, String value) {
|
||||
init();
|
||||
fQName = new QName(name);
|
||||
fValue = value;
|
||||
}
|
||||
|
||||
public AttributeImpl(String prefix, String name, String value) {
|
||||
this(prefix, null,name, value, null,null,false );
|
||||
}
|
||||
|
||||
public AttributeImpl(String prefix, String uri, String localPart, String value, String type) {
|
||||
this(prefix, uri, localPart, value, null, type, false);
|
||||
}
|
||||
|
||||
public AttributeImpl(String prefix, String uri, String localPart, String value, String nonNormalizedvalue, String type, boolean isSpecified) {
|
||||
this(new QName(uri, localPart, prefix), value, nonNormalizedvalue, type, isSpecified);
|
||||
}
|
||||
|
||||
|
||||
public AttributeImpl(QName qname, String value, String nonNormalizedvalue, String type, boolean isSpecified) {
|
||||
init();
|
||||
fQName = qname ;
|
||||
fValue = value ;
|
||||
if(type != null && !type.equals(""))
|
||||
fAttributeType = type;
|
||||
|
||||
fNonNormalizedvalue = nonNormalizedvalue;
|
||||
fIsSpecified = isSpecified ;
|
||||
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
if( fQName.getPrefix() != null && fQName.getPrefix().length() > 0 )
|
||||
return fQName.getPrefix() + ":" + fQName.getLocalPart() + "='" + fValue + "'";
|
||||
else
|
||||
return fQName.getLocalPart() + "='" + fValue + "'";
|
||||
}
|
||||
|
||||
public void setName(QName name){
|
||||
fQName = name ;
|
||||
}
|
||||
|
||||
public QName getName() {
|
||||
return fQName;
|
||||
}
|
||||
|
||||
public void setValue(String value){
|
||||
fValue = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return fValue;
|
||||
}
|
||||
|
||||
public void setNonNormalizedValue(String nonNormalizedvalue){
|
||||
fNonNormalizedvalue = nonNormalizedvalue;
|
||||
}
|
||||
|
||||
public String getNonNormalizedValue(){
|
||||
return fNonNormalizedvalue ;
|
||||
}
|
||||
|
||||
public void setAttributeType(String attributeType){
|
||||
fAttributeType = attributeType ;
|
||||
}
|
||||
|
||||
/** Gets the type of this attribute, default is "CDATA */
|
||||
// We dont need to take care of default value.. implementation takes care of it.
|
||||
public String getDTDType() {
|
||||
return fAttributeType;
|
||||
}
|
||||
|
||||
/** is this attribute is specified in the instance document */
|
||||
|
||||
public void setSpecified(boolean isSpecified){
|
||||
fIsSpecified = isSpecified ;
|
||||
}
|
||||
|
||||
public boolean isSpecified() {
|
||||
return fIsSpecified ;
|
||||
}
|
||||
|
||||
protected void writeAsEncodedUnicodeEx(java.io.Writer writer)
|
||||
throws java.io.IOException
|
||||
{
|
||||
writer.write(toString());
|
||||
}
|
||||
|
||||
|
||||
protected void init(){
|
||||
setEventType(XMLEvent.ATTRIBUTE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}//AttributeImpl
|
||||
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.stream.events;
|
||||
|
||||
import javax.xml.stream.events.Characters;
|
||||
import java.io.Writer;
|
||||
import java.io.IOException;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
import com.sun.org.apache.xerces.internal.util.XMLChar;
|
||||
|
||||
/** Implementation of Character event.
|
||||
*
|
||||
*@author Neeraj Bajaj, Sun Microsystems
|
||||
*@author K.Venugopal, Sun Microsystems
|
||||
*
|
||||
*/
|
||||
|
||||
public class CharacterEvent extends DummyEvent
|
||||
implements Characters {
|
||||
/* data */
|
||||
private String fData;
|
||||
/*true if fData is CData */
|
||||
private boolean fIsCData;
|
||||
/* true if fData is ignorableWhitespace*/
|
||||
private boolean fIsIgnorableWhitespace;
|
||||
/* true if fData contet is whitespace*/
|
||||
private boolean fIsSpace = false;
|
||||
/*used to prevent scanning of data multiple times */
|
||||
private boolean fCheckIfSpaceNeeded = true;
|
||||
|
||||
public CharacterEvent() {
|
||||
fIsCData = false;
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data Character Data.
|
||||
*/
|
||||
public CharacterEvent(String data) {
|
||||
fIsCData = false;
|
||||
init();
|
||||
fData = data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data Character Data.
|
||||
* @param flag true if CData
|
||||
*/
|
||||
public CharacterEvent(String data, boolean flag) {
|
||||
init();
|
||||
fData = data;
|
||||
fIsCData = flag;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data Character Data.
|
||||
* @param flag true if CData
|
||||
* @param isIgnorableWhiteSpace true if data is ignorable whitespace.
|
||||
*/
|
||||
public CharacterEvent(String data, boolean flag, boolean isIgnorableWhiteSpace) {
|
||||
init();
|
||||
fData = data;
|
||||
fIsCData = flag;
|
||||
fIsIgnorableWhitespace = isIgnorableWhiteSpace ;
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
setEventType(XMLEvent.CHARACTERS);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return return data.
|
||||
*/
|
||||
public String getData() {
|
||||
return fData;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param String data
|
||||
*/
|
||||
public void setData(String data){
|
||||
fData = data;
|
||||
fCheckIfSpaceNeeded = true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return boolean returns true if the data is CData
|
||||
*/
|
||||
public boolean isCData() {
|
||||
return fIsCData;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return String return the String representation of this event.
|
||||
*/
|
||||
public String toString() {
|
||||
if(fIsCData)
|
||||
return "<![CDATA[" + getData() + "]]>";
|
||||
else
|
||||
return fData;
|
||||
}
|
||||
|
||||
/** This method will write the XMLEvent as per the XML 1.0 specification as Unicode characters.
|
||||
* No indentation or whitespace should be outputted.
|
||||
*
|
||||
* Any user defined event type SHALL have this method
|
||||
* called when being written to on an output stream.
|
||||
* Built in Event types MUST implement this method,
|
||||
* but implementations MAY choose not call these methods
|
||||
* for optimizations reasons when writing out built in
|
||||
* Events to an output stream.
|
||||
* The output generated MUST be equivalent in terms of the
|
||||
* infoset expressed.
|
||||
*
|
||||
* @param writer The writer that will output the data
|
||||
* @throws XMLStreamException if there is a fatal error writing the event
|
||||
*/
|
||||
protected void writeAsEncodedUnicodeEx(Writer writer) throws IOException
|
||||
{
|
||||
if (fIsCData) {
|
||||
writer.write("<![CDATA[" + getData() + "]]>");
|
||||
} else {
|
||||
charEncode(writer, fData);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this is ignorableWhiteSpace. If
|
||||
* this event is ignorableWhiteSpace its event type will
|
||||
* be SPACE.
|
||||
* @return
|
||||
*/
|
||||
public boolean isIgnorableWhiteSpace() {
|
||||
return fIsIgnorableWhitespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this set of Characters
|
||||
* is all whitespace. Whitspace inside a document
|
||||
* is reported as CHARACTERS. This method allows
|
||||
* checking of CHARACTERS events to see if they
|
||||
* are composed of only whitespace characters
|
||||
* @return
|
||||
*/
|
||||
public boolean isWhiteSpace() {
|
||||
//no synchronization checks made.
|
||||
if(fCheckIfSpaceNeeded){
|
||||
checkWhiteSpace();
|
||||
fCheckIfSpaceNeeded = false;
|
||||
}
|
||||
return fIsSpace;
|
||||
}
|
||||
|
||||
private void checkWhiteSpace(){
|
||||
//for now - remove dependancy of XMLChar
|
||||
if(fData != null && fData.length() >0 ){
|
||||
fIsSpace = true;
|
||||
for(int i=0;i<fData.length();i++){
|
||||
if(!XMLChar.isSpace(fData.charAt(i))){
|
||||
fIsSpace = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.stream.events;
|
||||
|
||||
import javax.xml.stream.events.Comment;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
|
||||
/**
|
||||
* This class contains information about Comment event.
|
||||
*
|
||||
* @author Neeraj Bajaj, Sun Microsystems.
|
||||
*/
|
||||
public class CommentEvent extends DummyEvent implements Comment {
|
||||
|
||||
/* String data for this event */
|
||||
private String fText ;
|
||||
|
||||
public CommentEvent() {
|
||||
init();
|
||||
}
|
||||
|
||||
public CommentEvent(String text) {
|
||||
init();
|
||||
fText = text;
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
setEventType(XMLEvent.COMMENT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String String representation of this event
|
||||
*/
|
||||
public String toString() {
|
||||
return "<!--" + getText() + "-->";
|
||||
}
|
||||
|
||||
|
||||
/** Return the string data of the comment, returns empty string if it
|
||||
* does not exist
|
||||
* @return String
|
||||
*/
|
||||
public String getText() {
|
||||
return fText ;
|
||||
}
|
||||
|
||||
protected void writeAsEncodedUnicodeEx(java.io.Writer writer)
|
||||
throws java.io.IOException
|
||||
{
|
||||
writer.write("<!--" + getText() + "-->");
|
||||
}
|
||||
|
||||
}
|
||||
104
jdkSrc/jdk8/com/sun/xml/internal/stream/events/DTDEvent.java
Normal file
104
jdkSrc/jdk8/com/sun/xml/internal/stream/events/DTDEvent.java
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.stream.events;
|
||||
|
||||
import javax.xml.stream.events.DTD;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Neeraj Bajaj, Sun Microsystesm.
|
||||
*
|
||||
*/
|
||||
public class DTDEvent extends DummyEvent implements DTD{
|
||||
|
||||
private String fDoctypeDeclaration;
|
||||
private java.util.List fNotations;
|
||||
private java.util.List fEntities;
|
||||
|
||||
/** Creates a new instance of DTDEvent */
|
||||
public DTDEvent() {
|
||||
init();
|
||||
}
|
||||
|
||||
public DTDEvent(String doctypeDeclaration){
|
||||
init();
|
||||
fDoctypeDeclaration = doctypeDeclaration;
|
||||
}
|
||||
|
||||
public void setDocumentTypeDeclaration(String doctypeDeclaration){
|
||||
fDoctypeDeclaration = doctypeDeclaration;
|
||||
}
|
||||
|
||||
public String getDocumentTypeDeclaration() {
|
||||
return fDoctypeDeclaration;
|
||||
}
|
||||
|
||||
//xxx: we can change the signature if the implementation doesn't store the entities in List Datatype.
|
||||
//and then convert that DT to list format here. That way callee dont need to bother about conversion
|
||||
|
||||
public void setEntities(java.util.List entites){
|
||||
fEntities = entites;
|
||||
}
|
||||
|
||||
public java.util.List getEntities() {
|
||||
return fEntities;
|
||||
}
|
||||
|
||||
//xxx: we can change the signature if the implementation doesn't store the entities in List Datatype.
|
||||
//and then convert that DT to list format here. That way callee dont need to bother about conversion
|
||||
|
||||
public void setNotations(java.util.List notations){
|
||||
fNotations = notations;
|
||||
}
|
||||
|
||||
public java.util.List getNotations() {
|
||||
return fNotations;
|
||||
}
|
||||
|
||||
/**
|
||||
*Returns an implementation defined representation of the DTD.
|
||||
* This method may return null if no representation is available.
|
||||
*
|
||||
*/
|
||||
public Object getProcessedDTD() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void init(){
|
||||
setEventType(XMLEvent.DTD);
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return fDoctypeDeclaration ;
|
||||
}
|
||||
|
||||
protected void writeAsEncodedUnicodeEx(java.io.Writer writer)
|
||||
throws java.io.IOException
|
||||
{
|
||||
writer.write(fDoctypeDeclaration);
|
||||
}
|
||||
}
|
||||
258
jdkSrc/jdk8/com/sun/xml/internal/stream/events/DummyEvent.java
Normal file
258
jdkSrc/jdk8/com/sun/xml/internal/stream/events/DummyEvent.java
Normal file
@@ -0,0 +1,258 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.stream.events;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
import javax.xml.stream.events.Characters;
|
||||
import javax.xml.stream.events.EndElement;
|
||||
import javax.xml.stream.events.StartElement;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.Location;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
|
||||
/** DummyEvent is an abstract class. It provides functionality for most of the
|
||||
* function of XMLEvent.
|
||||
*
|
||||
* @author Neeraj Bajaj Sun Microsystems,Inc.
|
||||
* @author K.Venugopal Sun Microsystems,Inc.
|
||||
*
|
||||
*/
|
||||
|
||||
public abstract class DummyEvent implements XMLEvent {
|
||||
// Make sure that getLocation() never returns null. Instead, return this dummy location
|
||||
// that indicates "nowhere" as effectively as possible.
|
||||
private static DummyLocation nowhere = new DummyLocation();
|
||||
|
||||
/* Event type this event corresponds to */
|
||||
private int fEventType;
|
||||
protected Location fLocation = (Location) nowhere;
|
||||
|
||||
public DummyEvent() {
|
||||
}
|
||||
|
||||
public DummyEvent(int i) {
|
||||
fEventType = i;
|
||||
}
|
||||
|
||||
public int getEventType() {
|
||||
return fEventType;
|
||||
}
|
||||
|
||||
protected void setEventType(int eventType){
|
||||
fEventType = eventType;
|
||||
}
|
||||
|
||||
|
||||
public boolean isStartElement() {
|
||||
return fEventType == XMLEvent.START_ELEMENT;
|
||||
}
|
||||
|
||||
public boolean isEndElement() {
|
||||
return fEventType == XMLEvent.END_ELEMENT;
|
||||
}
|
||||
|
||||
public boolean isEntityReference() {
|
||||
return fEventType == XMLEvent.ENTITY_REFERENCE;
|
||||
}
|
||||
|
||||
public boolean isProcessingInstruction() {
|
||||
return fEventType == XMLEvent.PROCESSING_INSTRUCTION;
|
||||
}
|
||||
|
||||
public boolean isCharacterData() {
|
||||
return fEventType == XMLEvent.CHARACTERS;
|
||||
}
|
||||
|
||||
public boolean isStartDocument() {
|
||||
return fEventType == XMLEvent.START_DOCUMENT;
|
||||
}
|
||||
|
||||
public boolean isEndDocument() {
|
||||
return fEventType == XMLEvent.END_DOCUMENT;
|
||||
}
|
||||
|
||||
public Location getLocation(){
|
||||
return fLocation;
|
||||
}
|
||||
|
||||
void setLocation(Location loc){
|
||||
if (loc == null) {
|
||||
fLocation = nowhere;
|
||||
} else {
|
||||
fLocation = loc;
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns this event as Characters, may result in
|
||||
* a class cast exception if this event is not Characters.
|
||||
*/
|
||||
public Characters asCharacters() {
|
||||
return (Characters)this;
|
||||
}
|
||||
|
||||
/** Returns this event as an end element event, may result in
|
||||
* a class cast exception if this event is not a end element.
|
||||
*/
|
||||
public EndElement asEndElement() {
|
||||
return (EndElement)this;
|
||||
}
|
||||
|
||||
/** Returns this event as a start element event, may result in
|
||||
* a class cast exception if this event is not a start element.
|
||||
*/
|
||||
public StartElement asStartElement() {
|
||||
return (StartElement)this;
|
||||
}
|
||||
|
||||
/** This method is provided for implementations to provide
|
||||
* optional type information about the associated event.
|
||||
* It is optional and will return null if no information
|
||||
* is available.
|
||||
*/
|
||||
public QName getSchemaType() {
|
||||
//Base class will take care of providing extra information about this event.
|
||||
return null;
|
||||
}
|
||||
|
||||
/** A utility function to check if this event is an Attribute.
|
||||
* @see Attribute
|
||||
*/
|
||||
public boolean isAttribute() {
|
||||
return fEventType == XMLEvent.ATTRIBUTE;
|
||||
}
|
||||
|
||||
/** A utility function to check if this event is Characters.
|
||||
* @see Characters
|
||||
*/
|
||||
public boolean isCharacters() {
|
||||
return fEventType == XMLEvent.CHARACTERS;
|
||||
}
|
||||
|
||||
/** A utility function to check if this event is a Namespace.
|
||||
* @see Namespace
|
||||
*/
|
||||
public boolean isNamespace() {
|
||||
return fEventType == XMLEvent.NAMESPACE;
|
||||
}
|
||||
|
||||
/** This method will write the XMLEvent as per the XML 1.0 specification as Unicode characters.
|
||||
* No indentation or whitespace should be outputted.
|
||||
*
|
||||
* Any user defined event type SHALL have this method
|
||||
* called when being written to on an output stream.
|
||||
* Built in Event types MUST implement this method,
|
||||
* but implementations MAY choose not call these methods
|
||||
* for optimizations reasons when writing out built in
|
||||
* Events to an output stream.
|
||||
* The output generated MUST be equivalent in terms of the
|
||||
* infoset expressed.
|
||||
*
|
||||
* @param writer The writer that will output the data
|
||||
* @throws XMLStreamException if there is a fatal error writing the event
|
||||
*/
|
||||
public void writeAsEncodedUnicode(Writer writer) throws XMLStreamException {
|
||||
try {
|
||||
writeAsEncodedUnicodeEx(writer);
|
||||
} catch (IOException e) {
|
||||
throw new XMLStreamException(e);
|
||||
}
|
||||
}
|
||||
/** Helper method in order to expose IOException.
|
||||
* @param writer The writer that will output the data
|
||||
* @throws XMLStreamException if there is a fatal error writing the event
|
||||
* @throws IOException if there is an IO error
|
||||
*/
|
||||
protected abstract void writeAsEncodedUnicodeEx(Writer writer)
|
||||
throws IOException, XMLStreamException;
|
||||
|
||||
/** Helper method to escape < > & for characters event and
|
||||
* quotes, lt and amps for Entity
|
||||
*/
|
||||
protected void charEncode(Writer writer, String data)
|
||||
throws IOException
|
||||
{
|
||||
if (data == null || data == "") return;
|
||||
int i = 0, start = 0;
|
||||
int len = data.length();
|
||||
|
||||
loop:
|
||||
for (; i < len; ++i) {
|
||||
switch (data.charAt(i)) {
|
||||
case '<':
|
||||
writer.write(data, start, i - start);
|
||||
writer.write("<");
|
||||
start = i + 1;
|
||||
break;
|
||||
|
||||
case '&':
|
||||
writer.write(data, start, i - start);
|
||||
writer.write("&");
|
||||
start = i + 1;
|
||||
break;
|
||||
|
||||
case '>':
|
||||
writer.write(data, start, i - start);
|
||||
writer.write(">");
|
||||
start = i + 1;
|
||||
break;
|
||||
case '"':
|
||||
writer.write(data, start, i - start);
|
||||
writer.write(""");
|
||||
start = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Write any pending data
|
||||
writer.write(data, start, len - start);
|
||||
}
|
||||
|
||||
static class DummyLocation implements Location {
|
||||
public DummyLocation() {
|
||||
}
|
||||
|
||||
public int getCharacterOffset() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int getColumnNumber() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int getLineNumber() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public String getPublicId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getSystemId() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.stream.events;
|
||||
|
||||
import javax.xml.stream.events.EndDocument;
|
||||
import java.io.Writer;
|
||||
import javax.xml.stream.XMLStreamConstants;
|
||||
|
||||
/**
|
||||
* This class contains information about EndDocument event.
|
||||
*
|
||||
* @author Neeraj Bajaj, Sun Microsystems.
|
||||
*/
|
||||
|
||||
|
||||
public class EndDocumentEvent extends DummyEvent
|
||||
implements EndDocument {
|
||||
|
||||
public EndDocumentEvent() {
|
||||
init();
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
setEventType(XMLStreamConstants.END_DOCUMENT);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "ENDDOCUMENT";
|
||||
}
|
||||
|
||||
protected void writeAsEncodedUnicodeEx(java.io.Writer writer)
|
||||
throws java.io.IOException
|
||||
{
|
||||
//end document
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.stream.events;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.events.EndElement;
|
||||
import javax.xml.stream.events.Namespace;
|
||||
import java.io.Writer;
|
||||
import java.util.Iterator;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
import com.sun.xml.internal.stream.util.ReadOnlyIterator;
|
||||
|
||||
/** Implementation of EndElement event.
|
||||
*
|
||||
* @author Neeraj Bajaj Sun Microsystems,Inc.
|
||||
* @author K.Venugopal Sun Microsystems,Inc.
|
||||
*/
|
||||
|
||||
public class EndElementEvent extends DummyEvent
|
||||
implements EndElement {
|
||||
|
||||
List fNamespaces = null;
|
||||
QName fQName ;
|
||||
|
||||
public EndElementEvent() {
|
||||
init();
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
setEventType(XMLEvent.END_ELEMENT);
|
||||
fNamespaces = new ArrayList();
|
||||
}
|
||||
|
||||
|
||||
public EndElementEvent(String prefix, String uri, String localpart) {
|
||||
this(new QName(uri,localpart,prefix));
|
||||
}
|
||||
|
||||
public EndElementEvent(QName qname) {
|
||||
this.fQName = qname;
|
||||
init();
|
||||
}
|
||||
|
||||
public QName getName() {
|
||||
return fQName;
|
||||
}
|
||||
|
||||
public void setName(QName qname) {
|
||||
this.fQName = qname;
|
||||
}
|
||||
|
||||
protected void writeAsEncodedUnicodeEx(java.io.Writer writer)
|
||||
throws java.io.IOException
|
||||
{
|
||||
writer.write("</");
|
||||
String prefix = fQName.getPrefix();
|
||||
if (prefix != null && prefix.length() > 0) {
|
||||
writer.write(prefix);
|
||||
writer.write(':');
|
||||
}
|
||||
writer.write(fQName.getLocalPart());
|
||||
writer.write('>');
|
||||
}
|
||||
|
||||
/** Returns an Iterator of namespaces that have gone out
|
||||
* of scope. Returns an empty iterator if no namespaces have gone
|
||||
* out of scope.
|
||||
* @return an Iterator over Namespace interfaces, or an
|
||||
* empty iterator
|
||||
*/
|
||||
public Iterator getNamespaces() {
|
||||
if(fNamespaces != null)
|
||||
fNamespaces.iterator();
|
||||
return new ReadOnlyIterator();
|
||||
}
|
||||
|
||||
void addNamespace(Namespace attr){
|
||||
if(attr != null){
|
||||
fNamespaces.add(attr);
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String s = "</" + nameAsString();
|
||||
s = s + ">";
|
||||
return s;
|
||||
}
|
||||
|
||||
public String nameAsString() {
|
||||
if("".equals(fQName.getNamespaceURI()))
|
||||
return fQName.getLocalPart();
|
||||
if(fQName.getPrefix() != null)
|
||||
return "['" + fQName.getNamespaceURI() + "']:" + fQName.getPrefix() + ":" + fQName.getLocalPart();
|
||||
else
|
||||
return "['" + fQName.getNamespaceURI() + "']:" + fQName.getLocalPart();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.stream.events;
|
||||
|
||||
import javax.xml.stream.events.EntityDeclaration;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier;
|
||||
import jdk.xml.internal.JdkXmlUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class store all the information for a particular EntityDeclaration. EntityDeclaration interface
|
||||
* has various get* functiosn to retirve information about a particular EntityDeclaration.
|
||||
*
|
||||
* @author Neeraj Bajaj, Sun Microsystems.
|
||||
*/
|
||||
public class EntityDeclarationImpl extends DummyEvent implements EntityDeclaration {
|
||||
|
||||
private XMLResourceIdentifier fXMLResourceIdentifier ;
|
||||
private String fEntityName;
|
||||
private String fReplacementText;
|
||||
private String fNotationName;
|
||||
|
||||
/** Creates a new instance of EntityDeclarationImpl */
|
||||
public EntityDeclarationImpl() {
|
||||
init();
|
||||
}
|
||||
|
||||
public EntityDeclarationImpl(String entityName , String replacementText){
|
||||
this(entityName,replacementText,null);
|
||||
|
||||
}
|
||||
|
||||
public EntityDeclarationImpl(String entityName, String replacementText, XMLResourceIdentifier resourceIdentifier){
|
||||
init();
|
||||
fEntityName = entityName;
|
||||
fReplacementText = replacementText;
|
||||
fXMLResourceIdentifier = resourceIdentifier;
|
||||
}
|
||||
|
||||
public void setEntityName(String entityName){
|
||||
fEntityName = entityName;
|
||||
}
|
||||
|
||||
public String getEntityName(){
|
||||
return fEntityName;
|
||||
}
|
||||
|
||||
public void setEntityReplacementText(String replacementText){
|
||||
fReplacementText = replacementText;
|
||||
}
|
||||
|
||||
public void setXMLResourceIdentifier(XMLResourceIdentifier resourceIdentifier){
|
||||
fXMLResourceIdentifier = resourceIdentifier ;
|
||||
}
|
||||
|
||||
public XMLResourceIdentifier getXMLResourceIdentifier(){
|
||||
return fXMLResourceIdentifier;
|
||||
}
|
||||
|
||||
public String getSystemId(){
|
||||
if(fXMLResourceIdentifier != null)
|
||||
return fXMLResourceIdentifier.getLiteralSystemId();
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getPublicId(){
|
||||
if(fXMLResourceIdentifier != null)
|
||||
return fXMLResourceIdentifier.getPublicId();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getBaseURI() {
|
||||
if(fXMLResourceIdentifier != null)
|
||||
return fXMLResourceIdentifier.getBaseSystemId();
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getName(){
|
||||
return fEntityName;
|
||||
}
|
||||
|
||||
public String getNotationName() {
|
||||
return fNotationName;
|
||||
}
|
||||
|
||||
public void setNotationName(String notationName){
|
||||
fNotationName = notationName;
|
||||
}
|
||||
|
||||
public String getReplacementText() {
|
||||
return fReplacementText;
|
||||
}
|
||||
|
||||
protected void init(){
|
||||
setEventType(XMLEvent.ENTITY_DECLARATION);
|
||||
}
|
||||
|
||||
protected void writeAsEncodedUnicodeEx(java.io.Writer writer)
|
||||
throws java.io.IOException
|
||||
{
|
||||
writer.write("<!ENTITY ");
|
||||
writer.write(fEntityName);
|
||||
if (fReplacementText != null) {
|
||||
//internal entity
|
||||
//escape quotes, lt and amps
|
||||
writer.write(" \"");
|
||||
charEncode(writer, fReplacementText);
|
||||
writer.write("\"");
|
||||
} else {
|
||||
//external entity
|
||||
writer.write(JdkXmlUtils.getDTDExternalDecl(getPublicId(), getSystemId()));
|
||||
}
|
||||
|
||||
if (fNotationName != null) {
|
||||
writer.write(" NDATA ");
|
||||
writer.write(fNotationName);
|
||||
}
|
||||
writer.write(">");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.stream.events;
|
||||
|
||||
import javax.xml.stream.events.EntityReference;
|
||||
import java.io.Writer;
|
||||
import javax.xml.stream.events.EntityDeclaration;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
|
||||
/** Implements EntityReference event.
|
||||
*
|
||||
*@author Neeraj Bajaj, Sun Microsystems,
|
||||
*/
|
||||
public class EntityReferenceEvent extends DummyEvent
|
||||
implements EntityReference {
|
||||
private EntityDeclaration fEntityDeclaration ;
|
||||
private String fEntityName;
|
||||
|
||||
public EntityReferenceEvent() {
|
||||
init();
|
||||
}
|
||||
|
||||
public EntityReferenceEvent(String entityName , EntityDeclaration entityDeclaration) {
|
||||
init();
|
||||
fEntityName = entityName;
|
||||
fEntityDeclaration = entityDeclaration ;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return fEntityName;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String text = fEntityDeclaration.getReplacementText();
|
||||
if(text == null)
|
||||
text = "";
|
||||
return "&" + getName() + ";='" + text + "'";
|
||||
}
|
||||
|
||||
protected void writeAsEncodedUnicodeEx(java.io.Writer writer)
|
||||
throws java.io.IOException
|
||||
{
|
||||
writer.write('&');
|
||||
writer.write(getName());
|
||||
writer.write(';');
|
||||
}
|
||||
|
||||
public EntityDeclaration getDeclaration(){
|
||||
return fEntityDeclaration ;
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
setEventType(XMLEvent.ENTITY_REFERENCE);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.stream.events;
|
||||
|
||||
import javax.xml.stream.Location;
|
||||
|
||||
/**
|
||||
*Implementation of Location interface to be used by
|
||||
*event readers.
|
||||
*@author Neeraj.bajaj@sun.com,k.venugopal@sun.com
|
||||
*/
|
||||
public class LocationImpl implements Location{
|
||||
String systemId;
|
||||
String publicId;
|
||||
int colNo;
|
||||
int lineNo;
|
||||
int charOffset;
|
||||
LocationImpl(Location loc){
|
||||
systemId = loc.getSystemId();
|
||||
publicId = loc.getPublicId();
|
||||
lineNo = loc.getLineNumber();
|
||||
colNo = loc.getColumnNumber();
|
||||
charOffset = loc.getCharacterOffset();
|
||||
}
|
||||
|
||||
public int getCharacterOffset(){
|
||||
return charOffset;
|
||||
}
|
||||
|
||||
public int getColumnNumber() {
|
||||
return colNo;
|
||||
}
|
||||
|
||||
public int getLineNumber(){
|
||||
return lineNo;
|
||||
}
|
||||
|
||||
public String getPublicId(){
|
||||
return publicId;
|
||||
}
|
||||
|
||||
public String getSystemId(){
|
||||
return systemId;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
StringBuffer sbuffer = new StringBuffer() ;
|
||||
sbuffer.append("Line number = " + getLineNumber());
|
||||
sbuffer.append("\n") ;
|
||||
sbuffer.append("Column number = " + getColumnNumber());
|
||||
sbuffer.append("\n") ;
|
||||
sbuffer.append("System Id = " + getSystemId());
|
||||
sbuffer.append("\n") ;
|
||||
sbuffer.append("Public Id = " + getPublicId());
|
||||
sbuffer.append("\n") ;
|
||||
sbuffer.append("CharacterOffset = " + getCharacterOffset());
|
||||
sbuffer.append("\n") ;
|
||||
return sbuffer.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.stream.events;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
/**
|
||||
*
|
||||
*@author Neeraj Bajaj, Sun Microsystems
|
||||
*
|
||||
*/
|
||||
public class NamedEvent extends DummyEvent {
|
||||
|
||||
private QName name;
|
||||
|
||||
public NamedEvent() {
|
||||
}
|
||||
|
||||
|
||||
public NamedEvent(QName qname) {
|
||||
this.name = qname;
|
||||
}
|
||||
|
||||
|
||||
public NamedEvent(String prefix, String uri, String localpart) {
|
||||
this.name = new QName(uri, localpart, prefix);
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return this.name.getPrefix();
|
||||
}
|
||||
|
||||
|
||||
public QName getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(QName qname) {
|
||||
this.name = qname;
|
||||
}
|
||||
|
||||
public String nameAsString() {
|
||||
if("".equals(name.getNamespaceURI()))
|
||||
return name.getLocalPart();
|
||||
if(name.getPrefix() != null)
|
||||
return "['" + name.getNamespaceURI() + "']:" + getPrefix() + ":" + name.getLocalPart();
|
||||
else
|
||||
return "['" + name.getNamespaceURI() + "']:" + name.getLocalPart();
|
||||
}
|
||||
|
||||
public String getNamespace(){
|
||||
return name.getNamespaceURI();
|
||||
}
|
||||
|
||||
protected void writeAsEncodedUnicodeEx(java.io.Writer writer)
|
||||
throws java.io.IOException
|
||||
{
|
||||
writer.write(nameAsString());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.stream.events;
|
||||
|
||||
import javax.xml.stream.events.Namespace;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
/**
|
||||
*
|
||||
* @author Neeraj Bajaj,K.Venugopal@sun.com Sun Microsystems.
|
||||
*/
|
||||
public class NamespaceImpl extends AttributeImpl implements Namespace{
|
||||
|
||||
public NamespaceImpl( ) {
|
||||
init();
|
||||
}
|
||||
|
||||
/** Creates a new instance of NamespaceImpl */
|
||||
public NamespaceImpl(String namespaceURI) {
|
||||
super(XMLConstants.XMLNS_ATTRIBUTE,XMLConstants.XMLNS_ATTRIBUTE_NS_URI,XMLConstants.DEFAULT_NS_PREFIX,namespaceURI,null);
|
||||
init();
|
||||
}
|
||||
|
||||
public NamespaceImpl(String prefix, String namespaceURI){
|
||||
super(XMLConstants.XMLNS_ATTRIBUTE,XMLConstants.XMLNS_ATTRIBUTE_NS_URI,prefix,namespaceURI,null);
|
||||
init();
|
||||
}
|
||||
|
||||
public boolean isDefaultNamespaceDeclaration() {
|
||||
QName name = this.getName();
|
||||
|
||||
if(name != null && (name.getLocalPart().equals(XMLConstants.DEFAULT_NS_PREFIX)))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void setPrefix(String prefix){
|
||||
if(prefix == null)
|
||||
setName(new QName(XMLConstants.XMLNS_ATTRIBUTE_NS_URI,XMLConstants.DEFAULT_NS_PREFIX,XMLConstants.XMLNS_ATTRIBUTE));
|
||||
else// new QName(uri, localpart, prefix)
|
||||
setName(new QName(XMLConstants.XMLNS_ATTRIBUTE_NS_URI,prefix,XMLConstants.XMLNS_ATTRIBUTE));
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
//for a namespace declaration xmlns:prefix="uri" to get the prefix we have to get the
|
||||
//local name if this declaration is stored as QName.
|
||||
QName name = this.getName();
|
||||
if(name != null)
|
||||
return name.getLocalPart();
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getNamespaceURI() {
|
||||
//we are treating namespace declaration as attribute -- so URI is stored as value
|
||||
//xmlns:prefix="Value"
|
||||
return this.getValue();
|
||||
}
|
||||
|
||||
void setNamespaceURI(String uri) {
|
||||
//we are treating namespace declaration as attribute -- so URI is stored as value
|
||||
//xmlns:prefix="Value"
|
||||
this.setValue(uri);
|
||||
}
|
||||
|
||||
protected void init(){
|
||||
setEventType(XMLEvent.NAMESPACE);
|
||||
}
|
||||
|
||||
public int getEventType(){
|
||||
return XMLEvent.NAMESPACE;
|
||||
}
|
||||
|
||||
public boolean isNamespace(){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.stream.events;
|
||||
|
||||
import javax.xml.stream.events.NotationDeclaration;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
import com.sun.xml.internal.stream.dtd.nonvalidating.XMLNotationDecl;
|
||||
import jdk.xml.internal.JdkXmlUtils;
|
||||
|
||||
/**
|
||||
* Implementation of NotationDeclaration event.
|
||||
*
|
||||
* @author k.venugopal@sun.com
|
||||
*/
|
||||
public class NotationDeclarationImpl extends DummyEvent implements NotationDeclaration {
|
||||
|
||||
String fName = null;
|
||||
String fPublicId = null;
|
||||
String fSystemId = null;
|
||||
|
||||
/** Creates a new instance of NotationDeclarationImpl */
|
||||
public NotationDeclarationImpl() {
|
||||
setEventType(XMLEvent.NOTATION_DECLARATION);
|
||||
}
|
||||
|
||||
public NotationDeclarationImpl(String name,String publicId,String systemId){
|
||||
this.fName = name;
|
||||
this.fPublicId = publicId;
|
||||
this.fSystemId = systemId;
|
||||
setEventType(XMLEvent.NOTATION_DECLARATION);
|
||||
}
|
||||
|
||||
public NotationDeclarationImpl(XMLNotationDecl notation){
|
||||
this.fName = notation.name;
|
||||
this.fPublicId = notation.publicId;
|
||||
this.fSystemId = notation.systemId;
|
||||
setEventType(XMLEvent.NOTATION_DECLARATION);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return fName;
|
||||
}
|
||||
|
||||
public String getPublicId() {
|
||||
return fPublicId;
|
||||
}
|
||||
|
||||
public String getSystemId() {
|
||||
return fSystemId;
|
||||
}
|
||||
|
||||
void setPublicId(String publicId){
|
||||
this.fPublicId = publicId;
|
||||
}
|
||||
|
||||
void setSystemId(String systemId){
|
||||
this.fSystemId = systemId;
|
||||
}
|
||||
|
||||
void setName(String name){
|
||||
this.fName = name;
|
||||
}
|
||||
|
||||
protected void writeAsEncodedUnicodeEx(java.io.Writer writer)
|
||||
throws java.io.IOException
|
||||
{
|
||||
writer.write("<!NOTATION ");
|
||||
writer.write(getName());
|
||||
writer.write(JdkXmlUtils.getDTDExternalDecl(fPublicId, fSystemId));
|
||||
writer.write('>');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.stream.events;
|
||||
|
||||
import java.io.Writer;
|
||||
import javax.xml.stream.Location;
|
||||
import javax.xml.stream.XMLStreamConstants;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.events.ProcessingInstruction;
|
||||
|
||||
/** Implements Processing Instruction Event
|
||||
*
|
||||
*@author Neeraj Bajaj, Sun Microsystems.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
public class ProcessingInstructionEvent extends DummyEvent
|
||||
implements ProcessingInstruction {
|
||||
|
||||
/** Processing Instruction Name */
|
||||
private String fName;
|
||||
/** Processsing instruction content */
|
||||
private String fContent;
|
||||
|
||||
public ProcessingInstructionEvent() {
|
||||
init();
|
||||
}
|
||||
|
||||
public ProcessingInstructionEvent(String targetName, String data) {
|
||||
this(targetName,data,null);
|
||||
}
|
||||
|
||||
public ProcessingInstructionEvent(String targetName, String data,Location loc) {
|
||||
init();
|
||||
this.fName = targetName;
|
||||
fContent = data;
|
||||
setLocation(loc);
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
setEventType(XMLStreamConstants.PROCESSING_INSTRUCTION);
|
||||
}
|
||||
|
||||
public String getTarget() {
|
||||
return fName;
|
||||
}
|
||||
|
||||
public void setTarget(String targetName) {
|
||||
fName = targetName;
|
||||
}
|
||||
|
||||
public void setData(String data) {
|
||||
fContent = data;
|
||||
}
|
||||
|
||||
public String getData() {
|
||||
return fContent;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
if(fContent != null && fName != null)
|
||||
return "<?" + fName + " " + fContent + "?>";
|
||||
if(fName != null)
|
||||
return "<?" + fName + "?>";
|
||||
if(fContent != null)
|
||||
return "<?" + fContent + "?>";
|
||||
else
|
||||
return "<??>";
|
||||
}
|
||||
|
||||
protected void writeAsEncodedUnicodeEx(java.io.Writer writer)
|
||||
throws java.io.IOException
|
||||
{
|
||||
writer.write(toString());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.stream.events;
|
||||
|
||||
import javax.xml.stream.events.StartDocument;
|
||||
import javax.xml.stream.Location;
|
||||
import javax.xml.stream.XMLStreamConstants;
|
||||
|
||||
/** Implementation of StartDocumentEvent.
|
||||
*
|
||||
* @author Neeraj Bajaj Sun Microsystems,Inc.
|
||||
* @author K.Venugopal Sun Microsystems,Inc.
|
||||
*
|
||||
*/
|
||||
|
||||
public class StartDocumentEvent extends DummyEvent
|
||||
implements StartDocument {
|
||||
|
||||
protected String fSystemId;
|
||||
protected String fEncodingScheam;
|
||||
protected boolean fStandalone;
|
||||
protected String fVersion;
|
||||
private boolean fEncodingSchemeSet = false;
|
||||
private boolean fStandaloneSet = false;
|
||||
private boolean nestedCall = false;
|
||||
|
||||
public StartDocumentEvent() {
|
||||
init("UTF-8","1.0",true,null);
|
||||
}
|
||||
|
||||
public StartDocumentEvent(String encoding){
|
||||
init(encoding,"1.0",true,null);
|
||||
}
|
||||
|
||||
public StartDocumentEvent(String encoding, String version){
|
||||
init(encoding,version,true,null);
|
||||
}
|
||||
|
||||
public StartDocumentEvent(String encoding, String version, boolean standalone){
|
||||
this.fStandaloneSet = true;
|
||||
init(encoding,version,standalone,null);
|
||||
}
|
||||
|
||||
public StartDocumentEvent(String encoding, String version, boolean standalone,Location loc){
|
||||
this.fStandaloneSet = true;
|
||||
init(encoding, version, standalone, loc);
|
||||
}
|
||||
protected void init(String encoding, String version, boolean standalone,Location loc) {
|
||||
setEventType(XMLStreamConstants.START_DOCUMENT);
|
||||
this.fEncodingScheam = encoding;
|
||||
this.fVersion = version;
|
||||
this.fStandalone = standalone;
|
||||
if (encoding != null && !encoding.equals(""))
|
||||
this.fEncodingSchemeSet = true;
|
||||
else {
|
||||
this.fEncodingSchemeSet = false;
|
||||
this.fEncodingScheam = "UTF-8";
|
||||
}
|
||||
this.fLocation = loc;
|
||||
}
|
||||
|
||||
public String getSystemId() {
|
||||
if(fLocation == null )
|
||||
return "";
|
||||
else
|
||||
return fLocation.getSystemId();
|
||||
}
|
||||
|
||||
|
||||
public String getCharacterEncodingScheme() {
|
||||
return fEncodingScheam;
|
||||
}
|
||||
|
||||
public boolean isStandalone() {
|
||||
return fStandalone;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return fVersion;
|
||||
}
|
||||
|
||||
public void setStandalone(boolean flag) {
|
||||
fStandaloneSet = true;
|
||||
fStandalone = flag;
|
||||
}
|
||||
|
||||
public void setStandalone(String s) {
|
||||
fStandaloneSet = true;
|
||||
if(s == null) {
|
||||
fStandalone = true;
|
||||
return;
|
||||
}
|
||||
if(s.equals("yes"))
|
||||
fStandalone = true;
|
||||
else
|
||||
fStandalone = false;
|
||||
}
|
||||
|
||||
public boolean encodingSet() {
|
||||
return fEncodingSchemeSet;
|
||||
}
|
||||
|
||||
public boolean standaloneSet() {
|
||||
return fStandaloneSet;
|
||||
}
|
||||
|
||||
public void setEncoding(String encoding) {
|
||||
fEncodingScheam = encoding;
|
||||
}
|
||||
|
||||
void setDeclaredEncoding(boolean value){
|
||||
fEncodingSchemeSet = value;
|
||||
}
|
||||
|
||||
public void setVersion(String s) {
|
||||
fVersion = s;
|
||||
}
|
||||
|
||||
void clear() {
|
||||
fEncodingScheam = "UTF-8";
|
||||
fStandalone = true;
|
||||
fVersion = "1.0";
|
||||
fEncodingSchemeSet = false;
|
||||
fStandaloneSet = false;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
String s = "<?xml version=\"" + fVersion + "\"";
|
||||
s = s + " encoding='" + fEncodingScheam + "'";
|
||||
if(fStandaloneSet) {
|
||||
if(fStandalone)
|
||||
s = s + " standalone='yes'?>";
|
||||
else
|
||||
s = s + " standalone='no'?>";
|
||||
} else {
|
||||
s = s + "?>";
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
public boolean isStartDocument() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void writeAsEncodedUnicodeEx(java.io.Writer writer)
|
||||
throws java.io.IOException
|
||||
{
|
||||
writer.write(toString());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.stream.events;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.events.StartElement;
|
||||
import javax.xml.stream.events.Attribute;
|
||||
import javax.xml.namespace.NamespaceContext;
|
||||
import java.io.Writer;
|
||||
import com.sun.xml.internal.stream.util.ReadOnlyIterator;
|
||||
import javax.xml.stream.XMLStreamConstants;
|
||||
import javax.xml.stream.events.Namespace;
|
||||
|
||||
/** Implementation of StartElementEvent.
|
||||
*
|
||||
* @author Neeraj Bajaj Sun Microsystems,Inc.
|
||||
* @author K.Venugopal Sun Microsystems,Inc.
|
||||
*/
|
||||
|
||||
public class StartElementEvent extends DummyEvent
|
||||
implements StartElement {
|
||||
|
||||
private Map fAttributes;
|
||||
private List fNamespaces;
|
||||
private NamespaceContext fNamespaceContext = null;
|
||||
private QName fQName;
|
||||
|
||||
public StartElementEvent(String prefix, String uri, String localpart) {
|
||||
this(new QName(uri, localpart, prefix));
|
||||
}
|
||||
|
||||
public StartElementEvent(QName qname) {
|
||||
fQName = qname;
|
||||
init();
|
||||
}
|
||||
|
||||
public StartElementEvent(StartElement startelement) {
|
||||
this(startelement.getName());
|
||||
addAttributes(startelement.getAttributes());
|
||||
addNamespaceAttributes(startelement.getNamespaces());
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
setEventType(XMLStreamConstants.START_ELEMENT);
|
||||
fAttributes = new HashMap();
|
||||
fNamespaces = new ArrayList();
|
||||
}
|
||||
|
||||
public QName getName() {
|
||||
return fQName;
|
||||
}
|
||||
|
||||
public void setName(QName qname) {
|
||||
this.fQName = qname;
|
||||
}
|
||||
|
||||
public Iterator getAttributes() {
|
||||
if(fAttributes != null){
|
||||
Collection coll = fAttributes.values();
|
||||
return new ReadOnlyIterator(coll.iterator());
|
||||
}
|
||||
return new ReadOnlyIterator();
|
||||
}
|
||||
|
||||
public Iterator getNamespaces() {
|
||||
if(fNamespaces != null){
|
||||
return new ReadOnlyIterator(fNamespaces.iterator());
|
||||
}
|
||||
return new ReadOnlyIterator();
|
||||
}
|
||||
|
||||
public Attribute getAttributeByName(QName qname) {
|
||||
if(qname == null)
|
||||
return null;
|
||||
return (Attribute)fAttributes.get(qname);
|
||||
}
|
||||
|
||||
public String getNamespace(){
|
||||
return fQName.getNamespaceURI();
|
||||
}
|
||||
|
||||
public String getNamespaceURI(String prefix) {
|
||||
//check that URI was supplied when creating this startElement event and prefix matches
|
||||
if( getNamespace() != null && fQName.getPrefix().equals(prefix)) return getNamespace();
|
||||
//else check the namespace context
|
||||
if(fNamespaceContext != null)
|
||||
return fNamespaceContext.getNamespaceURI(prefix);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Return a <code>String</code> representation of this
|
||||
* <code>StartElement</code> formatted as XML.</p>
|
||||
*
|
||||
* @return <code>String</code> representation of this
|
||||
* <code>StartElement</code> formatted as XML.
|
||||
*/
|
||||
public String toString() {
|
||||
|
||||
StringBuffer startElement = new StringBuffer();
|
||||
|
||||
// open element
|
||||
startElement.append("<");
|
||||
startElement.append(nameAsString());
|
||||
|
||||
// add any attributes
|
||||
if (fAttributes != null) {
|
||||
Iterator it = this.getAttributes();
|
||||
Attribute attr = null;
|
||||
while (it.hasNext()) {
|
||||
attr = (Attribute) it.next();
|
||||
startElement.append(" ");
|
||||
startElement.append(attr.toString());
|
||||
}
|
||||
}
|
||||
|
||||
// add any namespaces
|
||||
if (fNamespaces != null) {
|
||||
Iterator it = fNamespaces.iterator();
|
||||
Namespace attr = null;
|
||||
while (it.hasNext()) {
|
||||
attr = (Namespace) it.next();
|
||||
startElement.append(" ");
|
||||
startElement.append(attr.toString());
|
||||
}
|
||||
}
|
||||
|
||||
// close start tag
|
||||
startElement.append(">");
|
||||
|
||||
// return StartElement as a String
|
||||
return startElement.toString();
|
||||
}
|
||||
|
||||
/** Return this event as String
|
||||
* @return String Event returned as string.
|
||||
*/
|
||||
public String nameAsString() {
|
||||
if("".equals(fQName.getNamespaceURI()))
|
||||
return fQName.getLocalPart();
|
||||
if(fQName.getPrefix() != null)
|
||||
return "['" + fQName.getNamespaceURI() + "']:" + fQName.getPrefix() + ":" + fQName.getLocalPart();
|
||||
else
|
||||
return "['" + fQName.getNamespaceURI() + "']:" + fQName.getLocalPart();
|
||||
}
|
||||
|
||||
|
||||
/** Gets a read-only namespace context. If no context is
|
||||
* available this method will return an empty namespace context.
|
||||
* The NamespaceContext contains information about all namespaces
|
||||
* in scope for this StartElement.
|
||||
*
|
||||
* @return the current namespace context
|
||||
*/
|
||||
public NamespaceContext getNamespaceContext() {
|
||||
return fNamespaceContext;
|
||||
}
|
||||
|
||||
public void setNamespaceContext(NamespaceContext nc) {
|
||||
fNamespaceContext = nc;
|
||||
}
|
||||
|
||||
protected void writeAsEncodedUnicodeEx(java.io.Writer writer)
|
||||
throws java.io.IOException
|
||||
{
|
||||
writer.write(toString());
|
||||
}
|
||||
|
||||
void addAttribute(Attribute attr){
|
||||
if(attr.isNamespace()){
|
||||
fNamespaces.add(attr);
|
||||
}else{
|
||||
fAttributes.put(attr.getName(),attr);
|
||||
}
|
||||
}
|
||||
|
||||
void addAttributes(Iterator attrs){
|
||||
if(attrs == null)
|
||||
return;
|
||||
while(attrs.hasNext()){
|
||||
Attribute attr = (Attribute)attrs.next();
|
||||
fAttributes.put(attr.getName(),attr);
|
||||
}
|
||||
}
|
||||
|
||||
void addNamespaceAttribute(Namespace attr){
|
||||
if(attr == null)
|
||||
return;
|
||||
fNamespaces.add(attr);
|
||||
}
|
||||
|
||||
void addNamespaceAttributes(Iterator attrs){
|
||||
if(attrs == null)
|
||||
return;
|
||||
while(attrs.hasNext()){
|
||||
Namespace attr = (Namespace)attrs.next();
|
||||
fNamespaces.add(attr);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,257 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.stream.events;
|
||||
|
||||
import com.sun.org.apache.xerces.internal.impl.PropertyManager;
|
||||
import java.util.List;
|
||||
import javax.xml.stream.util.XMLEventAllocator;
|
||||
import javax.xml.stream.*;
|
||||
import javax.xml.stream.events.*;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import com.sun.org.apache.xerces.internal.util.NamespaceContextWrapper;
|
||||
import com.sun.org.apache.xerces.internal.util.NamespaceSupport;
|
||||
|
||||
/**
|
||||
* Implementation of XMLEvent Allocator.
|
||||
* @author Neeraj.bajaj@sun.com, k.venugopal@sun.com
|
||||
*/
|
||||
public class XMLEventAllocatorImpl implements XMLEventAllocator {
|
||||
|
||||
/** Creates a new instance of XMLEventAllocator */
|
||||
public XMLEventAllocatorImpl() {
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.XMLEvent allocate(javax.xml.stream.XMLStreamReader xMLStreamReader) throws javax.xml.stream.XMLStreamException {
|
||||
if(xMLStreamReader == null )
|
||||
throw new XMLStreamException("Reader cannot be null");
|
||||
// allocate is not supposed to change the state of the reader so we shouldn't be calling next.
|
||||
// return getNextEvent(xMLStreamReader);
|
||||
return getXMLEvent(xMLStreamReader);
|
||||
}
|
||||
|
||||
public void allocate(javax.xml.stream.XMLStreamReader xMLStreamReader, javax.xml.stream.util.XMLEventConsumer xMLEventConsumer) throws javax.xml.stream.XMLStreamException {
|
||||
XMLEvent currentEvent = getXMLEvent(xMLStreamReader);
|
||||
if(currentEvent != null )
|
||||
xMLEventConsumer.add(currentEvent);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public javax.xml.stream.util.XMLEventAllocator newInstance() {
|
||||
return new XMLEventAllocatorImpl();
|
||||
}
|
||||
|
||||
//REVISIT: shouldn't we be using XMLEventFactory to create events.
|
||||
XMLEvent getXMLEvent(XMLStreamReader streamReader){
|
||||
XMLEvent event = null;
|
||||
//returns the current event
|
||||
int eventType = streamReader.getEventType();
|
||||
switch(eventType){
|
||||
|
||||
case XMLEvent.START_ELEMENT:{
|
||||
StartElementEvent startElementEvent = new StartElementEvent(getQName(streamReader));
|
||||
fillAttributes(startElementEvent,streamReader);
|
||||
//we might have different XMLStreamReader so check every time for the namespace aware property
|
||||
//we should be setting namespace related values only when isNamespaceAware is 'true'
|
||||
if( ((Boolean)streamReader.getProperty(XMLInputFactory.IS_NAMESPACE_AWARE)).booleanValue() ){
|
||||
fillNamespaceAttributes(startElementEvent, streamReader);
|
||||
setNamespaceContext(startElementEvent,streamReader);
|
||||
}
|
||||
|
||||
startElementEvent.setLocation(streamReader.getLocation());
|
||||
event = startElementEvent ;
|
||||
break;
|
||||
}
|
||||
case XMLEvent.END_ELEMENT:{
|
||||
EndElementEvent endElementEvent = new EndElementEvent(getQName(streamReader));
|
||||
endElementEvent.setLocation(streamReader.getLocation());
|
||||
|
||||
if( ((Boolean)streamReader.getProperty(XMLInputFactory.IS_NAMESPACE_AWARE)).booleanValue() ){
|
||||
fillNamespaceAttributes(endElementEvent,streamReader);
|
||||
}
|
||||
event = endElementEvent ;
|
||||
break;
|
||||
}
|
||||
case XMLEvent.PROCESSING_INSTRUCTION:{
|
||||
ProcessingInstructionEvent piEvent = new ProcessingInstructionEvent(streamReader.getPITarget(),streamReader.getPIData());
|
||||
piEvent.setLocation(streamReader.getLocation());
|
||||
event = piEvent ;
|
||||
break;
|
||||
}
|
||||
case XMLEvent.CHARACTERS:{
|
||||
CharacterEvent cDataEvent = new CharacterEvent(streamReader.getText());
|
||||
cDataEvent.setLocation(streamReader.getLocation());
|
||||
event = cDataEvent ;
|
||||
break;
|
||||
}
|
||||
case XMLEvent.COMMENT:{
|
||||
CommentEvent commentEvent = new CommentEvent(streamReader.getText());
|
||||
commentEvent.setLocation(streamReader.getLocation());
|
||||
event = commentEvent ;
|
||||
break;
|
||||
}
|
||||
case XMLEvent.START_DOCUMENT:{
|
||||
StartDocumentEvent sdEvent = new StartDocumentEvent();
|
||||
sdEvent.setVersion(streamReader.getVersion());
|
||||
sdEvent.setEncoding(streamReader.getEncoding());
|
||||
if(streamReader.getCharacterEncodingScheme() != null){
|
||||
sdEvent.setDeclaredEncoding(true);
|
||||
}else{
|
||||
sdEvent.setDeclaredEncoding(false);
|
||||
}
|
||||
sdEvent.setStandalone(streamReader.isStandalone());
|
||||
sdEvent.setLocation(streamReader.getLocation());
|
||||
event = sdEvent ;
|
||||
break;
|
||||
}
|
||||
case XMLEvent.END_DOCUMENT:{
|
||||
EndDocumentEvent endDocumentEvent = new EndDocumentEvent() ;
|
||||
endDocumentEvent.setLocation(streamReader.getLocation());
|
||||
event = endDocumentEvent ;
|
||||
break;
|
||||
}
|
||||
case XMLEvent.ENTITY_REFERENCE:{
|
||||
EntityReferenceEvent entityEvent = new EntityReferenceEvent(streamReader.getLocalName(), new EntityDeclarationImpl(streamReader.getLocalName(),streamReader.getText()));
|
||||
entityEvent.setLocation(streamReader.getLocation());
|
||||
event = entityEvent;
|
||||
break;
|
||||
|
||||
}
|
||||
case XMLEvent.ATTRIBUTE:{
|
||||
event = null ;
|
||||
break;
|
||||
}
|
||||
case XMLEvent.DTD:{
|
||||
DTDEvent dtdEvent = new DTDEvent(streamReader.getText());
|
||||
dtdEvent.setLocation(streamReader.getLocation());
|
||||
List entities = (List)streamReader.getProperty(PropertyManager.STAX_ENTITIES);
|
||||
if (entities != null && entities.size() != 0) dtdEvent.setEntities(entities);
|
||||
List notations = (List)streamReader.getProperty(PropertyManager.STAX_NOTATIONS);
|
||||
if (notations != null && notations.size() != 0) dtdEvent.setNotations(notations);
|
||||
event = dtdEvent;
|
||||
break;
|
||||
}
|
||||
case XMLEvent.CDATA:{
|
||||
CharacterEvent cDataEvent = new CharacterEvent(streamReader.getText(),true);
|
||||
cDataEvent.setLocation(streamReader.getLocation());
|
||||
event = cDataEvent ;
|
||||
break;
|
||||
}
|
||||
case XMLEvent.SPACE:{
|
||||
CharacterEvent spaceEvent = new CharacterEvent(streamReader.getText(),false,true);
|
||||
spaceEvent.setLocation(streamReader.getLocation());
|
||||
event = spaceEvent ;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return event ;
|
||||
}
|
||||
|
||||
//this function is not used..
|
||||
protected XMLEvent getNextEvent(XMLStreamReader streamReader) throws XMLStreamException{
|
||||
//advance the reader to next event.
|
||||
streamReader.next();
|
||||
return getXMLEvent(streamReader);
|
||||
}
|
||||
|
||||
protected void fillAttributes(StartElementEvent event,XMLStreamReader xmlr){
|
||||
|
||||
int len = xmlr.getAttributeCount();
|
||||
QName qname = null;
|
||||
AttributeImpl attr = null;
|
||||
NamespaceImpl nattr = null;
|
||||
for(int i=0; i<len ;i++){
|
||||
qname = xmlr.getAttributeName(i);
|
||||
//this method doesn't include namespace declarations
|
||||
//so we can be sure that there wont be any namespace declaration as part of this function call
|
||||
//we can avoid this check - nb.
|
||||
/**
|
||||
* prefix = qname.getPrefix();
|
||||
* localpart = qname.getLocalPart();
|
||||
* if (prefix.equals(XMLConstants.XMLNS_ATTRIBUTE) ) {
|
||||
* attr = new NamespaceImpl(localpart,xmlr.getAttributeValue(i));
|
||||
* }else if (prefix.equals(XMLConstants.DEFAULT_NS_PREFIX)){
|
||||
* attr = new NamespaceImpl(xmlr.getAttributeValue(i));
|
||||
* }else{
|
||||
* attr = new AttributeImpl();
|
||||
* attr.setName(qname);
|
||||
* }
|
||||
**/
|
||||
attr = new AttributeImpl();
|
||||
attr.setName(qname);
|
||||
attr.setAttributeType(xmlr.getAttributeType(i));
|
||||
attr.setSpecified(xmlr.isAttributeSpecified(i));
|
||||
attr.setValue(xmlr.getAttributeValue(i));
|
||||
event.addAttribute(attr);
|
||||
}
|
||||
}
|
||||
|
||||
protected void fillNamespaceAttributes(StartElementEvent event,XMLStreamReader xmlr){
|
||||
int count = xmlr.getNamespaceCount();
|
||||
String uri = null;
|
||||
String prefix = null;
|
||||
NamespaceImpl attr = null;
|
||||
for(int i=0;i< count;i++){
|
||||
uri = xmlr.getNamespaceURI(i);
|
||||
prefix = xmlr.getNamespacePrefix(i);
|
||||
if(prefix == null){
|
||||
prefix = XMLConstants.DEFAULT_NS_PREFIX;
|
||||
}
|
||||
attr = new NamespaceImpl(prefix,uri);
|
||||
event.addNamespaceAttribute(attr);
|
||||
}
|
||||
}
|
||||
|
||||
protected void fillNamespaceAttributes(EndElementEvent event,XMLStreamReader xmlr){
|
||||
int count = xmlr.getNamespaceCount();
|
||||
String uri = null;
|
||||
String prefix = null;
|
||||
NamespaceImpl attr = null;
|
||||
for(int i=0;i< count;i++){
|
||||
uri = xmlr.getNamespaceURI(i);
|
||||
prefix = xmlr.getNamespacePrefix(i);
|
||||
if(prefix == null){
|
||||
prefix = XMLConstants.DEFAULT_NS_PREFIX;
|
||||
}
|
||||
attr = new NamespaceImpl(prefix,uri);
|
||||
event.addNamespace(attr);
|
||||
}
|
||||
}
|
||||
|
||||
//Revisit : Creating a new Namespacecontext for now.
|
||||
//see if we can do better job.
|
||||
private void setNamespaceContext(StartElementEvent event , XMLStreamReader xmlr){
|
||||
NamespaceContextWrapper contextWrapper =(NamespaceContextWrapper) xmlr.getNamespaceContext();
|
||||
NamespaceSupport ns = new NamespaceSupport(contextWrapper.getNamespaceContext());
|
||||
event.setNamespaceContext(new NamespaceContextWrapper(ns));
|
||||
}
|
||||
|
||||
private QName getQName(XMLStreamReader xmlr) {
|
||||
return new QName(xmlr.getNamespaceURI(), xmlr.getLocalName(),
|
||||
xmlr.getPrefix());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.stream.events;
|
||||
|
||||
import javax.xml.stream.XMLEventFactory;
|
||||
import javax.xml.stream.Location;
|
||||
import javax.xml.stream.events.Namespace;
|
||||
import javax.xml.stream.events.EntityDeclaration;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Neeraj Bajaj, k.venugopal@sun.com
|
||||
*/
|
||||
public class XMLEventFactoryImpl extends XMLEventFactory {
|
||||
|
||||
Location location = null;
|
||||
/** Creates a new instance of XMLEventFactory */
|
||||
public XMLEventFactoryImpl() {
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.Attribute createAttribute(String localName, String value) {
|
||||
AttributeImpl attr = new AttributeImpl(localName, value);
|
||||
if(location != null)attr.setLocation(location);
|
||||
return attr;
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.Attribute createAttribute(javax.xml.namespace.QName name, String value) {
|
||||
return createAttribute(name.getPrefix(), name.getNamespaceURI(), name.getLocalPart(), value);
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.Attribute createAttribute(String prefix, String namespaceURI, String localName, String value) {
|
||||
AttributeImpl attr = new AttributeImpl(prefix, namespaceURI, localName, value, null);
|
||||
if(location != null)attr.setLocation(location);
|
||||
return attr;
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.Characters createCData(String content) {
|
||||
//stax doesn't have separate CDATA event. This is taken care by
|
||||
//CHRACTERS event setting the cdata flag to true.
|
||||
CharacterEvent charEvent = new CharacterEvent(content, true);
|
||||
if(location != null)charEvent.setLocation(location);
|
||||
return charEvent;
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.Characters createCharacters(String content) {
|
||||
CharacterEvent charEvent = new CharacterEvent(content);
|
||||
if(location != null)charEvent.setLocation(location);
|
||||
return charEvent;
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.Comment createComment(String text) {
|
||||
CommentEvent charEvent = new CommentEvent(text);
|
||||
if(location != null)charEvent.setLocation(location);
|
||||
return charEvent;
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.DTD createDTD(String dtd) {
|
||||
DTDEvent dtdEvent = new DTDEvent(dtd);
|
||||
if(location != null)dtdEvent.setLocation(location);
|
||||
return dtdEvent;
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.EndDocument createEndDocument() {
|
||||
EndDocumentEvent event =new EndDocumentEvent();
|
||||
if(location != null)event.setLocation(location);
|
||||
return event;
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.EndElement createEndElement(javax.xml.namespace.QName name, java.util.Iterator namespaces) {
|
||||
return createEndElement(name.getPrefix(), name.getNamespaceURI(), name.getLocalPart());
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.EndElement createEndElement(String prefix, String namespaceUri, String localName) {
|
||||
EndElementEvent event = new EndElementEvent(prefix, namespaceUri, localName);
|
||||
if(location != null)event.setLocation(location);
|
||||
return event;
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.EndElement createEndElement(String prefix, String namespaceUri, String localName, java.util.Iterator namespaces) {
|
||||
|
||||
EndElementEvent event = new EndElementEvent(prefix, namespaceUri, localName);
|
||||
if(namespaces!=null){
|
||||
while(namespaces.hasNext())
|
||||
event.addNamespace((Namespace)namespaces.next());
|
||||
}
|
||||
if(location != null)event.setLocation(location);
|
||||
return event;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.Characters createIgnorableSpace(String content) {
|
||||
CharacterEvent event = new CharacterEvent(content, false, true);
|
||||
if(location != null)event.setLocation(location);
|
||||
return event;
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.Namespace createNamespace(String namespaceURI) {
|
||||
NamespaceImpl event = new NamespaceImpl(namespaceURI);
|
||||
if(location != null)event.setLocation(location);
|
||||
return event;
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.Namespace createNamespace(String prefix, String namespaceURI) {
|
||||
NamespaceImpl event = new NamespaceImpl(prefix, namespaceURI);
|
||||
if(location != null)event.setLocation(location);
|
||||
return event;
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.ProcessingInstruction createProcessingInstruction(String target, String data) {
|
||||
ProcessingInstructionEvent event = new ProcessingInstructionEvent(target, data);
|
||||
if(location != null)event.setLocation(location);
|
||||
return event;
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.Characters createSpace(String content) {
|
||||
CharacterEvent event = new CharacterEvent(content);
|
||||
if(location != null)event.setLocation(location);
|
||||
return event;
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.StartDocument createStartDocument() {
|
||||
StartDocumentEvent event = new StartDocumentEvent();
|
||||
if(location != null)event.setLocation(location);
|
||||
return event;
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.StartDocument createStartDocument(String encoding) {
|
||||
StartDocumentEvent event = new StartDocumentEvent(encoding);
|
||||
if(location != null)event.setLocation(location);
|
||||
return event;
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.StartDocument createStartDocument(String encoding, String version) {
|
||||
StartDocumentEvent event = new StartDocumentEvent(encoding, version);
|
||||
if(location != null)event.setLocation(location);
|
||||
return event;
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.StartDocument createStartDocument(String encoding, String version, boolean standalone) {
|
||||
StartDocumentEvent event = new StartDocumentEvent(encoding, version, standalone);
|
||||
if(location != null)event.setLocation(location);
|
||||
return event;
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.StartElement createStartElement(javax.xml.namespace.QName name, java.util.Iterator attributes, java.util.Iterator namespaces) {
|
||||
return createStartElement(name.getPrefix(), name.getNamespaceURI(), name.getLocalPart(), attributes, namespaces);
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.StartElement createStartElement(String prefix, String namespaceUri, String localName) {
|
||||
StartElementEvent event = new StartElementEvent(prefix, namespaceUri, localName);
|
||||
if(location != null)event.setLocation(location);
|
||||
return event;
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.StartElement createStartElement(String prefix, String namespaceUri, String localName, java.util.Iterator attributes, java.util.Iterator namespaces) {
|
||||
return createStartElement(prefix, namespaceUri, localName, attributes, namespaces, null);
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.StartElement createStartElement(String prefix, String namespaceUri, String localName, java.util.Iterator attributes, java.util.Iterator namespaces, javax.xml.namespace.NamespaceContext context) {
|
||||
StartElementEvent elem = new StartElementEvent(prefix, namespaceUri, localName);
|
||||
elem.addAttributes(attributes);
|
||||
elem.addNamespaceAttributes(namespaces);
|
||||
elem.setNamespaceContext(context);
|
||||
if(location != null)elem.setLocation(location);
|
||||
return elem;
|
||||
}
|
||||
|
||||
public void setLocation(javax.xml.stream.Location location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user