View Javadoc

1   /*   Copyright 2004 BEA Systems, Inc.
2    *
3    *   Licensed under the Apache License, Version 2.0 (the "License");
4    *   you may not use this file except in compliance with the License.
5    *   You may obtain a copy of the License at
6    *
7    *       http://www.apache.org/licenses/LICENSE-2.0
8    *
9    *   Unless required by applicable law or agreed to in writing, software
10   *   distributed under the License is distributed on an "AS IS" BASIS,
11   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   *   See the License for the specific language governing permissions and
13   *   limitations under the License.
14   */
15  
16  package com.bea.xml.stream.events;
17  import javax.xml.stream.events.XMLEvent;
18  import javax.xml.stream.events.EntityReference;
19  import javax.xml.stream.events.EntityDeclaration;
20  public class EntityReferenceEvent 
21    extends BaseEvent 
22    implements EntityReference
23  {
24    private String name;
25    private String replacementText;
26    private EntityDeclaration ed;
27    public EntityReferenceEvent() {super();init();}
28    public EntityReferenceEvent(String name,
29                                EntityDeclaration ed) {
30      super();
31      init();
32      this.name = name;
33      this.ed = ed;
34    }
35    public String getReplacementText() {
36      return ed.getReplacementText();
37    }
38    public String getName() {
39      return name;
40    }
41    public void setName(String name) {
42      this.name = name;
43    }
44    public void setReplacementText(String text) {
45      this.replacementText = text;
46    }
47    public String getBaseURI() {
48      return null;
49    }
50    public String getPublicId() {
51      return null;
52    }
53    public String getSystemId() {
54      return null;
55    }
56    public EntityDeclaration getDeclaration() {
57      return ed;
58    }
59    protected void init() {setEventType(XMLEvent.ENTITY_REFERENCE); }
60    public String toString() {
61      String replacement = getReplacementText();
62      if (replacement == null) replacement="";
63      return "&"+
64        getName()+
65        ":='"+
66        replacement+
67        "'"; 
68    }
69  }