curcuru     01/01/23 07:32:20

  Modified:    test/java/src/org/apache/qetest/xslwrapper XalanWrapper.java
  Log:
  Updated to also record parser version data in getDescription (Xerces only so 
far)
  
  Revision  Changes    Path
  1.4       +31 -4     
xml-xalan/test/java/src/org/apache/qetest/xslwrapper/XalanWrapper.java
  
  Index: XalanWrapper.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/test/java/src/org/apache/qetest/xslwrapper/XalanWrapper.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XalanWrapper.java 2001/01/19 03:00:43     1.3
  +++ XalanWrapper.java 2001/01/23 15:32:19     1.4
  @@ -80,7 +80,7 @@
    * <p>Note: Updated to work with either Xalan-J 1.x or with 
    * Xalan-J 2.x's compatibility layer seamlessly.</p>
    * @author Shane Curcuru
  - * @version $Id: XalanWrapper.java,v 1.3 2001/01/19 03:00:43 curcuru Exp $
  + * @version $Id: XalanWrapper.java,v 1.4 2001/01/23 15:32:19 curcuru Exp $
    */
   public class XalanWrapper extends ProcessorWrapper
   {
  @@ -142,6 +142,12 @@
       /** FQCN of Xalan-J 2.x's version file, when using the compatibility 
layer.   */
       public static final String XALAN2_VERSION_CLASS = 
"org.apache.xalan.processor.XSLProcessorVersion";
   
  +    /** Marker string added to getDescription, when using the compatibility 
layer.   */
  +    public static final String XALAN2_MARKER = "-compat1";
  +
  +    /** FQCN of Xerces-J 1.x's version file, for convenience.   */
  +    public static final String XERCES1_VERSION_CLASS = 
"org.apache.xerces.framework.Version";
  +
       /**
        * Get a description of the wrappered processor.
        * @return info-string describing the processor and possibly it's common 
options
  @@ -157,12 +163,28 @@
           else
           {
               StringBuffer buf = new StringBuffer("No Xalan version info 
found");
  -
  -            // Compatibility with either 1.x or 2.x compatibility layer
  +            String parserVersion = new String("no-parser-info-avail");
               Class clazz = null;
               Field f = null;
  +
  +            // As a convenience, see if we can find the version 
  +            //  of the parser we're using as well
               try
               {
  +                // Currently, only check for Xerces versions
  +                clazz = Class.forName(XERCES1_VERSION_CLASS);
  +                // Found 1.x, grab it's version fields
  +                f = clazz.getField("fVersion");
  +                parserVersion = (String)f.get(null);
  +            }
  +            catch (Exception e2)
  +            {
  +                // no-op, leave value as-is
  +            }
  +
  +            // Check for either 1.x or 2.x compatibility layer
  +            try
  +            {
                   clazz = Class.forName(XALAN1_VERSION_CLASS);
                   // Found 1.x, grab it's version fields
                   buf = new StringBuffer();
  @@ -176,6 +198,8 @@
                   buf.append(f.get(null));
                   buf.append(";");
                   buf.append(processor.getXMLProcessorLiaison());
  +                buf.append(";");
  +                buf.append(parserVersion);
               }
               catch (Exception e1)
               {
  @@ -187,14 +211,17 @@
                       buf = new StringBuffer();
                       f = clazz.getField("PRODUCT");
                       buf.append(f.get(null));
  +                    buf.append(XALAN2_MARKER);  // so user knows we're doing 
compatibility layer
                       buf.append(";");
                       f = clazz.getField("LANGUAGE");
                       buf.append(f.get(null));
                       buf.append(";");
                       f = clazz.getField("S_VERSION");
                       buf.append(f.get(null));
  +                    buf.append(";");
  +                    // Liaison info not applicable
                       buf.append(";");
  -                    //@todo find way to figure out parser info too
  +                    buf.append(parserVersion);
                   }
                   catch (Exception e2)
                   {
  
  
  

Reply via email to