net.sourceforge.wurfl.core.utils
Class StringMatchUtils

java.lang.Object
  extended by net.sourceforge.wurfl.core.utils.StringMatchUtils

public final class StringMatchUtils
extends Object

Strings matching utility class.

This class contains the utility methods for the strings.

Version:
$Id: StringMatchUtils.java 934 2012-03-27 13:34:26Z fulvio.crivellaro $

Field Summary
static String EMPTY_STRING
           
 
Method Summary
static boolean containsAllOf(String haystack, List<String> needles)
           
static boolean containsAllOf(String haystack, String... needles)
           
static boolean containsAnyOf(String userAgent, String... needles)
           
static boolean containsAnyOfIgnoreCase(String userAgent, String... needles)
           
static int firstSemiColon(String target)
           
static int firstSlash(String target)
          Return the position of first slash of the userAgent string.
static int firstSpace(String target)
          Return the position of first space of the given string.
static String format(Set<String> mozillaData)
           
static String hierarchyAsString(List<ModelDevice> hierarchy)
          Display a device hierarchy as String: generic -> ...
static int indexOf(String userAgent, String key)
           
static int indexOfAnyOrLength(String userAgent, String... needles)
           
static int indexOfAnyOrLength(String userAgent, String[] needles, int startIndex)
           
static int indexOfOrLength(String target, String needle)
           
static int indexOfOrLength(String target, String needle, int startIndex)
           
static String ldMatch(Set<String> candidates, String needle, int tolerance)
          This method use the LDMatcher to search the given needle.
static int ordinalIndexOfOrLength(String target, String needle, int ordinal)
           
static int ordinalIndexOfOrLength(String target, String needle, int ordinal, int startIndex)
           
static String removeSubstringBefore(String userAgent, String needle)
           
static String risMatch(Set<String> candidates, String needle, int tolerance)
          This method use the RISMatcher to search the given needle.
static int secondSlash(String target)
          Return the index of second of the given string.
static boolean startsWithAnyOf(String userAgent, String... strings)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_STRING

public static final String EMPTY_STRING
See Also:
Constant Field Values
Method Detail

firstSlash

public static int firstSlash(String target)
Return the position of first slash of the userAgent string.

Parameters:
target - A string to search first slash
Returns:
A index of first slash in the string or, if the string does not contain a slash, the string length

secondSlash

public static int secondSlash(String target)
Return the index of second of the given string.

Parameters:
target - A string on which find second slash.
Returns:
A index of second slash in the string.

firstSemiColon

public static int firstSemiColon(String target)

firstSpace

public static int firstSpace(String target)
Return the position of first space of the given string.

Parameters:
target - A string to search first slash
Returns:
A index of first space in the string or, if the string not containing a space, the whole string length

indexOfOrLength

public static int indexOfOrLength(String target,
                                  String needle)

indexOfOrLength

public static int indexOfOrLength(String target,
                                  String needle,
                                  int startIndex)

ordinalIndexOfOrLength

public static int ordinalIndexOfOrLength(String target,
                                         String needle,
                                         int ordinal)

ordinalIndexOfOrLength

public static int ordinalIndexOfOrLength(String target,
                                         String needle,
                                         int ordinal,
                                         int startIndex)

risMatch

public static String risMatch(Set<String> candidates,
                              String needle,
                              int tolerance)
This method use the RISMatcher to search the given needle.

Parameters:
needle - String to search
candidates - Strings to search against
tolerance - The tolerance to use in matching.
See Also:
RISMatcher.match(Set, String, int)

ldMatch

public static String ldMatch(Set<String> candidates,
                             String needle,
                             int tolerance)
This method use the LDMatcher to search the given needle.

Parameters:
needle - String to search
candidates - Strings to search against
tolerance - The tolerance to use in matching.
See Also:
LDMatcher.match(Set, String, int)

hierarchyAsString

public static String hierarchyAsString(List<ModelDevice> hierarchy)
Display a device hierarchy as String: generic -> ... -> root.

Parameters:
hierarchy - The hierarchy to convert.
Returns:
A string representing the given hierarchy.

indexOf

public static int indexOf(String userAgent,
                          String key)

removeSubstringBefore

public static String removeSubstringBefore(String userAgent,
                                           String needle)

containsAnyOf

public static boolean containsAnyOf(String userAgent,
                                    String... needles)

containsAnyOfIgnoreCase

public static boolean containsAnyOfIgnoreCase(String userAgent,
                                              String... needles)

startsWithAnyOf

public static boolean startsWithAnyOf(String userAgent,
                                      String... strings)

indexOfAnyOrLength

public static int indexOfAnyOrLength(String userAgent,
                                     String... needles)

indexOfAnyOrLength

public static int indexOfAnyOrLength(String userAgent,
                                     String[] needles,
                                     int startIndex)

containsAllOf

public static boolean containsAllOf(String haystack,
                                    String... needles)

containsAllOf

public static boolean containsAllOf(String haystack,
                                    List<String> needles)

format

public static String format(Set<String> mozillaData)


Copyright © 2012 ScientiaMobile Inc.. All Rights Reserved.