private void checkTokenCollectionIndex() throws MtasParserException {
    if (tokenCollectionIndex.size() != tokenCollection.size()) {
      MtasToken token;
      Integer maxId = null;
      Integer minId = null;
      tokenCollectionIndex.clear();
      for (Entry<Integer, MtasToken> entry : tokenCollection.entrySet()) {
        token = entry.getValue();
        maxId = ((maxId == null) ? entry.getKey()
            : Math.max(maxId, entry.getKey()));
        minId = ((minId == null) ? entry.getKey()
            : Math.min(minId, entry.getKey()));
        if (token.getId() == null) {
          throw new MtasParserException(
              "no id for token (" + token.getValue() + ")");
        } else if ((token.getPositionStart() == null)
            || (token.getPositionEnd() == null)) {
          throw new MtasParserException("no position for token with id "
              + token.getId() + " (" + token.getValue() + ")");
        } else if (token.getValue() == null || (token.getValue().equals(""))) {
          throw new MtasParserException(
              "no value for token with id " + token.getId());
        } else if (token.getPrefix() == null
            || (token.getPrefix().equals(""))) {
          throw new MtasParserException(
              "no prefix for token with id " + token.getId());
        } else if ((token.getParentId() != null)
            && !tokenCollection.containsKey(token.getParentId())) {
          throw new MtasParserException(
              "missing parentId for token with id " + token.getId());
        } else if ((token.getOffsetStart() == null)
            || (token.getOffsetEnd() == null)) {
          throw new MtasParserException("missing offset for token with id "
              + token.getId() + " (" + token.getValue() + ")");
        }
        tokenCollectionIndex.add(entry.getKey());
      }
      if ((tokenCollection.size() > 0)
          && ((minId > 0) || ((1 + maxId - minId) != tokenCollection.size()))) {
        throw new MtasParserException("missing ids");
      }
      Collections.sort(tokenCollectionIndex, getCompByName());
    }
  }
private void checkTokenCollectionIndex ( ) throws MtasParserException { if ( tokenCollectionIndex . size ( ) != tokenCollection . size ( ) ) { MtasToken token ; Integer maxId = null ; Integer minId = null ; tokenCollectionIndex . clear ( ) ; for ( Entry < Integer , MtasToken > entry : tokenCollection . entrySet ( ) ) { token = entry . getValue ( ) ; maxId = ( ( maxId == null ) ? entry . getKey ( ) : Math . max ( maxId , entry . getKey ( ) ) ) ; minId = ( ( minId == null ) ? entry . getKey ( ) : Math . min ( minId , entry . getKey ( ) ) ) ; if ( token . getId ( ) == null ) { throw new MtasParserException ( "no id for token (" + token . getValue ( ) + ")" ) ; } else if ( ( token . getPositionStart ( ) == null ) || ( token . getPositionEnd ( ) == null ) ) { throw new MtasParserException ( "no position for token with id " + token . getId ( ) + " (" + token . getValue ( ) + ")" ) ; } else if ( token . getValue ( ) == null || ( token . getValue ( ) . equals ( "" ) ) ) { throw new MtasParserException ( "no value for token with id " + token . getId ( ) ) ; } else if ( token . getPrefix ( ) == null || ( token . getPrefix ( ) . equals ( "" ) ) ) { throw new MtasParserException ( "no prefix for token with id " + token . getId ( ) ) ; } else if ( ( token . getParentId ( ) != null ) && ! tokenCollection . containsKey ( token . getParentId ( ) ) ) { throw new MtasParserException ( "missing parentId for token with id " + token . getId ( ) ) ; } else if ( ( token . getOffsetStart ( ) == null ) || ( token . getOffsetEnd ( ) == null ) ) { throw new MtasParserException ( "missing offset for token with id " + token . getId ( ) + " (" + token . getValue ( ) + ")" ) ; } tokenCollectionIndex . add ( entry . getKey ( ) ) ; } if ( ( tokenCollection . size ( ) > 0 ) && ( ( minId > 0 ) || ( ( 1 + maxId - minId ) != tokenCollection . size ( ) ) ) ) { throw new MtasParserException ( "missing ids" ) ; } Collections . sort ( tokenCollectionIndex , getCompByName ( ) ) ; } }
Check token collection index.

@throws MtasParserException the mtas parser exception