byte[] resizeCollection(byte[] collectionData, int objectRefSize) throws IOException {
        ByteBuffer input = ByteBuffer.wrap(collectionData);
        ByteArrayOutputStream output = new ByteArrayOutputStream(collectionData.length);
        short type = (short)(0xff & input.get());
        int numberOfItems = (collectionData.length - 1) / 4; // number of object references to read
        int collectionSize = (type == BinaryPlist.DICT) ?  numberOfItems / 2 : numberOfItems;
        log.fine("Resizing collection of type " + type + " size " + collectionSize + " with " + numberOfItems + " pointers");
        output.write(getObjectHeader(type, collectionSize));
        switch (objectRefSize) {
            case 1:
                for (int i=0; i< numberOfItems; i++) {
                    int objectRef = input.getInt();
                    if (objectRef > 255) throw new EncodingException("Can't encode " + objectRef + " in one byte");
                    output.write((byte)(objectRef & 0xff));
                }
                break;
            case 2:
                for (int i=0; i< numberOfItems; i++) {
                    int objectRef = input.getInt();
                    if (objectRef > 65535) throw new EncodingException("Can't encode " + objectRef + " in one short");
                    writeShort(output, (short) (objectRef & 0xffff));
                }
                break;
            default:
                for (int i=0; i< numberOfItems; i++) {
                    int objectRef = input.getInt();
                    writeInt(output, objectRef);
                }
                break;
        }
        return output.toByteArray();
    }