diff options
| author | abranson <andrew.branson@cern.ch> | 2011-08-04 00:42:34 +0200 |
|---|---|---|
| committer | abranson <andrew.branson@cern.ch> | 2011-08-04 00:42:34 +0200 |
| commit | 0ec8481c10cd8277d84c7c1a785483a0a739e5a0 (patch) | |
| tree | 5f6e5d9ae75193e67e6f3b3dfa488960c5cde1d5 /source/com/c2kernel/persistency/outcome/Outcome.java | |
| parent | 036cbdba66f804743c4c838ed598d6972c4b3e17 (diff) | |
More code cleanup:
Refactored Entity Proxy Subscription to handle generics better
Rewrote RemoteMap to use TreeMap instead of the internal array for
order. It now sorts its keys by number if they parse, else as strings.
Removed a no-longer-in-progress outcome form class
Diffstat (limited to 'source/com/c2kernel/persistency/outcome/Outcome.java')
| -rw-r--r--[-rwxr-xr-x] | source/com/c2kernel/persistency/outcome/Outcome.java | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/source/com/c2kernel/persistency/outcome/Outcome.java b/source/com/c2kernel/persistency/outcome/Outcome.java index f919230..a5ecb29 100755..100644 --- a/source/com/c2kernel/persistency/outcome/Outcome.java +++ b/source/com/c2kernel/persistency/outcome/Outcome.java @@ -24,18 +24,18 @@ public class Outcome implements C2KLocalObject { String mSchemaType;
int mSchemaVersion;
static DocumentBuilder parser;
-
+
static {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(false);
- dbf.setNamespaceAware(false);
+ dbf.setNamespaceAware(false);
try {
parser = dbf.newDocumentBuilder();
} catch (ParserConfigurationException e) {
Logger.error(e);
- }
+ }
}
-
+
//id is the eventID
public Outcome(int id, String data, String schemaType, int schemaVersion) {
mID = id;
@@ -43,23 +43,23 @@ public class Outcome implements C2KLocalObject { mSchemaType = schemaType;
mSchemaVersion = schemaVersion;
}
-
+
public Outcome(String path, String data) throws PersistencyException {
// derive all the meta data from the path
StringTokenizer tok = new StringTokenizer(path,"/");
- if (tok.countTokens() != 3 && !(tok.nextToken().equals("Outcome")))
+ if (tok.countTokens() != 3 && !(tok.nextToken().equals("Outcome")))
throw new PersistencyException("Outcome() - Outcome path must have three components: "+path, null);
mSchemaType = tok.nextToken();
String verstring = tok.nextToken();
String objId = tok.nextToken();
try {
mSchemaVersion = Integer.parseInt(verstring);
- } catch (NumberFormatException ex) {
+ } catch (NumberFormatException ex) {
throw new PersistencyException("Outcome() - Outcome version was an invalid number: "+verstring, null);
}
try {
mID = Integer.parseInt(objId);
- } catch (NumberFormatException ex) {
+ } catch (NumberFormatException ex) {
mID = -1;
}
mData = data;
@@ -73,7 +73,8 @@ public class Outcome implements C2KLocalObject { return mID;
}
- public void setName(String name) {
+ @Override
+ public void setName(String name) {
try {
mID = Integer.parseInt(name);
} catch (NumberFormatException e) {
@@ -81,14 +82,15 @@ public class Outcome implements C2KLocalObject { }
}
- public String getName() {
+ @Override
+ public String getName() {
return String.valueOf(mID);
}
public void setData(String data) {
mData = data;
}
-
+
public void setData(Document data) {
mData = serialize(data, false);
}
@@ -96,11 +98,11 @@ public class Outcome implements C2KLocalObject { public String getData() {
return mData;
}
-
+
public void setSchemaType(String schemaType) {
mSchemaType = schemaType;
}
-
+
public String getSchemaType() {
return mSchemaType;
}
@@ -108,24 +110,25 @@ public class Outcome implements C2KLocalObject { public void setSchemaURL(int schemaVersion) {
mSchemaVersion = schemaVersion;
}
-
+
public int getSchemaVersion() {
return mSchemaVersion;
- }
-
+ }
+
public void setSchemaVersion(int schVer) {
mSchemaVersion = schVer;
- }
-
+ }
+
+ @Override
public String getClusterType() {
return ClusterStorage.OUTCOME;
}
-
+
// special script API methods
/**
* Parses the outcome into a DOM tree
- * @return a DOM Document
+ * @return a DOM Document
*/
public Document getDOM() {
try {
@@ -137,7 +140,7 @@ public class Outcome implements C2KLocalObject { return null;
}
}
-
+
static public String serialize(Document doc, boolean prettyPrint)
{
String serializedDoc = null;
|
