curcuru 01/06/25 13:06:18
Modified: java/src/org/apache/xalan/processor
TransformerFactoryImpl.java
Log:
Update setAttribute to accept either Boolean or String values;
Updated javadoc; implement getAttribute to at least throw exceptions
describing what attributes are recognized or not
Revision Changes Path
1.37 +45 -5
xml-xalan/java/src/org/apache/xalan/processor/TransformerFactoryImpl.java
Index: TransformerFactoryImpl.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/processor/TransformerFactoryImpl.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- TransformerFactoryImpl.java 2001/06/23 17:35:23 1.36
+++ TransformerFactoryImpl.java 2001/06/25 20:06:16 1.37
@@ -509,7 +509,7 @@
* implementation.
*
* @param name The name of the attribute.
- * @param value The value of the attribute.
+ * @param value The value of the attribute; Boolean or
String="true"|"false"
*
* @throws IllegalArgumentException thrown if the underlying
* implementation doesn't recognize the attribute.
@@ -518,11 +518,45 @@
throws IllegalArgumentException
{
if (name.equals(FEATURE_INCREMENTAL))
-
org.apache.xml.dtm.DTMManager.setIncremental(((Boolean)value).booleanValue());
+ {
+ if(value instanceof Boolean)
+ {
+ // Accept a Boolean object..
+
org.apache.xml.dtm.DTMManager.setIncremental(((Boolean)value).booleanValue());
+ }
+ else if(value instanceof String)
+ {
+ // .. or a String object
+ org.apache.xml.dtm.DTMManager.setIncremental((new
Boolean((String)value)).booleanValue());
+ }
+ else
+ {
+ // Give a more meaningful error message
+ throw new IllegalArgumentException(name + " bad value " + value);
+ }
+ }
else if (name.equals(FEATURE_OPTIMIZE))
- m_optimize = ((Boolean)value).booleanValue();
+ {
+ if(value instanceof Boolean)
+ {
+ // Accept a Boolean object..
+ m_optimize = ((Boolean)value).booleanValue();
+ }
+ else if(value instanceof String)
+ {
+ // .. or a String object
+ m_optimize = (new Boolean((String)value)).booleanValue();
+ }
+ else
+ {
+ // Give a more meaningful error message
+ throw new IllegalArgumentException(name + " bad value " + value);
+ }
+ }
else
- throw new IllegalArgumentException(name);
+ {
+ throw new IllegalArgumentException(name + "not supported");
+ }
}
/**
@@ -537,7 +571,13 @@
*/
public Object getAttribute(String name) throws IllegalArgumentException
{
- throw new IllegalArgumentException(name);
+ // Please implement this method for testing purposes 25-Jun-01 -sc
+ if (name.equals(FEATURE_INCREMENTAL))
+ throw new IllegalArgumentException(name + " attribute value not
found");
+ else if (name.equals(FEATURE_OPTIMIZE))
+ throw new IllegalArgumentException(name + " attribute value not
found");
+ else
+ throw new IllegalArgumentException(name + " attribute not recognized");
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]