curcuru     01/12/18 15:20:02

  Modified:    test/java/src/org/apache/qetest/xslwrapper
                        TraxWrapperUtils.java
  Log:
  Update setAttribute to special-case setURIResolver and setErrorListener
  
  Revision  Changes    Path
  1.3       +58 -14    
xml-xalan/test/java/src/org/apache/qetest/xslwrapper/TraxWrapperUtils.java
  
  Index: TraxWrapperUtils.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/test/java/src/org/apache/qetest/xslwrapper/TraxWrapperUtils.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TraxWrapperUtils.java     2001/06/25 14:35:26     1.2
  +++ TraxWrapperUtils.java     2001/12/18 23:20:02     1.3
  @@ -57,6 +57,8 @@
   package org.apache.qetest.xslwrapper;
   
   import javax.xml.transform.TransformerFactory;
  +import javax.xml.transform.URIResolver;
  +import javax.xml.transform.ErrorListener;
   
   import java.lang.reflect.Field;
   import java.util.Enumeration;
  @@ -67,7 +69,7 @@
    * Cheap-o utilities for Trax*Wrapper implementations.
    *
    * @author Shane Curcuru
  - * @version $Id: TraxWrapperUtils.java,v 1.2 2001/06/25 14:35:26 curcuru Exp $
  + * @version $Id: TraxWrapperUtils.java,v 1.3 2001/12/18 23:20:02 curcuru Exp $
    */
   public abstract class TraxWrapperUtils
   {
  @@ -120,9 +122,13 @@
   
   
       /**
  -     * Apply specific Attributes to a TransformerFactory.  
  +     * Apply specific Attributes to a TransformerFactory OR call 
  +     * specific setFoo() API's on a TransformerFactory.  
        *
        * Filters on hashkeys.startsWith("Processor.setAttribute.")
  +     * Most Attributes are simply passed to factory.setAttribute(), 
  +     * however certain special cases are handled:
  +     * setURIResolver, setErrorListener.
        * Exceptions thrown by underlying factory are ignored.
        *
        * @param factory TransformerFactory to call setAttributes on.
  @@ -155,20 +161,58 @@
               {
                   // Strip off our marker for the property name
                   String processorKey = 
key.substring(TransformWrapper.SET_PROCESSOR_ATTRIBUTES.length());
  -                Object value = null;
  -                try
  -                {
  -                    value = ((Properties)attrs).getProperty(key);
  -                }
  -                catch (ClassCastException cce)
  -                {
  -                    // Simply get as Hashtable instead
  -                    value = attrs.get(key);
  -                }
  -                // Note: allow exceptions to propagate here
  -                factory.setAttribute(processorKey, value);
  +                Object value = attrs.get(key);
  +                setAttribute(factory, processorKey, value);
               }
           }
   
  +    }
  +
  +
  +    /** Token specifying a call to setURIResolver.  */
  +    public static String SET_URI_RESOLVER = "setURIResolver";
  +
  +    /** Token specifying a call to setErrorListener.  */
  +    public static String SET_ERROR_LISTENER = "setErrorListener";
  +
  +    /**
  +     * Apply specific Attributes to a TransformerFactory OR call 
  +     * specific setFoo() API's on a TransformerFactory.  
  +     *
  +     * Filters on hashkeys.startsWith("Processor.setAttribute.")
  +     * Most Attributes are simply passed to factory.setAttribute(), 
  +     * however certain special cases are handled:
  +     * setURIResolver, setErrorListener.
  +     * Exceptions thrown by underlying factory are ignored.
  +     *
  +     * @param factory TransformerFactory to call setAttributes on.
  +     * @param key specific attribute or special case attr.
  +     * @param value to set for key.
  +     */
  +    private static void setAttribute(TransformerFactory factory, 
  +                                     String key, 
  +                                     Object value)
  +                                     throws IllegalArgumentException
  +    {
  +        if ((null == factory) || (null == key))
  +            return;
  +
  +        // Note: allow exceptions to propagate here
  +
  +        // Check if this is a special case to call a specific 
  +        //  API, or the general case to call setAttribute(key...)
  +        if (SET_URI_RESOLVER.equals(key))
  +        {
  +            factory.setURIResolver((URIResolver)value);
  +        }
  +        else if (SET_ERROR_LISTENER.equals(key))
  +        {
  +            factory.setErrorListener((ErrorListener)value);
  +        }
  +        else
  +        {
  +            // General case; just call setAttribute
  +            factory.setAttribute(key, value);
  +        }
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to