private void addSegment ( byte type , Object value , int off , int len ) { assert ! isClosed ; assert len > 0 : "Empty segments should never be added" ; final int arraylen = segmentValues . length ; if ( segmentCount == arraylen ) { // Need to grow if ( arraylen == 0 ) { this . segmentTypes = new byte [ START_LEN ] ; this . segmentValues = new Object [ START_LEN ] ; this . segmentOffsets = new int [ START_LEN ] ; this . segmentLengths = new int [ START_LEN ] ; } else { // Double capacity and copy int newLen = arraylen << 1 ; byte [ ] newTypes = new byte [ newLen ] ; System . arraycopy ( segmentTypes , 0 , newTypes , 0 , arraylen ) ; this . segmentTypes = newTypes ; Object [ ] newValues = new Object [ newLen ] ; System . arraycopy ( segmentValues , 0 , newValues , 0 , arraylen ) ; this . segmentValues = newValues ; int [ ] newOffsets = new int [ newLen ] ; System . arraycopy ( segmentOffsets , 0 , newOffsets , 0 , arraylen ) ; this . segmentOffsets = newOffsets ; int [ ] newLengths = new int [ newLen ] ; System . arraycopy ( segmentLengths , 0 , newLengths , 0 , arraylen ) ; this . segmentLengths = newLengths ; } } segmentTypes [ segmentCount ] = type ; segmentValues [ segmentCount ] = value ; segmentOffsets [ segmentCount ] = off ; segmentLengths [ segmentCount ++ ] = len ; }
Adds a new segment .