12005
|
1 |
/*
|
42802
|
2 |
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
|
12005
|
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 |
|
42802
|
28 |
import java.util.List;
|
12005
|
29 |
import javax.xml.stream.events.DTD;
|
42802
|
30 |
import javax.xml.stream.events.EntityDeclaration;
|
|
31 |
import javax.xml.stream.events.NotationDeclaration;
|
12005
|
32 |
import javax.xml.stream.events.XMLEvent;
|
|
33 |
|
|
34 |
/**
|
|
35 |
*
|
42802
|
36 |
* @author Neeraj Bajaj, Sun Microsystesm.
|
12005
|
37 |
*
|
|
38 |
*/
|
42802
|
39 |
public class DTDEvent extends DummyEvent implements DTD {
|
12005
|
40 |
|
|
41 |
private String fDoctypeDeclaration;
|
42802
|
42 |
private List<NotationDeclaration> fNotations;
|
|
43 |
private List<EntityDeclaration> fEntities;
|
12005
|
44 |
|
42802
|
45 |
/**
|
|
46 |
* Creates a new instance of DTDEvent
|
|
47 |
*/
|
12005
|
48 |
public DTDEvent() {
|
|
49 |
init();
|
|
50 |
}
|
|
51 |
|
42802
|
52 |
public DTDEvent(String doctypeDeclaration) {
|
12005
|
53 |
init();
|
|
54 |
fDoctypeDeclaration = doctypeDeclaration;
|
|
55 |
}
|
|
56 |
|
42802
|
57 |
public void setDocumentTypeDeclaration(String doctypeDeclaration) {
|
12005
|
58 |
fDoctypeDeclaration = doctypeDeclaration;
|
|
59 |
}
|
|
60 |
|
42802
|
61 |
@Override
|
12005
|
62 |
public String getDocumentTypeDeclaration() {
|
|
63 |
return fDoctypeDeclaration;
|
|
64 |
}
|
|
65 |
|
|
66 |
//xxx: we can change the signature if the implementation doesn't store the entities in List Datatype.
|
|
67 |
//and then convert that DT to list format here. That way callee dont need to bother about conversion
|
42802
|
68 |
public void setEntities(List<EntityDeclaration> entites) {
|
12005
|
69 |
fEntities = entites;
|
|
70 |
}
|
|
71 |
|
42802
|
72 |
@Override
|
|
73 |
public List<EntityDeclaration> getEntities() {
|
12005
|
74 |
return fEntities;
|
|
75 |
}
|
|
76 |
|
|
77 |
//xxx: we can change the signature if the implementation doesn't store the entities in List Datatype.
|
|
78 |
//and then convert that DT to list format here. That way callee dont need to bother about conversion
|
42802
|
79 |
public void setNotations(List<NotationDeclaration> notations) {
|
12005
|
80 |
fNotations = notations;
|
|
81 |
}
|
|
82 |
|
42802
|
83 |
@Override
|
|
84 |
public List<NotationDeclaration> getNotations() {
|
12005
|
85 |
return fNotations;
|
|
86 |
}
|
|
87 |
|
|
88 |
/**
|
42802
|
89 |
* Returns an implementation defined representation of the DTD. This method
|
|
90 |
* may return null if no representation is available.
|
12005
|
91 |
*
|
|
92 |
*/
|
42802
|
93 |
@Override
|
12005
|
94 |
public Object getProcessedDTD() {
|
|
95 |
return null;
|
|
96 |
}
|
|
97 |
|
42802
|
98 |
protected final void init() {
|
12005
|
99 |
setEventType(XMLEvent.DTD);
|
|
100 |
}
|
|
101 |
|
42802
|
102 |
@Override
|
|
103 |
public String toString() {
|
|
104 |
return fDoctypeDeclaration;
|
12005
|
105 |
}
|
|
106 |
|
42802
|
107 |
@Override
|
12005
|
108 |
protected void writeAsEncodedUnicodeEx(java.io.Writer writer)
|
42802
|
109 |
throws java.io.IOException {
|
12005
|
110 |
writer.write(fDoctypeDeclaration);
|
|
111 |
}
|
|
112 |
}
|