1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package com.bea.xml.stream.events;
16
17 import java.io.Writer;
18 import javax.xml.stream.XMLStreamException;
19 import javax.xml.namespace.QName;
20 import javax.xml.stream.events.XMLEvent;
21 import javax.xml.stream.Location;
22 import javax.xml.stream.events.StartElement;
23 import javax.xml.stream.events.EndElement;
24 import javax.xml.stream.events.Characters;
25 import com.bea.xml.stream.util.ElementTypeNames;
26
27 /***
28 * <p> Base event class for events to extend from </p>
29 */
30
31
32 public class BaseEvent implements XMLEvent, Location {
33 private int eventType = -1;
34 private int line = -1;
35 private int column = -1;
36 private int characterOffset = 0;
37 private String locationURI;
38 public BaseEvent(){}
39 public BaseEvent(int type) {
40 eventType = type;
41 }
42 public int getEventType() {
43 return eventType;
44 }
45 protected void setEventType(int type) {
46 this.eventType = type;
47 }
48 public String getTypeAsString() {
49 return ElementTypeNames.getEventTypeString(eventType);
50 }
51 public boolean isStartElement() {
52 return (eventType == XMLEvent.START_ELEMENT);
53 }
54 public boolean isEndElement() {
55 return (eventType == XMLEvent.END_ELEMENT);
56 }
57 public boolean isEntityReference(){
58 return (eventType == XMLEvent.ENTITY_REFERENCE);
59 }
60 public boolean isProcessingInstruction(){
61 return (eventType == XMLEvent.PROCESSING_INSTRUCTION);
62 }
63 public boolean isCharacters(){
64 return (eventType == XMLEvent.CHARACTERS);
65 }
66 public boolean isStartDocument(){
67 return (eventType == XMLEvent.START_DOCUMENT);
68 }
69 public boolean isEndDocument(){
70 return (eventType == XMLEvent.END_DOCUMENT);
71 }
72 public boolean isAttribute(){
73 return (eventType == XMLEvent.ATTRIBUTE);
74 }
75 public boolean isNamespace(){
76 return (eventType == XMLEvent.NAMESPACE);
77 }
78
79 public Location getLocation() {
80 return this;
81 }
82 public String getPublicId() {
83 return null;
84 }
85 public String getSystemId() {
86 return null;
87 }
88 public String getSourceName() { return null; }
89 public int getLineNumber() { return line; }
90 public void setLineNumber(int line) { this.line = line; }
91 public int getColumnNumber() { return column; }
92 public void setColumnNumber(int col) { this.column = col; }
93 public int getCharacterOffset() { return characterOffset; }
94 public void setCharacterOffset(int c) { characterOffset = c; }
95 public String getLocationURI() { return locationURI; }
96 public void setLocationURI(String uri) { locationURI = uri; }
97 public StartElement asStartElement() {
98 return (StartElement) this;
99 }
100 public EndElement asEndElement() {
101 return (EndElement) this;
102 }
103 public Characters asCharacters() {
104 return (Characters) this;
105 }
106 public void recycle() {
107 }
108 public QName getSchemaType() { return null; }
109
110 public void writeAsEncodedUnicode(Writer writer)
111 throws XMLStreamException
112 {
113
114 }
115
116 }
117