Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: /tada-sax/META-INF/, /tada-sax/, /tada-sax/src/se/tada/util/sax/

tada-sax
Discussion topic

Back to topic list

CVS update: /tada-sax/META-INF/, /tada-sax/, /tada-sax/src/se/tada/util/sax/

Reply

Author thhal
Full name Thomas Hallgren
Date 2005-11-11 01:50:34 PST
Message User: thhal
Date: 2005/11/11 01:50:34

Removed:
   tada-sax/tada-sax-0.​2.1-bundle.jar

Added:
   tada-sax/src/se/tada​/util/sax/HandlerKey​.java

Modified:
   tada-sax/META-INF/MANIFEST.MF
   tada-sax/src/se/tada​/util/sax/ChildHandl​er.java
   tada-sax/src/se/tada​/util/sax/TopHandler​.java
   tada-sax/src/se/tada​/util/sax/StringElem​entHandler.java

Log:
 Now Java 5.0 only

File Changes:

Directory: /tada-sax/META-INF/
==============================

File [changed]: MANIFEST.MF
Url: http://tada-sax.tigr​is.org/source/browse​/tada-sax/META-INF/M​ANIFEST.MF?r1=1.2​&r2=1.3
Delta lines: +1 -1
-------------------
--- MANIFEST.MF 10 Nov 2005 22:03:20 -0000 1.2
+++ MANIFEST.MF 11 Nov 2005 09:50:31 -0000 1.3
@@ -2,7 +2,7 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: tada-sax
 Bundle-SymbolicName: se.tada.util.sax
-Bundle-Version: 0.2.1
+Bundle-Version: 1.0.0
 Bundle-ClassPath: tada-sax.jar
 Bundle-Vendor: Tada AB, Täby Sweden
 Bundle-Localization: plugin

Directory: /tada-sax/
=====================

File [removed]: tada-sax-0.2.1-bundle.jar

Directory: /tada-sax/src/se/tada/util/sax/
====================​====================​==

File [changed]: ChildHandler.java
Url: http://tada-sax.tigr​is.org/source/browse​/tada-sax/src/se/tad​a/util/sax/ChildHand​ler.java?r1=1.4&​r2=1.5
Delta lines: +8 -67
--------------------
--- ChildHandler.java 10 Nov 2005 22:03:20 -0000 1.4
+++ ChildHandler.java 11 Nov 2005 09:50:31 -0000 1.5
@@ -8,7 +8,7 @@
 
 import java.lang.reflect.Field;
 import java.lang.reflect.Modifier;
-import java.util.HashMap;
+import java.util.Map;
 
 import javax.xml.XMLConstants;
 
@@ -54,6 +54,7 @@
      * @exception org.xml.sax.SAXException
      * Any SAX exception, possibly wrapping another exception.
      */
