-/*
- // 16 = resourceCount + 3 arrays
-// long start = System.nanoTime();
- int actualSize = 16 + 8*tg.values.length + 4*tg.statements.length + 5*tg.identities.length;
- for(Value v : tg.values) actualSize += v.value.length;
- for(Identity id : tg.identities) {
- if(id.definition instanceof Internal) actualSize += (4 + ((Internal)id.definition).name.length() + 5);
- else if(id.definition instanceof External) actualSize += (4 + ((External)id.definition).name.length() + 5);
- else if(id.definition instanceof Root) actualSize += (((Root)id.definition).name.length() + ((Root)id.definition).type.length() + 10);
- else if(id.definition instanceof Optional) actualSize += (4 + ((Optional)id.definition).name.length() + 5);
- }
-// long end = System.nanoTime() - start;
-// System.err.println("size took " + 1e-9*end);
-
-// long start2 = System.nanoTime();
-
-
- byte[] bytes = new byte[actualSize];
- int byteIndex = 0;
-
- int i = tg.resourceCount;
-
- bytes[byteIndex+3] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex+2] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex+1] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex] = (byte)(i & 0xFF);i >>>= 8;
- byteIndex+=4;
-
- i = tg.identities.length;
-
- bytes[byteIndex+3] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex+2] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex+1] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex] = (byte)(i & 0xFF);i >>>= 8;
- byteIndex+=4;
-
- for(Identity id : tg.identities) {
-
- i = id.resource;
- bytes[byteIndex+3] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex+2] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex+1] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex] = (byte)(i & 0xFF);i >>>= 8;
- byteIndex+=4;
-
- if(id.definition instanceof Internal) {
-
- Internal r = (Internal)id.definition;
-
- bytes[byteIndex++] = 3;
-
- i = r.parent;
- bytes[byteIndex+3] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex+2] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex+1] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex] = (byte)(i & 0xFF);i >>>= 8;
- byteIndex+=4;
-
- byteIndex += writeUTF(r.name, bytes, byteIndex);
-
- } else if(id.definition instanceof External) {
-
- External r = (External)id.definition;
-
- bytes[byteIndex++] = 1;
-
- i = r.parent;
- bytes[byteIndex+3] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex+2] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex+1] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex] = (byte)(i & 0xFF);i >>>= 8;
- byteIndex+=4;
-
- byteIndex += writeUTF(r.name, bytes, byteIndex);
-
- } else if(id.definition instanceof Root) {
-
- bytes[byteIndex++] = 0;
-
- Root r = (Root)id.definition;
- byteIndex += writeUTF(r.name, bytes, byteIndex);
- byteIndex += writeUTF(r.type, bytes, byteIndex);
-
- } else if(id.definition instanceof Optional) {
-
- Optional r = (Optional)id.definition;
-
- bytes[byteIndex++] = 2;
-
- i = r.parent;
- bytes[byteIndex+3] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex+2] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex+1] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex] = (byte)(i & 0xFF);i >>>= 8;
- byteIndex+=4;
-
- byteIndex += writeUTF(r.name, bytes, byteIndex);
-
- }
-
- }
-
- i = tg.statements.length;
- bytes[byteIndex+3] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex+2] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex+1] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex] = (byte)(i & 0xFF);i >>>= 8;
- byteIndex+=4;
-
- for(int s : tg.statements) {
- i = s;
- bytes[byteIndex+3] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex+2] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex+1] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex] = (byte)(i & 0xFF);i >>>= 8;
- byteIndex+=4;
- }
-
- i = tg.values.length;
- bytes[byteIndex+3] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex+2] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex+1] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex] = (byte)(i & 0xFF);i >>>= 8;
- byteIndex+=4;
-
- for(Value v : tg.values) {
-
- i = v.resource;
- bytes[byteIndex+3] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex+2] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex+1] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex] = (byte)(i & 0xFF);i >>>= 8;
- byteIndex+=4;
-
- i = v.value.length;
- bytes[byteIndex+3] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex+2] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex+1] = (byte)(i & 0xFF);i >>>= 8;
- bytes[byteIndex] = (byte)(i & 0xFF);i >>>= 8;
- byteIndex+=4;
-
- System.arraycopy(v.value, 0, bytes, byteIndex, v.value.length);
- byteIndex += v.value.length;
-
- }
-
-// return bytes;
-
-// byte[] result = new byte[byteIndex];
-// System.arraycopy(bytes, 0, result, 0, byteIndex);
-//
-// byte[] result = Arrays.copyOf(bytes, byteIndex);
-
-// long end2 = System.nanoTime() - start2;
-// System.err.println("size2 took " + 1e-9*end2);
-
- return bytes;
-
-// long[] data = (long[])obj;
-// byte[] result = new byte[4+8*data.length];
-//
-// int len = data.length;
-//
-// result[3] = (byte)(len & 0xFF);
-// len >>>= 8;
-// result[2] = (byte)(len & 0xFF);
-// len >>>= 8;
-// result[1] = (byte)(len & 0xFF);
-// len >>>= 8;
-// result[0] = (byte)(len & 0xFF);
-//
-// int index = 4;
-//
-// for(int i=0;i<data.length;i++) {
-//
-// long l = data[i];
-//
-// result[index+7] = (byte)(l & 0xFF);
-// l >>>= 8;
-// result[index+6] = (byte)(l & 0xFF);
-// l >>>= 8;
-// result[index+5] = (byte)(l & 0xFF);
-// l >>>= 8;
-// result[index+4] = (byte)(l & 0xFF);
-// l >>>= 8;
-// result[index+3] = (byte)(l & 0xFF);
-// l >>>= 8;
-// result[index+2] = (byte)(l & 0xFF);
-// l >>>= 8;
-// result[index+1] = (byte)(l & 0xFF);
-// l >>>= 8;
-// result[index] = (byte)(l & 0xFF);
-// l >>>= 8;
-//
-// index += 8;
-//
-// }
-//
-// return result;
-*/