public static int getLength(ByteArray bytes, int index, int headerWord) { // FIXME: WE NEED TO SUPPORT CONSTRAINTS HERE TOO, so need to look at headerWord, and return // diff // size if it's a constraint (or even same size) e.g. for Boolean. boolean isConstraint = CompactAttrCodec.getAttrFunction(headerWord) == AttrFunction.constraint; switch (AttrDefinitionMgr.getAttrType(headerWord)) { case booleanValue: return isConstraint ? BooleanConstraintCodec.BOOLEAN_SIZE : BooleanCodec.BOOLEAN_SIZE; case enumExclusiveValue: return isConstraint ? bytes.getByte(index + LENGTH_OFFSET) : EnumCodec.EXCLUSIVE_ENUM_SIZE; case floatValue: return isConstraint ? bytes.getByte(index + LENGTH_OFFSET) : FloatCodec.FLOAT_SIZE; case floatRangePrefValue: // could have fixed size // FALLTHRU case enumMultiValue: // could have fixed size // FALLTHRU default: // all remainder have variable size int length = bytes.getByte(index + LENGTH_OFFSET); return length; } }
public static int getAttrId(int headerWord) { return AttrDefinitionMgr.getAttrIndexAndType(headerWord); }