More changes to make Froyo compatible.
authorkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Thu, 26 Jul 2012 14:19:48 +0000 (14:19 +0000)
committerkruland2607 <kruland2607@180e2498-e6e9-4542-8430-84ac67f01cd8>
Thu, 26 Jul 2012 14:19:48 +0000 (14:19 +0000)
git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@943 180e2498-e6e9-4542-8430-84ac67f01cd8

core/src/net/sf/openrocket/file/GeneralRocketLoader.java
core/src/net/sf/openrocket/file/rocksim/importt/FinSetHandler.java
core/src/net/sf/openrocket/util/ArrayUtils.java

index 16f9c9acd748448d1d99fb43837b19667b5cb5ad..f4b64622949bdf865ce3959d7dccbd7803c4c077 100644 (file)
@@ -12,6 +12,7 @@ import java.util.zip.ZipInputStream;
 import net.sf.openrocket.document.OpenRocketDocument;
 import net.sf.openrocket.file.openrocket.importt.OpenRocketLoader;
 import net.sf.openrocket.file.rocksim.importt.RocksimLoader;
+import net.sf.openrocket.util.ArrayUtils;
 import net.sf.openrocket.util.TextUtil;
 
 
@@ -94,7 +95,7 @@ public class GeneralRocketLoader extends AbstractRocketLoader {
                        }
                }
                
-               byte[] typeIdentifier = Arrays.copyOf(buffer, ROCKSIM_SIGNATURE.length);
+               byte[] typeIdentifier = ArrayUtils.copyOf(buffer, ROCKSIM_SIGNATURE.length);
                if (Arrays.equals(ROCKSIM_SIGNATURE, typeIdentifier)) {
                        return loadUsing(source, rocksimLoader, motorFinder);
                }
index 048a2fd4f2a730b9cefd57fbded3ec34fa323acc..01b49030d0ccf1428bee439da11601780e7416ac 100644 (file)
@@ -330,7 +330,7 @@ class FinSetHandler extends AbstractElementHandler {
      */
     private Coordinate[] toCoordinates (String pointList, WarningSet warnings) {
         List<Coordinate> result = new ArrayList<Coordinate>();
-        if (pointList != null && !pointList.isEmpty()) {
+        if (pointList != null && pointList.length() > 0) {
             String[] points = pointList.split("\\Q|\\E");
             for (String point : points) {
                 String[] aPoint = point.split(",");
index ac32abbe0a057d42bac42a27e7ee7bf1bf6c0da7..67209f323ea4a0db5b5fa014cfdfab96c15744c4 100644 (file)
@@ -80,4 +80,37 @@ public class ArrayUtils {
                
        }
 
+       public static byte[] copyOf( byte[] original, int length ) {
+               return copyOfRange(original,0,length);
+       }
+       
+       public static byte[] copyOfRange( byte[] original, int start, int end ) {
+               
+               if ( original == null ) {
+                       throw new NullPointerException();
+               }
+               
+               if ( start < 0 || start > original.length ) {
+                       throw new ArrayIndexOutOfBoundsException();
+               }
+               
+               if ( start > end ) {
+                       throw new IllegalArgumentException();
+               }
+               
+               byte[] result = new byte[(end-start)];
+               
+               int index = 0;
+               int stop = original.length < end ? original.length : end;
+               for ( int i = start; i < stop; i ++ ) {
+                       if ( i < original.length ) {
+                               result[index] = original[i];
+                       }
+                       index++;
+               }
+               
+               return result;
+               
+       }
+
 }