/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Implementation of XMLEvent Allocator.
* @author Neeraj.bajaj@sun.com, k.venugopal@sun.com
*/
/** Creates a new instance of XMLEventAllocator */
public XMLEventAllocatorImpl() {
}
public javax.xml.stream.events.XMLEvent allocate(javax.xml.stream.XMLStreamReader xMLStreamReader) throws javax.xml.stream.XMLStreamException {
if(xMLStreamReader == null )
throw new XMLStreamException("Reader cannot be null");
// allocate is not supposed to change the state of the reader so we shouldn't be calling next.
// return getNextEvent(xMLStreamReader);
return getXMLEvent(xMLStreamReader);
}
public void allocate(javax.xml.stream.XMLStreamReader xMLStreamReader, javax.xml.stream.util.XMLEventConsumer xMLEventConsumer) throws javax.xml.stream.XMLStreamException {
if(currentEvent != null )
return;
}
return new XMLEventAllocatorImpl();
}
//REVISIT: shouldn't we be using XMLEventFactory to create events.
//returns the current event
switch(eventType){
case XMLEvent.START_ELEMENT:{
//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'
}
break;
}
case XMLEvent.END_ELEMENT:{
}
event = endElementEvent ;
break;
}
case XMLEvent.PROCESSING_INSTRUCTION:{
ProcessingInstructionEvent piEvent = new ProcessingInstructionEvent(streamReader.getPITarget(),streamReader.getPIData());
break;
}
case XMLEvent.CHARACTERS:{
event = cDataEvent ;
break;
}
event = commentEvent ;
break;
}
case XMLEvent.START_DOCUMENT:{
sdEvent.setDeclaredEncoding(true);
}else{
sdEvent.setDeclaredEncoding(false);
}
break;
}
case XMLEvent.END_DOCUMENT:{
break;
}
case XMLEvent.ENTITY_REFERENCE:{
EntityReferenceEvent entityEvent = new EntityReferenceEvent(streamReader.getLocalName(), new EntityDeclarationImpl(streamReader.getLocalName(),streamReader.getText()));
event = entityEvent;
break;
}
break;
}
break;
}
event = cDataEvent ;
break;
}
event = spaceEvent ;
break;
}
}
return event ;
}
//this function is not used..
//advance the reader to next event.
streamReader.next();
return getXMLEvent(streamReader);
}
for(int i=0; i<len ;i++){
//this method doesn't include namespace declarations
//so we can be sure that there wont be any namespace declaration as part of this function call
//we can avoid this check - nb.
/**
* prefix = qname.getPrefix();
* localpart = qname.getLocalPart();
* if (prefix.equals(XMLConstants.XMLNS_ATTRIBUTE) ) {
* attr = new NamespaceImpl(localpart,xmlr.getAttributeValue(i));
* }else if (prefix.equals(XMLConstants.DEFAULT_NS_PREFIX)){
* attr = new NamespaceImpl(xmlr.getAttributeValue(i));
* }else{
* attr = new AttributeImpl();
* attr.setName(qname);
* }
**/
attr = new AttributeImpl();
}
}
for(int i=0;i< count;i++){
}
}
}
for(int i=0;i< count;i++){
}
}
}
//Revisit : Creating a new Namespacecontext for now.
//see if we can do better job.
}
}
}