vgritsenko    2004/08/27 08:55:29

  Modified:    java/src/org/apache/xindice/xml SymbolTableSymbols.java
               java/src/org/apache/xindice/xml/dom ContainerNodeImpl.java
               .        status.xml
               java/src/org/apache/xindice/util SymbolDeserializer.java
                        SymbolSerializer.java
  Log:
  <action dev="VG" type="update">
      Make SymbolTableSymbols singleton.
  </action>
  <action dev="VG" type="fix">
      Fixed bug in SymbolSerializer. SymbolDeserializer expects
      DocumentImpl, but SymbolSerializer was sending document element.
  </action>
  
  Revision  Changes    Path
  1.9       +18 -15    
xml-xindice/java/src/org/apache/xindice/xml/SymbolTableSymbols.java
  
  Index: SymbolTableSymbols.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/xml/SymbolTableSymbols.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SymbolTableSymbols.java   8 Feb 2004 03:50:13 -0000       1.8
  +++ SymbolTableSymbols.java   27 Aug 2004 15:55:29 -0000      1.9
  @@ -36,24 +36,24 @@
   
       private static String SYMBOLS_DEFINITION
               = "<symbols>"
  -            + "   <symbol name=\"" + SYMBOLS + "\" id=\"0\" />"
  -            + "   <symbol name=\"" + SYMBOL + "\" id=\"1\" />"
  -            + "   <symbol name=\"" + NAME + "\" id=\"2\" />"
  -            + "   <symbol name=\"" + ID + "\" id=\"3\" />"
  -            + "   <symbol name=\"" + NSURI + "\" id=\"4\" />"
  +            + "  <symbol name=\"" + SYMBOLS + "\" id=\"0\" />"
  +            + "  <symbol name=\"" + SYMBOL + "\" id=\"1\" />"
  +            + "  <symbol name=\"" + NAME + "\" id=\"2\" />"
  +            + "  <symbol name=\"" + ID + "\" id=\"3\" />"
  +            + "  <symbol name=\"" + NSURI + "\" id=\"4\" />"
               + "</symbols>";
   
  -    private Element symbolsElem;
  +    private static SymbolTableSymbols SYMBOLS_INSTANCE;
  +
   
       private SymbolTableSymbols() {
           try {
  -            symbolsElem = 
DOMParser.toDocument(SYMBOLS_DEFINITION).getDocumentElement();
  +            Element symbols = 
DOMParser.toDocument(SYMBOLS_DEFINITION).getDocumentElement();
  +            streamFromXML(symbols);
           } catch (Exception e) {
  -            if (log.isWarnEnabled()) {
  -                log.warn("ignored exception", e);
  -            }
  +            // Should not happen
  +            log.error("Failed to create SymbolTableSymbols", e);
           }
  -        streamFromXML(symbolsElem);
       }
   
       public static String getDefinition() {
  @@ -61,7 +61,10 @@
       }
   
       public static SymbolTableSymbols getInstance() {
  -        return new SymbolTableSymbols();
  +        if (SYMBOLS_INSTANCE == null) {
  +            SYMBOLS_INSTANCE = new SymbolTableSymbols();
  +        }
  +
  +        return SYMBOLS_INSTANCE;
       }
   }
  -
  
  
  
  1.18      +6 -5      
