You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by jk...@apache.org on 2001/08/28 20:18:32 UTC

cvs commit: xml-xalan/java/src/org/apache/xml/dtm/ref DTMDefaultBase.java

jkesselm    01/08/28 11:18:32

  Modified:    java/src/org/apache/xml/dtm/ref DTMDefaultBase.java
  Log:
  added dumpNode method, convenience for debugging.
  
  We might want to move this function up to DTMDefaultBase, or
   perhaps to the DTM API itself.
  
  Revision  Changes    Path
  1.17      +76 -0     xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBase.java
  
  Index: DTMDefaultBase.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMDefaultBase.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- DTMDefaultBase.java	2001/08/24 04:49:31	1.16
  +++ DTMDefaultBase.java	2001/08/28 18:18:32	1.17
  @@ -779,6 +779,82 @@
         System.exit(-1);
       }
     }
  +  
  +  /**
  +   * Diagnostics function to dump a single node.
  +   * 
  +   * %REVIEW% KNOWN GLITCH: If you pass it a node index rather than a 
  +   * node handle, it works just fine... but the displayed identity 
  +   * number before the colon is different, which complicates comparing
  +   * it with nodes printed the other way. We could always OR the DTM ID
  +   * into the value, to suppress that distinction...
  +   * 
  +   * %REVIEW% This might want to be moved up to DTMDefaultBase, or possibly
  +   * DTM itself, since it's a useful diagnostic and uses only DTM's public
  +   * APIs.
  +   */
  +  public String dumpNode(int nodeHandle)
  +  {	  
  +	  if(nodeHandle==DTM.NULL)
  +		  return "[null]";
  +		  
  +        String typestring;
  +        switch (getNodeType(nodeHandle))
  +        {
  +        case DTM.ATTRIBUTE_NODE :
  +          typestring = "ATTR";
  +          break;
  +        case DTM.CDATA_SECTION_NODE :
  +          typestring = "CDATA";
  +          break;
  +        case DTM.COMMENT_NODE :
  +          typestring = "COMMENT";
  +          break;
  +        case DTM.DOCUMENT_FRAGMENT_NODE :
  +          typestring = "DOC_FRAG";
  +          break;
  +        case DTM.DOCUMENT_NODE :
  +          typestring = "DOC";
  +          break;
  +        case DTM.DOCUMENT_TYPE_NODE :
  +          typestring = "DOC_TYPE";
  +          break;
  +        case DTM.ELEMENT_NODE :
  +          typestring = "ELEMENT";
  +          break;
  +        case DTM.ENTITY_NODE :
  +          typestring = "ENTITY";
  +          break;
  +        case DTM.ENTITY_REFERENCE_NODE :
  +          typestring = "ENT_REF";
  +          break;
  +        case DTM.NAMESPACE_NODE :
  +          typestring = "NAMESPACE";
  +          break;
  +        case DTM.NOTATION_NODE :
  +          typestring = "NOTATION";
  +          break;
  +        case DTM.NULL :
  +          typestring = "null";
  +          break;
  +        case DTM.PROCESSING_INSTRUCTION_NODE :
  +          typestring = "PI";
  +          break;
  +        case DTM.TEXT_NODE :
  +          typestring = "TEXT";
  +          break;
  +        default :
  +          typestring = "Unknown!";
  +          break;
  +        }
  +
  +      StringBuffer sb=new StringBuffer();
  +	  sb.append("["+nodeHandle+": "+typestring+
  +				"(0x"+Integer.toHexString(getExpandedTypeID(nodeHandle))+") "+
  +				getNodeNameX(nodeHandle)+" {"+getNamespaceURI(nodeHandle)+"}"+
  +				"=\""+ getNodeValue(nodeHandle)+"\"]");
  +	  return sb.toString();
  +  }
   
     // ========= DTM Implementation Control Functions. ==============
   
  
  
  

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