Mercurial > hg > blitz_stable
comparison src/org/dancres/blitz/stats/FieldsStat.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.stats; | |
2 | |
3 import java.util.Collection; | |
4 | |
5 /** | |
6 <p>Tracks the known fields of a particular type known to the blitz core. | |
7 One can consider this a summary of the schema of the Entry.</p> | |
8 */ | |
9 public class FieldsStat implements Stat, StatGenerator { | |
10 private long theId = StatGenerator.UNSET_ID; | |
11 | |
12 private String theType; | |
13 private String[] theFields; | |
14 | |
15 public FieldsStat(String aType, Collection aFieldNames) { | |
16 theType = aType; | |
17 String[] myFields = new String[aFieldNames.size()]; | |
18 theFields = (String[]) aFieldNames.toArray(myFields); | |
19 } | |
20 | |
21 private FieldsStat(long anId) { | |
22 theId = anId; | |
23 } | |
24 | |
25 public void setId(long anId) { | |
26 theId = anId; | |
27 } | |
28 | |
29 public long getId() { | |
30 return theId; | |
31 } | |
32 | |
33 public String[] getFields() { | |
34 return theFields; | |
35 } | |
36 | |
37 public String getType() { | |
38 return theType; | |
39 } | |
40 | |
41 private void setType(String aType) { | |
42 theType = aType; | |
43 } | |
44 | |
45 private void setFields(String[] aFields) { | |
46 theFields = aFields; | |
47 } | |
48 | |
49 public Stat generate() { | |
50 String[] myFields = new String[theFields.length]; | |
51 | |
52 System.arraycopy(theFields, 0, myFields, 0, theFields.length); | |
53 | |
54 FieldsStat myStat = new FieldsStat(theId); | |
55 myStat.setFields(myFields); | |
56 myStat.setType(theType); | |
57 | |
58 return myStat; | |
59 } | |
60 | |
61 public String toString() { | |
62 StringBuffer myFields = new StringBuffer("Fields for " + theType + | |
63 ": "); | |
64 | |
65 for (int i = 0; i < theFields.length; i++) { | |
66 myFields.append(theFields[i]); | |
67 myFields.append(", "); | |
68 } | |
69 | |
70 return myFields.toString(); | |
71 } | |
72 } |