1 package eu.simuline.relana.sys;
2
3 import eu.simuline.relana.model.ClassLocator;
4 import eu.simuline.relana.model.InstanceLocator;
5
6 import eu.simuline.util.sgml.ParseExceptionHandler;
7
8
9 import java.net.URL;
10 import java.net.MalformedURLException;
11
12 import java.util.Set;
13 import java.util.HashSet;
14
15 import org.xml.sax.ContentHandler;
16 import org.xml.sax.Locator;
17 import org.xml.sax.SAXException;
18 import org.xml.sax.Attributes;
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 public final class Project
34 implements ProjectDesc, ContentHandler, ParseExceptionHandler {
35
36
37
38
39
40 private URL library;
41 private ClassLocator baseClass;
42 private final Set<InstanceLocator> outputEffects;
43
44
45
46
47
48 public Project() {
49
50 this.outputEffects = new HashSet<InstanceLocator>();
51 }
52
53
54
55
56
57
58
59 public URL getLibrary() {
60 return this.library;
61 }
62
63 public ClassLocator getBaseClass() {
64 return this.baseClass;
65 }
66
67 public Set<InstanceLocator> getOutputEffects() {
68 return this.outputEffects;
69 }
70
71
72
73
74
75 public void setDocumentLocator(Locator locator) {
76
77 }
78
79 public void startDocument() throws SAXException {
80
81 }
82
83 public void endDocument() throws SAXException {
84
85 }
86
87 public void startPrefixMapping(String prefix,
88 String uri)
89 throws SAXException {
90
91 }
92
93 public void endPrefixMapping(String prefix)
94 throws SAXException {
95
96 }
97
98 public void startElement(String namespaceURI,
99 String localName,
100 String qName,
101 Attributes atts)
102 throws SAXException {
103 if ("Rml".equals(qName)) {
104 this.baseClass = ClassLocator
105 .getLocator(atts.getValue("baseClass"));
106 try {
107 this.library = new URL(atts.getValue("library"));
108 } catch (MalformedURLException e) {
109 throw new SAXException
110 ("Found malformed url \"" + atts.getValue("library") +
111 "\". ");
112 }
113 return;
114 }
115 if ("Output".equals(qName)) {
116 InstanceLocator loc = InstanceLocator
117 .getLocator(atts.getValue("effect"));
118 this.outputEffects.add(loc);
119 }
120 }
121
122 public void endElement(String namespaceURI,
123 String localName,
124 String qName)
125 throws SAXException {
126
127
128 }
129
130 public void characters(char[] chr,
131 int start,
132 int length)
133 throws SAXException {
134
135 }
136
137 public void ignorableWhitespace(char[] chr,
138 int start,
139 int length)
140 throws SAXException {
141
142 }
143
144 public void processingInstruction(String target,
145 String data)
146 throws SAXException {
147
148
149 }
150
151 public void skippedEntity(String name)
152 throws SAXException {
153
154 }
155
156
157
158
159
160 @edu.umd.cs.findbugs.annotations.SuppressWarnings
161 (value = "UC_USELESS_OBJECT",
162 justification = "use if activated ")
163 public void foundMultipleAttribute(String attrName,
164 Object oldAttrValue) {
165
166
167
168
169
170
171
172
173
174
175
176
177
178 }
179
180
181 public void foundIllegalCharInTag(char chr) {
182
183 }
184
185 public void foundCharAfterEndOfEndTag(char chr) {
186
187 }
188
189 public void foundUnexpectedEndOfDocument() {
190
191 }
192
193
194
195
196
197 public String toString() {
198 StringBuilder res = new StringBuilder();
199 res.append("\n<Rml library=\"");
200 res.append(getLibrary().toString());
201 res.append("\" baseClass=\"");
202 res.append(getBaseClass().getPath().toString());
203 res.append("\">\n</Rml>\n");
204 return res.toString();
205 }
206 }