xml-xindice/java/src/org/apache/xindice/xml/dom/ContainerNodeImpl.java
  
  Index: ContainerNodeImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/xml/dom/ContainerNodeImpl.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ContainerNodeImpl.java    20 Jul 2004 20:34:35 -0000      1.17
  +++ ContainerNodeImpl.java    27 Aug 2004 15:55:29 -0000      1.18
  @@ -83,7 +83,7 @@
           } else {
               loaded = true;
           }
  -        
  +
           try {
               if (data != null) {
                   DocumentImpl doc = (DocumentImpl) getOwnerDocument();
  @@ -155,7 +155,7 @@
                   case Node.NOTATION_NODE:
                       childNodes.add(new NotationImpl(this, data, pos, len));
                       break;
  -                    
  +
                   default:
                       if (log.isWarnEnabled()) {
                           log.warn("invalid node type : " + in.getNodeType());
  @@ -423,8 +423,9 @@
        * Returns a <code>NodeList</code> of all descendant elements with a 
given
        * tag name, in the order in which they would be encountered in a 
preorder
        * traversal of the <code>Element</code> tree.
  +     *
        * @param name The name of the tag to match on. The special value "*"
  -     *   matches all tags.
  +     *             matches all tags.
        * @return A list of matching <code>Element</code> nodes.
        */
       public final NodeList getElementsByTagName(final String name) {
  
  
  
  1.46      +7 -0      xml-xindice/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/xml-xindice/status.xml,v
  retrieving revision 1.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- status.xml        10 Jun 2004 14:46:47 -0000      1.45
  +++ status.xml        27 Aug 2004 15:55:29 -0000      1.46
  @@ -74,6 +74,13 @@
   
       <changes>
           <release version="1.1b5-dev">
  +            <action dev="VG" type="update">
  +                Make SymbolTableSymbols singleton.
  +            </action>
  +            <action dev="VG" type="fix">
  +                Fixed bug in SymbolSerializer. SymbolDeserializer expects
  +                DocumentImpl, but SymbolSerializer was sending document 
element.
  +            </action>
               <action dev="VG" type="fix">
                   Fixed saving of custom meta data documents.
               </action>
  
  
  
  1.9       +11 -4     
xml-xindice/java/src/org/apache/xindice/util/SymbolDeserializer.java
  
  Index: SymbolDeserializer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/util/SymbolDeserializer.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SymbolDeserializer.java   8 Feb 2004 02:59:39 -0000       1.8
  +++ SymbolDeserializer.java   27 Aug 2004 15:55:29 -0000      1.9
  @@ -35,8 +35,15 @@
   public final class SymbolDeserializer {
       private static final SymbolTableSymbols hcSyms = 
SymbolTableSymbols.getInstance();
   
  -    private SymbolTable syms = null; // The Collection's SymbolTable
  -    private long lastMod = 0;        // Last time we caught a SymbolTable 
modification
  +    /**
  +     * The collection's SymbolTable
  +     */
  +    private SymbolTable syms;
  +
  +    /**
  +     * Last time we caught a SymbolTable modification
  +     */
  +    private long lastMod;
   
       /**
        * convertToDocument converts the compressed Hashtable to
  
  
  
  1.9       +25 -9     
xml-xindice/java/src/org/apache/xindice/util/SymbolSerializer.java
  
  Index: SymbolSerializer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xindice/java/src/org/apache/xindice/util/SymbolSerializer.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SymbolSerializer.java     8 Feb 2004 02:59:39 -0000       1.8
  +++ SymbolSerializer.java     27 Aug 2004 15:55:29 -0000      1.9
  @@ -42,16 +42,26 @@
       private static final Log log = LogFactory.getLog(SymbolSerializer.class);
   
       private static final SymbolTableSymbols hcSyms = 
SymbolTableSymbols.getInstance();
  -    private static final DocumentImpl elemFactory = new DocumentImpl();
   
  -    private SymbolTable syms = null; // The Collection's SymbolTable
  -    private long lastMod = 0;        // Last time we caught a SymbolTable 
modification
  -    private byte[] symBytes = null;  // Stores a byte representation of the 
SymbolTable
  +    /**
  +     * The collection's SymbolTable
  +     */
  +    private SymbolTable syms;
  +
  +    /**
  +     * Last time we caught a SymbolTable modification
  +     */
  +    private long lastMod;
  +
  +    /**
  +     * Stores a byte representation of the SymbolTable
  +     */
  +    private byte[] symBytes; 
   
   
       public SymbolSerializer(SymbolTable syms) {
           this.syms = syms;
  -        elemFactory.setSymbols(syms);
  +        // elemFactory.setSymbols(syms);
       }
   
       /**
  @@ -65,10 +75,16 @@
       public Hashtable getSymBuffer() {
           long lm = syms.getLastModified();
           if (lm > lastMod) {
  +            DocumentImpl doc = new DocumentImpl();
  +            doc.setSymbols(syms);
  +
               synchronized (syms) {
  -                Element elem = syms.streamToXML(elemFactory);
  +                Element elem = syms.streamToXML(doc);
  +                doc.appendChild(elem);
  +
  +                // Element elem = syms.streamToXML(elemFactory);
                   try {
  -                    symBytes = DOMCompressor.Compress(elem, hcSyms);
  +                    symBytes = DOMCompressor.Compress(doc, hcSyms);
                       lastMod = lm;
                   } catch (Exception e) {
                       if (log.isErrorEnabled()) {
  
  
  

Reply via email to