Debug Code entfernt, ArrayHelper#cast hinzugefügt

thobaben_serialize
Harald Wolff 2016-10-26 19:23:42 +02:00
parent 2ac6099d89
commit 9458dff0f0
3 changed files with 23 additions and 6 deletions

View File

@ -1,5 +1,9 @@
package org.hwo;
import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
public class ArrayHelper {
@ -35,4 +39,23 @@ public class ArrayHelper {
return t;
}
public static <T> T[] cast(Object[] src,T[] dstType){
T[] dst;
try {
dst = (T[])Array.newInstance(dstType.getClass().getComponentType(), src.length);
for (int i=0;i<src.length;i++){
System.err.println(src[i].getClass().getCanonicalName());
dst[i] = (T)src[i];
}
return dst;
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}

View File

@ -9,13 +9,11 @@ public class ByteArrayHexlifier {
public static String hexlify(String source){
String hex = byteArrayToString(source.getBytes());
log(DEBUG,"hexlify: %s -> %s",source,hex);
return hex;
}
public static String unhexlify(String source){
String unhex = new String( stringToByteArray(source) );
log(DEBUG,"unhexlify: %s -> %s",source,unhex);
return unhex;
}
@ -62,7 +60,6 @@ public class ByteArrayHexlifier {
buffer[i] |= (byte)((source[(2*i)+1] - '0'));
}
log(DEBUG,"buffer[%d] = %d",i,buffer[i]);
}
return buffer;
}

View File

@ -123,15 +123,12 @@ public class ConfigurableObjects {
Hashtable<String,String> hash = new Hashtable<String, String>();
for (int n=0;n<l.size();n++){
log(DEBUG,"l: %s",l.get(n));
String c = l.get(n);
String[] split = c.split("\\=",2);
if (split.length==1){
log(DEBUG,"split: (%s)",split[0]);
hash.put(split[0], "");
} else if (split.length==2){
log(DEBUG,"split: (%s:%s)",split[0],split[1]);
hash.put(split[0], split[1]);
}
}