+ @Override
     public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException
     {
         if(localName.length() == 0)
@@ -73,6 +74,7 @@
      * @param qName
      * The qualified name, ignored.
      */
+ @Override
     public void endElement(String uri, String localName, String qName) throws SAXException
     {
         this.popHandler();
@@ -96,15 +98,15 @@
     throws SAXException
     {
         String typeName = attrs.getValue(XMLCo​nstants.W3C_XML_SCHE​MA_NS_URI, "type");
- HashMap handlerCache = this.getTopHandler()​.getHandlerCache();
+ Map<HandlerKey,Ch​ildHandler> handlerCache = this.getTopHandler()​.getHandlerCache();
         synchronized(s_keyTemplate)
         {
             s_keyTemplate.init(uri, localName, typeName);
- ChildHandler ch = (ChildHandler)handle​rCache.get(s_keyTemp​late);
+ ChildHandler ch = handlerCache.get(s_k​eyTemplate);
             if(ch == null)
             {
                 ch = this.createHandler(uri, localName, typeName);
- handlerCache.put(s_k​eyTemplate.clone(), ch);
+ handlerCache.put((Ha​ndlerKey)s_keyTempla​te.clone(), ch);
                 ch.setTopHandler(m_topHandler);
             }
             return ch;
@@ -150,6 +152,7 @@
      *
      * @return the document locator.
      */
+ @Override
     protected final Locator getDocumentLocator()
     {
         return m_topHandler.getDocu​mentLocator();
@@ -199,6 +202,7 @@
      * Return the value of the public static String TAG field declared for the
      * class of the receiver of the call.
      */
+ @Override
     protected String getTAG()
     {
         try
@@ -230,68 +234,5 @@
     protected final void setTopHandler(TopHandler topHandler)
     {
         m_topHandler = topHandler;
- }
-
- private static class HandlerKey implements Cloneable
- {
- private String m_uri;
-
- private String m_localName;
-
- private String m_typeName;
-
- private int m_hash;
-
- void init(String uri, String localName, String typeName)
- {
- int hash = (localName == null) ? 1 : 31 + localName.hashCode();
- if(uri != null)
- hash = 31 * hash + uri.hashCode();
- if(typeName != null)
- hash = 31 * hash + typeName.hashCode();
-
- m_uri = uri;
- m_localName = localName;
- m_typeName = typeName;
- m_hash = hash;
- }
-
- public Object clone()
- {
- try
- {
- return super.clone();
- }
- catch(CloneNotSuppor​tedException e)
- {
- return null;
- }
- }
-
- public boolean equals(Object obj)
- {
- if(this == obj)
- return true;
-
- if(!(obj instanceof HandlerKey))
- return false;
-
- HandlerKey other = (HandlerKey)obj;
- return nullEquals(m_uri, other.m_uri)
- && nullEquals(m_typeName, other.m_typeName)
- && nullEquals(m_localName, other.m_localName);
- }
-
- public int hashCode()
- {
- return m_hash;
- }
-
- private static boolean nullEquals(String a, String b)
- {
- return (a == null)
- ? (b == null)
- : (b != null) && a.equals(b);
- }
     }
 }

File [changed]: TopHandler.java
Url: http://tada-sax.tigr​is.org/source/browse​/tada-sax/src/se/tad​a/util/sax/TopHandle​r.java?r1=1.5&r2​=1.6
Delta lines: +13 -7
--------------------
--- TopHandler.java 17 May 2005 10:47:49 -0000 1.5
+++ TopHandler.java 11 Nov 2005 09:50:31 -0000 1.6
@@ -8,6 +8,7 @@
 
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.Map;
 import java.util.Stack;
 
 import org.xml.sax.Attributes;
@@ -33,9 +34,9 @@
 
     private XMLReader m_reader;
 
- private final Stack m_handlerStack = new Stack();
+ private final Stack<ContentHandler> m_handlerStack = new Stack<ContentHandler>();
 
- private final ArrayList m_handlerCache = new ArrayList();
+ private final ArrayList<Map<​HandlerKey,ChildHand​ler>> m_handlerCache = new ArrayList<Map<​HandlerKey,ChildHand​ler>>();
 
     /**
      * Create a <code>TopHandl​er</code> and assing a <code>XMLReade​r</code>
@@ -125,6 +126,7 @@
      * @throws UnrecognizedElementException
      * unless overridden.
      */
+ @Override
     public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
     {
         throw new UnrecognizedElementE​xception("root", qName, this.getDocumentLocator());
@@ -140,6 +142,7 @@
      * @param qName
      * The qualified name, ignored.
      */
+ @Override
     public void endElement(String uri, String localName, String qName) throws SAXException
     {
         this.popHandler();
@@ -160,6 +163,7 @@
     /**
      * Called from parsers that support the <code>Locator​</code> interface.
      */
+ @Override
     public final void setDocumentLocator(Locator locator)
     {
         m_documentLocator = locator;
@@ -217,6 +221,7 @@
      *
      * @return The document <code>Locator​</code> or <code>null</code>.
      */
+ @Override
     protected final Locator getDocumentLocator()
     {
         return m_documentLocator;
@@ -246,13 +251,14 @@
      */
     protected final void popHandler()
     {
- m_reader.setContentH​andler((ContentHandl​er)m_handlerStack.po​p());
+ m_reader.setContentH​andler(m_handlerStac​k.pop());
     }
 
     /**
      * Returns the string &quot;root&quot;.
      */
- protected final String getTAG()
+ @Override
+ protected String getTAG()
     {
         return "root";
     }
@@ -269,16 +275,16 @@
     /**
      * Return the handler cache for the current nesting level
      */
- protected final HashMap getHandlerCache()
+ protected final Map<HandlerKey,Ch​ildHandler> getHandlerCache()
     {
         int depth = m_handlerStack.size();
         int cacheSize = m_handlerCache.size();
         while(cacheSize <= depth)
         {
- m_handlerCache.add(new HashMap());
+ m_handlerCache.add(new HashMap<HandlerKe​y,ChildHandler>()​);
             ++cacheSize;
         }
- return (HashMap)m_handlerCa​che.get(depth);
+ return m_handlerCache.get(depth);
     }
 
     /**

File [changed]: StringElementHandler.java
Url: http://tada-sax.tigr​is.org/source/browse​/tada-sax/src/se/tad​a/util/sax/StringEle​mentHandler.java?r1=​1.1&r2=1.2
Delta lines: +1 -0
-------------------
--- StringElementHandler.java 25 Jan 2005 19:20:47 -0000 1.1
+++ StringElementHandler.java 11 Nov 2005 09:50:31 -0000 1.2
@@ -19,6 +19,7 @@
     private char[] m_buffer = new char[64];
     private int m_length;
 
+ @Override
     public void characters(char[] chars, int start, int length)
     throws SAXException
     {

File [added]: HandlerKey.java
Url: http://tada-sax.tigr​is.org/source/browse​/tada-sax/src/se/tad​a/util/sax/HandlerKe​y.java?rev=1.1&c​ontent-type=text/vnd​.viewcvs-markup
Added lines: 78
---------------
/*
 * Copyright (c) 2004 TADA AB - Taby Sweden
 * Distributed under the terms shown in the file COPYRIGHT
 * found in the root directory of this distribution or at
 * http://eng.tada.se/o​sprojects/COPYRIGHT.​html
 */

package se.tada.util.sax;

/**
 * A key that uniqely identifies a handler in the handler cache.
 * @author Thomas Hallgren
 */
class HandlerKey implements Cloneable
{
    private String m_uri;

    private String m_localName;

    private String m_typeName;

    private int m_hash;

    void init(String uri, String localName, String typeName)
    {
        int hash = (localName == null) ? 1 : 31 + localName.hashCode();
        if(uri != null)
            hash = 31 * hash + uri.hashCode();
        if(typeName != null)
            hash = 31 * hash + typeName.hashCode();

        m_uri = uri;
        m_localName = localName;
        m_typeName = typeName;
        m_hash = hash;
    }

    @Override
    public Object clone()
    {
        try
        {
            return super.clone();
        }
        catch(CloneNotSuppor​tedException e)
        {
            return null;
        }
    }

    @Override
    public boolean equals(Object obj)
    {
        if(this == obj)
            return true;

        if(!(obj instanceof HandlerKey))
            return false;

        HandlerKey other = (HandlerKey)obj;
        return nullEquals(m_uri, other.m_uri)
            && nullEquals(m_typeName, other.m_typeName)
            && nullEquals(m_localName, other.m_localName);
    }

    @Override
    public int hashCode()
    {
        return m_hash;
    }

    static boolean nullEquals(String a, String b)
    {
        return (a == null)
            ? (b == null)
            : (b != null) && a.equals(b);
    }
}

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: /tada-sax/META-INF/, /tada-sax/, /tada-sax/src/se/tada/util/sax/ thhal Thomas Hallgren 2005-11-11 01:50:34 PST
Messages per page: