]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/src/org/simantics/modeling/subscription/SubscriptionItem.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / subscription / SubscriptionItem.java
diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/subscription/SubscriptionItem.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/subscription/SubscriptionItem.java
new file mode 100644 (file)
index 0000000..6703933
--- /dev/null
@@ -0,0 +1,69 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007 VTT Technical Research Centre of Finland and others.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.modeling.subscription;\r
+\r
+import org.simantics.databoard.annotations.Identifier;\r
+import org.simantics.databoard.annotations.Optional;\r
+import org.simantics.databoard.util.Bean;\r
+import org.simantics.utils.strings.AlphanumComparator;\r
+\r
+/**\r
+ * @author Antti Villberg\r
+ */\r
+public class SubscriptionItem extends Bean {\r
+       \r
+       // Normal Label (eg. The label in CSV file)\r
+       public @Optional String simpleLabel;\r
+       // Variable reference in user friendly format\r
+       public @Optional String variableReference;\r
+       \r
+       // GroupId in the history\r
+       public @Identifier String groupId;\r
+       // ItemId in the group\r
+       public @Identifier String groupItemId;\r
+       // Variable id in format understood by org.simantics.simulation.data.Datasource\r
+       public @Identifier String variableId;\r
+       \r
+       public @Optional String unit;\r
+       \r
+       public SubscriptionItem() {\r
+       }\r
+       \r
+       @Override\r
+       public int compareTo(Bean o) {\r
+               if ( o instanceof SubscriptionItem == false ) return 0;\r
+               SubscriptionItem other = (SubscriptionItem) o;\r
+               \r
+               String myLabel2 = simpleLabel!=null?simpleLabel:"";\r
+               String otLabel2 = other.simpleLabel!=null?other.simpleLabel:"";\r
+               int c = AlphanumComparator.CASE_INSENSITIVE_COMPARATOR.compare(myLabel2, otLabel2);\r
+               if ( c!=0 ) return c;\r
+               \r
+               String mySid = groupId!=null?groupId:""; \r
+               String otSid = other.groupId!=null?other.groupId:""; \r
+               c = mySid.compareTo(otSid);\r
+               if ( c!=0 ) return c;\r
+\r
+               String myGiid = groupItemId!=null?groupItemId:""; \r
+               String otGiid = other.groupItemId!=null?other.groupItemId:""; \r
+               c = myGiid.compareTo(otGiid);\r
+               if ( c!=0 ) return c;\r
+\r
+               String myVid = variableId!=null?variableId:""; \r
+               String otVid = other.variableId!=null?other.variableId:""; \r
+               c = myVid.compareTo(otVid);\r
+               if ( c!=0 ) return c;\r
+               \r
+               return c;               \r
+       }\r
+       \r
+}\r
+\r