/[gzz]/gzz/lava/test/gzz/storm/util/TestVersion.java
ViewVC logotype

Diff of /gzz/lava/test/gzz/storm/util/TestVersion.java

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

revision 1.1 by benja, Sat Jan 18 15:47:44 2003 UTC revision 1.2 by benja, Sat Jan 18 16:32:57 2003 UTC
# Line 1  Line 1 
1  //(c):Benja Fallenstein  //(c):Benja Fallenstein
2  package gzz.storm.util;  package gzz.storm.util;
3  import gzz.util.*;  import gzz.util.*;
4    import java.io.*;
5  import java.util.*;  import java.util.*;
6    
7  /** A simple mock implementation of Version, for testing.  /** A simple mock implementation of Version, for testing.
# Line 61  public class TestVersion implements Vers Line 62  public class TestVersion implements Vers
62              return 138789^diff;              return 138789^diff;
63          }          }
64      }      }
65    
66        /** A version format for use with TestVersions and TestVersion.Diffs.
67         *  Stores the value/difference as an ASCII number.
68         */
69        public static class Format implements VersionFormat {
70            public void writeVersion(OutputStream out, Version v) throws IOException {
71                String s = ""+((TestVersion)v).value;
72                out.write(s.getBytes("US-ASCII"));
73            }
74            public void writeDiff(OutputStream out, Version.Diff d) throws IOException {
75                String s = ""+((Diff)d).diff;
76                out.write(s.getBytes("US-ASCII"));
77            }
78    
79            public Version readVersion(InputStream in) throws IOException {
80                ByteArrayOutputStream bos = new ByteArrayOutputStream();
81                CopyUtil.copy(in, bos);
82                String s = new String(bos.toByteArray(), "US-ASCII");
83                return new TestVersion(Integer.parseInt(s));
84            }
85            public Version.Diff readDiff(InputStream in) throws IOException {
86                ByteArrayOutputStream bos = new ByteArrayOutputStream();
87                CopyUtil.copy(in, bos);
88                String s = new String(bos.toByteArray(), "US-ASCII");
89                return new Diff(Integer.parseInt(s));
90            }
91        }
92  }  }

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