Mercurial > hg > blitz_condensed
comparison test/org/dancres/blitz/mangler/StaticTest.java @ 0:3dc0c5604566
Initial checkin of blitz 2.0 fcs - no installer yet.
author | Dan Creswell <dan.creswell@gmail.com> |
---|---|
date | Sat, 21 Mar 2009 11:00:06 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3dc0c5604566 |
---|---|
1 package org.dancres.blitz.mangler; | |
2 | |
3 import net.jini.core.entry.Entry; | |
4 | |
5 public class StaticTest { | |
6 private void test(Entry anEntry) { | |
7 try { | |
8 EntryMangler myMangler = new EntryMangler(); | |
9 MangledEntry myEntry = myMangler.mangle(anEntry); | |
10 | |
11 myEntry.dump(System.out); | |
12 | |
13 Entry myNewEntry = myMangler.unMangle(myEntry); | |
14 | |
15 System.out.println("Unpacked result...."); | |
16 System.out.println(myNewEntry); | |
17 } catch (Exception anE) { | |
18 System.err.println("Failed"); | |
19 anE.printStackTrace(System.err); | |
20 } | |
21 } | |
22 | |
23 public static void main(String args[]) { | |
24 new StaticTest().test(new ArrayMetaData("name", ArrayMetaData.HEAD, | |
25 12)); | |
26 } | |
27 | |
28 public static class ArrayMetaData | |
29 implements net.jini.core.entry.Entry{ | |
30 | |
31 public String _name; | |
32 public Integer _index; | |
33 public Integer _type; | |
34 | |
35 public static final Integer HEAD=new Integer(0); | |
36 public static final Integer TAIL=new Integer(1); | |
37 | |
38 //required no-args constructor | |
39 public ArrayMetaData(){ | |
40 | |
41 } | |
42 //for matching | |
43 public ArrayMetaData(String name,Integer type){ | |
44 _name=name; | |
45 checkType(type); | |
46 _type=type; | |
47 } | |
48 //for creation | |
49 public ArrayMetaData(String name,Integer type,int index){ | |
50 this(name,type); | |
51 _index=new Integer(index); | |
52 } | |
53 //increment | |
54 public void increment(){ | |
55 _index= | |
56 new Integer(_index.intValue()+1); | |
57 } | |
58 public Integer getIndex(){ | |
59 return _index; | |
60 } | |
61 private void checkType(Integer type){ | |
62 if(type.equals(HEAD)==false | |
63 && type.equals(TAIL)==false){ | |
64 | |
65 throw new IllegalArgumentException("Invalid type"); | |
66 } | |
67 } | |
68 public String toString() { | |
69 return super.toString() + ", " + _name + ", " + _index + ", " + | |
70 _type; | |
71 } | |
72 } | |
73 } |