Create and configure an extractor using builder(), then call extractLinks.
| Modifier and Type | Class and Description |
|---|---|
| public static class | LinkExtractor.
Builder for configuring link extractor. |
| private class | |
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private final Scanner | |
| private final Scanner | |
| private final Scanner |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static LinkExtractor. | |
| public Iterable | Returns: a lazy iterable for the links in order that they appear in the input, never nullthe input text, must not be null input)Extract the links from the input text. |
| public Iterable | Returns: a lazy iterable for the spans in order that they appear in the input, never nullthe input text, must not be null input)Extract spans from the input text. |
| private Scanner |
| emailScanner | back to summary |
|---|---|
| private final Scanner emailScanner | |
| urlScanner | back to summary |
|---|---|
| private final Scanner urlScanner | |
| wwwScanner | back to summary |
|---|---|
| private final Scanner wwwScanner | |
| LinkExtractor | back to summary |
|---|---|
| private LinkExtractor(UrlScanner urlScanner, WwwScanner wwwScanner, EmailScanner emailScanner) | |
| builder | back to summary |
|---|---|
| public static LinkExtractor. | |
| extractLinks | back to summary |
|---|---|
| public Iterable Extract the links from the input text. Can be called multiple times with different inputs (thread-safe).
| |
| extractSpans | back to summary |
|---|---|
| public Iterable Extract spans from the input text. A span is a substring of the input and represents either a link
(see
Using this is more convenient than
| |
| trigger | back to summary |
|---|---|
| private Scanner trigger(char c) | |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public LinkExtractor | |
| public LinkExtractor. | Returns: this buildertrue if the domain in an email address is required to have more than one part,
false if it can also just have single part (e.g. foo@com); true by default emailDomainMustHaveDot)
|
| public LinkExtractor. |
| emailDomainMustHaveDot | back to summary |
|---|---|
| private boolean emailDomainMustHaveDot | |
| linkTypes | back to summary |
|---|---|
| private Set<LinkType> linkTypes | |
| Builder | back to summary |
|---|---|
| private Builder() | |
| build | back to summary |
|---|---|
public LinkExtractor build()
| |
| emailDomainMustHaveDot | back to summary |
|---|---|
public LinkExtractor.
| |
| linkTypes | back to summary |
|---|---|
public LinkExtractor.
| |
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private final CharSequence | |
| private LinkSpan | |
| private int |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public LinkSpan | |
| public void | remove()
Overrides default java. Removes from the underlying collection the last element returned by this iterator (optional operation). |
| private void |
| index | back to summary |
|---|---|
| private int index | |
| input | back to summary |
|---|---|
| private final CharSequence input | |
| next | back to summary |
|---|---|
| private LinkSpan next | |
| rewindIndex | back to summary |
|---|---|
| private int rewindIndex | |
| LinkIterator | back to summary |
|---|---|
| public LinkIterator(CharSequence input) | |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| next | back to summary |
|---|---|
| public LinkSpan next() Implements java. Doc from java. Returns the next element in the iteration. | |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. Doc from java. Removes from the underlying collection the last element returned
by this iterator (optional operation). This method can be called
only once per call to The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.
The behavior of an iterator is unspecified if this method is called
after a call to the
| |
| setNext | back to summary |
|---|---|
| private void setNext() | |
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private final CharSequence | |
| private final LinkExtractor. | |
| private LinkSpan |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public Span | |
| private Span | |
| public void | remove()
Overrides default java. Removes from the underlying collection the last element returned by this iterator (optional operation). |
| index | back to summary |
|---|---|
| private int index | |
| input | back to summary |
|---|---|
| private final CharSequence input | |
| linkIterator | back to summary |
|---|---|
| private final LinkExtractor. | |
| nextLink | back to summary |
|---|---|
| private LinkSpan nextLink | |
| SpanIterator | back to summary |
|---|---|
| public SpanIterator(CharSequence input, LinkExtractor. | |
| hasNext | back to summary |
|---|---|
| public boolean hasNext() Implements java. Doc from java. Returns
| |
| next | back to summary |
|---|---|
| public Span next() Implements java. Doc from java. Returns the next element in the iteration. | |
| nextTextSpan | back to summary |
|---|---|
| private Span nextTextSpan(int endIndex) | |
| remove | back to summary |
|---|---|
| public void remove() Overrides default java. Doc from java. Removes from the underlying collection the last element returned
by this iterator (optional operation). This method can be called
only once per call to The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.
The behavior of an iterator is unspecified if this method is called
after a call to the
| |