svn commit: r532556 - in /xml/xindice/trunk/java/src/org/apache/xindice: core/DocumentCache.java xml/dom/DOMParser.java

[email protected]
Newsgroups gmane.text.xml.xindice.devel
Message-ID <[email protected]>
Author: vgritsenko
Date: Wed Apr 25 18:18:26 2007
New Revision: 532556

URL: http://svn.apache.org/viewvc?view=rev&rev=532556
Log:
add return to document cache; comments & tweaks

Modified:
    xml/xindice/trunk/java/src/org/apache/xindice/core/DocumentCache.java
    xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMParser.java

Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/DocumentCache.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/DocumentCache.java?view=diff&rev=532556&r1=532555&r2=532556
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/core/DocumentCache.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/core/DocumentCache.java Wed Apr 25 18:18:26 2007
@@ -61,19 +61,24 @@
      */
     public Document getDocument(Collection col, Key key) {
         Object v = table.get(new CacheKey(col, key));
+
         if (v == null) {
             return null;
+
         } else if (v instanceof Document) {
             return (Document) v;
+
         } else if (v instanceof String) {
             try {
                 Document doc = DOMParser.toDocument((String) v);
                 ((DBDocument) doc).setSource(new NodeSource(col, key));
+                return doc;
             } catch (Exception e) {
                 if (log.isWarnEnabled()) {
                     log.warn("ignored exception", e);
                 }
             }
+
         } else if (v instanceof byte[]) {
             try {
                 SymbolTable s = col.getSymbols();
@@ -85,31 +90,30 @@
                 }
             }
         }
+
         return null;
     }
 
     /**
-     * Stores document in the cache
+     * Stores compressed document's bytes in the cache
      *
      * @param col document collection
      * @param key document key
      * @param bytes compressed document
      */
     public void putDocument(Collection col, Key key, byte[] bytes) {
-        CacheKey ckey = new CacheKey(col, key);
-        table.put(ckey, bytes);
+        table.put(new CacheKey(col, key), bytes);
     }
 
     /**
-     * Stores document in the cache
+     * Stores serialized document's text in the cache
      *
      * @param col document collection
      * @param key document key
      * @param chars uncompressed document
      */
     public void putDocument(Collection col, Key key, String chars) {
-        CacheKey ckey = new CacheKey(col, key);
-        table.put(ckey, chars);
+        table.put(new CacheKey(col, key), chars);
     }
 
     /**
@@ -147,18 +151,18 @@
             } else {
                 return Integer.parseInt(cache);
             }
-        } else {
-            return -1;
         }
+
+        return -1;
     }
 
     /**
      * CacheKey
      */
     private static class CacheKey {
-        private Collection col;
+        private final Collection col;
+        private final Key key;
         private String strVal;
-        private Key key;
 
         public CacheKey(Collection col, Key key) {
             this.col = col;

Modified: xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMParser.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMParser.java?view=diff&rev=532556&r1=532555&r2=532556
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMParser.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/xml/dom/DOMParser.java Wed Apr 25 18:18:26 2007
@@ -186,6 +186,7 @@
 
     /**
      * Returns the parsed Document
+     * @return the parsed document
      */
     public Document getDocument() {
         return doc;
@@ -218,7 +219,7 @@
      * @param xr XMLReader
      * @param name SAX feature name
      * @param value feature value
-     * @throws SAXNotRecognizedException
+     * @throws SAXNotRecognizedException is the SAX feature is not known
      * @throws SAXNotSupportedException if the SAX feature is not supported and
      *         the value is <em>true</em>
      */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.