net.sourceforge.rssowl.util.shop
Class RegExShop

java.lang.Object
  extended bynet.sourceforge.rssowl.util.shop.RegExShop

public class RegExShop
extends Object

Factory class for regular expression concerns in RSSOwl

Version:
1.1.3
Author:
Benjamin Pasero

Field Summary
private static String HTML_ANCHOR_REGEX
          The reg. expression to match HTML Anchors
private static Pattern HTML_ANCHOR_REGEX_PATTERN
          The compiled pattern to match HTML Anchors (is Case Insensitive)
(package private) static String HTML_TAG_REGEX
          The reg. expression for HTML tags
(package private) static Pattern HTML_TAG_REGEX_PATTERN
          The compiled pattern to match HTML tags
static String REGEX_OK
          Constant to show that regex was compiled successfully
private static String[] regExSymbols
          List of common RegEx special chars
private static String URL_REGEX
          The reg. expression for an URL
private static Pattern URL_REGEX_PATTERN
          The compiled pattern to match an URL
(package private) static Pattern WHITESPACE_PATTERN
          The compiled pattern to match Whitespaces
private static String WHITESPACE_REGEX
          The reg. expression to match Whitespaces
 
Constructor Summary
private RegExShop()
          This utility class constructor is hidden
 
Method Summary
static String compileRegEx(String str)
          Compile a String and return either "OK" if the String is a valid RegEx, or the warning message if not.
static String escapeRegEx(String str)
          Escape RegEx special chars from the String and return it.
static void extractLinksFromHTML(String text, Vector linkList)
          Extract all links from the given String and fill them into the given HashSet.
static void extractLinksFromText(String text, Vector linkList)
          Extract all links from the given String and fill them into the given HashSet.
static boolean isInsideTags(String haystack, String needle)
          Returns TRUE in case the needle is surrounded by tags or includes tags inside the haystack
static boolean isValidURL(String url)
          Check if the given URL is valid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REGEX_OK

public static final String REGEX_OK
Constant to show that regex was compiled successfully

See Also:
Constant Field Values

HTML_ANCHOR_REGEX

private static final String HTML_ANCHOR_REGEX
The reg. expression to match HTML Anchors

See Also:
Constant Field Values

HTML_ANCHOR_REGEX_PATTERN

private static final Pattern HTML_ANCHOR_REGEX_PATTERN
The compiled pattern to match HTML Anchors (is Case Insensitive)


regExSymbols

private static final String[] regExSymbols
List of common RegEx special chars


URL_REGEX

private static final String URL_REGEX
The reg. expression for an URL

See Also:
Constant Field Values

URL_REGEX_PATTERN

private static final Pattern URL_REGEX_PATTERN
The compiled pattern to match an URL


WHITESPACE_REGEX

private static final String WHITESPACE_REGEX
The reg. expression to match Whitespaces

See Also:
Constant Field Values

HTML_TAG_REGEX

static final String HTML_TAG_REGEX
The reg. expression for HTML tags

See Also:
Constant Field Values

HTML_TAG_REGEX_PATTERN

static final Pattern HTML_TAG_REGEX_PATTERN
The compiled pattern to match HTML tags


WHITESPACE_PATTERN

static final Pattern WHITESPACE_PATTERN
The compiled pattern to match Whitespaces

Constructor Detail

RegExShop

private RegExShop()
This utility class constructor is hidden

Method Detail

compileRegEx

public static String compileRegEx(String str)
Compile a String and return either "OK" if the String is a valid RegEx, or the warning message if not.

Parameters:
str - Any String interpreted as RegEx
Returns:
String The Result of the compilation

escapeRegEx

public static String escapeRegEx(String str)
Escape RegEx special chars from the String and return it.

Parameters:
str - Any String
Returns:
String RegEx escaped String

extractLinksFromHTML

public static void extractLinksFromHTML(String text,
                                        Vector linkList)
Extract all links from the given String and fill them into the given HashSet. This method considers relative links too. Only use this method if the Text is using HTML links in anchor-tags.

Parameters:
text - The String to search for links
linkList - The collection to fill

extractLinksFromText

public static void extractLinksFromText(String text,
                                        Vector linkList)
Extract all links from the given String and fill them into the given HashSet. This method will NOT consider relative links. Only use this method when you are searching for absolute links in a text (which may also be HTML).

Parameters:
text - The String to search for links
linkList - The collection to fill

isInsideTags

public static boolean isInsideTags(String haystack,
                                   String needle)
Returns TRUE in case the needle is surrounded by tags or includes tags inside the haystack

Parameters:
haystack - The String to search for tags
needle - The String to check if surrounded by tags
Returns:
boolean TRUE in case the needle is surrounded by tags

isValidURL

public static boolean isValidURL(String url)
Check if the given URL is valid

Parameters:
url - The URL to check
Returns:
boolean TRUE if the link is valid


RSSOwl - RSS / RDF / Atom Newsreader

SourceForge.net Logo