001: /*
002: * $Id: EventFactory.java,v 1.1 2004/07/05 23:09:59 cniles Exp $
003: *
004: * Copyright (c) 2004, Christian Niles, unit12.net
005: * All rights reserved.
006: *
007: * Redistribution and use in source and binary forms, with or without
008: * modification, are permitted provided that the following conditions are met:
009: *
010: * * Redistributions of source code must retain the above copyright
011: * notice, this list of conditions and the following disclaimer.
012: *
013: * * Redistributions in binary form must reproduce the above copyright
014: * notice, this list of conditions and the following disclaimer in the
015: * documentation and/or other materials provided with the distribution.
016: *
017: * * Neither the name of Christian Niles, Unit12, nor the names of its
018: * contributors may be used to endorse or promote products derived from
019: * this software without specific prior written permission.
020: *
021: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
022: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
023: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
024: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
025: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
026: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
027: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
028: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
029: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
030: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
031: * POSSIBILITY OF SUCH DAMAGE.
032: *
033: */
034: package javanet.staxutils.events;
035:
036: import java.util.Iterator;
037:
038: import javax.xml.namespace.NamespaceContext;
039: import javax.xml.namespace.QName;
040: import javax.xml.stream.Location;
041: import javax.xml.stream.events.Attribute;
042: import javax.xml.stream.events.Characters;
043: import javax.xml.stream.events.Comment;
044: import javax.xml.stream.events.DTD;
045: import javax.xml.stream.events.EndDocument;
046: import javax.xml.stream.events.EndElement;
047: import javax.xml.stream.events.EntityDeclaration;
048: import javax.xml.stream.events.EntityReference;
049: import javax.xml.stream.events.Namespace;
050: import javax.xml.stream.events.ProcessingInstruction;
051: import javax.xml.stream.events.StartDocument;
052: import javax.xml.stream.events.StartElement;
053:
054: /**
055: * Factory for events within this package.
056: *
057: * @author Christian Niles
058: * @version $Revision: 1.1 $
059: */
060: public class EventFactory extends BaseXMLEventFactory {
061:
062: public Attribute createAttribute(QName name, String value,
063: Location location, QName schemaType) {
064:
065: return new AttributeEvent(name, value, location, schemaType);
066:
067: }
068:
069: public Characters createCData(String content, Location location,
070: QName schemaType) {
071:
072: return new CDataEvent(content, location, schemaType);
073:
074: }
075:
076: public Characters createCharacters(String content,
077: Location location, QName schemaType) {
078:
079: return new CharactersEvent(content, location, schemaType);
080:
081: }
082:
083: public Comment createComment(String text, Location location) {
084:
085: return new CommentEvent(text, location);
086:
087: }
088:
089: public DTD createDTD(String dtd, Location location) {
090:
091: return new DTDEvent(dtd, location);
092:
093: }
094:
095: public EndDocument createEndDocument(Location location) {
096:
097: return new EndDocumentEvent(location);
098:
099: }
100:
101: public EndElement createEndElement(QName name, Iterator namespaces,
102: Location location, QName schemaType) {
103:
104: return new EndElementEvent(name, namespaces, location,
105: schemaType);
106:
107: }
108:
109: public EntityReference createEntityReference(String name,
110: EntityDeclaration declaration, Location location) {
111:
112: return new EntityReferenceEvent(name, declaration, location);
113:
114: }
115:
116: public Characters createIgnorableSpace(String content,
117: Location location) {
118:
119: return new IgnorableSpaceEvent(content, location);
120:
121: }
122:
123: public Namespace createNamespace(String prefix,
124: String namespaceUri, Location location) {
125:
126: return new NamespaceEvent(prefix, namespaceUri, location);
127:
128: }
129:
130: public ProcessingInstruction createProcessingInstruction(
131: String target, String data, Location location) {
132:
133: return new ProcessingInstructionEvent(target, data, location);
134:
135: }
136:
137: public Characters createSpace(String content, Location location) {
138:
139: return new IgnorableSpaceEvent(content, location);
140:
141: }
142:
143: public StartDocument createStartDocument(String encoding,
144: String version, Boolean standalone, Location location,
145: QName schemaType) {
146:
147: return new StartDocumentEvent(encoding, standalone, version,
148: location, schemaType);
149:
150: }
151:
152: public StartElement createStartElement(QName name,
153: Iterator attributes, Iterator namespaces,
154: NamespaceContext namespaceCtx, Location location,
155: QName schemaType) {
156:
157: return new StartElementEvent(name, attributes, namespaces,
158: namespaceCtx, location, schemaType);
159:
160: }
161: }
|