]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.databoard/src/org/simantics/databoard/type/ArrayType.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / type / ArrayType.java
index ba7b90977c2ffeca28ebe2d0997de140b7e23a66..da03b9790e560d7145bf9fce52d105203d1a8001 100644 (file)
@@ -1,37 +1,37 @@
-/*******************************************************************************\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.Limit;\r
-import org.simantics.databoard.util.ObjectUtils;\r
-import org.simantics.databoard.util.Range;\r
-import org.simantics.databoard.util.RangeException;\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.Limit;
+import org.simantics.databoard.util.ObjectUtils;
+import org.simantics.databoard.util.Range;
+import org.simantics.databoard.util.RangeException;
 
 public class ArrayType extends Datatype {
-    \r
-       /** Metadata key for array length */\r
-       public static final String KEY_LENGTH = "length";\r
-\r
-       private transient Range _length; \r
-       private transient String _lengthIsForStr;\r
+    
+       /** Metadata key for array length */
+       public static final String KEY_LENGTH = "length";
+
+       private transient Range _length; 
+       private transient String _lengthIsForStr;
        
     public Datatype componentType;
     
@@ -42,34 +42,34 @@ public class ArrayType extends Datatype {
     }
     
     public ArrayType(Datatype componentType, String length) {
-       this.componentType = componentType;\r
+       this.componentType = componentType;
        setLength(length);
     }
 
     public ArrayType(Datatype componentType, Range length) {
        this.componentType = componentType;
        setLength(length);
-    }\r
-    \r
-    @Override\r
-    public int getComponentCount() {\r
-       return 1;\r
-    }\r
-    \r
-    @Override\r
-    public Datatype getComponentType(int index) {\r
-       if (index!=0) throw new IllegalArgumentException();\r
-       return componentType;\r
-    }\r
-    \r
-    @Override\r
-    public Datatype getComponentType(ChildReference path) {\r
-       if (path==null) return this;\r
-       if (path instanceof KeyReference) throw new IllegalArgumentException("KeyReference is not supported in ArrayType"); \r
-       if (path instanceof NameReference) throw new IllegalArgumentException("NameReference is not supported in ArrayType"); \r
-       if (path instanceof IndexReference && ((IndexReference) path).index!=0) throw new IllegalArgumentException("Index out of bounds");\r
-       if (path instanceof LabelReference && !((LabelReference) path).label.equals("v")) throw new IllegalArgumentException("Unknown label");\r
-       return componentType.getComponentType(path.childReference);\r
+    }
+    
+    @Override
+    public int getComponentCount() {
+       return 1;
+    }
+    
+    @Override
+    public Datatype getComponentType(int index) {
+       if (index!=0) throw new IllegalArgumentException();
+       return componentType;
+    }
+    
+    @Override
+    public Datatype getComponentType(ChildReference path) {
+       if (path==null) return this;
+       if (path instanceof KeyReference) throw new IllegalArgumentException("KeyReference is not supported in ArrayType"); 
+       if (path instanceof NameReference) throw new IllegalArgumentException("NameReference is not supported in ArrayType"); 
+       if (path instanceof IndexReference && ((IndexReference) path).index!=0) throw new IllegalArgumentException("Index out of bounds");
+       if (path instanceof LabelReference && !((LabelReference) path).label.equals("v")) throw new IllegalArgumentException("Unknown label");
+       return componentType.getComponentType(path.childReference);
     }
     
        @Override
@@ -79,18 +79,18 @@ public class ArrayType 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 ArrayType == false) return false;
-               ArrayType other = (ArrayType) obj;\r
+               ArrayType other = (ArrayType) obj;
                return componentType.deepEquals(other.componentType, compareHistory);
        }
        
        @Override
