You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ve...@apache.org on 2004/07/12 08:44:25 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/dom CoreDocumentImpl.java DocumentTypeImpl.java ParentNode.java

venu        2004/07/11 23:44:25

  Modified:    java/src/org/apache/xerces/dom CoreDocumentImpl.java
                        DocumentTypeImpl.java ParentNode.java
  Log:
  Changes w.r.t bug 973.
  
  Revision  Changes    Path
  1.74      +15 -24    xml-xerces/java/src/org/apache/xerces/dom/CoreDocumentImpl.java
  
  Index: CoreDocumentImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/CoreDocumentImpl.java,v
  retrieving revision 1.73
  retrieving revision 1.74
  diff -u -r1.73 -r1.74
  --- CoreDocumentImpl.java	18 Jun 2004 21:36:16 -0000	1.73
  +++ CoreDocumentImpl.java	12 Jul 2004 06:44:24 -0000	1.74
  @@ -121,9 +121,11 @@
       /**Experimental DOM Level 3 feature: documentURI */
       protected String fDocumentURI;
   
  +	//Revisit :: change to a better data structure.
       /** Table for user data attached to this document nodes. */
       protected Hashtable userData;
   
  +
       /** Identifiers. */
       protected Hashtable identifiers;
   
  @@ -131,6 +133,9 @@
       transient DOMNormalizer domNormalizer = null;
       transient DOMConfigurationImpl fConfiguration= null;
   
  +    // support of XPath API
  +    transient Object fXPathEvaluator = null;
  +
       /** Table for quick check of child insertion. */
       private final static int[] kidOK;
   
  @@ -2151,17 +2156,6 @@
       }
   
   
  -    /*
  -     * a class to store some user data along with its handler
  -     */
  -    class UserDataRecord implements Serializable {
  -        Object fData;
  -        UserDataHandler fHandler;
  -        UserDataRecord(Object data, UserDataHandler handler) {
  -            fData = data;
  -            fHandler = handler;
  -        }
  -    }
   
       /**
        * Associate an object to a key on this node. The object can later be
  @@ -2216,6 +2210,7 @@
               return null;
           }
       }
  +	
   
       /**
        * Retrieves the object associated to a key on a this node. The object
  @@ -2289,18 +2284,14 @@
           if (userData == null) {
               return;
           }
  -        Hashtable t = (Hashtable) userData.get(n);
  -        if (t == null || t.isEmpty()) {
  -            return;
  -        }
  -        Enumeration keys = t.keys();
  -        while (keys.hasMoreElements()) {
  -            String key = (String) keys.nextElement();
  -            UserDataRecord r = (UserDataRecord) t.get(key);
  -            if (r.fHandler != null) {
  -                r.fHandler.handle(operation, key, r.fData, n, c);
  -            }
  -        }
  +        //Hashtable t = (Hashtable) userData.get(n);
  +		if(n instanceof NodeImpl){
  +			Hashtable t = ((NodeImpl)n).getUserDataRecord();
  +			if (t == null || t.isEmpty()) {
  +				return;
  +			}
  +			callUserDataHandlers(n, c, operation,t);
  +		}
       }
   
   	/**
  
  
  
  1.27      +44 -2     xml-xerces/java/src/org/apache/xerces/dom/DocumentTypeImpl.java
  
  Index: DocumentTypeImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/DocumentTypeImpl.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- DocumentTypeImpl.java	24 Feb 2004 23:23:17 -0000	1.26
  +++ DocumentTypeImpl.java	12 Jul 2004 06:44:25 -0000	1.27
  @@ -20,6 +20,8 @@
   import org.w3c.dom.DocumentType;
   import org.w3c.dom.Node;
   import org.w3c.dom.NamedNodeMap;
  +import java.util.Hashtable;
  +import org.apache.xerces.dom3.UserDataHandler;
   
   /**
    * This class represents a Document Type <em>declaraction</em> in
  @@ -91,7 +93,7 @@
       //
       // Constructors
       //
  -
  +    private Hashtable userData =  null;
       /** Factory method for creating a document type node. */
       public DocumentTypeImpl(CoreDocumentImpl ownerDocument, String name) {
           super(ownerDocument);
  @@ -433,6 +435,46 @@
               synchronizeChildren();
           }
       	return elements;
  +    }
  +    
  +    public Object setUserData(String key,
  +    Object data, UserDataHandler handler) {
  +        if(userData == null)
  +            userData = new Hashtable();
  +        if (data == null) {
  +            if (userData != null) {
  +                Object o = userData.remove(key);
  +                if (o != null) {
  +                    UserDataRecord r = (UserDataRecord) o;
  +                    return r.fData;
  +                }
  +            }
  +            return null;
  +        }
  +        else {
  +            Object o = userData.put(key, new UserDataRecord(data, handler));
  +            if (o != null) {
  +                UserDataRecord r = (UserDataRecord) o;
  +                return r.fData;
  +            }
  +        }
  +        return null;
  +    }
  +    
  +    public Object getUserData(String key) {
  +        if (userData == null) {
  +            return null;
  +        }
  +        Object o = userData.get(key);
  +        if (o != null) {
  +            UserDataRecord r = (UserDataRecord) o;
  +            return r.fData;
  +        }
  +        return null;
  +    }
  +    
  +    protected Hashtable getUserDataRecord(){
  +        return userData;
       }
       
   } // class DocumentTypeImpl
  
  
  
  1.45      +14 -1     xml-xerces/java/src/org/apache/xerces/dom/ParentNode.java
  
  Index: ParentNode.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/ParentNode.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- ParentNode.java	19 May 2004 19:16:57 -0000	1.44
  +++ ParentNode.java	12 Jul 2004 06:44:25 -0000	1.45
  @@ -16,6 +16,7 @@
   
   package org.apache.xerces.dom;
   
  +import java.io.Serializable;
   import java.io.IOException;
   import java.io.ObjectInputStream;
   import java.io.ObjectOutputStream;
  @@ -24,6 +25,7 @@
   import org.w3c.dom.Document;
   import org.w3c.dom.Node;
   import org.w3c.dom.NodeList;
  +import org.apache.xerces.dom3.UserDataHandler;
   
   /**
    * ParentNode inherits from ChildNode and adds the capability of having child
  @@ -1008,4 +1010,15 @@
   
       } // readObject(ObjectInputStream)
   
  +    /*
  +     * a class to store some user data along with its handler
  +     */
  +    class UserDataRecord implements Serializable {
  +        Object fData;
  +        UserDataHandler fHandler;
  +        UserDataRecord(Object data, UserDataHandler handler) {
  +            fData = data;
  +            fHandler = handler;
  +        }
  +    }
   } // class ParentNode
  
  
  

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