]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.databoard/src/org/simantics/databoard/type/MapType.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / type / MapType.java
index 4fede9cf9479d813e4f34ee2fe2595fb5c8aad6c..7a0ac3dc34010bffdea05a61340b24bd74e888b7 100644 (file)
@@ -1,34 +1,34 @@
-/*******************************************************************************\r
- *  Copyright (c) 2010 Association for Decentralized Information Management in\r
- *  Industry THTH ry.\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
+/*******************************************************************************
+ *  Copyright (c) 2010 Association for Decentralized Information Management in
+ *  Industry THTH ry.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ *
+ *  Contributors:
+ *      VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
 package org.simantics.databoard.type;
 
-import java.util.Set;\r
-\r
-import org.simantics.databoard.accessor.error.ReferenceException;\r
-import org.simantics.databoard.accessor.reference.ChildReference;\r
-import org.simantics.databoard.accessor.reference.IndexReference;\r
-import org.simantics.databoard.accessor.reference.KeyReference;\r
-import org.simantics.databoard.accessor.reference.LabelReference;\r
-import org.simantics.databoard.accessor.reference.NameReference;\r
-import org.simantics.databoard.util.IdentityPair;\r
-import org.simantics.databoard.util.ObjectUtils;\r
+import java.util.Set;
+
+import org.simantics.databoard.accessor.error.ReferenceException;
+import org.simantics.databoard.accessor.reference.ChildReference;
+import org.simantics.databoard.accessor.reference.IndexReference;
+import org.simantics.databoard.accessor.reference.KeyReference;
+import org.simantics.databoard.accessor.reference.LabelReference;
+import org.simantics.databoard.accessor.reference.NameReference;
+import org.simantics.databoard.util.IdentityPair;
+import org.simantics.databoard.util.ObjectUtils;
 
 public class MapType extends Datatype {
-\r
+
        /** Key to describe if map is to be serialized ordered, the value is boolean value "false"/"true" */
-       public static final String KEY_ORDERED = "ordered";\r
-       \r
+       public static final String KEY_ORDERED = "ordered";
+       
        public Datatype keyType;
-       public Datatype valueType;\r
+       public Datatype valueType;
        
        public MapType() {              
        }
@@ -39,38 +39,38 @@ public class MapType extends Datatype {
                this.keyType = keyType;
                this.valueType = valueType;
        }
-       \r
-    @Override\r
-    public int getComponentCount() {\r
-       return 2;\r
-    }\r
-    \r
-    @Override\r
-    public Datatype getComponentType(int index) {\r
-       if (index==0) return keyType;\r
-       if (index==1) return valueType;\r
-       throw new IllegalArgumentException();\r
-    }\r
-    \r
-    @Override\r
-    public Datatype getComponentType(ChildReference path) {\r
-       if (path==null) return this;\r
-       if (path instanceof IndexReference) {\r
-               IndexReference ir = (IndexReference) path;\r
-               if (ir.index==0) return keyType.getComponentType(path.childReference);\r
-               if (ir.index==1) return valueType.getComponentType(path.childReference);\r
-       }\r
-       if (path instanceof LabelReference) {\r
-               LabelReference lr = (LabelReference) path;\r
-               if (lr.label.equals("0") || lr.label.equals("key")) return keyType.getComponentType(path.childReference);\r
-               if (lr.label.equals("1") || lr.label.equals("value")) return valueType.getComponentType(path.childReference);\r
-       }\r
-       if (path instanceof NameReference) {\r
-               NameReference nr = (NameReference) path;\r
-               if (nr.name.equals("key")) return keyType.getComponentType(path.childReference);\r
-               if (nr.name.equals("value")) return valueType.getComponentType(path.childReference);\r
-       }\r
-       throw new IllegalArgumentException();\r
+       
+    @Override
+    public int getComponentCount() {
+       return 2;
+    }
+    
+    @Override
+    public Datatype getComponentType(int index) {
+       if (index==0) return keyType;
+       if (index==1) return valueType;
+       throw new IllegalArgumentException();
+    }
+    
+    @Override
+    public Datatype getComponentType(ChildReference path) {
+       if (path==null) return this;
+       if (path instanceof IndexReference) {
+               IndexReference ir = (IndexReference) path;
+               if (ir.index==0) return keyType.getComponentType(path.childReference);
+               if (ir.index==1) return valueType.getComponentType(path.childReference);
+       }
+       if (path instanceof LabelReference) {
+               LabelReference lr = (LabelReference) path;
+               if (lr.label.equals("0") || lr.label.equals("key")) return keyType.getComponentType(path.childReference);
+               if (lr.label.equals("1") || lr.label.equals("value")) return valueType.getComponentType(path.childReference);
+       }
+       if (path instanceof NameReference) {
+               NameReference nr = (NameReference) path;
+               if (nr.name.equals("key")) return keyType.getComponentType(path.childReference);
+               if (nr.name.equals("value")) return valueType.getComponentType(path.childReference);
+       }
+       throw new IllegalArgumentException();
     }  
        @Override
        public void accept(Visitor1 v, Object obj) {
@@ -85,8 +85,8 @@ public class MapType extends Datatype {
        @Override
        protected boolean deepEquals(Object obj,
                        Set<IdentityPair<Datatype, Datatype>> compareHistory) {         
-               if (this==obj) return true;\r
-               if ( !hasEqualMetadata(obj) ) return false;\r
+               if (this==obj) return true;
+               if ( !hasEqualMetadata(obj) ) return false;
                if (obj instanceof MapType == false) return false;
                MapType other = (MapType) obj;
                
@@ -108,21 +108,21 @@ public class MapType extends Datatype {
                        ObjectUtils.hashCode(keyType) * 13 +
                        ObjectUtils.hashCode(valueType) * 17;
        }
-\r
-       @SuppressWarnings("unchecked")\r
-       @Override\r
-       public <T extends Datatype> T getChildType(ChildReference reference) throws ReferenceException {\r
-               if (reference==null) return (T) this;\r
-               \r
-               if (reference instanceof LabelReference) {\r
-//                     LabelReference lr = (LabelReference) reference;\r
-                       return keyType.getChildType(reference.getChildReference());\r
-               } else if (reference instanceof KeyReference) {\r
-//                     KeyReference ref = (KeyReference) reference;\r
-                       return keyType.getChildType(reference.getChildReference());\r
-               } \r
-               throw new ReferenceException(reference.getClass().getName()+" is not a reference of a map");    \r
-       }\r
+
+       @SuppressWarnings("unchecked")
+       @Override
+       public <T extends Datatype> T getChildType(ChildReference reference) throws ReferenceException {
+               if (reference==null) return (T) this;
+               
+               if (reference instanceof LabelReference) {
+//                     LabelReference lr = (LabelReference) reference;
+                       return keyType.getChildType(reference.getChildReference());
+               } else if (reference instanceof KeyReference) {
+//                     KeyReference ref = (KeyReference) reference;
+                       return keyType.getChildType(reference.getChildReference());
+               } 
+               throw new ReferenceException(reference.getClass().getName()+" is not a reference of a map");    
+       }
        
 }