/** * Returns a new character sequence that is a subsequence of this sequence. * <p> * This is logically equivalent to <code>toString().subSequence(beginIndex,endIndex)</code> * for valid values of <code>beginIndex</code> and <code>endIndex</code>. * <p> * However because this implementation works directly on the underlying document source text, * it should not be assumed that an <code>IndexOutOfBoundsException</code> is thrown * for invalid argument values as described in the <code>String.subSequence(int,int)</code> method. * * @param beginIndex the begin index, inclusive. * @param endIndex the end index, exclusive. * @return a new character sequence that is a subsequence of this sequence. */ public CharSequence subSequence(final int beginIndex, final int endIndex) { return source.subSequence(begin+beginIndex,begin+endIndex); }
/** * Returns the source text of this segment as a <code>String</code>. * <p> * The returned <code>String</code> is newly created with every call to this method, unless this * segment is itself an instance of {@link Source}. * * @return the source text of this segment as a <code>String</code>. */ public String toString() { return source.subSequence(begin,end).toString(); }
final String substring(final int begin, final int end) { return subSequence(begin,end).toString(); }
private String parseText(int start, int end) { StringBuilder sb = new StringBuilder(); while (start < end) { CharacterReference ref = source.getNextCharacterReference(start); if (ref == null || ref.getBegin() >= end) { break; } sb.append(source.subSequence(start, ref.getBegin())); sb.append(ref.getChar()); start = ref.getEnd(); } sb.append(source.subSequence(start, end)); return sb.toString(); }
private String parseText(int start, int end) { StringBuilder sb = new StringBuilder(); while (start < end) { CharacterReference ref = source.getNextCharacterReference(start); if (ref == null || ref.getBegin() >= end) { break; } sb.append(source.subSequence(start, ref.getBegin())); sb.append(ref.getChar()); start = ref.getEnd(); } sb.append(source.subSequence(start, end)); return sb.toString(); }
if (ch==';') { end=x+1; name=source.subSequence(nameBegin,x).toString(); break; name=source.subSequence(nameBegin,x).toString(); break;
private void appendPreformattedSegment(final int begin, final int end) throws IOException { assert begin<end; assert begin>=renderedIndex; if (isBlockBoundary()) appendBlockVerticalMargin(); final String text=CharacterReference.decode(source.subSequence(begin,end),false,convertNonBreakingSpaces); for (int i=0; i<text.length(); i++) { final char ch=text.charAt(i); if (ch=='\n') { newLine(); } else if (ch=='\r') { newLine(); final int nextI=i+1; if (nextI==text.length()) break; if (text.charAt(nextI)=='\n') i++; } else { append(ch); } } }
private void appendNonPreformattedSegment(final int begin, final int end) throws IOException { assert begin<end; assert begin>=renderedIndex; final String text=CharacterReference.decodeCollapseWhiteSpace(source.subSequence(begin,end),convertNonBreakingSpaces); if (text.length()==0) { // collapsed text is zero length but original segment wasn't, meaning it consists purely of white space. if (!ignoreInitialWhiteSpace) lastCharWhiteSpace=true; return; } appendNonPreformattedText(text,Segment.isWhiteSpace(source.charAt(begin)),Segment.isWhiteSpace(source.charAt(end-1))); }
final String cfscript = elem.getSource().subSequence(elem.getStartTag().getEnd(), nextTag.getBegin()) .toString(); visitor.visitScript(parseScript(cfscript));
cfscript = elem.getSource().subSequence(elem.getStartTag().getEnd(), nextTag.getBegin()) .toString(); skipToPosition = nextTag.getEnd();
cfscript = elem.getSource().subSequence(elem.getStartTag().getEnd(), nextTag.getBegin()) .toString(); skipToPosition = nextTag.getEnd();