Skip to content

Commit de539d2

Browse files
hansonrhansonr
authored andcommitted
extraneous java.lang.; upgrade of JSSAXParser and SAXParserFactory
1 parent c333bc7 commit de539d2

File tree

4 files changed

+238
-104
lines changed

4 files changed

+238
-104
lines changed

sources/net.sf.j2s.java.core/src/java/awt/geom/NoninvertibleTransformException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
*/
3737

3838
@SuppressWarnings("serial")
39-
public class NoninvertibleTransformException extends java.lang.Exception {
39+
public class NoninvertibleTransformException extends Exception {
4040
/**
4141
* Constructs an instance of
4242
* <code>NoninvertibleTransformException</code>

sources/net.sf.j2s.java.core/src/java/awt/image/RasterFormatException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* invalid layout information in the {@link Raster}.
3535
*/
3636
@SuppressWarnings("serial")
37-
public class RasterFormatException extends java.lang.RuntimeException {
37+
public class RasterFormatException extends RuntimeException {
3838

3939
/**
4040
* Constructs a new <code>RasterFormatException</code> with the

sources/net.sf.j2s.java.core/src/javax/xml/parsers/SAXParserFactory.java

Lines changed: 229 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -7,126 +7,253 @@
77
import java.lang.ClassNotFoundException;
88
import java.lang.IllegalAccessException;
99
import java.lang.InstantiationException;
10+
import java.util.Properties;
1011
import java.lang.ClassCastException;
1112

1213
import javax.xml.parsers.SAXParser;
1314

1415
import javax.xml.sax.Parser;
15-
16+
import javax.xml.sax.XMLReader;
17+
import javax.xml.validation.Schema;
1618

1719
/**
18-
* Java-specific class for dynamically loading SAX parsers.
19-
*
20-
* <p>This class is not part of the platform-independent definition
21-
* of SAX; it is an additional convenience class designed
22-
* specifically for Java XML application writers. SAX applications
23-
* can use the static methods in this class to allocate a SAX parser
24-
* dynamically at run-time based either on the value of the
25-
* `org.xml.sax.parser' system property or on a string containing the class
26-
* name.</p>
27-
*
28-
* <p>Note that the application still requires an XML parser that
29-
* implements SAX.</p>
30-
*
31-
* @author David Megginson (ak117@freenet.carleton.ca)
32-
* @version 1.0
33-
* @see org.xml.sax.Parser
34-
* @see java.lang.Class
35-
*/
20+
*
21+
* SwingJS note: These class in the JDK is abstract. Here we allow instantiation
22+
* just of this. The default parser created is swingjs.JSSAXParser, a minimal implementation,
23+
* but this default can be set by the developer on the page using
24+
*
25+
* System.setProperty("org.xml.sax.parser", fullClassName);
26+
*
27+
*
28+
* Create a new Java-specific class for dynamically loading SAX parsers.
29+
*
30+
* <p>
31+
* This class is not part of the platform-independent definition of SAX; it is
32+
* an additional convenience class designed specifically for Java XML
33+
* application writers. SAX applications can use the static methods in this
34+
* class to allocate a SAX parser dynamically at run-time based either on the
35+
* value of the `org.xml.sax.parser' system property or on a string containing
36+
* the class name.
37+
* </p>
38+
*
39+
* <p>
40+
* Note that the application still requires an XML parser that implements SAX.
41+
* </p>
42+
*
43+
* @author David Megginson (ak117@freenet.carleton.ca)
44+
* @version 1.0
45+
* @see org.xml.sax.Parser
46+
* @see java.lang.Class
47+
*/
3648
@SuppressWarnings("deprecation")
3749
public class SAXParserFactory {
3850

51+
private Properties props = new Properties();
52+
53+
private boolean validating;
54+
private boolean xIncludeAware;
55+
private boolean nameSpaceAware;
56+
57+
Schema schema; // SwingJS: This class is not implemented
58+
59+
/**
60+
* Obtain a new instance of a SAXParserFactory from class name.
61+
*
62+
*
63+
* @param factoryClassName
64+
* @param classLoader
65+
* @return
66+
* @throws ClassNotFoundException
67+
* @throws IllegalAccessException
68+
* @throws InstantiationException
69+
*/
70+
static SAXParserFactory newInstance(String factoryClassName, ClassLoader classLoader) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
71+
return (SAXParserFactory) Class.forName(factoryClassName).newInstance();
72+
}
73+
3974
/**
4075
* Just use this class
4176
*
4277
* @return
4378
*/
4479

45-
public static SAXParserFactory newInstance() {
46-
return new SAXParserFactory();
47-
}
48-
49-
/**
50-
* Just get a Parser
51-
*
52-
* @return
53-
*/
54-
public SAXParser newSAXParser() {
55-
try {
56-
// double qualification will be ignored in JavaScript
57-
return (SAXParser) (Object) makeParser();
80+
public static SAXParserFactory newInstance() {
81+
return new SAXParserFactory();
82+
}
83+
84+
/**
85+
* Just get a Parser
86+
*
87+
* @return
88+
*/
89+
public SAXParser newSAXParser() {
90+
try {
91+
SAXParser p = (SAXParser) makeParser();
92+
if (p instanceof XMLReader) {
93+
XMLReader r = (XMLReader) p;
94+
for (Object name : props.keySet()) {
95+
r.setProperty((String) name, props.getProperty((String)name));
96+
}
97+
}
98+
return p;
5899
} catch (Exception e) {
59100
return null;
60101
}
61-
}
62-
63-
64-
/**
65-
* Create a new SAX parser using the `org.xml.sax.parser' system property.
66-
*
67-
* <p>The named class must exist and must implement the
68-
* org.xml.sax.Parser interface.</p>
69-
*
70-
* @exception java.lang.NullPointerException There is no value
71-
* for the `org.xml.sax.parser' system property.
72-
* @exception java.lang.ClassNotFoundException The SAX parser
73-
* class was not found (check your CLASSPATH).
74-
* @exception IllegalAccessException The SAX parser class was
75-
* found, but you do not have permission to load
76-
* it.
77-
* @exception InstantiationException The SAX parser class was
78-
* found but could not be instantiated.
79-
* @exception java.lang.ClassCastException The SAX parser class
80-
* was found and instantiated, but does not implement
81-
* org.xml.sax.Parser.
82-
* @see #makeParser(java.lang.String)
83-
* @see org.xml.sax.Parser
84-
*/
85-
public static Parser makeParser ()
86-
throws ClassNotFoundException,
87-
IllegalAccessException,
88-
InstantiationException,
89-
NullPointerException,
90-
ClassCastException
91-
{
92-
// SwingJS -- directs to swingjs.JSSAXParser
93-
String className = System.getProperty("org.xml.sax.parser", "swingjs.JSSAXParser");
94-
if (className == null) {
95-
throw new NullPointerException("No value for sax.parser property");
96-
} else {
97-
return makeParser(className);
98-
}
99-
}
100-
101-
/**
102-
* Create a new SAX parser object using the class name provided.
103-
*
104-
* <p>The named class must exist and must implement the
105-
* org.xml.sax.Parser interface.</p>
106-
*
107-
* @param className A string containing the name of the
108-
* SAX parser class.
109-
* @exception java.lang.ClassNotFoundException The SAX parser
110-
* class was not found (check your CLASSPATH).
111-
* @exception IllegalAccessException The SAX parser class was
112-
* found, but you do not have permission to load
113-
* it.
114-
* @exception InstantiationException The SAX parser class was
115-
* found but could not be instantiated.
116-
* @exception java.lang.ClassCastException The SAX parser class
117-
* was found and instantiated, but does not implement
118-
* org.xml.sax.Parser.
119-
* @see #makeParser()
120-
* @see org.xml.sax.Parser
121-
*/
122-
public static Parser makeParser (String className)
123-
throws ClassNotFoundException,
124-
IllegalAccessException,
125-
InstantiationException,
126-
ClassCastException
127-
{
128-
return (Parser)(Class.forName(className).newInstance());
129-
}
102+
}
130103

131-
}
104+
/**
105+
* Create a new SAX parser using the `org.xml.sax.parser' system property.
106+
*
107+
* <p>
108+
* The named class must exist and must implement the org.xml.sax.Parser
109+
* interface.
110+
* </p>
111+
*
112+
* @exception java.lang.NullPointerException There is no
113+
* value for the `org.xml.sax.parser' system
114+
* property.
115+
* @exception java.lang.ClassNotFoundException The SAX
116+
* parser class was not found (check your
117+
* CLASSPATH).
118+
* @exception IllegalAccessException The SAX parser class was found, but you do
119+
* not have permission to load it.
120+
* @exception InstantiationException The SAX parser class was found but could
121+
* not be instantiated.
122+
* @exception java.lang.ClassCastException The SAX parser
123+
* class was found and instantiated, but does
124+
* not implement org.xml.sax.Parser.
125+
* @see #makeParser(java.lang.String)
126+
* @see org.xml.sax.Parser
127+
*/
128+
public static Parser makeParser() throws ClassNotFoundException, IllegalAccessException, InstantiationException,
129+
NullPointerException, ClassCastException {
130+
// SwingJS -- directs to swingjs.JSSAXParser
131+
String className = System.getProperty("org.xml.sax.parser", "swingjs.JSSAXParser");
132+
if (className == null) {
133+
throw new NullPointerException("No value for sax.parser property");
134+
} else {
135+
return makeParser(className);
136+
}
137+
}
138+
139+
/**
140+
*
141+
* SAX parser object using the class name provided.
142+
*
143+
* <p>
144+
* The named class must exist and must implement the org.xml.sax.Parser
145+
* interface.
146+
* </p>
147+
*
148+
* @param className A string containing the name of the SAX parser class.
149+
* @exception java.lang.ClassNotFoundException The SAX
150+
* parser class was not found (check your
151+
* CLASSPATH).
152+
* @exception IllegalAccessException The SAX parser class was found, but you do
153+
* not have permission to load it.
154+
* @exception InstantiationException The SAX parser class was found but could
155+
* not be instantiated.
156+
* @exception java.lang.ClassCastException The SAX parser
157+
* class was found and instantiated, but does
158+
* not implement org.xml.sax.Parser.
159+
* @see #makeParser()
160+
* @see org.xml.sax.Parser
161+
*/
162+
public static Parser makeParser(String className)
163+
throws ClassNotFoundException, IllegalAccessException, InstantiationException, ClassCastException {
164+
return (Parser) (Class.forName(className).newInstance());
165+
}
166+
167+
/**
168+
* Returns the particular property requested for in the underlying
169+
* implementation of org.xml.sax.XMLReader.
170+
*
171+
* @param name
172+
* @return
173+
*/
174+
public boolean getFeature(String name) {
175+
return props.getProperty(name, "false").equals("true");
176+
}
177+
178+
179+
/**
180+
* Gets the Schema object specified through the setSchema(Schema schema) method.
181+
*
182+
* @return
183+
*/
184+
public Schema getSchema() {
185+
return schema;
186+
}
132187

188+
/**
189+
* Indicates whether or not the factory is configured to produce parsers which
190+
* are namespace aware.
191+
*
192+
* @return
193+
*/
194+
public boolean isNamespaceAware() {
195+
return nameSpaceAware;
196+
}
197+
198+
/**
199+
* Indicates whether or not the factory is configured to produce parsers which
200+
* validate the XML content during parse.
201+
*
202+
* @return
203+
*/
204+
public boolean isValidating() {
205+
return validating;
206+
}
207+
208+
/**
209+
* Get state of XInclude processing.
210+
*
211+
* @return
212+
*/
213+
public boolean isXIncludeAware() {
214+
return xIncludeAware;
215+
}
216+
217+
public void setFeature(String name, boolean value) {
218+
props.setProperty(name, "" + value);
219+
}
220+
221+
/**
222+
* Specifies that the parser produced by this code will provide support for XML
223+
* namespaces.
224+
*
225+
* @param awareness
226+
*/
227+
public void setNamespaceAware(boolean awareness) {
228+
nameSpaceAware = awareness;
229+
230+
}
231+
232+
/**
233+
* Set the Schema to be used by parsers created from this factory.
234+
*
235+
* @param schema
236+
*/
237+
public void setSchema(Schema schema) {
238+
this.schema = schema;
239+
}
240+
241+
/**
242+
* Specifies that the parser produced by this code will validate documents as
243+
* they are parsed.
244+
*
245+
* @param validating
246+
*/
247+
public void setValidating(boolean validating) {
248+
this.validating = validating;
249+
}
250+
251+
/**
252+
* Set state of XInclude processing.
253+
*
254+
* @param state
255+
*/
256+
public void setXIncludeAware(boolean state) {
257+
this.xIncludeAware = state;
258+
}
259+
}

sources/net.sf.j2s.java.core/src/swingjs/JSSAXParser.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ private void error(Exception e) throws SAXException {
152152

153153
private boolean ver2;
154154

155+
156+
/**
157+
* early Jmol method allowing reading data from an XHTML document
158+
*
159+
* @param doc
160+
* @throws SAXException
161+
*/
155162
private void parseDocument(DOMNode doc) throws SAXException {
156163
if (docHandler == null && contentHandler == null)
157164
contentHandler = new JSSAXContentHandler();

0 commit comments

Comments
 (0)