-       public int hashCode() {\r
-               if (componentType==this) return 0;              \r
+       public int hashCode() {
+               if (componentType==this) return 0;              
                return 0x234ae + metadataHashCode() + 13* ObjectUtils.hashCode(componentType);
-       }       \r
+       }       
        
        @Override
        public void accept(Visitor1 v, Object obj) {
@@ -104,18 +104,18 @@ public class ArrayType extends Datatype {
 
        public Datatype componentType() {
                return componentType;
-       }\r
-\r
-       @Deprecated\r
-       public Datatype getComponentType() {\r
-               return componentType;\r
-       }\r
+       }
+
+       @Deprecated
+       public Datatype getComponentType() {
+               return componentType;
+       }
 
        public void setComponentType(Datatype componentType) {
                this.componentType = componentType;
        }
 
-    public int minLength() {\r
+    public int minLength() {
        Range length = getLength();
        if (length==null) return 0;
        Limit l = length.getLower();
@@ -125,7 +125,7 @@ public class ArrayType extends Datatype {
     }
     
     public int maxLength() {
-       Range length = getLength();\r
+       Range length = getLength();
        if (length==null) return Integer.MAX_VALUE;
        Limit l = length.getUpper();
        int value = l.getValue().intValue();
@@ -134,61 +134,61 @@ public class ArrayType extends Datatype {
     }
        
        public Range getLength() {
-               String lengthStr = metadata.get( KEY_LENGTH );\r
-               if (lengthStr == null) return null;\r
-               if (_length != null && lengthStr!=null && lengthStr==_lengthIsForStr) return _length;\r
-               try {\r
-                       _lengthIsForStr = lengthStr;\r
-                       _length = Range.valueOf( lengthStr );\r
-               } catch (RangeException e) {\r
-                       _length = null;\r
-               }\r
-               return _length;\r
+               String lengthStr = metadata.get( KEY_LENGTH );
+               if (lengthStr == null) return null;
+               if (_length != null && lengthStr!=null && lengthStr==_lengthIsForStr) return _length;
+               try {
+                       _lengthIsForStr = lengthStr;
+                       _length = Range.valueOf( lengthStr );
+               } catch (RangeException e) {
+                       _length = null;
+               }
+               return _length;
        }
 
        public String getLengthStr() {
                return metadata.get( KEY_LENGTH );
        }
        
-       public void setLength(String length) {\r
-               _length = null;\r
-               _lengthIsForStr = null;\r
-               if ( length == null ) {\r
-                       metadata.remove( KEY_LENGTH ); \r
-               } else {\r
-                       metadata.put( KEY_LENGTH, length );\r
+       public void setLength(String length) {
+               _length = null;
+               _lengthIsForStr = null;
+               if ( length == null ) {
+                       metadata.remove( KEY_LENGTH ); 
+               } else {
+                       metadata.put( KEY_LENGTH, length );
                }
        }
        
-       public void setLength(Range range) {\r
-               if (range==null) {\r
-                       metadata.remove( KEY_LENGTH );\r
-                       _length = null;\r
-                       _lengthIsForStr = null;\r
-               } else {\r
-                       _length = range;\r
-                       _lengthIsForStr = range.toString();\r
-                       metadata.put( KEY_LENGTH, _lengthIsForStr );\r
+       public void setLength(Range range) {
+               if (range==null) {
+                       metadata.remove( KEY_LENGTH );
+                       _length = null;
+                       _lengthIsForStr = null;
+               } else {
+                       _length = range;
+                       _lengthIsForStr = range.toString();
+                       metadata.put( KEY_LENGTH, _lengthIsForStr );
                }
        }
-\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
-                       try {\r
-                               Integer.valueOf( lr.label );\r
-                               return componentType.getChildType(reference.getChildReference());\r
-                       } catch ( NumberFormatException nfe ) {\r
-                               throw new ReferenceException(nfe);\r
-                       }                       \r
-               } else if (reference instanceof IndexReference) {\r
-                       return componentType.getChildType(reference.getChildReference());\r
-               } \r
-               throw new ReferenceException(reference.getClass().getName()+" is not a reference of an array"); \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;
+                       try {
+                               Integer.valueOf( lr.label );
+                               return componentType.getChildType(reference.getChildReference());
+                       } catch ( NumberFormatException nfe ) {
+                               throw new ReferenceException(nfe);
+                       }                       
+               } else if (reference instanceof IndexReference) {
+                       return componentType.getChildType(reference.getChildReference());
+               } 
+               throw new ReferenceException(reference.getClass().getName()+" is not a reference of an array"); 
+       }
        
 }