xalan-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From curc...@apache.org
Subject cvs commit: xml-xalan/test/java/src/org/apache/qetest/xalanj2 XalanDumper.java
Date Mon, 26 Nov 2001 20:48:52 GMT
curcuru     01/11/26 12:48:52

  Modified:    test/java/src/org/apache/qetest/xalanj2 XalanDumper.java
  Log:
  Add dump(DTMNodeProxy...) method and NOIDS exclusion constant
  
  Revision  Changes    Path
  1.5       +75 -1     xml-xalan/test/java/src/org/apache/qetest/xalanj2/XalanDumper.java
  
  Index: XalanDumper.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/test/java/src/org/apache/qetest/xalanj2/XalanDumper.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XalanDumper.java	2001/07/05 16:37:18	1.4
  +++ XalanDumper.java	2001/11/26 20:48:52	1.5
  @@ -73,6 +73,7 @@
   import org.apache.xalan.templates.ElemLiteralResult;
   import org.apache.xalan.templates.Constants;
   import org.apache.xalan.transformer.TransformerImpl;
  +import org.apache.xml.dtm.ref.DTMNodeProxy;
   import org.apache.xml.utils.QName;
   import org.apache.xpath.XPath;
   
  @@ -91,7 +92,7 @@
    * logging utilities to output our data without escaping, etc.
    * 
    * @author shane_curcuru@lotus.com
  - * @version $Id: XalanDumper.java,v 1.4 2001/07/05 16:37:18 curcuru Exp $
  + * @version $Id: XalanDumper.java,v 1.5 2001/11/26 20:48:52 curcuru Exp $
    */
   public abstract class XalanDumper 
   {
  @@ -118,6 +119,8 @@
       public static final int DUMP_CONTAINED = 2;
       /** Simple output formats: don't close block.  */
       public static final int DUMP_NOCLOSE = 4;
  +    /** Simple output formats: don't include id's or other items likely to change.  */
  +    public static final int DUMP_NOIDS = 8;
   
       /** Cheap-o recursion marker: already recursing in Nodes/NodeLists.  */
       public static final int DUMP_NODE_RECURSION = 16;
  @@ -351,6 +354,77 @@
               return LBRACKET + buf.toString() + RBRACKET;
           else
               return "Node" + LBRACKET + buf.toString() + RBRACKET;
  +    }
  +
  +    /**
  +     * Return String describing a DTMNodeProxy.
  +     * This is the Xalan-J 2.x internal wrapper for Nodes.
  +     *
  +     * @param n the DTMNodeProxy to print info of
  +     * @param dumpLevel what format/how much to dump
  +     */
  +    public static String dump(DTMNodeProxy n, int dumpLevel)
  +    {
  +        if (null == n)
  +            return "DTMNodeProxy" + LBRACKET + NULL + RBRACKET;
  +
  +        // Copied but modified from TracerEvent; ditch hashCode
  +        StringBuffer buf = new StringBuffer();
  +
  +        if (DUMP_NOIDS != (dumpLevel & DUMP_NOIDS))
  +        {
  +            // Only include the DTM node number if asked
  +            buf.append(n.getDTMNodeNumber());
  +        }
  +        
  +        if (n instanceof Element)
  +        {
  +            buf.append(n.getNodeName());
  +            // Also output first x chars of value
  +            buf.append(substr(n.getNodeValue()));
  +
  +            DTMNodeProxy c = (DTMNodeProxy)n.getFirstChild();
  +
  +            while (null != c)
  +            {
  +                buf.append(dump(c, dumpLevel | DUMP_NODE_RECURSION) + " ");
  +                c = (DTMNodeProxy)c.getNextSibling();
  +            }
  +        }
  +        else
  +        {
  +            if (n instanceof Attr)
  +            {
  +                buf.append(n.getNodeName() + "=" + n.getNodeValue());
  +            }
  +            else
  +            {
  +                buf.append(n.getNodeName());
  +                // Also output first x chars of value
  +                buf.append(substr(n.getNodeValue()));
  +            }
  +        }
  +
  +            
  +        // If we're already recursing, don't bother printing out 'Node' again
  +        if (DUMP_NODE_RECURSION == (dumpLevel & DUMP_NODE_RECURSION))
  +            return LBRACKET + buf.toString() + RBRACKET;
  +        else
  +            return "DTMNodeProxy" + LBRACKET + buf.toString() + RBRACKET;
  +    }
  +
  +    /** Cheap-o worker method to substring a string.  */
  +    public static int MAX_SUBSTR = 8;
  +
  +    /** Cheap-o worker method to substring a string.  */
  +    public static String SUBSTR_PREFIX = ":";
  +
  +    /** Cheap-o worker method to substring a string.  */
  +    protected static String substr(String s)
  +    {
  +        if (null == s)
  +            return "";
  +        return SUBSTR_PREFIX + s.substring(0, Math.min(s.length(), MAX_SUBSTR));
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org


Mime
View raw message