xlawrence 2004/12/08 17:05:29 CET
Modified files:
src/java/org/jahia/suite/calendar/util
StateValueConverter.java
Log:
Added conversion methods to/from String Objects to int or char
Revision Changes Path
1.3 +109 -1
uwcal_JSR168/src/java/org/jahia/suite/calendar/util/StateValueConverter.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/uwcal_JSR168/src/java/org/jahia/suite/calendar/util/StateValueConverter.java.diff?r1=1.2&r2=1.3&f=h
Index: StateValueConverter.java
===================================================================
RCS file:
/home/cvs/repository/uwcal_JSR168/src/java/org/jahia/suite/calendar/util/StateValueConverter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- StateValueConverter.java 23 Nov 2004 10:30:19 -0000 1.2
+++ StateValueConverter.java 8 Dec 2004 16:05:29 -0000 1.3
@@ -43,7 +43,7 @@
/**
- * Utility class that converts a state value of a Sync4j SyncItemState into
the
+ * Utility class that converts a state value of a Sync4j SyncItemState into
the
* corresponding state value of a SyncEvent and vice versa.
*
* @author Xavier Lawrence
@@ -78,6 +78,33 @@
}
/**
+ * Converts a Sync4j SyncItemState value into a SyncItemState String
value
+ * @param state The value of the SyncItemState state
+ * @return A String representation of the state value
+ */
+ public static String toSync4jString(char state) {
+ switch (state) {
+ case SyncItemState.DELETED:
+ return "DELETED";
+
+ case SyncItemState.UPDATED:
+ return "UPDATED";
+
+ case SyncItemState.NEW:
+ return "NEW";
+
+ case SyncItemState.SYNCHRONIZED:
+ return "SYNCHRONIZED";
+
+ case SyncItemState.UNKNOWN:
+ return "UNKNOWN";
+
+ default:
+ throw new SyncException("Unknow state value: "+state);
+ }
+ }
+
+ /**
* Converts a Sync4j SyncItemState value into a SyncEvent state value
* @param state The value of the Sync4j SyncItemState
* @return The corresponding value as defined in SyncEvent
@@ -103,4 +130,85 @@
throw new SyncException("Unknow state value: "+state);
}
}
+
+ /**
+ * Converts a uwCAl SyncEvent value into a SyncEvent String value
+ * @param state The value of the uwCal SyncEvent
+ * @return A String representation of the state value
+ */
+ public static String toUWCalString(int state) {
+ switch (state) {
+ case SyncEvent.DELETED:
+ return "DELETED";
+
+ case SyncEvent.MODIFIED:
+ return "MODIFIED";
+
+ case SyncEvent.NEW:
+ return "NEW";
+
+ case SyncEvent.SYNCHRONIZED:
+ return "SYNCHRONIZED";
+
+ case SyncEvent.UNKNOWN:
+ return "UNKNOWN";
+
+ default:
+ throw new SyncException("Unknow state value: "+state);
+ }
+ }
+
+ /**
+ * Converts a uwCAl SyncEvent String value into a SyncEvent value
+ * @param state The String value of the uwCal SyncEvent
+ * @return The state value
+ */
+ public static int toUWCalInt(String state) {
+
+ if ("DELETED".equals(state)) {
+ return SyncEvent.DELETED;
+
+ } else if ("MODIFIED".equals(state)) {
+ return SyncEvent.MODIFIED;
+
+ } else if ("NEW".equals(state)) {
+ return SyncEvent.NEW;
+
+ } else if ("SYNCHRONIZED".equals(state)) {
+ return SyncEvent.SYNCHRONIZED;
+
+ } else if ("UNKNOWN".equals(state)) {
+ return SyncEvent.UNKNOWN;
+
+ } else {
+ throw new SyncException("Unknow state value: "+state);
+ }
+ }
+
+ /**
+ * Converts a uwCAl SyncEvent String value into a SyncEvent value
+ * @param state The String value of the uwCal SyncEvent
+ * @return The state value
+ */
+ public static char toSync4jChar(String state) {
+
+ if ("DELETED".equals(state)) {
+ return SyncItemState.DELETED;
+
+ } else if ("UPDATED".equals(state)) {
+ return SyncItemState.UPDATED;
+
+ } else if ("NEW".equals(state)) {
+ return SyncItemState.NEW;
+
+ } else if ("SYNCHRONIZED".equals(state)) {
+ return SyncItemState.SYNCHRONIZED;
+
+ } else if ("UNKNOWN".equals(state)) {
+ return SyncItemState.UNKNOWN;
+
+ } else {
+ throw new SyncException("Unknow state value: "+state);
+ }
+ }
}