dsto.dfc.swt.text
Class UrlScanner

java.lang.Object
  extended by dsto.dfc.swt.text.UrlScanner

public class UrlScanner
extends Object

Scans for URLs within a given text.


Nested Class Summary
static class UrlScanner.UrlRange
          A range in the text field that represents a URL.
 
Constructor Summary
UrlScanner()
           
 
Method Summary
 List<UrlScanner.UrlRange> scanForUrls(String text, int offset)
          Scan text for URL's.
 Set validSchemes()
          The set of valid URL schemes that are recognised as links.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UrlScanner

public UrlScanner()
Method Detail

validSchemes

public Set validSchemes()
The set of valid URL schemes that are recognised as links. Can add "*" to this to allow any vaguely URL-looking link. Default is {"http", "ftp", "mailto"}.


scanForUrls

public List<UrlScanner.UrlRange> scanForUrls(String text,
                                             int offset)
Scan text for URL's. adding UrlRange's to a list as they're found. Uses a simple state machine to scan in a single pass.

Parameters:
text - The text to scan.
offset - The offset to add to each range.


Copyright © 2008 Commonwealth of Australia