From 0ec8481c10cd8277d84c7c1a785483a0a739e5a0 Mon Sep 17 00:00:00 2001 From: abranson Date: Thu, 4 Aug 2011 00:42:34 +0200 Subject: 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 --- .../com/c2kernel/persistency/outcome/Outcome.java | 45 ++++++++++++---------- 1 file changed, 24 insertions(+), 21 deletions(-) mode change 100755 => 100644 source/com/c2kernel/persistency/outcome/Outcome.java (limited to 'source/com/c2kernel/persistency/outcome/Outcome.java') diff --git a/source/com/c2kernel/persistency/outcome/Outcome.java b/source/com/c2kernel/persistency/outcome/Outcome.java old mode 100755 new mode 100644 index f919230..a5ecb29 --- 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; -- cgit v1.2.3