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.ProcessingInstruction;
19  import javax.xml.namespace.QName;
20  public class ProcessingInstructionEvent 
21    extends BaseEvent
22    implements ProcessingInstruction 
23  {
24    String name;
25    String content;
26    public ProcessingInstructionEvent() {super();init();}
27    public ProcessingInstructionEvent(String name, String content) {
28      super(); init();
29      this.name = name;
30      this.content=content;
31    }
32    protected void init() {setEventType(XMLEvent.PROCESSING_INSTRUCTION); }
33    public String getTarget() {
34      return name;
35    }
36    public void setTarget(String target) {
37      name= target;
38    }
39    public void setData(String data) {
40      this.content = data;
41    }
42    public String getData() {
43      return content;
44    }
45    public String toString() {
46      if (content != null &&
47          name != null)
48        return("<?"+name+content+"?>");
49      else if (name != null)
50        return("<?"+name+"?>");
51      else if (content != null)
52        return("<?"+content+"?>");
53      return("<??>");
54    }
55  }