Esri Geoportal Server
1.2.9

com.esri.gpt.framework.util
Class Val

java.lang.Object
  extended by com.esri.gpt.framework.util.Val

public class Val
extends Object

Provides basic validation and conversion support.


Method Summary
static boolean chkBool(String s, boolean defaultVal)
          Converts a string to a boolean value.
static double chkDbl(String s, double defaultVal)
          Converts a string to a double value.
static boolean chkEmail(String s)
          Check a string to see if it matches an email address.
static int chkInt(String s, int defaultVal)
          Converts a string to an int value.
static long chkLong(String s, long defaultVal)
          Converts a string to a long value.
static String chkStr(String s)
          Check a string value.
static String chkStr(String s, int maxLength)
          Check a string value and ensures that it does not exceed a maximum length.
static String chkStr(String s, String defaultVal)
          Check a string value.
static String chkUrl(String url)
          Checks a string if it's a alid URL.
static String escapeSingleQuotes(String s)
          Escapes single and quotes within a string.
static String escapeStrForJson(String text)
          Escapes arbitrary text into a JSON escaped string.
static String escapeStrForLDAPSearch(String text)
          Escapes arbitrary text into a ldap escaped string.
static String escapeXml(String s)
          Escapes special xml characters within a string.
static String escapeXmlForBrowser(String s)
          Escapes special xml characters within a string.
static boolean isUrl(String url)
          Checks if URL is a valid URL.
static String join(String[] valArr, String delimiter)
           
static String removeBOM(String s)
          Removes a windows byte order mark if present.
static String stripControls(String input)
          Removes all unprintable characters from a string and replaces with a space for use in an HTTP header
static String stripHttpProtocol(String url)
           
static String stripHttpProtocol(String url, String replacement)
           
static String[] tokenize(String tokens, String delimiter)
          Tokenizes a delimited string into a string array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

chkBool

public static boolean chkBool(String s,
                              boolean defaultVal)
Converts a string to a boolean value.

Parameters:
s - the string to convert
defaultVal - the default value to return if the string is invalid
Returns:
the converted value

chkDbl

public static double chkDbl(String s,
                            double defaultVal)
Converts a string to a double value.

Parameters:
s - the string to convert
defaultVal - the default value to return if the string is invalid
Returns:
the converted value

chkEmail

public static boolean chkEmail(String s)
Check a string to see if it matches an email address.
The check is against a regular expression defined within gpt.xml:
/gptConfig/mail/@emailAddressRegexp

Parameters:
s - the string to check
Returns:
true if the string matches an email address

chkUrl

public static String chkUrl(String url)
Checks a string if it's a alid URL.

Parameters:
url - string to check
Returns:
url if it's valid or empty string if it's not valid

isUrl

public static boolean isUrl(String url)
Checks if URL is a valid URL.

Parameters:
url - URL
Returns:
true if this is valid URL

chkInt

public static int chkInt(String s,
                         int defaultVal)
Converts a string to an int value.

Parameters:
s - the string to convert
defaultVal - the default value to return if the string is invalid
Returns:
the converted value

chkLong

public static long chkLong(String s,
                           long defaultVal)
Converts a string to a long value.

Parameters:
s - the string to convert
defaultVal - the default value to return if the string is invalid
Returns:
the converted value

chkStr

public static String chkStr(String s)
Check a string value.

Parameters:
s - the string to check
Returns:
the checked string (trimmed, zero length if the supplied String was null)

chkStr

public static String chkStr(String s,
                            String defaultVal)
Check a string value.

Parameters:
s - the string to check
defaultVal - the default value to return if the string is null or empty
Returns:
the checked string (trimmed, default value if the supplied String was null or empty)

chkStr

public static String chkStr(String s,
                            int maxLength)
Check a string value and ensures that it does not exceed a maximum length.

Parameters:
s - the string to check
maxLength - the maximum length for the string
Returns:
the checked string (substring to the max length if applicable)

escapeSingleQuotes

public static String escapeSingleQuotes(String s)
Escapes single and quotes within a string.
The escape character inserted is a backslash.

Parameters:
s - the string to escape
Returns:
the escaped string

escapeXml

public static String escapeXml(String s)
Escapes special xml characters within a string.
< > & " ' are escaped.

Parameters:
s - the string to escape
Returns:
the escaped string

escapeXmlForBrowser

public static String escapeXmlForBrowser(String s)
Escapes special xml characters within a string.
< > & " are escaped. The single quote character is not escaped.

Parameters:
s - the string to escape
Returns:
the escaped string

escapeStrForJson

public static String escapeStrForJson(String text)
Escapes arbitrary text into a JSON escaped string.

Parameters:
text - text to escape
Returns:
esaped text
See Also:
JSON specification

escapeStrForLDAPSearch

public static String escapeStrForLDAPSearch(String text)
Escapes arbitrary text into a ldap escaped string.

Parameters:
text - text to escape
Returns:
escaped text

removeBOM

public static String removeBOM(String s)
Removes a windows byte order mark if present.

Parameters:
s - the string to check
Returns:
the string absent the byte order mark

tokenize

public static String[] tokenize(String tokens,
                                String delimiter)
Tokenizes a delimited string into a string array.

Parameters:
tokens - the delimited string to tokenize
delimiter - the delimiter
Returns:
the string array of tokens

join

public static String join(String[] valArr,
                          String delimiter)

stripControls

public static String stripControls(String input)
Removes all unprintable characters from a string and replaces with a space for use in an HTTP header

Parameters:
input -
Returns:
the stripped header

stripHttpProtocol

public static String stripHttpProtocol(String url,
                                       String replacement)

stripHttpProtocol

public static String stripHttpProtocol(String url)

Esri Geoportal Server
1.2.9

Copyright 2011 Environmental Systems Research Institute. All rights reserved. Use is subject to license terms.