final private short determineElementCount() throws Exception
    {
        switch (type)
        {
        case BOOL:
        case SINT:
        case INT:
        case DINT:
        case BITS:
        case REAL:
            return (short) (data.capacity() / type.element_size);
        case STRUCT:
        {
            final Type el_type = Type.forCode(data.getShort(0));
            if (el_type == Type.STRUCT_STRING)
                return 1;
            else
                throw new Exception("Structure elements of type " + type + " not handled");
        }
        default:
            throw new Exception("Type " + type + " not handled");
        }
    }