gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz gzz/util/HeaderUtil.java lava/gzz/storm/hea...


From: Benja Fallenstein
Subject: [Gzz-commits] gzz gzz/util/HeaderUtil.java lava/gzz/storm/hea...
Date: Fri, 08 Nov 2002 16:55:37 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Benja Fallenstein <address@hidden>      02/11/08 16:55:35

Modified files:
        gzz/util       : HeaderUtil.java 
        lava/gzz/storm/headers: DefaultHeaderLines822.java 
                                SortedHeader822.java 
        lava/gzz/storm/impl: DirPool.java 
Added files:
        lava/gzz/storm/headers: Headers822.java 

Log message:
        Make DirPool pass all current tests

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/util/HeaderUtil.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/headers/Headers822.java?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/headers/DefaultHeaderLines822.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/headers/SortedHeader822.java.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/lava/gzz/storm/impl/DirPool.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: gzz/gzz/util/HeaderUtil.java
diff -u gzz/gzz/util/HeaderUtil.java:1.4 gzz/gzz/util/HeaderUtil.java:1.5
--- gzz/gzz/util/HeaderUtil.java:1.4    Tue Oct 22 14:45:50 2002
+++ gzz/gzz/util/HeaderUtil.java        Fri Nov  8 16:55:34 2002
@@ -166,13 +166,6 @@
 
 
 
-    public static String canonicalizeFieldName(String fieldName) {
-       String s = fieldName;
-       return null; // XXX
-    }
-
-
-
     // ParseException
 
     public static class ParseException extends IOException {
Index: gzz/lava/gzz/storm/headers/DefaultHeaderLines822.java
diff -u gzz/lava/gzz/storm/headers/DefaultHeaderLines822.java:1.1 
gzz/lava/gzz/storm/headers/DefaultHeaderLines822.java:1.2
--- gzz/lava/gzz/storm/headers/DefaultHeaderLines822.java:1.1   Thu Nov  7 
17:07:00 2002
+++ gzz/lava/gzz/storm/headers/DefaultHeaderLines822.java       Fri Nov  8 
16:55:34 2002
@@ -41,6 +41,10 @@
        this(new ArrayList(), null);
     }
 
+    public DefaultHeaderLines822(List lines) {
+       this(new ArrayList(lines), null);
+    }
+
     public DefaultHeaderLines822(HeaderLines822 initializeWith) {
        this(new ArrayList(), initializeWith);
     }
Index: gzz/lava/gzz/storm/headers/SortedHeader822.java
diff -u gzz/lava/gzz/storm/headers/SortedHeader822.java:1.1 
gzz/lava/gzz/storm/headers/SortedHeader822.java:1.2
--- gzz/lava/gzz/storm/headers/SortedHeader822.java:1.1 Thu Nov  7 17:07:00 2002
+++ gzz/lava/gzz/storm/headers/SortedHeader822.java     Fri Nov  8 16:55:34 2002
@@ -26,6 +26,8 @@
 import java.util.*;
 
 public class SortedHeader822 extends ModularHeader822 {
+    public static boolean dbg = false;
+    private static void p(String s) { System.out.println(s); }
     
     public SortedHeader822() {
        super(null, new SortedHeaderMap822());
@@ -41,17 +43,21 @@
     public List getLines() {
        ArrayList lines = new ArrayList();
 
+       if(dbg) p("Sortedheader map: "+((DefaultHeaderMap822)map).fields);
+
        for(Iterator i=map.keySet().iterator(); i.hasNext();) {
            String fieldName = (String)i.next();
+           fieldName = Headers822.canonicalizeFieldName(fieldName);
 
            Collection values = map.getAll(fieldName);
-           for(Iterator j = values.iterator(); i.hasNext();) {
-               String fieldValue = (String)i.next();
-               fieldValue = HeaderUtil.canonicalizeFieldName(fieldName);
+           for(Iterator j = values.iterator(); j.hasNext();) {
+               String fieldValue = (String)j.next();
 
-               lines.add(fieldName + ": " + fieldValue); // no folding
+               lines.add(fieldName + ": " + fieldValue); // no folding for now
            }
        }
+
+       if(dbg) p("Sortedheader getlines: "+lines);
 
        return lines;
     }
Index: gzz/lava/gzz/storm/impl/DirPool.java
diff -u gzz/lava/gzz/storm/impl/DirPool.java:1.2 
gzz/lava/gzz/storm/impl/DirPool.java:1.3
--- gzz/lava/gzz/storm/impl/DirPool.java:1.2    Fri Nov  8 15:54:55 2002
+++ gzz/lava/gzz/storm/impl/DirPool.java        Fri Nov  8 16:55:34 2002
@@ -1,4 +1,25 @@
-//(c):Benja Fallenstein
+/*
+DirPool.java
+ *    
+ *    Copyright (c) 2002, Benja Fallenstein
+ *    
+ *    You may use and distribute under the terms of either the GNU Lesser
+ *    General Public License, either version 2 of the license or,
+ *    at your choice, any later version. Alternatively, you may use and
+ *    distribute under the terms of the XPL.
+ *    
+ *    See the LICENSE.lgpl and LICENSE.xpl files for the specific terms of
+ *    the licenses.
+ *    
+ *    This software is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the README
+ *    file for more details.
+ *    
+ */
+/*
+ * Written by Benja Fallenstein
+ */
 package gzz.storm.impl;
 import gzz.storm.*;
 import gzz.storm.headers.*;
@@ -52,16 +73,23 @@
         protected File file;
 
        protected BlockId id;
+       protected Header822 header;
 
        protected FileBlock(BlockId id) throws IOException {
            this.id = id;
            this.file = getFile(id);
+
+           InputStream is = new FileInputStream(file);
+           this.header = Headers822.readHeader(is);
+           is.close();
        }
        public BlockId getId() { return id; }
        public StormPool getPool() { return null; }
-       public Header822 getHeader() { return null; }
-       public InputStream getInputStream() {
-           return null;
+       public Header822 getHeader() { return header; }
+       public InputStream getInputStream() throws IOException {
+           InputStream is = new FileInputStream(file);
+           Headers822.readHeader(is);
+           return is;
        }
        public InputStream getRawInputStream() throws IOException {
            return new FileInputStream(file);
@@ -71,17 +99,28 @@
     /** Create a new DirPool.
      *  @param dir The directory blocks are stored in.
      *             Must already exist.
-     *  @throws IllegalArgumentException if the directory
-     *             does not exist yet.
+     *  @throws IllegalArgumentException if the file isn't a directory
+     *                                   or does not exist yet.
      */
     public DirPool(File dir) {
        this.dir = dir;
     }
 
-    public Block get(BlockId id) { return null; }
+    public Block get(BlockId id) throws IOException { 
+       return new FileBlock(id); 
+    }
     public void add(Block b) {}
     public void delete(Block b) {}
-    public Set getIds() { return null; }
+    public Set getIds() {
+       HashSet ids = new HashSet();
+       String[] list = dir.list();
+       
+       for(int i=0; i<list.length; i++)
+           if(list[i].startsWith("b_"))
+               ids.add(new BlockId("storm:block:" + list[i].substring(2)));
+
+       return ids;
+    }
     public BlockOutputStream getBlockOutputStream(String contentType) 
                                                           throws IOException {
        Header822 hdr = new UniqueHeader822();




reply via email to

[Prev in Thread] Current Thread [Next in Thread]