MCPcopy Create free account
hub / github.com/antlr/codebuff / length

Method length

corpus/java/training/guava/io/CharSource.java:153–169  ·  view source on GitHub ↗

Returns the length of this source in chars, even if doing so requires opening and traversing an entire stream. To avoid a potentially expensive operation, see #lengthIfKnown. The default implementation calls #lengthIfKnown and returns the value if present. If absent, it will fall

()

Source from the content-addressed store, hash-verified

151 * @since 19.0
152 */
153 @Beta
154 public long length() throws IOException {
155 Optional<Long> lengthIfKnown = lengthIfKnown();
156 if (lengthIfKnown.isPresent()) {
157 return lengthIfKnown.get();
158 }
159
160 Closer closer = Closer.create();
161 try {
162 Reader reader = closer.register(openStream());
163 return countBySkipping(reader);
164 } catch (Throwable e) {
165 throw closer.rethrow(e);
166 } finally {
167 closer.close();
168 }
169 }
170
171 private long countBySkipping(Reader reader) throws IOException {
172 long count = 0;

Callers 15

parseMethod · 0.45
initTableMethod · 0.45
lockedGetOrLoadMethod · 0.45
getFirstMethod · 0.45
containsValueMethod · 0.45
putMethod · 0.45
expandMethod · 0.45
replaceMethod · 0.45
removeMethod · 0.45
storeLoadedValueMethod · 0.45
clearMethod · 0.45

Calls 9

lengthIfKnownMethod · 0.95
createMethod · 0.95
registerMethod · 0.95
openStreamMethod · 0.95
countBySkippingMethod · 0.95
rethrowMethod · 0.95
closeMethod · 0.95
getMethod · 0.65
isPresentMethod · 0.45

Tested by

no test coverage detected