Returns a subsequence string or null if the location
is not valid.
@param beginPosition the sequence begin position.
@param endPosition the sequence end position.
@return a subsequence string or null if the location is not valid.
485029
public String getSequence(Long beginPosition, Long endPosition)
	{
		byte[] sequenceByte = getSequenceByte(beginPosition, endPosition);
		if (sequenceByte != null)
			return new String(sequenceByte);
		return null;
	}
320652
public static String substring(final String str, final int beginIndex) {
        assertStringNotNull(str);
        if (str.length() < beginIndex) {
            String msg = "The length of the string was smaller than the begin index:";
            msg = msg + " str=" + str + ", beginIndex=" + beginIndex;
            throw new StringIndexOutOfBoundsException(msg);
        }
        return str.substring(beginIndex);
    }
136705
public String getSubString(long pos, int length) throws SQLException {

    if (pos < 1) {
      throw ExceptionMapper.getSqlException("position must be >= 1");
    }

    if (length < 0) {
      throw ExceptionMapper.getSqlException("length must be > 0");
    }

    try {
      String val = toString();
      return val.substring((int) pos - 1, Math.min((int) pos - 1 + length, val.length()));
    } catch (Exception e) {
      throw new SQLException(e);
    }
  }
833664
public ExonSequence addExon(AccessionID accession, int begin, int end) throws Exception {
		if (exonSequenceHashMap.containsKey(accession.getID())) {
			throw new Exception("Duplicate accesion id " + accession.getID());
		}

		ExonSequence exonSequence = new ExonSequence(this, begin, end); //sense should be the same as parent
		exonSequence.setAccession(accession);
		exonSequenceList.add(exonSequence);
		exonSequenceHashMap.put(accession.getID(), exonSequence);
		return exonSequence;
	}
1151171
public String next( int n ) {
      int i = this.myIndex;
      int j = i + n;
      if( j >= this.mySource.length() ){
         throw syntaxError( "Substring bounds error" );
      }
      this.myIndex += n;
      return this.mySource.substring( i, j );
   }
1298913
@Override
  public int nextStartPosition() throws IOException {
    if (findMatches()) {
      currentMatch = queueMatches.get(0);
      queueMatches.remove(0);
      noMorePositions = false;
      return currentMatch.startPosition();
    } else {
      currentMatch = null;
      noMorePositions = true;
      return NO_MORE_POSITIONS;
    }
  }
339387
public String getNameByPosition(Integer position) {
        String name = null;

        name = this.order.get(position);

        return name;
    }
424374
public static String[] between(final String value, final String start, final String end) {
        validate(value, NULL_STRING_PREDICATE, NULL_STRING_MSG_SUPPLIER);
        validate(start, NULL_STRING_PREDICATE, () -> "'start' should be not null.");
        validate(end, NULL_STRING_PREDICATE, () -> "'end' should be not null.");

        String[] parts = value.split(end);
        return Arrays.stream(parts)
                .filter(subPart -> subPart.contains(start))
                .map(subPart -> subPart.substring(subPart.indexOf(start) + start.length()))
                .toArray(String[]::new);
    }
806963
public TranscriptSequence addTranscript(AccessionID accession, int begin, int end) throws Exception {
		if (transcriptSequenceHashMap.containsKey(accession.getID())) {
			throw new Exception("Duplicate accesion id " + accession.getID());
		}
		TranscriptSequence transcriptSequence = new TranscriptSequence(this, begin, end);
		transcriptSequence.setAccession(accession);
		transcriptSequenceHashMap.put(accession.getID(), transcriptSequence);
		return transcriptSequence;
	}
