/[gzz]/gzz/lava/gzz/storm/PointerIndexType.java
ViewVC logotype

Diff of /gzz/lava/gzz/storm/PointerIndexType.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by benja, Mon Dec 30 16:02:02 2002 UTC revision 1.2 by benja, Mon Dec 30 16:18:03 2002 UTC
# Line 28  public abstract class PointerIndexType i Line 28  public abstract class PointerIndexType i
28          Pointer getPointer(String uri);          Pointer getPointer(String uri);
29      }      }
30    
     abstract public Object getIndex(IndexedPool pool, IndexedPool.DB db)  
         throws IOException;  
   
31      public final String getIndexTypeURI() {      public final String getIndexTypeURI() {
32          return indexTypeURI;          return indexTypeURI;
33      }      }
34    
35      /** The default implementation of getting the mapping      abstract public Set getMappings(Block b) throws IOException;
      *  for a pointer block. Subclasses which override this  
      *  must provide exactly the same functionality;  
      *  the only reason to override would be if the subclass  
      *  had a more efficient way to parse pointer blocks.  
      */  
     public Set getMappings(Block b) throws IOException {  
         String blockContentType =  
             b.getHeader().get("Content-Type").toLowerCase();  
   
         if(blockContentType.equals(contentType)) {  
             BufferedReader br = new BufferedReader(  
                 new InputStreamReader(b.getInputStream(), "ISO8859_1"));  
             String s = br.readLine();  
             if(!s.equals("GZZPTR0"))  
                 // Unknown pointer block format-- ignore  
                 return Collections.EMPTY_SET;  
   
             byte[] key = br.readLine().getBytes("US-ASCII");  
   
             List items = new ArrayList(3);  
             int len = 0;  
36    
37              String hex;      abstract public Object createIndex(IndexedPool pool, IndexedPool.DB db);
             while((hex = br.readLine()) != null) {  
                 byte[] arr = HexUtil.hexToByteArr(hex);  
                 if(arr.length > 127)  
                     throw new IOException("Storm id is too long: "+hex);  
                 items.add(arr);  
                 len += arr.length + 1;  
             }  
   
             br.close();  
   
             byte[] value = new byte[len];  
             int pos = 0;  
             for(Iterator i=items.iterator(); i.hasNext();) {  
                 byte[] arr = (byte[])i.next();  
                 value[pos] = (byte)arr.length;  
                 pos++;  
                 System.arraycopy(arr, 0, value, pos, arr.length);  
                 pos += arr.length;  
             }  
   
             IndexedPool.Mapping m =  
                 new IndexedPool.Mapping(b.getId(), key, value);  
             return Collections.singleton(m);  
         } else {  
             return Collections.EMPTY_SET;  
         }  
     }  
38  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26