8170556: Warnings cleanup related to JDK-8167340
Reviewed-by: dfuchs, lancea, clanger
This commit is contained in:
parent
ea6028f37e
commit
95f72fe86a
@ -218,8 +218,8 @@ public class XMLDocumentFragmentScannerImpl
|
||||
};
|
||||
|
||||
|
||||
private static final char [] cdata = {'[','C','D','A','T','A','['};
|
||||
static final char [] xmlDecl = {'<','?','x','m','l'};
|
||||
private static final char [] CDATA = {'[','C','D','A','T','A','['};
|
||||
static final char [] XMLDECL = {'<','?','x','m','l'};
|
||||
// private static final char [] endTag = {'<','/'};
|
||||
// debugging
|
||||
|
||||
@ -232,13 +232,9 @@ public class XMLDocumentFragmentScannerImpl
|
||||
/** Debug content driver scanning. */
|
||||
protected static final boolean DEBUG_START_END_ELEMENT = false;
|
||||
|
||||
|
||||
/** Debug driver next */
|
||||
protected static final boolean DEBUG_NEXT = false ;
|
||||
|
||||
/** Debug driver next */
|
||||
protected static final boolean DEBUG = false;
|
||||
protected static final boolean DEBUG_COALESCE = false;
|
||||
|
||||
//
|
||||
// Data
|
||||
//
|
||||
@ -371,16 +367,16 @@ public class XMLDocumentFragmentScannerImpl
|
||||
protected XMLString fTempString2 = new XMLString();
|
||||
|
||||
/** Array of 3 strings. */
|
||||
private String[] fStrings = new String[3];
|
||||
private final String[] fStrings = new String[3];
|
||||
|
||||
/** Making the buffer accesible to derived class -- String buffer. */
|
||||
/** Making the buffer accessible to derived class -- String buffer. */
|
||||
protected XMLStringBuffer fStringBuffer = new XMLStringBuffer();
|
||||
|
||||
/** Making the buffer accesible to derived class -- String buffer. */
|
||||
/** Making the buffer accessible to derived class -- String buffer. */
|
||||
protected XMLStringBuffer fStringBuffer2 = new XMLStringBuffer();
|
||||
|
||||
/** stores character data. */
|
||||
/** Making the buffer accesible to derived class -- stores PI data */
|
||||
/** Making the buffer accessible to derived class -- stores PI data */
|
||||
protected XMLStringBuffer fContentBuffer = new XMLStringBuffer();
|
||||
|
||||
/** Single character array. */
|
||||
@ -633,22 +629,23 @@ public class XMLDocumentFragmentScannerImpl
|
||||
|
||||
// other settings
|
||||
// fDocumentSystemId = null;
|
||||
fNamespaces = ((Boolean)propertyManager.getProperty(XMLInputFactory.IS_NAMESPACE_AWARE)).booleanValue();
|
||||
fNamespaces = ((Boolean)propertyManager.getProperty(XMLInputFactory.IS_NAMESPACE_AWARE));
|
||||
fNotifyBuiltInRefs = false ;
|
||||
|
||||
//fElementStack2.clear();
|
||||
//fReplaceEntityReferences = true;
|
||||
//fSupportExternalEntities = true;
|
||||
Boolean bo = (Boolean)propertyManager.getProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES);
|
||||
fReplaceEntityReferences = bo.booleanValue();
|
||||
fReplaceEntityReferences = bo;
|
||||
bo = (Boolean)propertyManager.getProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES);
|
||||
fSupportExternalEntities = bo.booleanValue();
|
||||
Boolean cdata = (Boolean)propertyManager.getProperty(Constants.ZEPHYR_PROPERTY_PREFIX + Constants.STAX_REPORT_CDATA_EVENT) ;
|
||||
fSupportExternalEntities = bo;
|
||||
Boolean cdata = (Boolean)propertyManager.getProperty(
|
||||
Constants.ZEPHYR_PROPERTY_PREFIX + Constants.STAX_REPORT_CDATA_EVENT) ;
|
||||
if(cdata != null)
|
||||
fReportCdataEvent = cdata.booleanValue() ;
|
||||
fReportCdataEvent = cdata ;
|
||||
Boolean coalesce = (Boolean)propertyManager.getProperty(XMLInputFactory.IS_COALESCING) ;
|
||||
if(coalesce != null)
|
||||
fIsCoalesce = coalesce.booleanValue();
|
||||
fIsCoalesce = coalesce;
|
||||
fReportCdataEvent = fIsCoalesce ? false : (fReportCdataEvent && true) ;
|
||||
//if fIsCoalesce is set to true, set the value of fReplaceEntityReferences to true,
|
||||
//if fIsCoalesce is set to false, take the value of fReplaceEntityReferences as set by application
|
||||
@ -703,7 +700,7 @@ public class XMLDocumentFragmentScannerImpl
|
||||
* are recognized by this component.
|
||||
*/
|
||||
public String[] getRecognizedFeatures() {
|
||||
return (String[])(RECOGNIZED_FEATURES.clone());
|
||||
return RECOGNIZED_FEATURES.clone();
|
||||
} // getRecognizedFeatures():String[]
|
||||
|
||||
/**
|
||||
@ -742,7 +739,7 @@ public class XMLDocumentFragmentScannerImpl
|
||||
* are recognized by this component.
|
||||
*/
|
||||
public String[] getRecognizedProperties() {
|
||||
return (String[])(RECOGNIZED_PROPERTIES.clone());
|
||||
return RECOGNIZED_PROPERTIES.clone();
|
||||
} // getRecognizedProperties():String[]
|
||||
|
||||
/**
|
||||
@ -990,7 +987,8 @@ public class XMLDocumentFragmentScannerImpl
|
||||
// set standalone
|
||||
fStandaloneSet = standalone != null;
|
||||
fStandalone = fStandaloneSet && standalone.equals("yes");
|
||||
///xxx see where its used.. this is not used anywhere. it may be useful for entity to store this information
|
||||
///xxx see where its used.. this is not used anywhere.
|
||||
//it may be useful for entity to store this information
|
||||
//but this information is only related with Document Entity.
|
||||
fEntityManager.setStandalone(fStandalone);
|
||||
|
||||
@ -1199,7 +1197,8 @@ public class XMLDocumentFragmentScannerImpl
|
||||
if(rawname != null && skipFromTheBuffer(rawname)){
|
||||
fLastPointerLocation++ ;
|
||||
if(DEBUG_SKIP_ALGORITHM){
|
||||
System.out.println("Element " + fElementRawname + " was SKIPPED at pointer location = " + fLastPointerLocation);
|
||||
System.out.println("Element " + fElementRawname +
|
||||
" was SKIPPED at pointer location = " + fLastPointerLocation);
|
||||
}
|
||||
return true ;
|
||||
} else{
|
||||
@ -1233,7 +1232,8 @@ public class XMLDocumentFragmentScannerImpl
|
||||
if(fElementArray[pointer] != null && skipFromTheBuffer(fElementArray[pointer])){
|
||||
if(DEBUG_SKIP_ALGORITHM){
|
||||
System.out.println();
|
||||
System.out.println("Element " + fElementRawname + " was SKIPPED at depth = " + fElementStack.fDepth + " column = " + column );
|
||||
System.out.println("Element " + fElementRawname + " was SKIPPED at depth = " +
|
||||
fElementStack.fDepth + " column = " + column );
|
||||
System.out.println();
|
||||
}
|
||||
fLastPointerLocation = pointer ;
|
||||
@ -1317,7 +1317,8 @@ public class XMLDocumentFragmentScannerImpl
|
||||
if(DEBUG)System.out.println("Element scanned in start element is " + fElementQName.toString());
|
||||
if(DEBUG_SKIP_ALGORITHM){
|
||||
if(fAdd){
|
||||
System.out.println("Elements are being ADDED -- elemet added is = " + fElementQName.rawname + " at count = " + fElementStack.fCount);
|
||||
System.out.println("Elements are being ADDED -- elemet added is = " +
|
||||
fElementQName.rawname + " at count = " + fElementStack.fCount);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1395,7 +1396,8 @@ public class XMLDocumentFragmentScannerImpl
|
||||
}
|
||||
|
||||
|
||||
if (DEBUG_START_END_ELEMENT) System.out.println(this.getClass().toString() + "<<< scanStartElement(): "+fEmptyElement);
|
||||
if (DEBUG_START_END_ELEMENT) System.out.println(this.getClass().toString() +
|
||||
"<<< scanStartElement(): "+fEmptyElement);
|
||||
return fEmptyElement;
|
||||
|
||||
} // scanStartElement():boolean
|
||||
@ -1434,84 +1436,9 @@ public class XMLDocumentFragmentScannerImpl
|
||||
}
|
||||
|
||||
public boolean hasAttributes(){
|
||||
return fAttributes.getLength() > 0 ? true : false ;
|
||||
return fAttributes.getLength() > 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Scans an attribute.
|
||||
* <p>
|
||||
* <pre>
|
||||
* [41] Attribute ::= Name Eq AttValue
|
||||
* </pre>
|
||||
* <p>
|
||||
* <strong>Note:</strong> This method assumes that the next
|
||||
* character on the stream is the first character of the attribute
|
||||
* name.
|
||||
* <p>
|
||||
* <strong>Note:</strong> This method uses the fAttributeQName and
|
||||
* fQName variables. The contents of these variables will be
|
||||
* destroyed.
|
||||
*
|
||||
* @param attributes The attributes list for the scanned attribute.
|
||||
*/
|
||||
|
||||
/**
|
||||
* protected void scanAttribute(AttributeIteratorImpl attributes)
|
||||
* throws IOException, XNIException {
|
||||
* if (DEBUG_START_END_ELEMENT) System.out.println(">>> scanAttribute()");
|
||||
*
|
||||
*
|
||||
* // name
|
||||
* if (fNamespaces) {
|
||||
* fEntityScanner.scanQName(fAttributeQName);
|
||||
* }
|
||||
* else {
|
||||
* String name = fEntityScanner.scanName();
|
||||
* fAttributeQName.setValues(null, name, name, null);
|
||||
* }
|
||||
*
|
||||
* // equals
|
||||
* fEntityScanner.skipSpaces();
|
||||
* if (!fEntityScanner.skipChar('=')) {
|
||||
* reportFatalError("EqRequiredInAttribute",
|
||||
* new Object[]{fAttributeQName.rawname});
|
||||
* }
|
||||
* fEntityScanner.skipSpaces();
|
||||
*
|
||||
*
|
||||
* // content
|
||||
* int oldLen = attributes.getLength();
|
||||
*/
|
||||
/**xxx there is one check of duplicate attribute that has been removed.
|
||||
* attributes.addAttribute(fAttributeQName, XMLSymbols.fCDATASymbol, null);
|
||||
*
|
||||
* // WFC: Unique Att Spec
|
||||
* if (oldLen == attributes.getLength()) {
|
||||
* reportFatalError("AttributeNotUnique",
|
||||
* new Object[]{fCurrentElement.rawname,
|
||||
* fAttributeQName.rawname});
|
||||
* }
|
||||
*/
|
||||
|
||||
/*
|
||||
//REVISIT: one more case needs to be included: external PE and standalone is no
|
||||
boolean isVC = fHasExternalDTD && !fStandalone;
|
||||
scanAttributeValue(fTempString, fTempString2,
|
||||
fAttributeQName.rawname, attributes,
|
||||
oldLen, isVC);
|
||||
|
||||
//attributes.setValue(oldLen, fTempString.toString());
|
||||
//attributes.setNonNormalizedValue(oldLen, fTempString2.toString());
|
||||
//attributes.setSpecified(oldLen, true);
|
||||
|
||||
AttributeImpl attribute = new AttributeImpl(fAttributeQName.prefix,fAttributeQName.localpart,fAttributeQName.uri,fTempString.toString(),fTempString2.toString(),XMLSymbols.fCDATASymbol,true);
|
||||
fAttributes.addAttribute(attribute);
|
||||
if (DEBUG_START_END_ELEMENT) System.out.println("<<< scanAttribute()");
|
||||
} // scanAttribute(XMLAttributes)
|
||||
|
||||
*/
|
||||
|
||||
/** return the attribute iterator implementation */
|
||||
public XMLAttributesIteratorImpl getAttributeIterator(){
|
||||
if(dtdGrammarUtil != null && fAddDefaultAttr){
|
||||
@ -2624,7 +2551,7 @@ public class XMLDocumentFragmentScannerImpl
|
||||
null);
|
||||
}
|
||||
setScannerState(SCANNER_STATE_COMMENT);
|
||||
} else if (fEntityScanner.skipString(cdata)) {
|
||||
} else if (fEntityScanner.skipString(CDATA)) {
|
||||
fCDataStart = true;
|
||||
setScannerState(SCANNER_STATE_CDATA );
|
||||
} else if (!scanForDoctypeHook()) {
|
||||
@ -2710,62 +2637,56 @@ public class XMLDocumentFragmentScannerImpl
|
||||
public int next() throws IOException, XNIException {
|
||||
while (true) {
|
||||
try {
|
||||
if(DEBUG_NEXT){
|
||||
System.out.println("NOW IN FragmentContentDriver");
|
||||
System.out.println("Entering the FragmentContentDriver with = " + getScannerStateName(fScannerState));
|
||||
}
|
||||
|
||||
//decide the actual sub state of the scanner.For more information refer to the javadoc of
|
||||
//decideSubState.
|
||||
|
||||
switch (fScannerState) {
|
||||
case SCANNER_STATE_CONTENT: {
|
||||
final int ch = fEntityScanner.peekChar();
|
||||
if (ch == '<') {
|
||||
fEntityScanner.scanChar(null);
|
||||
setScannerState(SCANNER_STATE_START_OF_MARKUP);
|
||||
} else if (ch == '&') {
|
||||
fEntityScanner.scanChar(NameType.REFERENCE);
|
||||
setScannerState(SCANNER_STATE_REFERENCE) ; //XMLEvent.ENTITY_REFERENCE ); //SCANNER_STATE_REFERENCE
|
||||
break;
|
||||
} else {
|
||||
//element content is there..
|
||||
setScannerState(SCANNER_STATE_CHARACTER_DATA);
|
||||
break;
|
||||
}
|
||||
if (fScannerState == SCANNER_STATE_CONTENT) {
|
||||
final int ch = fEntityScanner.peekChar();
|
||||
if (ch == '<') {
|
||||
fEntityScanner.scanChar(null);
|
||||
setScannerState(SCANNER_STATE_START_OF_MARKUP);
|
||||
} else if (ch == '&') {
|
||||
fEntityScanner.scanChar(NameType.REFERENCE);
|
||||
setScannerState(SCANNER_STATE_REFERENCE) ;
|
||||
} else {
|
||||
//element content is there..
|
||||
setScannerState(SCANNER_STATE_CHARACTER_DATA);
|
||||
}
|
||||
}
|
||||
|
||||
case SCANNER_STATE_START_OF_MARKUP: {
|
||||
startOfMarkup();
|
||||
break;
|
||||
}//case: SCANNER_STATE_START_OF_MARKUP
|
||||
if (fScannerState == SCANNER_STATE_START_OF_MARKUP) {
|
||||
startOfMarkup();
|
||||
}
|
||||
|
||||
}//end of switch
|
||||
//decideSubState() ;
|
||||
|
||||
//do some special handling if isCoalesce is set to true.
|
||||
if(fIsCoalesce){
|
||||
if (fIsCoalesce) {
|
||||
fUsebuffer = true ;
|
||||
//if the last section was character data
|
||||
if(fLastSectionWasCharacterData){
|
||||
if (fLastSectionWasCharacterData) {
|
||||
|
||||
//if we dont encounter any CDATA or ENTITY REFERENCE and current state is also not SCANNER_STATE_CHARACTER_DATA
|
||||
//if we dont encounter any CDATA or ENTITY REFERENCE and
|
||||
//current state is also not SCANNER_STATE_CHARACTER_DATA
|
||||
//return the last scanned charactrer data.
|
||||
if((fScannerState != SCANNER_STATE_CDATA) && (fScannerState != SCANNER_STATE_REFERENCE)
|
||||
&& (fScannerState != SCANNER_STATE_CHARACTER_DATA)){
|
||||
if ((fScannerState != SCANNER_STATE_CDATA)
|
||||
&& (fScannerState != SCANNER_STATE_REFERENCE)
|
||||
&& (fScannerState != SCANNER_STATE_CHARACTER_DATA)) {
|
||||
fLastSectionWasCharacterData = false;
|
||||
return XMLEvent.CHARACTERS;
|
||||
}
|
||||
}//if last section was CDATA or ENTITY REFERENCE
|
||||
//xxx: there might be another entity reference or CDATA after this
|
||||
//<foo>blah blah &<<![CDATA[[aa]]>blah blah</foo>
|
||||
else if((fLastSectionWasCData || fLastSectionWasEntityReference)){
|
||||
else if ((fLastSectionWasCData || fLastSectionWasEntityReference)) {
|
||||
//and current state is not SCANNER_STATE_CHARACTER_DATA
|
||||
//or SCANNER_STATE_CDATA or SCANNER_STATE_REFERENCE
|
||||
//this means there is nothing more to be coalesced.
|
||||
//return the CHARACTERS event.
|
||||
if((fScannerState != SCANNER_STATE_CDATA) && (fScannerState != SCANNER_STATE_REFERENCE)
|
||||
&& (fScannerState != SCANNER_STATE_CHARACTER_DATA)){
|
||||
if ((fScannerState != SCANNER_STATE_CDATA)
|
||||
&& (fScannerState != SCANNER_STATE_REFERENCE)
|
||||
&& (fScannerState != SCANNER_STATE_CHARACTER_DATA)){
|
||||
|
||||
fLastSectionWasCData = false;
|
||||
fLastSectionWasEntityReference = false;
|
||||
@ -2774,11 +2695,6 @@ public class XMLDocumentFragmentScannerImpl
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(DEBUG_NEXT){
|
||||
System.out.println("Actual scanner state set by decideSubState is = " + getScannerStateName(fScannerState));
|
||||
}
|
||||
|
||||
switch(fScannerState){
|
||||
|
||||
case XMLEvent.START_DOCUMENT :
|
||||
@ -2786,7 +2702,6 @@ public class XMLDocumentFragmentScannerImpl
|
||||
|
||||
case SCANNER_STATE_START_ELEMENT_TAG :{
|
||||
|
||||
//xxx this function returns true when element is empty.. can be linked to end element event.
|
||||
//returns true if the element is empty
|
||||
fEmptyElement = scanStartElement() ;
|
||||
//if the element is empty the next event is "end element"
|
||||
@ -2800,15 +2715,16 @@ public class XMLDocumentFragmentScannerImpl
|
||||
}
|
||||
|
||||
case SCANNER_STATE_CHARACTER_DATA: {
|
||||
if(DEBUG_COALESCE){
|
||||
System.out.println("fLastSectionWasCData = " + fLastSectionWasCData);
|
||||
System.out.println("fIsCoalesce = " + fIsCoalesce);
|
||||
}
|
||||
//if last section was either entity reference or cdata or character data we should be using buffer
|
||||
fUsebuffer = fLastSectionWasEntityReference || fLastSectionWasCData || fLastSectionWasCharacterData ;
|
||||
|
||||
//When coalesce is set to true and last state was REFERENCE or CDATA or CHARACTER_DATA, buffer should not be cleared.
|
||||
if( fIsCoalesce && (fLastSectionWasEntityReference || fLastSectionWasCData || fLastSectionWasCharacterData) ){
|
||||
//if last section was either entity reference or cdata or
|
||||
//character data we should be using buffer
|
||||
fUsebuffer = fLastSectionWasEntityReference || fLastSectionWasCData
|
||||
|| fLastSectionWasCharacterData ;
|
||||
|
||||
//When coalesce is set to true and last state was REFERENCE or
|
||||
//CDATA or CHARACTER_DATA, buffer should not be cleared.
|
||||
if( fIsCoalesce && (fLastSectionWasEntityReference ||
|
||||
fLastSectionWasCData || fLastSectionWasCharacterData) ){
|
||||
fLastSectionWasEntityReference = false;
|
||||
fLastSectionWasCData = false;
|
||||
fLastSectionWasCharacterData = true ;
|
||||
@ -2822,9 +2738,7 @@ public class XMLDocumentFragmentScannerImpl
|
||||
//scanContent sets the correct co-ordinates as per the content read
|
||||
fTempString.length = 0;
|
||||
int c = fEntityScanner.scanContent(fTempString);
|
||||
if(DEBUG){
|
||||
System.out.println("fTempString = " + fTempString);
|
||||
}
|
||||
|
||||
if(fEntityScanner.skipChar('<', null)){
|
||||
//check if we have reached end of element
|
||||
if(fEntityScanner.skipChar('/', NameType.ELEMENTEND)){
|
||||
@ -2841,21 +2755,17 @@ public class XMLDocumentFragmentScannerImpl
|
||||
setScannerState(SCANNER_STATE_START_OF_MARKUP);
|
||||
//there can be cdata ahead if coalesce is true we should call again
|
||||
if(fIsCoalesce){
|
||||
fUsebuffer = true;
|
||||
fLastSectionWasCharacterData = true;
|
||||
fContentBuffer.append(fTempString);
|
||||
fTempString.length = 0;
|
||||
bufferContent();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
//in case last section was either entity reference or cdata or character data -- we should be using buffer
|
||||
//in case last section was either entity reference or
|
||||
//cdata or character data -- we should be using buffer
|
||||
if(fUsebuffer){
|
||||
fContentBuffer.append(fTempString);
|
||||
fTempString.length = 0;
|
||||
}
|
||||
if(DEBUG){
|
||||
System.out.println("NOT USING THE BUFFER, STRING = " + fTempString.toString());
|
||||
bufferContent();
|
||||
}
|
||||
|
||||
if(dtdGrammarUtil!= null && dtdGrammarUtil.isIgnorableWhiteSpace(fContentBuffer)){
|
||||
if(DEBUG)System.out.println("Return SPACE EVENT");
|
||||
return XMLEvent.SPACE;
|
||||
@ -2863,13 +2773,7 @@ public class XMLDocumentFragmentScannerImpl
|
||||
return XMLEvent.CHARACTERS;
|
||||
|
||||
} else{
|
||||
fUsebuffer = true ;
|
||||
if(DEBUG){
|
||||
System.out.println("fContentBuffer = " + fContentBuffer);
|
||||
System.out.println("fTempString = " + fTempString);
|
||||
}
|
||||
fContentBuffer.append(fTempString);
|
||||
fTempString.length = 0;
|
||||
bufferContent();
|
||||
}
|
||||
if (c == '\r') {
|
||||
if(DEBUG){
|
||||
@ -2969,7 +2873,8 @@ public class XMLDocumentFragmentScannerImpl
|
||||
setScannerState(SCANNER_STATE_CONTENT);
|
||||
//check the case when there is comment after single element document
|
||||
//<foo/> and some comment after this
|
||||
return (fMarkupDepth == 0 && elementDepthIsZeroHook() ) ? XMLEvent.END_ELEMENT : XMLEvent.END_ELEMENT ;
|
||||
return (fMarkupDepth == 0 && elementDepthIsZeroHook() ) ?
|
||||
XMLEvent.END_ELEMENT : XMLEvent.END_ELEMENT ;
|
||||
|
||||
} else if(scanEndElement() == 0) {
|
||||
//It is last element of the document
|
||||
@ -3093,7 +2998,8 @@ public class XMLDocumentFragmentScannerImpl
|
||||
|
||||
if(fScannerState == SCANNER_STATE_REFERENCE){
|
||||
setScannerState(SCANNER_STATE_CONTENT);
|
||||
if (fReplaceEntityReferences && fEntityStore.isDeclaredEntity(fCurrentEntityName)) {
|
||||
if (fReplaceEntityReferences &&
|
||||
fEntityStore.isDeclaredEntity(fCurrentEntityName)) {
|
||||
// Skip the entity reference, we don't care
|
||||
continue;
|
||||
}
|
||||
@ -3126,7 +3032,8 @@ public class XMLDocumentFragmentScannerImpl
|
||||
fStringBuffer.append((char)fEntityScanner.scanChar(null));
|
||||
}
|
||||
}
|
||||
String target = fSymbolTable.addSymbol(fStringBuffer.ch, fStringBuffer.offset, fStringBuffer.length);
|
||||
String target = fSymbolTable.addSymbol(fStringBuffer.ch,
|
||||
fStringBuffer.offset, fStringBuffer.length);
|
||||
fContentBuffer.clear();
|
||||
scanPIData(target, fContentBuffer);
|
||||
}
|
||||
@ -3269,7 +3176,8 @@ public class XMLDocumentFragmentScannerImpl
|
||||
*/
|
||||
|
||||
protected XMLString getString(){
|
||||
if(fAttributeCacheUsedCount < initialCacheCount || fAttributeCacheUsedCount < attributeValueCache.size()){
|
||||
if(fAttributeCacheUsedCount < initialCacheCount ||
|
||||
fAttributeCacheUsedCount < attributeValueCache.size()){
|
||||
return attributeValueCache.get(fAttributeCacheUsedCount++);
|
||||
} else{
|
||||
XMLString str = new XMLString();
|
||||
@ -3299,13 +3207,20 @@ public class XMLDocumentFragmentScannerImpl
|
||||
fAttributes.refresh();
|
||||
}
|
||||
if(fScannerState == SCANNER_STATE_CHARACTER_DATA){
|
||||
//since fTempString directly matches to the underlying main buffer
|
||||
//store the data into buffer
|
||||
fContentBuffer.append(fTempString);
|
||||
//clear the XMLString so that data can't be added again.
|
||||
fTempString.length = 0;
|
||||
fUsebuffer = true;
|
||||
bufferContent();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Since 'TempString' shares the buffer (a char array) with the CurrentEntity,
|
||||
* when the cursor position reaches the end, that is, before the buffer is
|
||||
* being loaded with new data, the content in the TempString needs to be
|
||||
* copied into the ContentBuffer.
|
||||
*/
|
||||
private void bufferContent() {
|
||||
fContentBuffer.append(fTempString);
|
||||
//clear the XMLString so that data can't be added again.
|
||||
fTempString.length = 0;
|
||||
fUsebuffer = true;
|
||||
}
|
||||
} // class XMLDocumentFragmentScannerImpl
|
||||
|
@ -733,9 +733,6 @@ public class XMLDocumentScannerImpl
|
||||
|
||||
|
||||
public int next() throws IOException, XNIException {
|
||||
if(DEBUG_NEXT){
|
||||
System.out.println("NOW IN XMLDeclDriver");
|
||||
}
|
||||
|
||||
// next driver is prolog regardless of whether there
|
||||
// is an XMLDecl in this document
|
||||
@ -745,7 +742,7 @@ public class XMLDocumentScannerImpl
|
||||
//System.out.println("fEntityScanner = " + fEntityScanner);
|
||||
// scan XMLDecl
|
||||
try {
|
||||
if (fEntityScanner.skipString(xmlDecl)) {
|
||||
if (fEntityScanner.skipString(XMLDECL)) {
|
||||
if (fEntityScanner.peekChar() == ' ') {
|
||||
fMarkupDepth++;
|
||||
scanXMLDeclOrTextDecl(false);
|
||||
@ -797,11 +794,7 @@ public class XMLDocumentScannerImpl
|
||||
*/
|
||||
|
||||
public int next() throws IOException, XNIException {
|
||||
//System.out.println("here in next");
|
||||
|
||||
if(DEBUG_NEXT){
|
||||
System.out.println("NOW IN PrologDriver");
|
||||
}
|
||||
try {
|
||||
do {
|
||||
switch (fScannerState) {
|
||||
@ -1014,17 +1007,9 @@ public class XMLDocumentScannerImpl
|
||||
//
|
||||
|
||||
public int next() throws IOException, XNIException{
|
||||
// throw new XNIException("DTD Parsing is currently not supported");
|
||||
if(DEBUG_NEXT){
|
||||
System.out.println("Now in DTD Driver");
|
||||
}
|
||||
|
||||
dispatch(true);
|
||||
|
||||
if(DEBUG_NEXT){
|
||||
System.out.println("After calling dispatch(true) -- At this point whole DTD is read.");
|
||||
}
|
||||
|
||||
//xxx: remove this hack and align this with reusing DTD components
|
||||
//currently this routine will only be executed from Stax
|
||||
if(fPropertyManager != null){
|
||||
@ -1380,10 +1365,9 @@ public class XMLDocumentScannerImpl
|
||||
break;
|
||||
}
|
||||
}
|
||||
}while(fScannerState == SCANNER_STATE_START_OF_MARKUP || fScannerState == SCANNER_STATE_TRAILING_MISC);
|
||||
if(DEBUG_NEXT){
|
||||
System.out.println("State set by deciding while loop [TrailingMiscellaneous] is = " + getScannerStateName(fScannerState));
|
||||
}
|
||||
} while(fScannerState == SCANNER_STATE_START_OF_MARKUP ||
|
||||
fScannerState == SCANNER_STATE_TRAILING_MISC);
|
||||
|
||||
switch (fScannerState){
|
||||
case SCANNER_STATE_PI: {
|
||||
fContentBuffer.clear();
|
||||
|
@ -967,7 +967,7 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
*/
|
||||
|
||||
public void setEntityHandler(com.sun.org.apache.xerces.internal.impl.XMLEntityHandler entityHandler) {
|
||||
fEntityHandler = (XMLEntityHandler) entityHandler;
|
||||
fEntityHandler = entityHandler;
|
||||
} // setEntityHandler(XMLEntityHandler)
|
||||
|
||||
//this function returns StaxXMLInputSource
|
||||
@ -1266,11 +1266,11 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
for (int i = size; i >= 0; i--) {
|
||||
Entity activeEntity = i == size
|
||||
? fCurrentEntity
|
||||
: (Entity)fEntityStack.elementAt(i);
|
||||
: fEntityStack.elementAt(i);
|
||||
if (activeEntity.name == entityName) {
|
||||
String path = entityName;
|
||||
for (int j = i + 1; j < size; j++) {
|
||||
activeEntity = (Entity)fEntityStack.elementAt(j);
|
||||
activeEntity = fEntityStack.elementAt(j);
|
||||
path = path + " -> " + activeEntity.name;
|
||||
}
|
||||
path = path + " -> " + fCurrentEntity.name;
|
||||
@ -1704,7 +1704,7 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
* are recognized by this component.
|
||||
*/
|
||||
public String[] getRecognizedFeatures() {
|
||||
return (String[])(RECOGNIZED_FEATURES.clone());
|
||||
return RECOGNIZED_FEATURES.clone();
|
||||
} // getRecognizedFeatures():String[]
|
||||
|
||||
/**
|
||||
@ -1824,7 +1824,7 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
* are recognized by this component.
|
||||
*/
|
||||
public String[] getRecognizedProperties() {
|
||||
return (String[])(RECOGNIZED_PROPERTIES.clone());
|
||||
return RECOGNIZED_PROPERTIES.clone();
|
||||
} // getRecognizedProperties():String[]
|
||||
/**
|
||||
* Returns the default state for a feature, or null if this
|
||||
@ -2952,7 +2952,7 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
public CharacterBuffer getBuffer(boolean external) {
|
||||
if (external) {
|
||||
if (fExternalTop > -1) {
|
||||
return (CharacterBuffer)fExternalBufferPool[fExternalTop--];
|
||||
return fExternalBufferPool[fExternalTop--];
|
||||
}
|
||||
else {
|
||||
return new CharacterBuffer(true, fExternalBufferSize);
|
||||
@ -2960,7 +2960,7 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
}
|
||||
else {
|
||||
if (fInternalTop > -1) {
|
||||
return (CharacterBuffer)fInternalBufferPool[fInternalTop--];
|
||||
return fInternalBufferPool[fInternalTop--];
|
||||
}
|
||||
else {
|
||||
return new CharacterBuffer(false, fInternalBufferSize);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -35,8 +35,6 @@ import com.sun.org.apache.xerces.internal.util.XMLResourceIdentifierImpl;
|
||||
import com.sun.org.apache.xerces.internal.utils.SecuritySupport;
|
||||
import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
|
||||
import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -142,16 +140,8 @@ public class XMLEntityStorage {
|
||||
return fEntities.get(name);
|
||||
} // getEntity(String)
|
||||
|
||||
public boolean hasEntities() {
|
||||
return (fEntities!=null);
|
||||
} // getEntity(String)
|
||||
|
||||
public int getEntitySize() {
|
||||
return fEntities.size();
|
||||
} // getEntity(String)
|
||||
|
||||
public Enumeration getEntityKeys() {
|
||||
return Collections.enumeration(fEntities.keySet());
|
||||
public Map<String, Entity> getEntities() {
|
||||
return fEntities;
|
||||
}
|
||||
/**
|
||||
* Adds an internal entity declaration.
|
||||
@ -310,9 +300,9 @@ public class XMLEntityStorage {
|
||||
|
||||
fCurrentEntity = fEntityManager.getCurrentEntity();
|
||||
if (!fEntities.containsKey(name)) {
|
||||
Entity entity = new Entity.ExternalEntity(name, new XMLResourceIdentifierImpl(publicId, systemId, baseSystemId, null), notation, fInExternalSubset);
|
||||
// (fCurrentEntity == null) ? fasle : fCurrentEntity.isEntityDeclInExternalSubset());
|
||||
// fCurrentEntity.isEntityDeclInExternalSubset());
|
||||
Entity entity = new Entity.ExternalEntity(name,
|
||||
new XMLResourceIdentifierImpl(publicId, systemId, baseSystemId, null),
|
||||
notation, fInExternalSubset);
|
||||
fEntities.put(name, entity);
|
||||
}
|
||||
else{
|
||||
@ -438,7 +428,7 @@ public class XMLEntityStorage {
|
||||
userDir = userDir.replace(separator, '/');
|
||||
|
||||
int len = userDir.length(), ch;
|
||||
StringBuffer buffer = new StringBuffer(len*3);
|
||||
StringBuilder buffer = new StringBuilder(len*3);
|
||||
// change C:/blah to /C:/blah
|
||||
if (len >= 2 && userDir.charAt(1) == ':') {
|
||||
ch = Character.toUpperCase(userDir.charAt(0));
|
||||
|
@ -1,15 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2005 The Apache Software Foundation.
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@ -24,8 +25,6 @@ import com.sun.xml.internal.stream.dtd.nonvalidating.XMLAttributeDecl;
|
||||
import com.sun.xml.internal.stream.dtd.nonvalidating.XMLElementDecl;
|
||||
import com.sun.xml.internal.stream.dtd.nonvalidating.XMLSimpleType;
|
||||
import com.sun.org.apache.xerces.internal.impl.Constants;
|
||||
import com.sun.org.apache.xerces.internal.impl.XMLEntityManager;
|
||||
import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter;
|
||||
import com.sun.org.apache.xerces.internal.util.SymbolTable;
|
||||
import com.sun.org.apache.xerces.internal.util.XMLChar;
|
||||
import com.sun.org.apache.xerces.internal.util.XMLSymbols;
|
||||
@ -33,13 +32,10 @@ import com.sun.org.apache.xerces.internal.xni.Augmentations;
|
||||
import com.sun.org.apache.xerces.internal.xni.QName;
|
||||
import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
|
||||
import com.sun.org.apache.xerces.internal.xni.XMLAttributes;
|
||||
import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
|
||||
import com.sun.org.apache.xerces.internal.xni.XMLLocator;
|
||||
import com.sun.org.apache.xerces.internal.xni.XMLString;
|
||||
import com.sun.org.apache.xerces.internal.xni.XNIException;
|
||||
import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
|
||||
import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
|
||||
import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource;
|
||||
import javax.xml.XMLConstants;
|
||||
|
||||
/*
|
||||
@ -96,7 +92,7 @@ public class DTDGrammarUtil {
|
||||
private QName fTempQName = new QName();
|
||||
|
||||
/** Temporary string buffers. */
|
||||
private StringBuffer fBuffer = new StringBuffer();
|
||||
private StringBuilder fBuffer = new StringBuilder();
|
||||
|
||||
private NamespaceContext fNamespaceContext = null;
|
||||
|
||||
@ -396,7 +392,7 @@ public class DTDGrammarUtil {
|
||||
XMLSymbols.fENTITYSymbol;
|
||||
}
|
||||
case XMLSimpleType.TYPE_ENUMERATION: {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append('(');
|
||||
for (int i = 0; i < attrDecl.simpleType.enumeration.length; i++) {
|
||||
if (i > 0) {
|
||||
|
@ -1,15 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2005 The Apache Software Foundation.
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@ -34,7 +35,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* A DTD grammar. This class implements the XNI handler interfaces
|
||||
@ -95,8 +95,8 @@ public class DTDGrammar {
|
||||
protected boolean fReadingExternalDTD = false;
|
||||
|
||||
/** Symbol table. */
|
||||
private SymbolTable fSymbolTable;
|
||||
private ArrayList notationDecls = new ArrayList();
|
||||
private final SymbolTable fSymbolTable;
|
||||
private final ArrayList<XMLNotationDecl> notationDecls = new ArrayList<>();
|
||||
|
||||
// element declarations
|
||||
|
||||
@ -334,18 +334,19 @@ public class DTDGrammar {
|
||||
fSimpleType.clear();
|
||||
if ( defaultType != null ) {
|
||||
if ( defaultType.equals( "#FIXED") ) {
|
||||
fSimpleType.defaultType = fSimpleType.DEFAULT_TYPE_FIXED;
|
||||
fSimpleType.defaultType = XMLSimpleType.DEFAULT_TYPE_FIXED;
|
||||
} else if ( defaultType.equals( "#IMPLIED") ) {
|
||||
fSimpleType.defaultType = fSimpleType.DEFAULT_TYPE_IMPLIED;
|
||||
fSimpleType.defaultType = XMLSimpleType.DEFAULT_TYPE_IMPLIED;
|
||||
} else if ( defaultType.equals( "#REQUIRED") ) {
|
||||
fSimpleType.defaultType = fSimpleType.DEFAULT_TYPE_REQUIRED;
|
||||
fSimpleType.defaultType = XMLSimpleType.DEFAULT_TYPE_REQUIRED;
|
||||
}
|
||||
}
|
||||
if ( DEBUG ) {
|
||||
System.out.println("defaultvalue = " + defaultValue.toString() );
|
||||
}
|
||||
fSimpleType.defaultValue = defaultValue!=null ? defaultValue.toString() : null;
|
||||
fSimpleType.nonNormalizedDefaultValue = nonNormalizedDefaultValue!=null ? nonNormalizedDefaultValue.toString() : null;
|
||||
fSimpleType.defaultValue = defaultValue!=null ? defaultValue.toString() : null;
|
||||
fSimpleType.nonNormalizedDefaultValue = nonNormalizedDefaultValue!=null ?
|
||||
nonNormalizedDefaultValue.toString() : null;
|
||||
fSimpleType.enumeration = enumeration;
|
||||
|
||||
if (type.equals("CDATA")) {
|
||||
@ -731,7 +732,7 @@ public class DTDGrammar {
|
||||
notationDecls.add(notationDecl);
|
||||
}
|
||||
|
||||
public List getNotationDecls(){
|
||||
public List<XMLNotationDecl> getNotationDecls() {
|
||||
return notationDecls;
|
||||
}
|
||||
|
||||
|
@ -3,13 +3,14 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2005 The Apache Software Foundation.
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
@ -3,13 +3,14 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2005 The Apache Software Foundation.
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
@ -3,13 +3,14 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2005 The Apache Software Foundation.
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2016, 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
|
||||
@ -25,80 +25,88 @@
|
||||
|
||||
package com.sun.xml.internal.stream.events;
|
||||
|
||||
import java.util.List;
|
||||
import javax.xml.stream.events.DTD;
|
||||
import javax.xml.stream.events.EntityDeclaration;
|
||||
import javax.xml.stream.events.NotationDeclaration;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Neeraj Bajaj, Sun Microsystesm.
|
||||
* @author Neeraj Bajaj, Sun Microsystesm.
|
||||
*
|
||||
*/
|
||||
public class DTDEvent extends DummyEvent implements DTD{
|
||||
public class DTDEvent extends DummyEvent implements DTD {
|
||||
|
||||
private String fDoctypeDeclaration;
|
||||
private java.util.List fNotations;
|
||||
private java.util.List fEntities;
|
||||
private List<NotationDeclaration> fNotations;
|
||||
private List<EntityDeclaration> fEntities;
|
||||
|
||||
/** Creates a new instance of DTDEvent */
|
||||
/**
|
||||
* Creates a new instance of DTDEvent
|
||||
*/
|
||||
public DTDEvent() {
|
||||
init();
|
||||
}
|
||||
|
||||
public DTDEvent(String doctypeDeclaration){
|
||||
public DTDEvent(String doctypeDeclaration) {
|
||||
init();
|
||||
fDoctypeDeclaration = doctypeDeclaration;
|
||||
}
|
||||
|
||||
public void setDocumentTypeDeclaration(String doctypeDeclaration){
|
||||
public void setDocumentTypeDeclaration(String doctypeDeclaration) {
|
||||
fDoctypeDeclaration = doctypeDeclaration;
|
||||
}
|
||||
|
||||
@Override
|
||||
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){
|
||||
public void setEntities(List<EntityDeclaration> entites) {
|
||||
fEntities = entites;
|
||||
}
|
||||
|
||||
public java.util.List getEntities() {
|
||||
@Override
|
||||
public List<EntityDeclaration> 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){
|
||||
public void setNotations(List<NotationDeclaration> notations) {
|
||||
fNotations = notations;
|
||||
}
|
||||
|
||||
public java.util.List getNotations() {
|
||||
@Override
|
||||
public List<NotationDeclaration> getNotations() {
|
||||
return fNotations;
|
||||
}
|
||||
|
||||
/**
|
||||
*Returns an implementation defined representation of the DTD.
|
||||
* This method may return null if no representation is available.
|
||||
* Returns an implementation defined representation of the DTD. This method
|
||||
* may return null if no representation is available.
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public Object getProcessedDTD() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void init(){
|
||||
protected final void init() {
|
||||
setEventType(XMLEvent.DTD);
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return fDoctypeDeclaration ;
|
||||
@Override
|
||||
public String toString() {
|
||||
return fDoctypeDeclaration;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeAsEncodedUnicodeEx(java.io.Writer writer)
|
||||
throws java.io.IOException
|
||||
{
|
||||
throws java.io.IOException {
|
||||
writer.write(fDoctypeDeclaration);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2016, 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
|
||||
@ -22,8 +22,7 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.stream.events ;
|
||||
package com.sun.xml.internal.stream.events;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
@ -31,35 +30,33 @@ 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.
|
||||
/**
|
||||
* Implementation of EndElement event.
|
||||
*
|
||||
* @author Neeraj Bajaj Sun Microsystems,Inc.
|
||||
* @author K.Venugopal Sun Microsystems,Inc.
|
||||
*/
|
||||
|
||||
public class EndElementEvent extends DummyEvent
|
||||
implements EndElement {
|
||||
implements EndElement {
|
||||
|
||||
List fNamespaces = null;
|
||||
QName fQName ;
|
||||
List<Namespace> fNamespaces = null;
|
||||
QName fQName;
|
||||
|
||||
public EndElementEvent() {
|
||||
init();
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
protected final void init() {
|
||||
setEventType(XMLEvent.END_ELEMENT);
|
||||
fNamespaces = new ArrayList();
|
||||
fNamespaces = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
public EndElementEvent(String prefix, String uri, String localpart) {
|
||||
this(new QName(uri,localpart,prefix));
|
||||
public EndElementEvent(String prefix, String uri, String localpart) {
|
||||
this(new QName(uri, localpart, prefix));
|
||||
}
|
||||
|
||||
public EndElementEvent(QName qname) {
|
||||
@ -67,6 +64,7 @@ implements EndElement {
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QName getName() {
|
||||
return fQName;
|
||||
}
|
||||
@ -75,34 +73,36 @@ implements EndElement {
|
||||
this.fQName = qname;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeAsEncodedUnicodeEx(java.io.Writer writer)
|
||||
throws java.io.IOException
|
||||
{
|
||||
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
|
||||
/**
|
||||
* 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)
|
||||
@Override
|
||||
public Iterator<Namespace> getNamespaces() {
|
||||
if (fNamespaces != null) {
|
||||
fNamespaces.iterator();
|
||||
return new ReadOnlyIterator();
|
||||
}
|
||||
return new ReadOnlyIterator<>();
|
||||
}
|
||||
|
||||
void addNamespace(Namespace attr){
|
||||
if(attr != null){
|
||||
fNamespaces.add(attr);
|
||||
void addNamespace(Namespace ns) {
|
||||
if (ns != null) {
|
||||
fNamespaces.add(ns);
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,12 +113,15 @@ implements EndElement {
|
||||
}
|
||||
|
||||
public String nameAsString() {
|
||||
if("".equals(fQName.getNamespaceURI()))
|
||||
if ("".equals(fQName.getNamespaceURI())) {
|
||||
return fQName.getLocalPart();
|
||||
if(fQName.getPrefix() != null)
|
||||
}
|
||||
|
||||
if (fQName.getPrefix() != null) {
|
||||
return "['" + fQName.getNamespaceURI() + "']:" + fQName.getPrefix() + ":" + fQName.getLocalPart();
|
||||
else
|
||||
} else {
|
||||
return "['" + fQName.getNamespaceURI() + "']:" + fQName.getLocalPart();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2016, 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
|
||||
@ -23,35 +23,33 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package com.sun.xml.internal.stream.events ;
|
||||
package com.sun.xml.internal.stream.events;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import com.sun.xml.internal.stream.util.ReadOnlyIterator;
|
||||
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 java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.xml.namespace.NamespaceContext;
|
||||
import java.io.Writer;
|
||||
import com.sun.xml.internal.stream.util.ReadOnlyIterator;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.XMLStreamConstants;
|
||||
import javax.xml.stream.events.Attribute;
|
||||
import javax.xml.stream.events.Namespace;
|
||||
import javax.xml.stream.events.StartElement;
|
||||
|
||||
/** Implementation of StartElementEvent.
|
||||
/**
|
||||
* Implementation of StartElementEvent.
|
||||
*
|
||||
* @author Neeraj Bajaj Sun Microsystems,Inc.
|
||||
* @author K.Venugopal Sun Microsystems,Inc.
|
||||
*/
|
||||
|
||||
public class StartElementEvent extends DummyEvent
|
||||
implements StartElement {
|
||||
implements StartElement {
|
||||
|
||||
private Map fAttributes;
|
||||
private List fNamespaces;
|
||||
private Map<QName, Attribute> fAttributes;
|
||||
private List<Namespace> fNamespaces;
|
||||
private NamespaceContext fNamespaceContext = null;
|
||||
private QName fQName;
|
||||
|
||||
@ -70,12 +68,13 @@ implements StartElement {
|
||||
addNamespaceAttributes(startelement.getNamespaces());
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
protected final void init() {
|
||||
setEventType(XMLStreamConstants.START_ELEMENT);
|
||||
fAttributes = new HashMap();
|
||||
fNamespaces = new ArrayList();
|
||||
fAttributes = new HashMap<>();
|
||||
fNamespaces = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QName getName() {
|
||||
return fQName;
|
||||
}
|
||||
@ -84,50 +83,60 @@ implements StartElement {
|
||||
this.fQName = qname;
|
||||
}
|
||||
|
||||
public Iterator getAttributes() {
|
||||
if(fAttributes != null){
|
||||
Collection coll = fAttributes.values();
|
||||
return new ReadOnlyIterator(coll.iterator());
|
||||
@Override
|
||||
public Iterator<Attribute> getAttributes() {
|
||||
if (fAttributes != null) {
|
||||
Collection<Attribute> coll = fAttributes.values();
|
||||
return new ReadOnlyIterator<>(coll.iterator());
|
||||
}
|
||||
return new ReadOnlyIterator();
|
||||
return new ReadOnlyIterator<>();
|
||||
}
|
||||
|
||||
public Iterator getNamespaces() {
|
||||
if(fNamespaces != null){
|
||||
return new ReadOnlyIterator(fNamespaces.iterator());
|
||||
@Override
|
||||
public Iterator<Namespace> getNamespaces() {
|
||||
if (fNamespaces != null) {
|
||||
return new ReadOnlyIterator<>(fNamespaces.iterator());
|
||||
}
|
||||
return new ReadOnlyIterator();
|
||||
return new ReadOnlyIterator<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Attribute getAttributeByName(QName qname) {
|
||||
if(qname == null)
|
||||
if (qname == null) {
|
||||
return null;
|
||||
return (Attribute)fAttributes.get(qname);
|
||||
}
|
||||
return fAttributes.get(qname);
|
||||
}
|
||||
|
||||
public String getNamespace(){
|
||||
public String getNamespace() {
|
||||
return fQName.getNamespaceURI();
|
||||
}
|
||||
|
||||
@Override
|
||||
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();
|
||||
if (getNamespace() != null && fQName.getPrefix().equals(prefix)) {
|
||||
return getNamespace();
|
||||
}
|
||||
//else check the namespace context
|
||||
if(fNamespaceContext != null)
|
||||
if (fNamespaceContext != null) {
|
||||
return fNamespaceContext.getNamespaceURI(prefix);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Return a <code>String</code> representation of this
|
||||
* <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.
|
||||
* <code>StartElement</code> formatted as XML.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
StringBuffer startElement = new StringBuffer();
|
||||
StringBuilder startElement = new StringBuilder();
|
||||
|
||||
// open element
|
||||
startElement.append("<");
|
||||
@ -135,10 +144,10 @@ implements StartElement {
|
||||
|
||||
// add any attributes
|
||||
if (fAttributes != null) {
|
||||
Iterator it = this.getAttributes();
|
||||
Attribute attr = null;
|
||||
Iterator<Attribute> it = this.getAttributes();
|
||||
Attribute attr;
|
||||
while (it.hasNext()) {
|
||||
attr = (Attribute) it.next();
|
||||
attr = it.next();
|
||||
startElement.append(" ");
|
||||
startElement.append(attr.toString());
|
||||
}
|
||||
@ -146,12 +155,12 @@ implements StartElement {
|
||||
|
||||
// add any namespaces
|
||||
if (fNamespaces != null) {
|
||||
Iterator it = fNamespaces.iterator();
|
||||
Namespace attr = null;
|
||||
Iterator<Namespace> it = fNamespaces.iterator();
|
||||
Namespace ns;
|
||||
while (it.hasNext()) {
|
||||
attr = (Namespace) it.next();
|
||||
ns = it.next();
|
||||
startElement.append(" ");
|
||||
startElement.append(attr.toString());
|
||||
startElement.append(ns.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -162,26 +171,31 @@ implements StartElement {
|
||||
return startElement.toString();
|
||||
}
|
||||
|
||||
/** Return this event as String
|
||||
/**
|
||||
* Return this event as String
|
||||
*
|
||||
* @return String Event returned as string.
|
||||
*/
|
||||
public String nameAsString() {
|
||||
if("".equals(fQName.getNamespaceURI()))
|
||||
if ("".equals(fQName.getNamespaceURI())) {
|
||||
return fQName.getLocalPart();
|
||||
if(fQName.getPrefix() != null)
|
||||
return "['" + fQName.getNamespaceURI() + "']:" + fQName.getPrefix() + ":" + fQName.getLocalPart();
|
||||
else
|
||||
}
|
||||
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.
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
@Override
|
||||
public NamespaceContext getNamespaceContext() {
|
||||
return fNamespaceContext;
|
||||
}
|
||||
@ -190,40 +204,43 @@ implements StartElement {
|
||||
fNamespaceContext = nc;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeAsEncodedUnicodeEx(java.io.Writer writer)
|
||||
throws java.io.IOException
|
||||
{
|
||||
throws java.io.IOException {
|
||||
writer.write(toString());
|
||||
}
|
||||
|
||||
void addAttribute(Attribute attr){
|
||||
if(attr.isNamespace()){
|
||||
fNamespaces.add(attr);
|
||||
}else{
|
||||
fAttributes.put(attr.getName(),attr);
|
||||
void addAttribute(Attribute attr) {
|
||||
if (attr.isNamespace()) {
|
||||
fNamespaces.add((Namespace) attr);
|
||||
} else {
|
||||
fAttributes.put(attr.getName(), attr);
|
||||
}
|
||||
}
|
||||
|
||||
void addAttributes(Iterator attrs){
|
||||
if(attrs == null)
|
||||
final void addAttributes(Iterator<? extends Attribute> attrs) {
|
||||
if (attrs == null) {
|
||||
return;
|
||||
while(attrs.hasNext()){
|
||||
Attribute attr = (Attribute)attrs.next();
|
||||
fAttributes.put(attr.getName(),attr);
|
||||
}
|
||||
while (attrs.hasNext()) {
|
||||
Attribute attr = attrs.next();
|
||||
fAttributes.put(attr.getName(), attr);
|
||||
}
|
||||
}
|
||||
|
||||
void addNamespaceAttribute(Namespace attr){
|
||||
if(attr == null)
|
||||
void addNamespaceAttribute(Namespace attr) {
|
||||
if (attr == null) {
|
||||
return;
|
||||
}
|
||||
fNamespaces.add(attr);
|
||||
}
|
||||
|
||||
void addNamespaceAttributes(Iterator attrs){
|
||||
if(attrs == null)
|
||||
final void addNamespaceAttributes(Iterator<? extends Namespace> attrs) {
|
||||
if (attrs == null) {
|
||||
return;
|
||||
while(attrs.hasNext()){
|
||||
Namespace attr = (Namespace)attrs.next();
|
||||
}
|
||||
while (attrs.hasNext()) {
|
||||
Namespace attr = attrs.next();
|
||||
fNamespaces.add(attr);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2016, 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
|
||||
@ -22,7 +22,6 @@
|
||||
* 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;
|
||||
@ -34,29 +33,36 @@ 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;
|
||||
import javax.xml.stream.util.XMLEventConsumer;
|
||||
|
||||
/**
|
||||
* Implementation of XMLEvent Allocator.
|
||||
*
|
||||
* @author Neeraj.bajaj@sun.com, k.venugopal@sun.com
|
||||
*/
|
||||
public class XMLEventAllocatorImpl implements XMLEventAllocator {
|
||||
|
||||
/** Creates a new instance of 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 )
|
||||
public XMLEvent allocate(XMLStreamReader xMLStreamReader) throws 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 {
|
||||
public void allocate(XMLStreamReader xMLStreamReader, XMLEventConsumer xMLEventConsumer)
|
||||
throws XMLStreamException {
|
||||
XMLEvent currentEvent = getXMLEvent(xMLStreamReader);
|
||||
if(currentEvent != null )
|
||||
if (currentEvent != null) {
|
||||
xMLEventConsumer.add(currentEvent);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@ -66,141 +72,149 @@ public class XMLEventAllocatorImpl implements XMLEventAllocator {
|
||||
}
|
||||
|
||||
//REVISIT: shouldn't we be using XMLEventFactory to create events.
|
||||
XMLEvent getXMLEvent(XMLStreamReader streamReader){
|
||||
XMLEvent getXMLEvent(XMLStreamReader streamReader) {
|
||||
XMLEvent event = null;
|
||||
//returns the current event
|
||||
int eventType = streamReader.getEventType();
|
||||
switch(eventType){
|
||||
switch (eventType) {
|
||||
|
||||
case XMLEvent.START_ELEMENT:{
|
||||
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() ){
|
||||
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))) {
|
||||
fillNamespaceAttributes(startElementEvent, streamReader);
|
||||
setNamespaceContext(startElementEvent,streamReader);
|
||||
setNamespaceContext(startElementEvent, streamReader);
|
||||
}
|
||||
|
||||
startElementEvent.setLocation(streamReader.getLocation());
|
||||
event = startElementEvent ;
|
||||
event = startElementEvent;
|
||||
break;
|
||||
}
|
||||
case XMLEvent.END_ELEMENT:{
|
||||
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);
|
||||
if (((Boolean) streamReader.getProperty(XMLInputFactory.IS_NAMESPACE_AWARE))) {
|
||||
fillNamespaceAttributes(endElementEvent, streamReader);
|
||||
}
|
||||
event = endElementEvent ;
|
||||
event = endElementEvent;
|
||||
break;
|
||||
}
|
||||
case XMLEvent.PROCESSING_INSTRUCTION:{
|
||||
ProcessingInstructionEvent piEvent = new ProcessingInstructionEvent(streamReader.getPITarget(),streamReader.getPIData());
|
||||
case XMLEvent.PROCESSING_INSTRUCTION: {
|
||||
ProcessingInstructionEvent piEvent = new ProcessingInstructionEvent(
|
||||
streamReader.getPITarget(), streamReader.getPIData());
|
||||
piEvent.setLocation(streamReader.getLocation());
|
||||
event = piEvent ;
|
||||
event = piEvent;
|
||||
break;
|
||||
}
|
||||
case XMLEvent.CHARACTERS:{
|
||||
case XMLEvent.CHARACTERS: {
|
||||
CharacterEvent cDataEvent = new CharacterEvent(streamReader.getText());
|
||||
cDataEvent.setLocation(streamReader.getLocation());
|
||||
event = cDataEvent ;
|
||||
event = cDataEvent;
|
||||
break;
|
||||
}
|
||||
case XMLEvent.COMMENT:{
|
||||
case XMLEvent.COMMENT: {
|
||||
CommentEvent commentEvent = new CommentEvent(streamReader.getText());
|
||||
commentEvent.setLocation(streamReader.getLocation());
|
||||
event = commentEvent ;
|
||||
event = commentEvent;
|
||||
break;
|
||||
}
|
||||
case XMLEvent.START_DOCUMENT:{
|
||||
case XMLEvent.START_DOCUMENT: {
|
||||
StartDocumentEvent sdEvent = new StartDocumentEvent();
|
||||
sdEvent.setVersion(streamReader.getVersion());
|
||||
sdEvent.setEncoding(streamReader.getEncoding());
|
||||
if(streamReader.getCharacterEncodingScheme() != null){
|
||||
if (streamReader.getCharacterEncodingScheme() != null) {
|
||||
sdEvent.setDeclaredEncoding(true);
|
||||
}else{
|
||||
} else {
|
||||
sdEvent.setDeclaredEncoding(false);
|
||||
}
|
||||
sdEvent.setStandalone(streamReader.isStandalone());
|
||||
sdEvent.setLocation(streamReader.getLocation());
|
||||
event = sdEvent ;
|
||||
event = sdEvent;
|
||||
break;
|
||||
}
|
||||
case XMLEvent.END_DOCUMENT:{
|
||||
EndDocumentEvent endDocumentEvent = new EndDocumentEvent() ;
|
||||
case XMLEvent.END_DOCUMENT: {
|
||||
EndDocumentEvent endDocumentEvent = new EndDocumentEvent();
|
||||
endDocumentEvent.setLocation(streamReader.getLocation());
|
||||
event = endDocumentEvent ;
|
||||
event = endDocumentEvent;
|
||||
break;
|
||||
}
|
||||
case XMLEvent.ENTITY_REFERENCE:{
|
||||
EntityReferenceEvent entityEvent = new EntityReferenceEvent(streamReader.getLocalName(), new EntityDeclarationImpl(streamReader.getLocalName(),streamReader.getText()));
|
||||
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 ;
|
||||
case XMLEvent.ATTRIBUTE: {
|
||||
event = null;
|
||||
break;
|
||||
}
|
||||
case XMLEvent.DTD:{
|
||||
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);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<EntityDeclaration> entities = (List<EntityDeclaration>)
|
||||
streamReader.getProperty(PropertyManager.STAX_ENTITIES);
|
||||
if (entities != null && entities.size() != 0) {
|
||||
dtdEvent.setEntities(entities);
|
||||
}
|
||||
@SuppressWarnings("unchecked")
|
||||
List<NotationDeclaration> notations = (List<NotationDeclaration>)
|
||||
streamReader.getProperty(PropertyManager.STAX_NOTATIONS);
|
||||
if (notations != null && !notations.isEmpty()) {
|
||||
dtdEvent.setNotations(notations);
|
||||
}
|
||||
event = dtdEvent;
|
||||
break;
|
||||
}
|
||||
case XMLEvent.CDATA:{
|
||||
CharacterEvent cDataEvent = new CharacterEvent(streamReader.getText(),true);
|
||||
case XMLEvent.CDATA: {
|
||||
CharacterEvent cDataEvent = new CharacterEvent(streamReader.getText(), true);
|
||||
cDataEvent.setLocation(streamReader.getLocation());
|
||||
event = cDataEvent ;
|
||||
event = cDataEvent;
|
||||
break;
|
||||
}
|
||||
case XMLEvent.SPACE:{
|
||||
CharacterEvent spaceEvent = new CharacterEvent(streamReader.getText(),false,true);
|
||||
case XMLEvent.SPACE: {
|
||||
CharacterEvent spaceEvent = new CharacterEvent(streamReader.getText(), false, true);
|
||||
spaceEvent.setLocation(streamReader.getLocation());
|
||||
event = spaceEvent ;
|
||||
event = spaceEvent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return event ;
|
||||
return event;
|
||||
}
|
||||
|
||||
//this function is not used..
|
||||
protected XMLEvent getNextEvent(XMLStreamReader streamReader) throws XMLStreamException{
|
||||
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){
|
||||
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++){
|
||||
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);
|
||||
* }
|
||||
**/
|
||||
* 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));
|
||||
@ -210,42 +224,42 @@ public class XMLEventAllocatorImpl implements XMLEventAllocator {
|
||||
}
|
||||
}
|
||||
|
||||
protected void fillNamespaceAttributes(StartElementEvent event,XMLStreamReader xmlr){
|
||||
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++){
|
||||
for (int i = 0; i < count; i++) {
|
||||
uri = xmlr.getNamespaceURI(i);
|
||||
prefix = xmlr.getNamespacePrefix(i);
|
||||
if(prefix == null){
|
||||
if (prefix == null) {
|
||||
prefix = XMLConstants.DEFAULT_NS_PREFIX;
|
||||
}
|
||||
attr = new NamespaceImpl(prefix,uri);
|
||||
attr = new NamespaceImpl(prefix, uri);
|
||||
event.addNamespaceAttribute(attr);
|
||||
}
|
||||
}
|
||||
|
||||
protected void fillNamespaceAttributes(EndElementEvent event,XMLStreamReader xmlr){
|
||||
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++){
|
||||
for (int i = 0; i < count; i++) {
|
||||
uri = xmlr.getNamespaceURI(i);
|
||||
prefix = xmlr.getNamespacePrefix(i);
|
||||
if(prefix == null){
|
||||
if (prefix == null) {
|
||||
prefix = XMLConstants.DEFAULT_NS_PREFIX;
|
||||
}
|
||||
attr = new NamespaceImpl(prefix,uri);
|
||||
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();
|
||||
private void setNamespaceContext(StartElementEvent event, XMLStreamReader xmlr) {
|
||||
NamespaceContextWrapper contextWrapper = (NamespaceContextWrapper) xmlr.getNamespaceContext();
|
||||
NamespaceSupport ns = new NamespaceSupport(contextWrapper.getNamespaceContext());
|
||||
event.setNamespaceContext(new NamespaceContextWrapper(ns));
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2016, 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
|
||||
@ -25,10 +25,19 @@
|
||||
|
||||
package com.sun.xml.internal.stream.events;
|
||||
|
||||
import java.util.Iterator;
|
||||
import javax.xml.namespace.NamespaceContext;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.XMLEventFactory;
|
||||
import javax.xml.stream.Location;
|
||||
import javax.xml.stream.events.Attribute;
|
||||
import javax.xml.stream.events.Characters;
|
||||
import javax.xml.stream.events.ProcessingInstruction;
|
||||
import javax.xml.stream.events.Namespace;
|
||||
import javax.xml.stream.events.EntityDeclaration;
|
||||
import javax.xml.stream.events.EntityReference;
|
||||
import javax.xml.stream.events.StartDocument;
|
||||
import javax.xml.stream.events.StartElement;
|
||||
|
||||
|
||||
/**
|
||||
@ -42,23 +51,27 @@ public class XMLEventFactoryImpl extends XMLEventFactory {
|
||||
public XMLEventFactoryImpl() {
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.Attribute createAttribute(String localName, String value) {
|
||||
@Override
|
||||
public 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) {
|
||||
@Override
|
||||
public Attribute createAttribute(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) {
|
||||
@Override
|
||||
public 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) {
|
||||
@Override
|
||||
public 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);
|
||||
@ -66,126 +79,156 @@ public class XMLEventFactoryImpl extends XMLEventFactory {
|
||||
return charEvent;
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.Characters createCharacters(String content) {
|
||||
@Override
|
||||
public Characters createCharacters(String content) {
|
||||
CharacterEvent charEvent = new CharacterEvent(content);
|
||||
if(location != null)charEvent.setLocation(location);
|
||||
return charEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public javax.xml.stream.events.Comment createComment(String text) {
|
||||
CommentEvent charEvent = new CommentEvent(text);
|
||||
if(location != null)charEvent.setLocation(location);
|
||||
return charEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public javax.xml.stream.events.DTD createDTD(String dtd) {
|
||||
DTDEvent dtdEvent = new DTDEvent(dtd);
|
||||
if(location != null)dtdEvent.setLocation(location);
|
||||
return dtdEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
@Override
|
||||
public javax.xml.stream.events.EndElement createEndElement(QName name,
|
||||
Iterator<? extends Namespace> namespaces) {
|
||||
return createEndElement(name.getPrefix(), name.getNamespaceURI(), name.getLocalPart());
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.EndElement createEndElement(String prefix, String namespaceUri, String localName) {
|
||||
@Override
|
||||
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) {
|
||||
@Override
|
||||
public javax.xml.stream.events.EndElement createEndElement(String prefix, String namespaceUri,
|
||||
String localName, Iterator<? extends Namespace> namespaces) {
|
||||
|
||||
EndElementEvent event = new EndElementEvent(prefix, namespaceUri, localName);
|
||||
if(namespaces!=null){
|
||||
while(namespaces.hasNext())
|
||||
event.addNamespace((Namespace)namespaces.next());
|
||||
event.addNamespace(namespaces.next());
|
||||
}
|
||||
if(location != null)event.setLocation(location);
|
||||
return event;
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.EntityReference createEntityReference(String name, EntityDeclaration entityDeclaration) {
|
||||
@Override
|
||||
public 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) {
|
||||
@Override
|
||||
public 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) {
|
||||
@Override
|
||||
public 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) {
|
||||
@Override
|
||||
public 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) {
|
||||
@Override
|
||||
public 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) {
|
||||
@Override
|
||||
public Characters createSpace(String content) {
|
||||
CharacterEvent event = new CharacterEvent(content);
|
||||
if(location != null)event.setLocation(location);
|
||||
return event;
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.StartDocument createStartDocument() {
|
||||
@Override
|
||||
public StartDocument createStartDocument() {
|
||||
StartDocumentEvent event = new StartDocumentEvent();
|
||||
if(location != null)event.setLocation(location);
|
||||
return event;
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.StartDocument createStartDocument(String encoding) {
|
||||
@Override
|
||||
public 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) {
|
||||
@Override
|
||||
public 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) {
|
||||
@Override
|
||||
public 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);
|
||||
@Override
|
||||
public StartElement createStartElement(QName name, Iterator<? extends Attribute> attributes,
|
||||
Iterator<? extends Namespace> namespaces) {
|
||||
return createStartElement(name.getPrefix(), name.getNamespaceURI(),
|
||||
name.getLocalPart(), attributes, namespaces);
|
||||
}
|
||||
|
||||
public javax.xml.stream.events.StartElement createStartElement(String prefix, String namespaceUri, String localName) {
|
||||
@Override
|
||||
public 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) {
|
||||
@Override
|
||||
public StartElement createStartElement(String prefix, String namespaceUri,
|
||||
String localName, Iterator<? extends Attribute> attributes,
|
||||
Iterator<? extends Namespace> 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) {
|
||||
@Override
|
||||
public StartElement createStartElement(String prefix, String namespaceUri,
|
||||
String localName, Iterator<? extends Attribute> attributes,
|
||||
Iterator<? extends Namespace> namespaces, NamespaceContext context) {
|
||||
StartElementEvent elem = new StartElementEvent(prefix, namespaceUri, localName);
|
||||
elem.addAttributes(attributes);
|
||||
elem.addNamespaceAttributes(namespaces);
|
||||
@ -194,6 +237,7 @@ public class XMLEventFactoryImpl extends XMLEventFactory {
|
||||
return elem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(javax.xml.stream.Location location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2016, 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
|
||||
@ -31,35 +31,32 @@ package com.sun.xml.internal.stream.util;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class ReadOnlyIterator implements Iterator {
|
||||
public class ReadOnlyIterator<T> implements Iterator<T> {
|
||||
|
||||
Iterator iterator = null;
|
||||
Iterator<T> iterator = null;
|
||||
|
||||
public ReadOnlyIterator(){
|
||||
}
|
||||
|
||||
public ReadOnlyIterator(Iterator itr){
|
||||
public ReadOnlyIterator(Iterator<T> itr){
|
||||
iterator = itr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
if(iterator != null)
|
||||
return iterator.hasNext();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public Object next() {
|
||||
@Override
|
||||
public T next() {
|
||||
if(iterator != null)
|
||||
return iterator.next();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException("Remove operation is not supported");
|
||||
}
|
||||
|
@ -39,15 +39,15 @@ import java.lang.ref.*;
|
||||
* @author Santiago.PericasGeertsen@sun.com
|
||||
*/
|
||||
public class ThreadLocalBufferAllocator {
|
||||
private static ThreadLocal tlba = new ThreadLocal();
|
||||
private static ThreadLocal<SoftReference> tlba = new ThreadLocal<>();
|
||||
|
||||
public static BufferAllocator getBufferAllocator() {
|
||||
SoftReference bAllocatorRef = (SoftReference) tlba.get();
|
||||
SoftReference<BufferAllocator> bAllocatorRef = tlba.get();
|
||||
if (bAllocatorRef == null || bAllocatorRef.get() == null) {
|
||||
bAllocatorRef = new SoftReference(new BufferAllocator());
|
||||
tlba.set(bAllocatorRef);
|
||||
}
|
||||
|
||||
return (BufferAllocator) bAllocatorRef.get();
|
||||
return bAllocatorRef.get();
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ public final class UTF8OutputStreamWriter extends Writer {
|
||||
// Otherwise, encode char as defined in UTF-8
|
||||
if (c < 0x80) {
|
||||
// 1 byte, 7 bits
|
||||
out.write((int) c);
|
||||
out.write(c);
|
||||
}
|
||||
else if (c < 0x800) {
|
||||
// 2 bytes, 11 bits
|
||||
|
@ -26,9 +26,12 @@
|
||||
package com.sun.xml.internal.stream.writers;
|
||||
|
||||
import java.util.Iterator;
|
||||
import javax.xml.namespace.NamespaceContext;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.XMLEventReader;
|
||||
import javax.xml.stream.XMLEventWriter;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.stream.events.Attribute;
|
||||
import javax.xml.stream.events.Characters;
|
||||
import javax.xml.stream.events.Comment;
|
||||
@ -39,24 +42,24 @@ import javax.xml.stream.events.ProcessingInstruction;
|
||||
import javax.xml.stream.events.StartDocument;
|
||||
import javax.xml.stream.events.StartElement;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Neeraj Bajaj, Sun Microsystems.
|
||||
* @author Neeraj Bajaj, Sun Microsystems.
|
||||
*
|
||||
*/
|
||||
public class XMLEventWriterImpl implements XMLEventWriter{
|
||||
public class XMLEventWriterImpl implements XMLEventWriter {
|
||||
|
||||
//delegate everything to XMLStreamWriter..
|
||||
private final XMLStreamWriterBase fStreamWriter ;
|
||||
private final XMLStreamWriterBase fStreamWriter;
|
||||
private static final boolean DEBUG = false;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param streamWriter
|
||||
*/
|
||||
public XMLEventWriterImpl(XMLStreamWriter streamWriter){
|
||||
fStreamWriter = (XMLStreamWriterBase)streamWriter;
|
||||
public XMLEventWriterImpl(XMLStreamWriter streamWriter) {
|
||||
fStreamWriter = (XMLStreamWriterBase) streamWriter;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,9 +67,11 @@ public class XMLEventWriterImpl implements XMLEventWriter{
|
||||
* @param xMLEventReader
|
||||
* @throws XMLStreamException
|
||||
*/
|
||||
public void add(javax.xml.stream.XMLEventReader xMLEventReader) throws javax.xml.stream.XMLStreamException {
|
||||
if(xMLEventReader == null) throw new XMLStreamException("Event reader shouldn't be null");
|
||||
while(xMLEventReader.hasNext()){
|
||||
public void add(XMLEventReader xMLEventReader) throws XMLStreamException {
|
||||
if (xMLEventReader == null) {
|
||||
throw new XMLStreamException("Event reader shouldn't be null");
|
||||
}
|
||||
while (xMLEventReader.hasNext()) {
|
||||
add(xMLEventReader.nextEvent());
|
||||
}
|
||||
}
|
||||
@ -76,101 +81,127 @@ public class XMLEventWriterImpl implements XMLEventWriter{
|
||||
* @param xMLEvent
|
||||
* @throws XMLStreamException
|
||||
*/
|
||||
public void add(javax.xml.stream.events.XMLEvent xMLEvent) throws javax.xml.stream.XMLStreamException {
|
||||
public void add(XMLEvent xMLEvent) throws XMLStreamException {
|
||||
int type = xMLEvent.getEventType();
|
||||
switch(type){
|
||||
case XMLEvent.DTD:{
|
||||
DTD dtd = (DTD)xMLEvent ;
|
||||
if (DEBUG)System.out.println("Adding DTD = " + dtd.toString());
|
||||
switch (type) {
|
||||
case XMLEvent.DTD: {
|
||||
DTD dtd = (DTD) xMLEvent;
|
||||
if (DEBUG) {
|
||||
System.out.println("Adding DTD = " + dtd.toString());
|
||||
}
|
||||
fStreamWriter.writeDTD(dtd.getDocumentTypeDeclaration());
|
||||
break;
|
||||
}
|
||||
case XMLEvent.START_DOCUMENT :{
|
||||
StartDocument startDocument = (StartDocument)xMLEvent ;
|
||||
if (DEBUG)System.out.println("Adding StartDocument = " + startDocument.toString());
|
||||
case XMLEvent.START_DOCUMENT: {
|
||||
StartDocument startDocument = (StartDocument) xMLEvent;
|
||||
if (DEBUG) {
|
||||
System.out.println("Adding StartDocument = " + startDocument.toString());
|
||||
}
|
||||
try {
|
||||
fStreamWriter.writeStartDocument(startDocument.getCharacterEncodingScheme(), startDocument.getVersion(),
|
||||
startDocument.isStandalone(), startDocument.standaloneSet());
|
||||
}catch(XMLStreamException e) {
|
||||
fStreamWriter.writeStartDocument(startDocument.getCharacterEncodingScheme(),
|
||||
startDocument.getVersion(),
|
||||
startDocument.isStandalone(), startDocument.standaloneSet());
|
||||
} catch (XMLStreamException e) {
|
||||
fStreamWriter.writeStartDocument(startDocument.getVersion());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case XMLEvent.START_ELEMENT :{
|
||||
StartElement startElement = xMLEvent.asStartElement() ;
|
||||
if (DEBUG)System.out.println("Adding startelement = " + startElement.toString());
|
||||
case XMLEvent.START_ELEMENT: {
|
||||
StartElement startElement = xMLEvent.asStartElement();
|
||||
if (DEBUG) {
|
||||
System.out.println("Adding startelement = " + startElement.toString());
|
||||
}
|
||||
QName qname = startElement.getName();
|
||||
fStreamWriter.writeStartElement(qname.getPrefix(), qname.getLocalPart(), qname.getNamespaceURI());
|
||||
fStreamWriter.writeStartElement(qname.getPrefix(), qname.getLocalPart(),
|
||||
qname.getNamespaceURI());
|
||||
|
||||
//getNamespaces() Returns an Iterator of namespaces declared on this element. This Iterator does not contain
|
||||
//previously declared namespaces unless they appear on the current START_ELEMENT. Therefore
|
||||
//this list may contain redeclared namespaces and duplicate namespace declarations. Use the
|
||||
//getNamespaceContext() method to get the current context of namespace declarations.
|
||||
|
||||
//so we should be using getNamespaces() to write namespace declarations for this START_ELEMENT
|
||||
Iterator iterator = startElement.getNamespaces();
|
||||
while(iterator.hasNext()){
|
||||
Namespace namespace = (Namespace)iterator.next();
|
||||
/*
|
||||
getNamespaces() Returns an Iterator of namespaces declared on this element.
|
||||
This Iterator does not contain previously declared namespaces unless they
|
||||
appear on the current START_ELEMENT. Therefore this list may contain redeclared
|
||||
namespaces and duplicate namespace declarations. Use the getNamespaceContext()
|
||||
method to get the current context of namespace declarations. We should be
|
||||
using getNamespaces() to write namespace declarations for this START_ELEMENT
|
||||
*/
|
||||
Iterator<? extends Namespace> iterator = startElement.getNamespaces();
|
||||
while (iterator.hasNext()) {
|
||||
Namespace namespace = iterator.next();
|
||||
fStreamWriter.writeNamespace(namespace.getPrefix(), namespace.getNamespaceURI());
|
||||
}
|
||||
//REVISIT: What about writing attributes ?
|
||||
Iterator attributes = startElement.getAttributes();
|
||||
while(attributes.hasNext()){
|
||||
Attribute attribute = (Attribute)attributes.next();
|
||||
Iterator<? extends Attribute> attributes = startElement.getAttributes();
|
||||
while (attributes.hasNext()) {
|
||||
Attribute attribute = attributes.next();
|
||||
QName aqname = attribute.getName();
|
||||
fStreamWriter.writeAttribute(aqname.getPrefix(), aqname.getNamespaceURI(), aqname.getLocalPart(),attribute.getValue());
|
||||
fStreamWriter.writeAttribute(aqname.getPrefix(), aqname.getNamespaceURI(),
|
||||
aqname.getLocalPart(), attribute.getValue());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case XMLEvent.NAMESPACE:{
|
||||
Namespace namespace = (Namespace)xMLEvent;
|
||||
if (DEBUG)System.out.println("Adding namespace = " + namespace.toString());
|
||||
case XMLEvent.NAMESPACE: {
|
||||
Namespace namespace = (Namespace) xMLEvent;
|
||||
if (DEBUG) {
|
||||
System.out.println("Adding namespace = " + namespace.toString());
|
||||
}
|
||||
fStreamWriter.writeNamespace(namespace.getPrefix(), namespace.getNamespaceURI());
|
||||
break ;
|
||||
break;
|
||||
}
|
||||
case XMLEvent.COMMENT: {
|
||||
Comment comment = (Comment)xMLEvent ;
|
||||
if (DEBUG)System.out.println("Adding comment = " + comment.toString());
|
||||
Comment comment = (Comment) xMLEvent;
|
||||
if (DEBUG) {
|
||||
System.out.println("Adding comment = " + comment.toString());
|
||||
}
|
||||
fStreamWriter.writeComment(comment.getText());
|
||||
break;
|
||||
}
|
||||
case XMLEvent.PROCESSING_INSTRUCTION:{
|
||||
ProcessingInstruction processingInstruction = (ProcessingInstruction)xMLEvent ;
|
||||
if (DEBUG)System.out.println("Adding processing instruction = " + processingInstruction.toString());
|
||||
fStreamWriter.writeProcessingInstruction(processingInstruction.getTarget(), processingInstruction.getData());
|
||||
case XMLEvent.PROCESSING_INSTRUCTION: {
|
||||
ProcessingInstruction processingInstruction = (ProcessingInstruction) xMLEvent;
|
||||
if (DEBUG) {
|
||||
System.out.println("Adding processing instruction = " + processingInstruction.toString());
|
||||
}
|
||||
fStreamWriter.writeProcessingInstruction(processingInstruction.getTarget(),
|
||||
processingInstruction.getData());
|
||||
break;
|
||||
}
|
||||
case XMLEvent.CHARACTERS:{
|
||||
case XMLEvent.CHARACTERS: {
|
||||
Characters characters = xMLEvent.asCharacters();
|
||||
if (DEBUG)System.out.println("Adding characters = " + characters.toString());
|
||||
//check if the CHARACTERS are CDATA
|
||||
if(characters.isCData()){
|
||||
fStreamWriter.writeCData(characters.getData());
|
||||
if (DEBUG) {
|
||||
System.out.println("Adding characters = " + characters.toString());
|
||||
}
|
||||
else{
|
||||
//check if the CHARACTERS are CDATA
|
||||
if (characters.isCData()) {
|
||||
fStreamWriter.writeCData(characters.getData());
|
||||
} else {
|
||||
fStreamWriter.writeCharacters(characters.getData());
|
||||
}
|
||||
break;
|
||||
}
|
||||
case XMLEvent.ENTITY_REFERENCE:{
|
||||
EntityReference entityReference = (EntityReference)xMLEvent ;
|
||||
if (DEBUG)System.out.println("Adding Entity Reference = "+ entityReference.toString());
|
||||
case XMLEvent.ENTITY_REFERENCE: {
|
||||
EntityReference entityReference = (EntityReference) xMLEvent;
|
||||
if (DEBUG) {
|
||||
System.out.println("Adding Entity Reference = " + entityReference.toString());
|
||||
}
|
||||
fStreamWriter.writeEntityRef(entityReference.getName());
|
||||
break;
|
||||
}
|
||||
case XMLEvent.ATTRIBUTE:{
|
||||
Attribute attribute = (Attribute)xMLEvent;
|
||||
if (DEBUG)System.out.println("Adding Attribute = " + attribute.toString());
|
||||
case XMLEvent.ATTRIBUTE: {
|
||||
Attribute attribute = (Attribute) xMLEvent;
|
||||
if (DEBUG) {
|
||||
System.out.println("Adding Attribute = " + attribute.toString());
|
||||
}
|
||||
QName qname = attribute.getName();
|
||||
fStreamWriter.writeAttribute(qname.getPrefix(), qname.getNamespaceURI(), qname.getLocalPart(),attribute.getValue());
|
||||
fStreamWriter.writeAttribute(qname.getPrefix(), qname.getNamespaceURI(),
|
||||
qname.getLocalPart(), attribute.getValue());
|
||||
break;
|
||||
}
|
||||
case XMLEvent.CDATA:{
|
||||
case XMLEvent.CDATA: {
|
||||
//there is no separate CDATA datatype but CDATA event can be reported
|
||||
//by using vendor specific CDATA property.
|
||||
Characters characters = (Characters)xMLEvent;
|
||||
if (DEBUG)System.out.println("Adding characters = " + characters.toString());
|
||||
if(characters.isCData()){
|
||||
Characters characters = (Characters) xMLEvent;
|
||||
if (DEBUG) {
|
||||
System.out.println("Adding characters = " + characters.toString());
|
||||
}
|
||||
if (characters.isCData()) {
|
||||
fStreamWriter.writeCData(characters.getData());
|
||||
}
|
||||
break;
|
||||
@ -179,15 +210,11 @@ public class XMLEventWriterImpl implements XMLEventWriter{
|
||||
//case XMLEvent.NOTATION_DECLARATION:{
|
||||
//}
|
||||
|
||||
case XMLEvent.END_ELEMENT:{
|
||||
//we dont need to typecast it.. just call writeEndElement() and fStreamWriter will take care of it.
|
||||
//EndElement endElement = (EndElement)xMLEvent;
|
||||
case XMLEvent.END_ELEMENT: {
|
||||
fStreamWriter.writeEndElement();
|
||||
break;
|
||||
}
|
||||
case XMLEvent.END_DOCUMENT:{
|
||||
//we dont need to typecast just call writeEndDocument() and fStreamWriter will take care rest.
|
||||
//EndDocument endDocument = (EndDocument)xMLEvent;
|
||||
case XMLEvent.END_DOCUMENT: {
|
||||
fStreamWriter.writeEndDocument();
|
||||
break;
|
||||
}
|
||||
@ -200,16 +227,16 @@ public class XMLEventWriterImpl implements XMLEventWriter{
|
||||
*
|
||||
* @throws XMLStreamException
|
||||
*/
|
||||
public void close() throws javax.xml.stream.XMLStreamException {
|
||||
public void close() throws XMLStreamException {
|
||||
fStreamWriter.close();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws XMLStreamException will inturn call flush on the stream to which data is being
|
||||
* written.
|
||||
* @throws XMLStreamException will inturn call flush on the stream to which
|
||||
* data is being written.
|
||||
*/
|
||||
public void flush() throws javax.xml.stream.XMLStreamException {
|
||||
public void flush() throws XMLStreamException {
|
||||
fStreamWriter.flush();
|
||||
}
|
||||
|
||||
@ -217,7 +244,7 @@ public class XMLEventWriterImpl implements XMLEventWriter{
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public javax.xml.namespace.NamespaceContext getNamespaceContext() {
|
||||
public NamespaceContext getNamespaceContext() {
|
||||
return fStreamWriter.getNamespaceContext();
|
||||
}
|
||||
|
||||
@ -227,7 +254,7 @@ public class XMLEventWriterImpl implements XMLEventWriter{
|
||||
* @throws XMLStreamException
|
||||
* @return prefix associated with the URI.
|
||||
*/
|
||||
public String getPrefix(String namespaceURI) throws javax.xml.stream.XMLStreamException {
|
||||
public String getPrefix(String namespaceURI) throws XMLStreamException {
|
||||
return fStreamWriter.getPrefix(namespaceURI);
|
||||
}
|
||||
|
||||
@ -236,7 +263,7 @@ public class XMLEventWriterImpl implements XMLEventWriter{
|
||||
* @param uri Namespace URI
|
||||
* @throws XMLStreamException
|
||||
*/
|
||||
public void setDefaultNamespace(String uri) throws javax.xml.stream.XMLStreamException {
|
||||
public void setDefaultNamespace(String uri) throws XMLStreamException {
|
||||
fStreamWriter.setDefaultNamespace(uri);
|
||||
}
|
||||
|
||||
@ -245,7 +272,8 @@ public class XMLEventWriterImpl implements XMLEventWriter{
|
||||
* @param namespaceContext Namespace Context
|
||||
* @throws XMLStreamException
|
||||
*/
|
||||
public void setNamespaceContext(javax.xml.namespace.NamespaceContext namespaceContext) throws javax.xml.stream.XMLStreamException {
|
||||
public void setNamespaceContext(NamespaceContext namespaceContext)
|
||||
throws XMLStreamException {
|
||||
fStreamWriter.setNamespaceContext(namespaceContext);
|
||||
}
|
||||
|
||||
@ -255,7 +283,7 @@ public class XMLEventWriterImpl implements XMLEventWriter{
|
||||
* @param uri Namespace URI
|
||||
* @throws XMLStreamException
|
||||
*/
|
||||
public void setPrefix(String prefix, String uri) throws javax.xml.stream.XMLStreamException {
|
||||
public void setPrefix(String prefix, String uri) throws XMLStreamException {
|
||||
fStreamWriter.setPrefix(prefix, uri);
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,6 @@ import java.nio.charset.CharsetEncoder;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Random;
|
||||
import java.util.Vector;
|
||||
import java.util.Set;
|
||||
@ -46,7 +45,6 @@ import javax.xml.namespace.NamespaceContext;
|
||||
import javax.xml.stream.XMLOutputFactory;
|
||||
import javax.xml.stream.XMLStreamConstants;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
import com.sun.org.apache.xerces.internal.impl.Constants;
|
||||
@ -71,7 +69,8 @@ import com.sun.xml.internal.stream.util.ReadOnlyIterator;
|
||||
* @author Santiago.Pericas-Geertsen@sun.com
|
||||
* @author Sunitha.Reddy@sun.com
|
||||
*/
|
||||
public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamWriterBase {
|
||||
public final class XMLStreamWriterImpl extends AbstractMap<Object, Object>
|
||||
implements XMLStreamWriterBase {
|
||||
|
||||
public static final String START_COMMENT = "<!--";
|
||||
public static final String END_COMMENT = "-->";
|
||||
@ -115,12 +114,12 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
/**
|
||||
* Collects attributes when the writer is in reparing mode.
|
||||
*/
|
||||
private ArrayList fAttributeCache;
|
||||
private ArrayList<Attribute> fAttributeCache;
|
||||
|
||||
/**
|
||||
* Collects namespace declarations when the writer is in reparing mode.
|
||||
*/
|
||||
private ArrayList fNamespaceDecls;
|
||||
private ArrayList<QName> fNamespaceDecls;
|
||||
|
||||
/**
|
||||
* Namespace context encapsulating user specified context
|
||||
@ -153,7 +152,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
|
||||
final private String DEFAULT_PREFIX = fSymbolTable.addSymbol("");
|
||||
|
||||
private final ReadOnlyIterator fReadOnlyIterator = new ReadOnlyIterator();
|
||||
private final ReadOnlyIterator<String> fReadOnlyIterator = new ReadOnlyIterator<>();
|
||||
|
||||
/**
|
||||
* In some cases, this charset encoder is used to determine if a char is
|
||||
@ -168,7 +167,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
* the same uri as the default namespace; It's added to avoid changing the
|
||||
* current impl. which has many redundant code for the repair mode
|
||||
*/
|
||||
HashMap fAttrNamespace = null;
|
||||
HashMap<String, String> fAttrNamespace = null;
|
||||
|
||||
/**
|
||||
* Creates a new instance of XMLStreamWriterImpl. Uses platform's default
|
||||
@ -230,9 +229,9 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
*/
|
||||
private void init() {
|
||||
fReuse = false;
|
||||
fNamespaceDecls = new ArrayList();
|
||||
fNamespaceDecls = new ArrayList<>();
|
||||
fPrefixGen = new Random();
|
||||
fAttributeCache = new ArrayList();
|
||||
fAttributeCache = new ArrayList<>();
|
||||
fInternalNamespaceContext = new NamespaceSupport();
|
||||
fInternalNamespaceContext.reset();
|
||||
fNamespaceContext = new NamespaceContextImpl();
|
||||
@ -240,9 +239,9 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
|
||||
// Set internal state based on property values
|
||||
Boolean ob = (Boolean) fPropertyManager.getProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES);
|
||||
fIsRepairingNamespace = ob.booleanValue();
|
||||
fIsRepairingNamespace = ob;
|
||||
ob = (Boolean) fPropertyManager.getProperty(Constants.ESCAPE_CHARACTERS);
|
||||
setEscapeCharacters(ob.booleanValue());
|
||||
setEscapeCharacters(ob);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -279,9 +278,9 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
|
||||
if (resetProperties) {
|
||||
Boolean ob = (Boolean) fPropertyManager.getProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES);
|
||||
fIsRepairingNamespace = ob.booleanValue();
|
||||
fIsRepairingNamespace = ob;
|
||||
ob = (Boolean) fPropertyManager.getProperty(Constants.ESCAPE_CHARACTERS);
|
||||
setEscapeCharacters(ob.booleanValue());
|
||||
setEscapeCharacters(ob);
|
||||
}
|
||||
}
|
||||
|
||||
@ -369,6 +368,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
/**
|
||||
* Close this XMLStreamWriter by closing underlying writer.
|
||||
*/
|
||||
@Override
|
||||
public void close() throws XMLStreamException {
|
||||
if (fWriter != null) {
|
||||
try {
|
||||
@ -392,6 +392,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
/**
|
||||
* Flush this XMLStreamWriter by flushin underlying writer.
|
||||
*/
|
||||
@Override
|
||||
public void flush() throws XMLStreamException {
|
||||
try {
|
||||
fWriter.flush();
|
||||
@ -405,6 +406,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
*
|
||||
* @return NamespaceContext
|
||||
*/
|
||||
@Override
|
||||
public NamespaceContext getNamespaceContext() {
|
||||
return fNamespaceContext;
|
||||
}
|
||||
@ -416,6 +418,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
* @param uri The namespace uri
|
||||
* @throws XMLStreamException if uri specified is "" or null
|
||||
*/
|
||||
@Override
|
||||
public String getPrefix(String uri) throws XMLStreamException {
|
||||
return fNamespaceContext.getPrefix(uri);
|
||||
}
|
||||
@ -427,6 +430,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
* @throws IllegalArgumentException if the specified property is not supported
|
||||
* @return value associated with the specified property.
|
||||
*/
|
||||
@Override
|
||||
public Object getProperty(String str)
|
||||
throws IllegalArgumentException {
|
||||
if (str == null) {
|
||||
@ -446,6 +450,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
*
|
||||
* @param uri Namespace URI
|
||||
*/
|
||||
@Override
|
||||
public void setDefaultNamespace(String uri) throws XMLStreamException {
|
||||
if (uri != null) {
|
||||
uri = fSymbolTable.addSymbol(uri);
|
||||
@ -479,6 +484,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
* @param namespaceContext the namespace context to use for this writer, may not be null
|
||||
* @throws XMLStreamException
|
||||
*/
|
||||
@Override
|
||||
public void setNamespaceContext(NamespaceContext namespaceContext)
|
||||
throws XMLStreamException {
|
||||
fNamespaceContext.userContext = namespaceContext;
|
||||
@ -493,6 +499,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
* @param uri
|
||||
* @throws XMLStreamException
|
||||
*/
|
||||
@Override
|
||||
public void setPrefix(String prefix, String uri) throws XMLStreamException {
|
||||
|
||||
if (prefix == null) {
|
||||
@ -525,6 +532,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
fInternalNamespaceContext.declarePrefix(prefix, uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeAttribute(String localName, String value)
|
||||
throws XMLStreamException {
|
||||
try {
|
||||
@ -554,6 +562,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeAttribute(String namespaceURI, String localName,
|
||||
String value) throws XMLStreamException {
|
||||
try {
|
||||
@ -590,7 +599,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
String value) throws IOException {
|
||||
fWriter.write(SPACE);
|
||||
|
||||
if ((prefix != null) && (prefix != XMLConstants.DEFAULT_NS_PREFIX)) {
|
||||
if ((prefix != null) && (!prefix.equals(XMLConstants.DEFAULT_NS_PREFIX))) {
|
||||
fWriter.write(prefix);
|
||||
fWriter.write(":");
|
||||
}
|
||||
@ -603,6 +612,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
fWriter.write("\"");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeAttribute(String prefix, String namespaceURI,
|
||||
String localName, String value) throws XMLStreamException {
|
||||
try {
|
||||
@ -629,7 +639,8 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
}
|
||||
}
|
||||
|
||||
if (!prefix.equals(XMLConstants.XML_NS_PREFIX) || !namespaceURI.equals(XMLConstants.XML_NS_URI)) {
|
||||
if (!prefix.equals(XMLConstants.XML_NS_PREFIX) ||
|
||||
!namespaceURI.equals(XMLConstants.XML_NS_URI)) {
|
||||
|
||||
prefix = fSymbolTable.addSymbol(prefix);
|
||||
namespaceURI = fSymbolTable.addSymbol(namespaceURI);
|
||||
@ -663,6 +674,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCData(String cdata) throws XMLStreamException {
|
||||
try {
|
||||
if (cdata == null) {
|
||||
@ -681,6 +693,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCharacters(String data) throws XMLStreamException {
|
||||
try {
|
||||
if (fStartTagOpened) {
|
||||
@ -693,6 +706,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeCharacters(char[] data, int start, int len)
|
||||
throws XMLStreamException {
|
||||
try {
|
||||
@ -706,6 +720,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeComment(String comment) throws XMLStreamException {
|
||||
try {
|
||||
if (fStartTagOpened) {
|
||||
@ -724,6 +739,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeDTD(String dtd) throws XMLStreamException {
|
||||
try {
|
||||
if (fStartTagOpened) {
|
||||
@ -750,11 +766,12 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
* @see <a href="http://www.w3.org/TR/REC-xml-names/#defaulting">
|
||||
* Namespaces in XML, 5.2 Namespace Defaulting</a>
|
||||
*/
|
||||
@Override
|
||||
public void writeDefaultNamespace(String namespaceURI)
|
||||
throws XMLStreamException {
|
||||
|
||||
// normalize namespaceURI
|
||||
String namespaceURINormalized = null;
|
||||
String namespaceURINormalized;
|
||||
if (namespaceURI == null) {
|
||||
namespaceURINormalized = ""; // XMLConstants.NULL_NS_URI
|
||||
} else {
|
||||
@ -782,7 +799,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
|
||||
String tmp = fInternalNamespaceContext.getURI("");
|
||||
|
||||
if (tmp != null && tmp != namespaceURINormalized) {
|
||||
if (tmp != null && !tmp.equals(namespaceURINormalized)) {
|
||||
throw new XMLStreamException(
|
||||
"xmlns has been already bound to " +tmp +
|
||||
". Rebinding it to "+ namespaceURINormalized +
|
||||
@ -798,6 +815,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEmptyElement(String localName) throws XMLStreamException {
|
||||
try {
|
||||
if (fStartTagOpened) {
|
||||
@ -816,6 +834,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEmptyElement(String namespaceURI, String localName)
|
||||
throws XMLStreamException {
|
||||
if (namespaceURI == null) {
|
||||
@ -828,6 +847,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
writeEmptyElement(prefix, localName, namespaceURI);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEmptyElement(String prefix, String localName,
|
||||
String namespaceURI) throws XMLStreamException {
|
||||
try {
|
||||
@ -863,7 +883,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
return;
|
||||
}
|
||||
|
||||
if ((prefix != null) && (prefix != XMLConstants.DEFAULT_NS_PREFIX)) {
|
||||
if ((prefix != null) && (!prefix.equals(XMLConstants.DEFAULT_NS_PREFIX))) {
|
||||
fWriter.write(prefix);
|
||||
fWriter.write(":");
|
||||
}
|
||||
@ -874,16 +894,15 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEndDocument() throws XMLStreamException {
|
||||
try {
|
||||
if (fStartTagOpened) {
|
||||
closeStartTag();
|
||||
}
|
||||
|
||||
ElementState elem = null;
|
||||
|
||||
while (!fElementStack.empty()) {
|
||||
elem = (ElementState) fElementStack.pop();
|
||||
ElementState elem = fElementStack.pop();
|
||||
fInternalNamespaceContext.popContext();
|
||||
|
||||
if (elem.isEmpty) {
|
||||
@ -907,13 +926,14 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEndElement() throws XMLStreamException {
|
||||
try {
|
||||
if (fStartTagOpened) {
|
||||
closeStartTag();
|
||||
}
|
||||
|
||||
ElementState currentElement = (ElementState) fElementStack.pop();
|
||||
ElementState currentElement = fElementStack.pop();
|
||||
|
||||
if (currentElement == null) {
|
||||
throw new XMLStreamException("No element was found to write");
|
||||
@ -944,6 +964,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEntityRef(String refName) throws XMLStreamException {
|
||||
try {
|
||||
if (fStartTagOpened) {
|
||||
@ -973,11 +994,12 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
* @see <a href="http://www.w3.org/TR/REC-xml-names/#defaulting">
|
||||
* Namespaces in XML, 5.2 Namespace Defaulting</a>
|
||||
*/
|
||||
@Override
|
||||
public void writeNamespace(String prefix, String namespaceURI)
|
||||
throws XMLStreamException {
|
||||
|
||||
// normalize namespaceURI
|
||||
String namespaceURINormalized = null;
|
||||
String namespaceURINormalized;
|
||||
if (namespaceURI == null) {
|
||||
namespaceURINormalized = ""; // XMLConstants.NULL_NS_URI
|
||||
} else {
|
||||
@ -985,7 +1007,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
}
|
||||
|
||||
try {
|
||||
QName qname = null;
|
||||
QName qname;
|
||||
|
||||
if (!fStartTagOpened) {
|
||||
throw new IllegalStateException(
|
||||
@ -1013,7 +1035,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
if (fIsRepairingNamespace) {
|
||||
String tmpURI = fInternalNamespaceContext.getURI(prefix);
|
||||
|
||||
if ((tmpURI != null) && (tmpURI == namespaceURINormalized)) {
|
||||
if ((tmpURI != null) && (tmpURI.equals(namespaceURINormalized))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1030,7 +1052,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
|
||||
String tmp = fInternalNamespaceContext.getURI(prefix);
|
||||
|
||||
if (tmp != null && tmp != namespaceURINormalized) {
|
||||
if (tmp != null && !tmp.equals(namespaceURINormalized)) {
|
||||
|
||||
throw new XMLStreamException("prefix "+prefix+
|
||||
" has been already bound to " +tmp +
|
||||
@ -1051,7 +1073,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
throws IOException {
|
||||
fWriter.write(" xmlns");
|
||||
|
||||
if ((prefix != null) && (prefix != XMLConstants.DEFAULT_NS_PREFIX)) {
|
||||
if ((prefix != null) && (!prefix.equals(XMLConstants.DEFAULT_NS_PREFIX))) {
|
||||
fWriter.write(":");
|
||||
fWriter.write(prefix);
|
||||
}
|
||||
@ -1064,6 +1086,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
fWriter.write("\"");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeProcessingInstruction(String target)
|
||||
throws XMLStreamException {
|
||||
try {
|
||||
@ -1090,6 +1113,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
* @param data
|
||||
* @throws XMLStreamException
|
||||
*/
|
||||
@Override
|
||||
public void writeProcessingInstruction(String target, String data)
|
||||
throws XMLStreamException {
|
||||
try {
|
||||
@ -1116,6 +1140,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
*
|
||||
* @throws XMLStreamException in case of an IOException
|
||||
*/
|
||||
@Override
|
||||
public void writeStartDocument() throws XMLStreamException {
|
||||
writeStartDocument(null, null, false, false);
|
||||
}
|
||||
@ -1126,6 +1151,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
* @param version the specified version
|
||||
* @throws XMLStreamException in case of an IOException
|
||||
*/
|
||||
@Override
|
||||
public void writeStartDocument(String version) throws XMLStreamException {
|
||||
writeStartDocument(null, version, false, false);
|
||||
}
|
||||
@ -1143,7 +1169,6 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
writeStartDocument(encoding, version, false, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeStartDocument(String encoding, String version,
|
||||
boolean standalone, boolean standaloneSet)
|
||||
throws XMLStreamException {
|
||||
@ -1212,9 +1237,9 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
if (streamEncoding != null && !streamEncoding.equalsIgnoreCase(encoding)) {
|
||||
// If the equality check failed, check for charset encoding aliases
|
||||
boolean foundAlias = false;
|
||||
Set aliases = Charset.forName(encoding).aliases();
|
||||
for (Iterator it = aliases.iterator(); !foundAlias && it.hasNext(); ) {
|
||||
if (streamEncoding.equalsIgnoreCase((String) it.next())) {
|
||||
Set<String> aliases = Charset.forName(encoding).aliases();
|
||||
for (Iterator<String> it = aliases.iterator(); !foundAlias && it.hasNext(); ) {
|
||||
if (streamEncoding.equalsIgnoreCase(it.next())) {
|
||||
foundAlias = true;
|
||||
}
|
||||
}
|
||||
@ -1232,6 +1257,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
* @param localName
|
||||
* @throws XMLStreamException
|
||||
*/
|
||||
@Override
|
||||
public void writeStartElement(String localName) throws XMLStreamException {
|
||||
try {
|
||||
if (localName == null) {
|
||||
@ -1261,6 +1287,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
* @param localName
|
||||
* @throws XMLStreamException
|
||||
*/
|
||||
@Override
|
||||
public void writeStartElement(String namespaceURI, String localName)
|
||||
throws XMLStreamException {
|
||||
if (localName == null) {
|
||||
@ -1292,6 +1319,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
* @param namespaceURI
|
||||
* @throws XMLStreamException
|
||||
*/
|
||||
@Override
|
||||
public void writeStartElement(String prefix, String localName,
|
||||
String namespaceURI) throws XMLStreamException {
|
||||
try {
|
||||
@ -1537,10 +1565,10 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
fWriter.write(currentElement.localpart);
|
||||
|
||||
int len = fNamespaceDecls.size();
|
||||
QName qname = null;
|
||||
QName qname;
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
qname = (QName) fNamespaceDecls.get(i);
|
||||
qname = fNamespaceDecls.get(i);
|
||||
|
||||
if (qname != null) {
|
||||
if (fInternalNamespaceContext.declarePrefix(qname.prefix,
|
||||
@ -1552,16 +1580,16 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
|
||||
fNamespaceDecls.clear();
|
||||
|
||||
Attribute attr = null;
|
||||
Attribute attr;
|
||||
|
||||
for (int j = 0; j < fAttributeCache.size(); j++) {
|
||||
attr = (Attribute) fAttributeCache.get(j);
|
||||
attr = fAttributeCache.get(j);
|
||||
|
||||
if ((attr.prefix != null) && (attr.uri != null)) {
|
||||
if (!attr.prefix.equals("") && !attr.uri.equals("") ) {
|
||||
String tmp = fInternalNamespaceContext.getPrefix(attr.uri);
|
||||
|
||||
if ((tmp == null) || (tmp != attr.prefix)) {
|
||||
if ((tmp == null) || (!tmp.equals(attr.prefix))) {
|
||||
tmp = getAttrPrefix(attr.uri);
|
||||
if (tmp == null) {
|
||||
if (fInternalNamespaceContext.declarePrefix(attr.prefix,
|
||||
@ -1611,29 +1639,29 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
* @return
|
||||
*/
|
||||
private void correctPrefix(QName attr, int type) {
|
||||
String tmpPrefix = null;
|
||||
String tmpPrefix;
|
||||
String prefix;
|
||||
String uri;
|
||||
prefix = attr.prefix;
|
||||
uri = attr.uri;
|
||||
boolean isSpecialCaseURI = false;
|
||||
|
||||
if (prefix == null || prefix.equals("")) {
|
||||
if (prefix == null || prefix.equals(XMLConstants.DEFAULT_NS_PREFIX)) {
|
||||
if (uri == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (prefix == XMLConstants.DEFAULT_NS_PREFIX && uri == XMLConstants.DEFAULT_NS_PREFIX)
|
||||
if (XMLConstants.DEFAULT_NS_PREFIX.equals(prefix) && uri.equals(XMLConstants.DEFAULT_NS_PREFIX))
|
||||
return;
|
||||
|
||||
uri = fSymbolTable.addSymbol(uri);
|
||||
|
||||
QName decl = null;
|
||||
QName decl;
|
||||
|
||||
for (int i = 0; i < fNamespaceDecls.size(); i++) {
|
||||
decl = (QName) fNamespaceDecls.get(i);
|
||||
decl = fNamespaceDecls.get(i);
|
||||
|
||||
if ((decl != null) && (decl.uri == attr.uri)) {
|
||||
if ((decl != null) && (decl.uri.equals(attr.uri))) {
|
||||
attr.prefix = decl.prefix;
|
||||
|
||||
return;
|
||||
@ -1642,7 +1670,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
|
||||
tmpPrefix = fNamespaceContext.getPrefix(uri);
|
||||
|
||||
if (tmpPrefix == XMLConstants.DEFAULT_NS_PREFIX) {
|
||||
if (XMLConstants.DEFAULT_NS_PREFIX.equals(tmpPrefix)) {
|
||||
if (type == XMLStreamConstants.START_ELEMENT) {
|
||||
return;
|
||||
}
|
||||
@ -1654,7 +1682,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
}
|
||||
|
||||
if (tmpPrefix == null) {
|
||||
StringBuffer genPrefix = new StringBuffer("zdef");
|
||||
StringBuilder genPrefix = new StringBuilder("zdef");
|
||||
|
||||
for (int i = 0; i < 1; i++) {
|
||||
genPrefix.append(fPrefixGen.nextInt());
|
||||
@ -1687,13 +1715,13 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
*/
|
||||
private String getAttrPrefix(String uri) {
|
||||
if (fAttrNamespace != null) {
|
||||
return (String)fAttrNamespace.get(uri);
|
||||
return fAttrNamespace.get(uri);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private void addAttrNamespace(String prefix, String uri) {
|
||||
if (fAttrNamespace == null) {
|
||||
fAttrNamespace = new HashMap();
|
||||
fAttrNamespace = new HashMap<>();
|
||||
}
|
||||
fAttrNamespace.put(prefix, uri);
|
||||
}
|
||||
@ -1704,7 +1732,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
private boolean isDefaultNamespace(String uri) {
|
||||
String defaultNamespace = fInternalNamespaceContext.getURI(DEFAULT_PREFIX);
|
||||
|
||||
if (uri == defaultNamespace) {
|
||||
if (uri.equals(defaultNamespace)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1732,13 +1760,13 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
* Correct's namespaces as per requirements of isReparisingNamespace property.
|
||||
*/
|
||||
protected void repair() {
|
||||
Attribute attr = null;
|
||||
Attribute attr2 = null;
|
||||
Attribute attr;
|
||||
Attribute attr2;
|
||||
ElementState currentElement = fElementStack.peek();
|
||||
removeDuplicateDecls();
|
||||
|
||||
for(int i=0 ; i< fAttributeCache.size();i++){
|
||||
attr = (Attribute)fAttributeCache.get(i);
|
||||
attr = fAttributeCache.get(i);
|
||||
if((attr.prefix != null && !attr.prefix.equals("")) || (attr.uri != null && !attr.uri.equals(""))) {
|
||||
correctPrefix(currentElement,attr);
|
||||
}
|
||||
@ -1754,9 +1782,9 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
}
|
||||
|
||||
for(int i=0 ; i< fAttributeCache.size();i++){
|
||||
attr = (Attribute)fAttributeCache.get(i);
|
||||
attr = fAttributeCache.get(i);
|
||||
for(int j=i+1;j<fAttributeCache.size();j++){
|
||||
attr2 = (Attribute)fAttributeCache.get(j);
|
||||
attr2 = fAttributeCache.get(j);
|
||||
if(!"".equals(attr.prefix)&& !"".equals(attr2.prefix)){
|
||||
correctPrefix(attr,attr2);
|
||||
}
|
||||
@ -1765,10 +1793,10 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
|
||||
repairNamespaceDecl(currentElement);
|
||||
|
||||
int i = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < fAttributeCache.size(); i++) {
|
||||
attr = (Attribute) fAttributeCache.get(i);
|
||||
attr = fAttributeCache.get(i);
|
||||
/* If 'attr' is an attribute and it is in no namespace(which means that prefix="", uri=""), attr's
|
||||
namespace should not be redinded. See [http://www.w3.org/TR/REC-xml-names/#defaulting].
|
||||
*/
|
||||
@ -1780,7 +1808,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
QName qname = null;
|
||||
|
||||
for (i = 0; i < fNamespaceDecls.size(); i++) {
|
||||
qname = (QName) fNamespaceDecls.get(i);
|
||||
qname = fNamespaceDecls.get(i);
|
||||
|
||||
if (qname != null) {
|
||||
fInternalNamespaceContext.declarePrefix(qname.prefix, qname.uri);
|
||||
@ -1788,7 +1816,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
}
|
||||
|
||||
for (i = 0; i < fAttributeCache.size(); i++) {
|
||||
attr = (Attribute) fAttributeCache.get(i);
|
||||
attr = fAttributeCache.get(i);
|
||||
correctPrefix(attr, XMLStreamConstants.ATTRIBUTE);
|
||||
}
|
||||
}
|
||||
@ -1801,9 +1829,8 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
*that is bound to the namespace URIs of those attributes.
|
||||
*/
|
||||
void correctPrefix(QName attr1, QName attr2) {
|
||||
String tmpPrefix = null;
|
||||
QName decl = null;
|
||||
boolean done = false;
|
||||
String tmpPrefix;
|
||||
QName decl;
|
||||
|
||||
checkForNull(attr1);
|
||||
checkForNull(attr2);
|
||||
@ -1815,10 +1842,9 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
if (tmpPrefix != null) {
|
||||
attr2.prefix = fSymbolTable.addSymbol(tmpPrefix);
|
||||
} else {
|
||||
decl = null;
|
||||
for(int n=0;n<fNamespaceDecls.size();n++){
|
||||
decl = (QName)fNamespaceDecls.get(n);
|
||||
if(decl != null && (decl.uri == attr2.uri)){
|
||||
for (int n=0; n<fNamespaceDecls.size(); n++) {
|
||||
decl = fNamespaceDecls.get(n);
|
||||
if(decl != null && (decl.uri.equals(attr2.uri))){
|
||||
attr2.prefix = decl.prefix;
|
||||
|
||||
return;
|
||||
@ -1826,7 +1852,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
}
|
||||
|
||||
//No namespace mapping found , so declare prefix.
|
||||
StringBuffer genPrefix = new StringBuffer("zdef");
|
||||
StringBuilder genPrefix = new StringBuilder("zdef");
|
||||
|
||||
for (int k = 0; k < 1; k++) {
|
||||
genPrefix.append(fPrefixGen.nextInt());
|
||||
@ -1851,11 +1877,11 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
|
||||
void removeDuplicateDecls(){
|
||||
QName decl1,decl2;
|
||||
for(int i =0;i<fNamespaceDecls.size();i++){
|
||||
decl1 = (QName)fNamespaceDecls.get(i);
|
||||
for(int i =0; i<fNamespaceDecls.size(); i++) {
|
||||
decl1 = fNamespaceDecls.get(i);
|
||||
if(decl1!=null) {
|
||||
for(int j=i+1;j<fNamespaceDecls.size();j++){
|
||||
decl2 = (QName)fNamespaceDecls.get(j);
|
||||
decl2 = fNamespaceDecls.get(j);
|
||||
// QName.equals relies on identity equality, so we can't use it,
|
||||
// because prefixes aren't interned
|
||||
if(decl2!=null && decl1.prefix.equals(decl2.prefix) && decl1.uri.equals(decl2.uri))
|
||||
@ -1873,12 +1899,12 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
*
|
||||
*/
|
||||
void repairNamespaceDecl(QName attr) {
|
||||
QName decl = null;
|
||||
QName decl;
|
||||
String tmpURI;
|
||||
|
||||
//check for null prefix.
|
||||
for (int j = 0; j < fNamespaceDecls.size(); j++) {
|
||||
decl = (QName) fNamespaceDecls.get(j);
|
||||
decl = fNamespaceDecls.get(j);
|
||||
|
||||
if (decl != null) {
|
||||
if ((attr.prefix != null) &&
|
||||
@ -1900,13 +1926,13 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
}
|
||||
|
||||
boolean isDeclared(QName attr) {
|
||||
QName decl = null;
|
||||
QName decl;
|
||||
|
||||
for (int n = 0; n < fNamespaceDecls.size(); n++) {
|
||||
decl = (QName) fNamespaceDecls.get(n);
|
||||
decl = fNamespaceDecls.get(n);
|
||||
|
||||
if ((attr.prefix != null) &&
|
||||
((attr.prefix == decl.prefix) && (decl.uri == attr.uri))) {
|
||||
((attr.prefix.equals(decl.prefix)) && (decl.uri.equals(attr.uri)))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -2121,9 +2147,10 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.util.Iterator getPrefixes(String uri) {
|
||||
//Cleanup note: leaving these warnings to a xerces.internal.util cleanup
|
||||
public Iterator<String> getPrefixes(String uri) {
|
||||
Vector prefixes = null;
|
||||
Iterator itr = null;
|
||||
Iterator<String> itr = null;
|
||||
|
||||
if (uri != null) {
|
||||
uri = fSymbolTable.addSymbol(uri);
|
||||
@ -2140,12 +2167,12 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
if ((prefixes == null) && (itr != null)) {
|
||||
return itr;
|
||||
} else if ((prefixes != null) && (itr == null)) {
|
||||
return new ReadOnlyIterator(prefixes.iterator());
|
||||
return new ReadOnlyIterator<>(prefixes.iterator());
|
||||
} else if ((prefixes != null) && (itr != null)) {
|
||||
String ob = null;
|
||||
|
||||
while (itr.hasNext()) {
|
||||
ob = (String) itr.next();
|
||||
ob = itr.next();
|
||||
|
||||
if (ob != null) {
|
||||
ob = fSymbolTable.addSymbol(ob);
|
||||
@ -2156,7 +2183,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
}
|
||||
}
|
||||
|
||||
return new ReadOnlyIterator(prefixes.iterator());
|
||||
return new ReadOnlyIterator<>(prefixes.iterator());
|
||||
}
|
||||
|
||||
return fReadOnlyIterator;
|
||||
@ -2165,14 +2192,17 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
|
||||
// -- Map Interface --------------------------------------------------
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
return key.equals(OUTPUTSTREAM_PROPERTY);
|
||||
}
|
||||
@ -2181,6 +2211,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
* Returns the value associated to an implementation-specific
|
||||
* property.
|
||||
*/
|
||||
@Override
|
||||
public Object get(Object key) {
|
||||
if (key.equals(OUTPUTSTREAM_PROPERTY)) {
|
||||
return fOutputStream;
|
||||
@ -2188,7 +2219,8 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
return null;
|
||||
}
|
||||
|
||||
public java.util.Set entrySet() {
|
||||
@Override
|
||||
public Set<Entry<Object,Object>> entrySet() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@ -2198,6 +2230,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
* AbstractMap would cause an unsupported exection to
|
||||
* be thrown.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getName() + "@" + Integer.toHexString(hashCode());
|
||||
}
|
||||
@ -2206,6 +2239,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
* Overrides the method defined in AbstractMap
|
||||
* This is required by the toString() method
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return fElementStack.hashCode();
|
||||
}
|
||||
@ -2213,6 +2247,7 @@ public final class XMLStreamWriterImpl extends AbstractMap implements XMLStreamW
|
||||
* Overrides the method defined in AbstractMap
|
||||
* This is required to satisfy the contract for hashCode.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (this == obj);
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream;
|
||||
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,9 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream;
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream;
|
||||
|
||||
/**
|
||||
|
@ -39,53 +39,34 @@ class SecuritySupport {
|
||||
|
||||
|
||||
ClassLoader getContextClassLoader() throws SecurityException{
|
||||
return (ClassLoader)
|
||||
AccessController.doPrivileged(new PrivilegedAction() {
|
||||
public Object run() {
|
||||
ClassLoader cl = null;
|
||||
//try {
|
||||
cl = Thread.currentThread().getContextClassLoader();
|
||||
//} catch (SecurityException ex) { }
|
||||
return AccessController.doPrivileged((PrivilegedAction<ClassLoader>) () -> {
|
||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||
|
||||
if (cl == null)
|
||||
cl = ClassLoader.getSystemClassLoader();
|
||||
if (cl == null)
|
||||
cl = ClassLoader.getSystemClassLoader();
|
||||
|
||||
return cl;
|
||||
}
|
||||
return cl;
|
||||
});
|
||||
}
|
||||
|
||||
String getSystemProperty(final String propName) {
|
||||
return (String)
|
||||
AccessController.doPrivileged(new PrivilegedAction() {
|
||||
public Object run() {
|
||||
return System.getProperty(propName);
|
||||
}
|
||||
});
|
||||
return AccessController.doPrivileged((PrivilegedAction<String>) () ->
|
||||
System.getProperty(propName));
|
||||
}
|
||||
|
||||
FileInputStream getFileInputStream(final File file)
|
||||
throws FileNotFoundException
|
||||
{
|
||||
try {
|
||||
return (FileInputStream)
|
||||
AccessController.doPrivileged(new PrivilegedExceptionAction() {
|
||||
public Object run() throws FileNotFoundException {
|
||||
return new FileInputStream(file);
|
||||
}
|
||||
});
|
||||
return AccessController.doPrivileged((PrivilegedExceptionAction<FileInputStream>) ()
|
||||
-> new FileInputStream(file));
|
||||
} catch (PrivilegedActionException e) {
|
||||
throw (FileNotFoundException)e.getException();
|
||||
}
|
||||
}
|
||||
|
||||
boolean doesFileExist(final File f) {
|
||||
return ((Boolean)
|
||||
AccessController.doPrivileged(new PrivilegedAction() {
|
||||
public Object run() {
|
||||
return new Boolean(f.exists());
|
||||
}
|
||||
})).booleanValue();
|
||||
return AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> f.exists());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2016, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009, 2015, by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream;
|
||||
import com.sun.xml.internal.stream.events.XMLEventFactoryImpl;
|
||||
import java.util.Iterator;
|
||||
@ -53,8 +50,7 @@ public abstract class XMLEventFactory {
|
||||
static final String JAXPFACTORYID = "javax.xml.stream.XMLEventFactory";
|
||||
static final String DEFAULIMPL = "com.sun.xml.internal.stream.events.XMLEventFactoryImpl";
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* Creates a new instance of the {@code XMLEventFactory} builtin
|
||||
* system-default implementation.
|
||||
*
|
||||
@ -159,6 +155,7 @@ public abstract class XMLEventFactory {
|
||||
* #newFactory(java.lang.String, java.lang.ClassLoader)}
|
||||
* method defines no changes in behavior.
|
||||
*/
|
||||
@Deprecated(since="7")
|
||||
public static XMLEventFactory newInstance(String factoryId,
|
||||
ClassLoader classLoader)
|
||||
throws FactoryConfigurationError {
|
||||
@ -307,8 +304,8 @@ public abstract class XMLEventFactory {
|
||||
* @return an instance of the requested StartElement
|
||||
*/
|
||||
public abstract StartElement createStartElement(QName name,
|
||||
Iterator attributes,
|
||||
Iterator namespaces);
|
||||
Iterator<? extends Attribute> attributes,
|
||||
Iterator<? extends Namespace> namespaces);
|
||||
|
||||
/**
|
||||
* Create a new StartElement. This defaults the NamespaceContext to
|
||||
@ -341,8 +338,8 @@ public abstract class XMLEventFactory {
|
||||
public abstract StartElement createStartElement(String prefix,
|
||||
String namespaceUri,
|
||||
String localName,
|
||||
Iterator attributes,
|
||||
Iterator namespaces
|
||||
Iterator<? extends Attribute> attributes,
|
||||
Iterator<? extends Namespace> namespaces
|
||||
);
|
||||
/**
|
||||
* Create a new StartElement. Namespaces can be added to this StartElement
|
||||
@ -363,8 +360,8 @@ public abstract class XMLEventFactory {
|
||||
public abstract StartElement createStartElement(String prefix,
|
||||
String namespaceUri,
|
||||
String localName,
|
||||
Iterator attributes,
|
||||
Iterator namespaces,
|
||||
Iterator<? extends Attribute> attributes,
|
||||
Iterator<? extends Namespace> namespaces,
|
||||
NamespaceContext context
|
||||
);
|
||||
|
||||
@ -376,7 +373,7 @@ public abstract class XMLEventFactory {
|
||||
* @return an instance of the requested EndElement
|
||||
*/
|
||||
public abstract EndElement createEndElement(QName name,
|
||||
Iterator namespaces);
|
||||
Iterator<? extends Namespace> namespaces);
|
||||
|
||||
/**
|
||||
* Create a new EndElement
|
||||
@ -400,7 +397,7 @@ public abstract class XMLEventFactory {
|
||||
public abstract EndElement createEndElement(String prefix,
|
||||
String namespaceUri,
|
||||
String localName,
|
||||
Iterator namespaces);
|
||||
Iterator<? extends Namespace> namespaces);
|
||||
|
||||
/**
|
||||
* Create a Characters event, this method does not check if the content
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream;
|
||||
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
@ -44,7 +41,7 @@ import java.util.Iterator;
|
||||
* @see XMLEventWriter
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface XMLEventReader extends Iterator {
|
||||
public interface XMLEventReader extends Iterator<Object> {
|
||||
/**
|
||||
* Gets the next XMLEvent. The initial event is
|
||||
* {@link javax.xml.stream.events.StartDocument StartDocument}.
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream;
|
||||
|
||||
import javax.xml.stream.events.*;
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2016, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009, 2013, by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream;
|
||||
|
||||
import com.sun.xml.internal.stream.XMLInputFactoryImpl;
|
||||
@ -225,6 +222,7 @@ public abstract class XMLInputFactory {
|
||||
* java.util.ServiceConfigurationError service configuration error} or if
|
||||
* the implementation is not available or cannot be instantiated.
|
||||
*/
|
||||
@Deprecated(since="7")
|
||||
public static XMLInputFactory newFactory()
|
||||
throws FactoryConfigurationError
|
||||
{
|
||||
@ -246,6 +244,7 @@ public abstract class XMLInputFactory {
|
||||
* #newFactory(java.lang.String, java.lang.ClassLoader)} method
|
||||
* defines no changes in behavior.
|
||||
*/
|
||||
@Deprecated(since="7")
|
||||
public static XMLInputFactory newInstance(String factoryId,
|
||||
ClassLoader classLoader)
|
||||
throws FactoryConfigurationError {
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2016, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009, 2013, by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream;
|
||||
|
||||
import com.sun.xml.internal.stream.XMLOutputFactoryImpl;
|
||||
@ -121,7 +118,7 @@ public abstract class XMLOutputFactory {
|
||||
|
||||
protected XMLOutputFactory(){}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Creates a new instance of the {@code XMLOutputFactory} builtin
|
||||
* system-default implementation.
|
||||
*
|
||||
@ -225,6 +222,7 @@ public abstract class XMLOutputFactory {
|
||||
* Use the new method {@link #newFactory(java.lang.String,
|
||||
* java.lang.ClassLoader)} instead.
|
||||
*/
|
||||
@Deprecated(since="7")
|
||||
public static XMLInputFactory newInstance(String factoryId,
|
||||
ClassLoader classLoader)
|
||||
throws FactoryConfigurationError {
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* 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
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream;
|
||||
|
||||
import javax.xml.namespace.NamespaceContext;
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream;
|
||||
|
||||
import javax.xml.namespace.NamespaceContext;
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream.events;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream.events;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream.events;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream.events;
|
||||
|
||||
import java.util.List;
|
||||
@ -39,36 +36,40 @@ import java.util.List;
|
||||
*/
|
||||
public interface DTD extends XMLEvent {
|
||||
|
||||
/**
|
||||
* Returns the entire Document Type Declaration as a string, including
|
||||
* the internal DTD subset.
|
||||
* This may be null if there is not an internal subset.
|
||||
* If it is not null it must return the entire
|
||||
* Document Type Declaration which matches the doctypedecl
|
||||
* production in the XML 1.0 specification
|
||||
*/
|
||||
String getDocumentTypeDeclaration();
|
||||
/**
|
||||
* Returns the entire Document Type Declaration as a string, including the
|
||||
* internal DTD subset. This may be null if there is not an internal subset.
|
||||
* If it is not null it must return the entire Document Type Declaration
|
||||
* which matches the doctypedecl production in the XML 1.0 specification
|
||||
*
|
||||
* @return the Document Type Declaration
|
||||
*/
|
||||
String getDocumentTypeDeclaration();
|
||||
|
||||
/**
|
||||
* Returns an implementation defined representation of the DTD.
|
||||
* This method may return null if no representation is available.
|
||||
*/
|
||||
Object getProcessedDTD();
|
||||
/**
|
||||
* Returns an implementation defined representation of the DTD. This method
|
||||
* may return null if no representation is available.
|
||||
*
|
||||
* @return the representation of the DTD
|
||||
*/
|
||||
Object getProcessedDTD();
|
||||
|
||||
/**
|
||||
* Return a List containing the notations declared in the DTD.
|
||||
* This list must contain NotationDeclaration events.
|
||||
* @see NotationDeclaration
|
||||
* @return an unordered list of NotationDeclaration events
|
||||
*/
|
||||
List getNotations();
|
||||
/**
|
||||
* Return a List containing the notations declared in the DTD. This list
|
||||
* must contain NotationDeclaration events.
|
||||
*
|
||||
* @see NotationDeclaration
|
||||
* @return an unordered list of NotationDeclaration events
|
||||
*/
|
||||
List<NotationDeclaration> getNotations();
|
||||
|
||||
/**
|
||||
* Return a List containing the general entities,
|
||||
* both external and internal, declared in the DTD.
|
||||
* This list must contain EntityDeclaration events.
|
||||
* @see EntityDeclaration
|
||||
* @return an unordered list of EntityDeclaration events
|
||||
*/
|
||||
List getEntities();
|
||||
/**
|
||||
* Return a List containing the general entities, both external and
|
||||
* internal, declared in the DTD. This list must contain EntityDeclaration
|
||||
* events.
|
||||
*
|
||||
* @see EntityDeclaration
|
||||
* @return an unordered list of EntityDeclaration events
|
||||
*/
|
||||
List<EntityDeclaration> getEntities();
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream.events;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream.events;
|
||||
|
||||
import java.util.Iterator;
|
||||
@ -54,6 +51,6 @@ public interface EndElement extends XMLEvent {
|
||||
* @return an Iterator over Namespace interfaces, or an
|
||||
* empty iterator
|
||||
*/
|
||||
public Iterator getNamespaces();
|
||||
public Iterator<Namespace> getNamespaces();
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream.events;
|
||||
/**
|
||||
* An interface for handling Entity Declarations
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream.events;
|
||||
/**
|
||||
* An interface for handling Entity events.
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream.events;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream.events;
|
||||
/**
|
||||
* An interface for handling Notation Declarations
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream.events;
|
||||
/**
|
||||
* An interface that describes the data found in processing instructions
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream.events;
|
||||
/**
|
||||
* An interface for the start document event
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,16 +23,10 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream.events;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.namespace.NamespaceContext;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
@ -62,7 +57,7 @@ public interface StartElement extends XMLEvent {
|
||||
* @return a readonly Iterator over Attribute interfaces, or an
|
||||
* empty iterator
|
||||
*/
|
||||
public Iterator getAttributes();
|
||||
public Iterator<Attribute> getAttributes();
|
||||
|
||||
/**
|
||||
* Returns an Iterator of namespaces declared on this element.
|
||||
@ -87,7 +82,7 @@ public interface StartElement extends XMLEvent {
|
||||
* empty iterator
|
||||
*
|
||||
*/
|
||||
public Iterator getNamespaces();
|
||||
public Iterator<Namespace> getNamespaces();
|
||||
|
||||
/**
|
||||
* Returns the attribute referred to by this name
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream.events;
|
||||
|
||||
import java.io.Writer;
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,17 +23,10 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream.util;
|
||||
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.namespace.NamespaceContext;
|
||||
import javax.xml.stream.XMLEventReader;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
import javax.xml.stream.Location;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,13 +23,8 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream.util;
|
||||
|
||||
import java.io.Reader;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.namespace.NamespaceContext;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream.util;
|
||||
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 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
|
||||
@ -22,10 +23,6 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 by Oracle Corporation. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package javax.xml.stream.util;
|
||||
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
|
Loading…
x
Reference in New Issue
Block a user