(DBElement element)
| 779 | } |
| 780 | |
| 781 | private int encodeStruct(DBElement element) |
| 782 | throws DBException |
| 783 | { |
| 784 | DBList list = (DBList)element.getValue(); |
| 785 | int fieldCount = list.getElementCount(); |
| 786 | int fieldOffset = 0; |
| 787 | |
| 788 | if (this.structArrayCount == this.structArraySize) { |
| 789 | this.structArraySize += 2000; |
| 790 | byte[] buffer = new byte[12 * this.structArraySize]; |
| 791 | System.arraycopy(this.structBuffer, 0, buffer, 0, this.structArrayCount * 12); |
| 792 | this.structBuffer = buffer; |
| 793 | } |
| 794 | |
| 795 | int structIndex = this.structArrayCount++; |
| 796 | |
| 797 | if (fieldCount == 1) { |
| 798 | fieldOffset = encodeField(list.getElement(0)); |
| 799 | } else if (fieldCount > 1) { |
| 800 | int indexLength = 4 * fieldCount; |
| 801 | if (this.fieldIndicesLength + indexLength > this.fieldIndicesSize) { |
| 802 | int increment = Math.max(indexLength, 8000); |
| 803 | this.fieldIndicesSize += increment; |
| 804 | byte[] buffer = new byte[this.fieldIndicesSize]; |
| 805 | System.arraycopy(this.fieldIndicesBuffer, 0, buffer, 0, this.fieldIndicesLength); |
| 806 | this.fieldIndicesBuffer = buffer; |
| 807 | } |
| 808 | |
| 809 | fieldOffset = this.fieldIndicesLength; |
| 810 | this.fieldIndicesLength += indexLength; |
| 811 | for (int i = 0; i < fieldCount; i++) { |
| 812 | int fieldIndex = encodeField(list.getElement(i)); |
| 813 | setInteger(fieldIndex, this.fieldIndicesBuffer, fieldOffset + 4 * i); |
| 814 | } |
| 815 | |
| 816 | } |
| 817 | |
| 818 | int structOffset = structIndex * 12; |
| 819 | setInteger(element.getID(), this.structBuffer, structOffset); |
| 820 | setInteger(fieldOffset, this.structBuffer, structOffset + 4); |
| 821 | setInteger(fieldCount, this.structBuffer, structOffset + 8); |
| 822 | return structIndex; |
| 823 | } |
| 824 | |
| 825 | private int encodeList(DBElement element) |
| 826 | throws DBException |
no test coverage detected