/** * Gets the number of characters in the source. Causes the contents of this source to be loaded * if they are loaded lazily. * * @since 0.8 or earlier */ public final int getLength() { return getTextMap().length(); }
/** * Gets the number of characters or bytes of the source. * * @throws UnsupportedOperationException if this source does not contain {@link #hasCharacters() * characters}, nor {@link #hasBytes() bytes}. * @since 0.8 */ public final int getLength() { if (hasCharacters()) { return getTextMap().length(); } else if (hasBytes()) { return getBytes().length(); } else { throw new UnsupportedOperationException("Operation is only enabled for sources with character or byte content."); } }
assert charIndex <= endIndex : charIndex + " > " + endIndex; int length = endIndex + 1 - charIndex; int sourceLength = getTextMap().length(); if (length == 1 && charIndex + length > sourceLength) {