952142
public static int getEndPos(JCTree tree, EndPosTable endPosTable) {
        if (tree == null)
            return Position.NOPOS;

        if (endPosTable == null) {
            // fall back on limited info in the tree
            return endPos(tree);
        }

        int mapPos = endPosTable.getEndPos(tree);
        if (mapPos != Position.NOPOS)
            return mapPos;

        switch(tree.getTag()) {
            case BITOR_ASG: case BITXOR_ASG: case BITAND_ASG:
            case SL_ASG: case SR_ASG: case USR_ASG:
            case PLUS_ASG: case MINUS_ASG: case MUL_ASG:
            case DIV_ASG: case MOD_ASG:
                return getEndPos(((JCAssignOp) tree).rhs, endPosTable);
            case OR: case AND: case BITOR:
            case BITXOR: case BITAND: case EQ:
            case NE: case LT: case GT:
            case LE: case GE: case SL:
            case SR: case USR: case PLUS:
            case MINUS: case MUL: case DIV:
            case MOD:
                return getEndPos(((JCBinary) tree).rhs, endPosTable);
            case CASE:
                return getEndPos(((JCCase) tree).stats.last(), endPosTable);
            case CATCH:
                return getEndPos(((JCCatch) tree).body, endPosTable);
            case CONDEXPR:
                return getEndPos(((JCConditional) tree).falsepart, endPosTable);
            case FORLOOP:
                return getEndPos(((JCForLoop) tree).body, endPosTable);
            case FOREACHLOOP:
                return getEndPos(((JCEnhancedForLoop) tree).body, endPosTable);
            case IF: {
                JCIf node = (JCIf)tree;
                if (node.elsepart == null) {
                    return getEndPos(node.thenpart, endPosTable);
                } else {
                    return getEndPos(node.elsepart, endPosTable);
                }
            }
            case LABELLED:
                return getEndPos(((JCLabeledStatement) tree).body, endPosTable);
            case MODIFIERS:
                return getEndPos(((JCModifiers) tree).annotations.last(), endPosTable);
            case SYNCHRONIZED:
                return getEndPos(((JCSynchronized) tree).body, endPosTable);
            case TOPLEVEL:
                return getEndPos(((JCCompilationUnit) tree).defs.last(), endPosTable);
            case TRY: {
                JCTry node = (JCTry)tree;
                if (node.finalizer != null) {
                    return getEndPos(node.finalizer, endPosTable);
                } else if (!node.catchers.isEmpty()) {
                    return getEndPos(node.catchers.last(), endPosTable);
                } else {
                    return getEndPos(node.body, endPosTable);
                }
            }
            case WILDCARD:
                return getEndPos(((JCWildcard) tree).inner, endPosTable);
            case TYPECAST:
                return getEndPos(((JCTypeCast) tree).expr, endPosTable);
            case TYPETEST:
                return getEndPos(((JCInstanceOf) tree).clazz, endPosTable);
            case POS:
            case NEG:
            case NOT:
            case COMPL:
            case PREINC:
            case PREDEC:
                return getEndPos(((JCUnary) tree).arg, endPosTable);
            case WHILELOOP:
                return getEndPos(((JCWhileLoop) tree).body, endPosTable);
            case ANNOTATED_TYPE:
                return getEndPos(((JCAnnotatedType) tree).underlyingType, endPosTable);
            case ERRONEOUS: {
                JCErroneous node = (JCErroneous)tree;
                if (node.errs != null && node.errs.nonEmpty())
                    return getEndPos(node.errs.last(), endPosTable);
            }
        }
        return Position.NOPOS;
    }
775039
public static Token findTokenByEndPosition(JCas jCas, int end)
    {
        for (Token token : JCasUtil.select(getInitialView(jCas), Token.class)) {
            if (token.getEnd() == end) {
                return token;
            }
        }

        return null;
    }
1010670
public StrBuilder insert(int index, CharSequence csq, int start, int end) {
		if (csq == null) {
			csq = "null";
		}
		final int csqLen = csq.length();
		if (start > csqLen) {
			return this;
		}
		if (start < 0) {
			start = 0;
		}
		if (end > csqLen) {
			end = csqLen;
		}
		if (start >= end) {
			return this;
		}
		if (index < 0) {
			index = 0;
		}

		final int length = end - start;
		moveDataAfterIndex(index, length);
		for (int i = start, j = this.position; i < end; i++, j++) {
			value[j] = csq.charAt(i);
		}
		this.position = Math.max(this.position, index) + length;
		return this;
	}
718975
public Long getRelativePosition(Long position) {
		long relativePosition = 0L;
		for (Location location : locations) {
			if (location instanceof RemoteLocation) {
				relativePosition += location.getLength();
			} else {
				if (position < location.getBeginPosition()
						|| position > location.getEndPosition()) {
					relativePosition += location.getLength();
				} else {
					if (location.isComplement()) {
						relativePosition += (location.getEndPosition()
								- position + 1);
					} else {
						relativePosition += (position
								- location.getBeginPosition() + 1);
					}
					if (isComplement()) {
						relativePosition = getLength() - relativePosition + 1;
					}
					return relativePosition;
				}
			}
		}
		return null;
	}
461415
public static boolean endWith(@Nullable CharSequence s, char c) {
		if (StringUtils.isEmpty(s)) {
			return false;
		}
		return s.charAt(s.length() - 1) == c;
	}
551122
protected final int nextStringEndPos(byte[] bytes, int startPos, int limit, byte[] delimiter) {
		int endPos = startPos;

		final int delimLimit = limit - delimiter.length + 1;

		while (endPos < limit) {
			if (endPos < delimLimit && delimiterNext(bytes, endPos, delimiter)) {
				break;
			}
			endPos++;
		}

		if (endPos == startPos) {
			setErrorState(ParseErrorState.EMPTY_COLUMN);
			return -1;
		}
		return endPos;
	}
63754
public String substringBetween(String string, String begin, String end) {
		return substringBetween(string, begin, end, false);
	}
1115248
public String next(int n) throws JSONException {
         if (n == 0) {
             return "";
         }

         char[] buffer = new char[n];
         int pos = 0;

         while (pos < n) {
             buffer[pos] = next();
             if (end()) {
                 throw syntaxError("Substring bounds error");                 
             }
             pos += 1;
         }
         return new String(buffer);
     }