private int length() { return(ValueLengthUtil.get(this.head()) - 1); }
internal int GetLength() { return(ValueLengthUtil.Get(this.Head) - 1); }
public virtual int getByteSize() { long size; byte head = head(); int valueLength = ValueLengthUtil.get(head ); if (valueLength != 0) { size = valueLength; } else { switch (this.type()) { case ValueType.ARRAY: case ValueType.OBJECT: { if (head == unchecked ((int)0x13) || head == unchecked ((int)0x14)) { // compact Array or Object size = NumberUtil.readVariableValueLength( this.vpack, this.start + 1, false); } else { /* if (head <= 0x14) */ size = NumberUtil.toLong(this.vpack, this.start + 1, ObjectArrayUtil.getOffsetSize(head)); } break; } case ValueType.STRING: { // long UTF-8 String size = this.getLongStringLength() + 1 + 8; break; } case ValueType.BINARY: { size = 1 + head - unchecked ((byte)unchecked ((int)0xbf)) + this.getBinaryLengthUnchecked (); break; } case ValueType.BCD: { if ((sbyte)head <= unchecked ((int)0xcf)) { size = 1 + head + unchecked ((byte)unchecked ((int)0xc7)) + NumberUtil .toLong(this.vpack, this.start + 1, head - unchecked ((byte)unchecked ((int)0xc7))); } else { size = 1 + head - unchecked ((byte)unchecked ((int)0xcf)) + NumberUtil .toLong(this.vpack, this.start + 1, head - unchecked ((byte)unchecked ((int)0xcf))); } break; } case ValueType.CUSTOM: { if (head == unchecked ((int)0xf4) || head == unchecked ((int)0xf5) || head == unchecked ( (int)0xf6)) { size = 2 + NumberUtil.toLong(this.vpack, this.start + 1, 1); } else { if (head == unchecked ((int)0xf7) || head == unchecked ((int)0xf8) || head == unchecked ( (int)0xf9)) { size = 3 + NumberUtil.toLong(this.vpack, this.start + 1, 2); } else { if (head == unchecked ((int)0xfa) || head == unchecked ((int)0xfb) || head == unchecked ( (int)0xfc)) { size = 5 + NumberUtil.toLong(this.vpack, this.start + 1, 4); } else { /* if (head == 0xfd || head == 0xfe || head == 0xff) */ size = 9 + NumberUtil.toLong(this.vpack, this.start + 1, 8); } } } break; } default: { // TODO throw new java.lang.InternalError(); } } } return((int)size); }
internal int GetByteSize() { long size; byte head = TypeCode; int valueLength = ValueLengthUtil.Get(head); if (valueLength != 0) { size = valueLength; } else { switch (Type) { case SliceType.Array: case SliceType.Object: if (head == 0x13 || head == 0x14) { // compact Array or Object size = NumberUtil.ReadVariableValueLength(vpack, start + 1, false); } else /* if (head <= 0x14) */ { size = NumberUtil.ToLong(vpack, start + 1, ObjectArrayUtil.GetOffsetSize(head)); } break; case SliceType.String: // long UTF-8 String size = GetLongStringLength() + 1 + 8; break; case SliceType.Binary: size = 1 + head - ((byte)0xbf) + GetBinaryLengthUnchecked(); break; case SliceType.Bcd: if (head <= 0xcf) { size = 1 + head + ((byte)0xc7) + NumberUtil.ToLong(vpack, start + 1, head - ((byte)0xc7)); } else { size = 1 + head - ((byte)0xcf) + NumberUtil.ToLong(vpack, start + 1, head - ((byte)0xcf)); } break; case SliceType.Custom: if (head == 0xf4 || head == 0xf5 || head == 0xf6) { size = 2 + NumberUtil.ToLong(vpack, start + 1, 1); } else if (head == 0xf7 || head == 0xf8 || head == 0xf9) { size = 3 + NumberUtil.ToLong(vpack, start + 1, 2); } else if (head == 0xfa || head == 0xfb || head == 0xfc) { size = 5 + NumberUtil.ToLong(vpack, start + 1, 4); } else /* if (head == 0xfd || head == 0xfe || head == 0xff) */ { size = 9 + NumberUtil.ToLong(vpack, start + 1, 8); } break; default: // TODO throw new Exception("Internal error"); } } return((int)size); }