📄 jenareader.java
字号:
* </dd>
* <dt>
* SAX2 properties
* </dt>
* <dd>
* See <a href="http://xml.apache.org/xerces-j/properties.html">Xerces properties</a>.
* </dd>
* <dt>
* Xerces features
* </dt>
* <dd>
* See <a href="http://xml.apache.org/xerces-j/features.html">Xerces features</a>.
* Value should be given as a String "true" or "false" or a Boolean.
* </dd>
* <dt>
* Xerces properties
* </dt>
* <dd>
* See <a href="http://xml.apache.org/xerces-j/properties.html">Xerces properties</a>.
* </dd>
* <dt>
* ARP properties
* </dt>
* <dd>
* These are referred to either by their property name, (see below) or by
* an absolute URL of the form <code>http://jena.hpl.hp.com/arp/properties/<PropertyName></code>.
* The value should be a String, an Integer or a Boolean depending on the property.
* <br>
* ARP property names and string values are case insensitive.
* <br>
* <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0">
* <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
* <TD COLSPAN=4><FONT SIZE="+2">
* <B>ARP Properties</B></FONT></TD>
* </TR>
* <tr BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
* <th>Property Name</th>
* <th>Description</th>
* <th>Value class</th>
* <th>Legal Values</th>
* </tr>
* <tr BGCOLOR="white" CLASS="TableRowColor">
* <td><CODE>error-mode</CODE></td>
* <td>
* {@link ARP#setDefaultErrorMode}<br>
* {@link ARP#setLaxErrorMode}<br>
* {@link ARP#setStrictErrorMode}<br>
* {@link ARP#setStrictErrorMode(int)}<br>
* </td>
* <td>String</td>
* <td><CODE>default</CODE><br>
* <CODE>lax</CODE><br>
* <CODE>strict</CODE><br>
* <CODE>strict-ignore</CODE><br>
* <CODE>strict-warning</CODE><br>
* <CODE>strict-error</CODE><br>
* <CODE>strict-fatal</CODE><br></td>
* </tr>
* <tr BGCOLOR="white" CLASS="TableRowColor">
* <td><CODE>embedding</CODE></td>
* <td>
* {@link ARP#setEmbedding}
* </td>
* <td>String or Boolean</td>
* <td><CODE>true</CODE> or <CODE>false</CODE></td>
* </tr>
* <tr BGCOLOR="white" CLASS="TableRowColor">
* <td>
* <code>ERR_<XXX></code><br>
* <code>WARN_<XXX></code><br>
* <code>IGN_<XXX></code></td>
* <td>
* {@link ARPErrorNumbers}<br>
* Any of the error condition numbers listed.<br>
* {@link ARP#setErrorMode(int, int)}
* </td>
* <td>String or Integer</td>
* <td>{@link ARPErrorNumbers#EM_IGNORE EM_IGNORE}<br>
* {@link ARPErrorNumbers#EM_WARNING EM_WARNING}<br>
* {@link ARPErrorNumbers#EM_ERROR EM_ERROR}<br>
* {@link ARPErrorNumbers#EM_FATAL EM_FATAL}<br>
* </td>
* </tr>
* </table>
* </dd>
* </dl>
*
* @param str The property to set.
* @param value The new value; values of class String will be converted into appropriate classes. Values of
* class Boolean or Integer will be used for appropriate properties.
* @throws RDFException For bad values.
* @return The old value, or null if none, or old value is inaccesible.
*/
public Object setProperty(String str,Object value) throws RDFException {
Object obj = value;
if ( str.startsWith("http:") ) {
if ( str.startsWith( arpPropertiesURL ) ) {
return setArpProperty( str.substring(arpPropertiesURLLength ), obj );
}
if ( str.startsWith( saxPropertiesURL ) || str.startsWith( apachePropertiesURL ) ) {
Object old;
try {
old = arpf.getProperty(str);
}
catch (SAXNotSupportedException ns) {
old = null;
}
catch (SAXNotRecognizedException nr) {
errorHandler.error(new RDFException(RDFException.UNKNOWNPROPERTY));
return null;
}
try {
arpf.setProperty(str,obj);
}
catch (SAXNotSupportedException ns) {
errorHandler.error(new RDFException(ns));
}
catch (SAXNotRecognizedException nr) {
errorHandler.error(new RDFException(RDFException.UNKNOWNPROPERTY));
return null;
}
return old;
}
if ( str.startsWith( saxFeaturesURL ) || str.startsWith( apacheFeaturesURL ) ) {
Boolean old;
try {
old = new Boolean( arpf.getFeature(str) );
}
catch (SAXNotSupportedException ns) {
old = null;
}
catch (SAXNotRecognizedException nr) {
errorHandler.error(new RDFException(RDFException.UNKNOWNPROPERTY));
return null;
}
try {
arpf.setFeature(str,((Boolean)obj).booleanValue());
}
catch (SAXNotSupportedException ns) {
errorHandler.error(new RDFException(ns));
}
catch (SAXNotRecognizedException nr) {
errorHandler.error(new RDFException(RDFException.UNKNOWNPROPERTY));
return null;
}
catch (ClassCastException cc) {
errorHandler.error(new RDFException(new SAXNotSupportedException("Feature: '"+str+"' can only have a boolean value.")));
}
return old;
}
}
return setArpProperty(str,obj);
}
static public int errorCode(String upper) {
Class c = ARPErrorNumbers.class;
try {
java.lang.reflect.Field fld = c.getField(upper);
return fld.getInt(null);
}
catch (Exception e) {
return -1;
}
}
static public String errorCodeName(int errNo) {
Class c = ARPErrorNumbers.class;
java.lang.reflect.Field flds[] = c.getDeclaredFields();
for (int i=0;i<flds.length;i++) {
try {
if ( flds[i].getInt(null) == errNo )
return flds[i].getName();
}
catch (Exception e) {
}
}
return null;
}
/**Supported proprties:
* error-mode (String) default, lax, strict, strict-ignore, strict-warning, strict-error, strict-fatal
* embedding (String/Boolean) true, false
* ERR_* (String/Integer) em_warning, em_fatal, em_ignore, em_error
* IGN_* ditto
* WARN_* ditto
*/
private Object setArpProperty(String str,Object v) {
str = str.toUpperCase();
if ( v == null )
v = "";
if ( v instanceof String ) {
v = ((String)v).toUpperCase();
}
if ( str.equals("ERROR-MODE") ) {
if ( v instanceof String ) {
String val = (String)v;
if ( val.equals("LAX") ) {
arpf.setLaxErrorMode();
return null;
}
if ( val.equals("DEFAULT") ) {
arpf.setDefaultErrorMode();
return null;
}
if ( val.equals("STRICT") ) {
arpf.setStrictErrorMode();
return null;
}
if ( val.equals("STRICT-WARNING") ) {
arpf.setStrictErrorMode(EM_WARNING);
return null;
}
if ( val.equals("STRICT-FATAL") ) {
arpf.setStrictErrorMode(EM_FATAL);
return null;
}
if ( val.equals("STRICT-IGNORE") ) {
arpf.setStrictErrorMode(EM_IGNORE);
return null;
}
if ( val.equals("STRICT-ERROR") ) {
arpf.setStrictErrorMode(EM_ERROR);
return null;
}
}
errorHandler.error(new IllegalArgumentException(
"Property \"ERROR-MODE\" takes the following values: "
+"\"default\", \"lax\", \"strict\", \"strict-ignore\", \"strict-warning\", \"strict-error\", \"strict-fatal\"."));
return null;
}
if ( str.equals("EMBEDDING") ) {
if ( v instanceof String ) {
v = Boolean.valueOf((String)v);
}
if (!(v instanceof Boolean)) {
// Illegal value.
errorHandler.error(new IllegalArgumentException(
"Property \"EMBEDDING\" requires a boolean value."));
boolean old = arpf.setEmbedding(false);
arpf.setEmbedding(old);
return new Boolean(old);
} else {
return new Boolean(arpf.setEmbedding(((Boolean)v).booleanValue()));
}
}
if ( str.startsWith("ERR_") || str.startsWith("IGN_") || str.startsWith("WARN_") ) {
int cond = errorCode(str);
if ( cond == -1 ) {
// error, see end of function.
} else {
if ( v instanceof String ) {
if ( !((String)v).startsWith("EM_") ) {
// error, see below.
} else {
int val = errorCode((String)v);
if ( val == -1 ) {
// error, see below.
} else {
int rslt = arpf.setErrorMode(cond,val);
return new Integer(rslt);
}
}
} else if ( v instanceof Integer ) {
int val = ((Integer)v).intValue();
switch ( val ) {
case EM_IGNORE:
case EM_WARNING:
case EM_ERROR:
case EM_FATAL:
int rslt = arpf.setErrorMode(cond,val);
return new Integer(rslt);
default:
// error, see below.
}
}
// Illegal value.
errorHandler.error(new IllegalArgumentException(
"Property \""+str+"\" cannot have value: " + v.toString()));
int old = arpf.setErrorMode(cond,EM_ERROR);
arpf.setErrorMode(cond,old);
return new Integer(old);
}
}
errorHandler.error(new RDFException(RDFException.UNKNOWNPROPERTY));
return null;
}
/** Create a instance of ModelMem() and set it to use JenaReader as its default reader.
* @deprecated This Reader is now the default.
* @return A new in-memory Jena model.
*/
static public Model memModel() {
Model rslt = new ModelMem();
useMe(rslt);
return rslt;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -