jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/events/XMLEventFactoryImpl.java
changeset 25868 686eef1e7a79
parent 12457 c348e06f0e82
child 42802 2a03abb03c06
equal deleted inserted replaced
25867:3d364c870c90 25868:686eef1e7a79
       
     1 /*
       
     2  * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.  Oracle designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Oracle in the LICENSE file that accompanied this code.
       
    10  *
       
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14  * version 2 for more details (a copy is included in the LICENSE file that
       
    15  * accompanied this code).
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License version
       
    18  * 2 along with this work; if not, write to the Free Software Foundation,
       
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20  *
       
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    22  * or visit www.oracle.com if you need additional information or have any
       
    23  * questions.
       
    24  */
       
    25 
       
    26 package com.sun.xml.internal.stream.events;
       
    27 
       
    28 import javax.xml.stream.XMLEventFactory;
       
    29 import javax.xml.stream.Location;
       
    30 import javax.xml.stream.events.Namespace;
       
    31 import javax.xml.stream.events.EntityDeclaration;
       
    32 
       
    33 
       
    34 /**
       
    35  *
       
    36  * @author  Neeraj Bajaj, k.venugopal@sun.com
       
    37  */
       
    38 public class XMLEventFactoryImpl extends XMLEventFactory {
       
    39 
       
    40     Location location = null;
       
    41     /** Creates a new instance of XMLEventFactory */
       
    42     public XMLEventFactoryImpl() {
       
    43     }
       
    44 
       
    45     public javax.xml.stream.events.Attribute createAttribute(String localName, String value) {
       
    46         AttributeImpl attr =  new AttributeImpl(localName, value);
       
    47         if(location != null)attr.setLocation(location);
       
    48         return attr;
       
    49     }
       
    50 
       
    51     public javax.xml.stream.events.Attribute createAttribute(javax.xml.namespace.QName name, String value) {
       
    52         return createAttribute(name.getPrefix(), name.getNamespaceURI(), name.getLocalPart(), value);
       
    53     }
       
    54 
       
    55     public javax.xml.stream.events.Attribute createAttribute(String prefix, String namespaceURI, String localName, String value) {
       
    56         AttributeImpl attr =  new AttributeImpl(prefix, namespaceURI, localName, value, null);
       
    57         if(location != null)attr.setLocation(location);
       
    58         return attr;
       
    59     }
       
    60 
       
    61     public javax.xml.stream.events.Characters createCData(String content) {
       
    62         //stax doesn't have separate CDATA event. This is taken care by
       
    63         //CHRACTERS event setting the cdata flag to true.
       
    64         CharacterEvent charEvent =  new CharacterEvent(content, true);
       
    65         if(location != null)charEvent.setLocation(location);
       
    66         return charEvent;
       
    67     }
       
    68 
       
    69     public javax.xml.stream.events.Characters createCharacters(String content) {
       
    70         CharacterEvent charEvent =  new CharacterEvent(content);
       
    71         if(location != null)charEvent.setLocation(location);
       
    72         return charEvent;
       
    73     }
       
    74 
       
    75     public javax.xml.stream.events.Comment createComment(String text) {
       
    76         CommentEvent charEvent =  new CommentEvent(text);
       
    77         if(location != null)charEvent.setLocation(location);
       
    78         return charEvent;
       
    79     }
       
    80 
       
    81     public javax.xml.stream.events.DTD createDTD(String dtd) {
       
    82         DTDEvent dtdEvent = new DTDEvent(dtd);
       
    83         if(location != null)dtdEvent.setLocation(location);
       
    84         return dtdEvent;
       
    85     }
       
    86 
       
    87     public javax.xml.stream.events.EndDocument createEndDocument() {
       
    88         EndDocumentEvent event =new EndDocumentEvent();
       
    89         if(location != null)event.setLocation(location);
       
    90         return event;
       
    91     }
       
    92 
       
    93     public javax.xml.stream.events.EndElement createEndElement(javax.xml.namespace.QName name, java.util.Iterator namespaces) {
       
    94         return createEndElement(name.getPrefix(), name.getNamespaceURI(), name.getLocalPart());
       
    95     }
       
    96 
       
    97     public javax.xml.stream.events.EndElement createEndElement(String prefix, String namespaceUri, String localName) {
       
    98         EndElementEvent event =  new EndElementEvent(prefix, namespaceUri, localName);
       
    99         if(location != null)event.setLocation(location);
       
   100         return event;
       
   101     }
       
   102 
       
   103     public javax.xml.stream.events.EndElement createEndElement(String prefix, String namespaceUri, String localName, java.util.Iterator namespaces) {
       
   104 
       
   105         EndElementEvent event =  new EndElementEvent(prefix, namespaceUri, localName);
       
   106         if(namespaces!=null){
       
   107             while(namespaces.hasNext())
       
   108                 event.addNamespace((Namespace)namespaces.next());
       
   109         }
       
   110         if(location != null)event.setLocation(location);
       
   111         return event;
       
   112     }
       
   113 
       
   114     public javax.xml.stream.events.EntityReference createEntityReference(String name, EntityDeclaration entityDeclaration) {
       
   115         EntityReferenceEvent event =  new EntityReferenceEvent(name, entityDeclaration);
       
   116         if(location != null)event.setLocation(location);
       
   117         return event;
       
   118     }
       
   119 
       
   120     public javax.xml.stream.events.Characters createIgnorableSpace(String content) {
       
   121         CharacterEvent event =  new CharacterEvent(content, false, true);
       
   122         if(location != null)event.setLocation(location);
       
   123         return event;
       
   124     }
       
   125 
       
   126     public javax.xml.stream.events.Namespace createNamespace(String namespaceURI) {
       
   127         NamespaceImpl event =  new NamespaceImpl(namespaceURI);
       
   128         if(location != null)event.setLocation(location);
       
   129         return event;
       
   130     }
       
   131 
       
   132     public javax.xml.stream.events.Namespace createNamespace(String prefix, String namespaceURI) {
       
   133         NamespaceImpl event =  new NamespaceImpl(prefix, namespaceURI);
       
   134         if(location != null)event.setLocation(location);
       
   135         return event;
       
   136     }
       
   137 
       
   138     public javax.xml.stream.events.ProcessingInstruction createProcessingInstruction(String target, String data) {
       
   139         ProcessingInstructionEvent event =  new ProcessingInstructionEvent(target, data);
       
   140         if(location != null)event.setLocation(location);
       
   141         return event;
       
   142     }
       
   143 
       
   144     public javax.xml.stream.events.Characters createSpace(String content) {
       
   145         CharacterEvent event =  new CharacterEvent(content);
       
   146         if(location != null)event.setLocation(location);
       
   147         return event;
       
   148     }
       
   149 
       
   150     public javax.xml.stream.events.StartDocument createStartDocument() {
       
   151         StartDocumentEvent event = new StartDocumentEvent();
       
   152         if(location != null)event.setLocation(location);
       
   153         return event;
       
   154     }
       
   155 
       
   156     public javax.xml.stream.events.StartDocument createStartDocument(String encoding) {
       
   157         StartDocumentEvent event =  new StartDocumentEvent(encoding);
       
   158         if(location != null)event.setLocation(location);
       
   159         return event;
       
   160     }
       
   161 
       
   162     public javax.xml.stream.events.StartDocument createStartDocument(String encoding, String version) {
       
   163         StartDocumentEvent event =  new StartDocumentEvent(encoding, version);
       
   164         if(location != null)event.setLocation(location);
       
   165         return event;
       
   166     }
       
   167 
       
   168     public javax.xml.stream.events.StartDocument createStartDocument(String encoding, String version, boolean standalone) {
       
   169         StartDocumentEvent event =  new StartDocumentEvent(encoding, version, standalone);
       
   170         if(location != null)event.setLocation(location);
       
   171         return event;
       
   172     }
       
   173 
       
   174     public javax.xml.stream.events.StartElement createStartElement(javax.xml.namespace.QName name, java.util.Iterator attributes, java.util.Iterator namespaces) {
       
   175         return createStartElement(name.getPrefix(), name.getNamespaceURI(), name.getLocalPart(), attributes, namespaces);
       
   176     }
       
   177 
       
   178     public javax.xml.stream.events.StartElement createStartElement(String prefix, String namespaceUri, String localName) {
       
   179         StartElementEvent event =  new StartElementEvent(prefix, namespaceUri, localName);
       
   180         if(location != null)event.setLocation(location);
       
   181         return event;
       
   182     }
       
   183 
       
   184     public javax.xml.stream.events.StartElement createStartElement(String prefix, String namespaceUri, String localName, java.util.Iterator attributes, java.util.Iterator namespaces) {
       
   185         return createStartElement(prefix, namespaceUri, localName, attributes, namespaces, null);
       
   186     }
       
   187 
       
   188     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) {
       
   189         StartElementEvent elem =  new StartElementEvent(prefix, namespaceUri, localName);
       
   190         elem.addAttributes(attributes);
       
   191         elem.addNamespaceAttributes(namespaces);
       
   192         elem.setNamespaceContext(context);
       
   193         if(location != null)elem.setLocation(location);
       
   194         return elem;
       
   195     }
       
   196 
       
   197     public void setLocation(javax.xml.stream.Location location) {
       
   198         this.location = location;
       
   199     }
       
   200 
       
   201 }