source: trunk/gsdl3/packages/javagdbm/java/au/com/pharos/dbinterface/vf/VFOrder.java@ 10737

Last change on this file since 10737 was 10737, checked in by kjdon, 19 years ago

Java Wrapper for GDBM, from Martin Pool. Original website gone, so added it all in here. I have modified the Makefiles to work in greenstone, and on macs, and added windows makefiles

  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 KB
Line 
1/*
2 * (C) Pharos IP PTy Ltd 1997
3 */
4
5package au.com.pharos.dbinterface.vf;
6
7import java.util.Date;
8import java.util.Vector;
9import java.util.Hashtable;
10import java.util.Enumeration;
11
12import java.text.SimpleDateFormat;
13import java.text.ParsePosition;
14
15import java.text.SimpleDateFormat;
16
17public class VFOrder {
18
19 /* The final date for submission */
20 public Date finalSubmit;
21
22 /* The date the order was created */
23 public Date orderDate;
24
25 /* A hash mapping titles requested to numbers of each title*/
26 public Hashtable orderNumbers;
27
28 /* The name of the ordering store */
29 public String name;
30
31 public VFOrder(Date newFinal,
32 String newName,
33 Hashtable newOrder)
34 {
35 finalSubmit = newFinal;
36 orderNumbers = newOrder;
37 name = newName;
38 orderDate = new Date(System.currentTimeMillis());
39 if (orderDate.after(finalSubmit)) {
40 throw new IllegalArgumentException("Final submission date is earlier than present date.");
41 }
42 }
43
44 public VFOrder(Date newFinal,
45 Date newDate,
46 String newName,
47 Hashtable newOrder)
48 {
49 finalSubmit = newFinal;
50 orderDate = newDate;
51 orderNumbers = newOrder;
52 name = newName;
53 orderDate = new Date(System.currentTimeMillis());
54 if (orderDate.after(finalSubmit)) {
55 throw new IllegalArgumentException("Final submission date is earlier than present date.");
56 }
57 }
58
59 public Vector toVectorString()
60 {
61 Vector result = new Vector();
62 result.addElement(new Long(finalSubmit.getTime()));
63 result.addElement(new Long(orderDate.getTime()));
64 result.addElement(orderNumbers.toString());
65 result.addElement(name);
66 return result;
67 }
68
69 public VFOrder fromVectorString(Vector input)
70 throws java.text.ParseException
71 {
72 Hashtable data = new Hashtable();
73 SimpleDateFormat form = new SimpleDateFormat();
74 for (Enumeration e = input.elements(); e.hasMoreElements(); ) {
75 System.out.println(e.nextElement());
76 }
77 try {
78 finalSubmit = new Date(((Long) input.elementAt(0)).longValue());
79 } catch (NullPointerException e) {
80 System.err.println("Waaaah!");
81 finalSubmit = new Date();
82 }
83 System.err.println("No 2:" + input.elementAt(1).toString());
84 orderDate = new Date(((Long) input.elementAt(1)).longValue());
85 name = (String) input.elementAt(3);
86 String hashString = (String) input.elementAt(2);
87 StringBuffer key = new StringBuffer();;
88 StringBuffer value = new StringBuffer();
89 String type = new String("key");
90 for (int count = 0; count < hashString.length(); count++) {
91 char i = hashString.charAt(count);
92 if (i == '{' || i == ' ') { ; }
93 else if (i == '}') { data.put(key, value); }
94 else if (i == ',') {data.put(key, value); }
95 else if (i == '=') {
96 if (type.equals("key")) {
97 type = "value";
98 } else {
99 type = "key";
100 }
101 } else {
102 if (type.equals("key")) {
103 key.append(i);
104 } else {
105 value.append(i);
106 }
107 }
108 }
109 return new VFOrder(finalSubmit, orderDate, name, data);
110 }
111
112
113
114
115}
116
Note: See TracBrowser for help on using the repository browser.