public static MtasTokenString getToken ( IndexInput inObject , IndexInput inTerm , Long ref ) throws IOException { MtasTokenString token = null ; try { inObject . seek ( ref ) ; token = new MtasTokenString ( null , "" ) ; token . setId ( inObject . readVInt ( ) ) ; token . setTokenRef ( ref ) ; int objectFlags = inObject . readVInt ( ) ; int [ ] positions = null ; if ( ( objectFlags & MTAS_OBJECT_HAS_PARENT ) == MTAS_OBJECT_HAS_PARENT ) { int parentId = inObject . readVInt ( ) ; token . setParentId ( parentId ) ; } if ( ( objectFlags & MTAS_OBJECT_HAS_POSITION_RANGE ) == MTAS_OBJECT_HAS_POSITION_RANGE ) { int positionStart = inObject . readVInt ( ) ; int positionEnd = positionStart + inObject . readVInt ( ) ; token . addPositionRange ( positionStart , positionEnd ) ; } else if ( ( objectFlags & MTAS_OBJECT_HAS_POSITION_SET ) == MTAS_OBJECT_HAS_POSITION_SET ) { int size = inObject . readVInt ( ) ; int tmpPrevious = 0 ; positions = new int [ size ] ; for ( int t = 0 ; t < size ; t ++ ) { int position = tmpPrevious + inObject . readVInt ( ) ; tmpPrevious = position ; positions [ t ] = position ; } token . addPositions ( positions ) ; } else { int position = inObject . readVInt ( ) ; token . addPosition ( position ) ; } if ( ( objectFlags & MTAS_OBJECT_HAS_OFFSET ) == MTAS_OBJECT_HAS_OFFSET ) { int offsetStart = inObject . readVInt ( ) ; int offsetEnd = offsetStart + inObject . readVInt ( ) ; token . setOffset ( offsetStart , offsetEnd ) ; } if ( ( objectFlags & MTAS_OBJECT_HAS_REALOFFSET ) == MTAS_OBJECT_HAS_REALOFFSET ) { int realOffsetStart = inObject . readVInt ( ) ; int realOffsetEnd = realOffsetStart + inObject . readVInt ( ) ; token . setRealOffset ( realOffsetStart , realOffsetEnd ) ; } if ( ( objectFlags & MTAS_OBJECT_HAS_PAYLOAD ) == MTAS_OBJECT_HAS_PAYLOAD ) { int length = inObject . readVInt ( ) ; byte [ ] mtasPayload = new byte [ length ] ; inObject . readBytes ( mtasPayload , 0 , length ) ; token . setPayload ( new BytesRef ( mtasPayload ) ) ; } Long termRef = inObject . readVLong ( ) ; inTerm . seek ( termRef ) ; token . setTermRef ( termRef ) ; token . setValue ( inTerm . readString ( ) ) ; } catch ( Exception e ) { throw new IOException ( e ) ; } return token ; }
Gets the token .