public class BRules extends Object
Constructor and Description |
---|
BRules() |
Modifier and Type | Method and Description |
---|---|
static Integer |
ageInYears(Date birthDate)
Calculates age in whole years based on today's date
{talendTypes} Integer
{Category} BRules
{param} date(birthDate) input: the date of birth
|
static Integer |
ageInYears(Date birthDate,
Date asOfDate)
Calculates age in whole years using the specified
as of date
Returns null if birthDate or asOfDate is null
{talendTypes} Integer
{Category} BRules
{param} date(birthDate) input: the date of birth
{param} date(asOfDate) input: date used for comparison; alternative to
today
|
static boolean |
all(Object... _objects)
all: true if all arguments are not empty (not null for Objects,
not null, empty string, or whitespace for java.lang.String)
{talendTypes} String
{Category} BRules
{param} object() input: a variable number of params to check
{example} all("one", "two", "") # false
{example} all("one") # true
|
static String |
comma(Object... _objects)
comma: join the string representation of objects together with a
comma
Appends an empty string where an element is null
{talendTypes} String
{Category} BRules
{param} object() input: a variable number of strings to join
{example} comma("one", "two", "three") # "one,two,three"
|
static boolean |
hasJSONPath(String _json,
String _path)
hasJSONPath: true if the passed-in json has elements referenced in path
Not supported for JDKs < 6; will throw exception
{talendTypes} String
{Category} BRules
{param} string("{name: 'Carl', program: 'BRules'}") input: json to be tested
{example} hasJSONPath("
|
protected static String |
htmlList(String _styleClass,
String _listType,
Object... _objects) |
static boolean |
isBlank(String _s)
isBlank: true if the string is null, the empty string, or whitespace
{talendTypes} String
{Category} BRules
{param} string("hello") input : string to be tested
{example} isBlank("hello") # false
{example} isBlank(null) # true
{example} isBlank("") # true
{example} isBlank(" ") # true
|
static boolean |
isJSON(String _json)
isJSON: true if the passed-in string adheres to JSON format
Not supported for JDKs < 6; will throw exception
Empty expressions - {} and [] - will return true
{talendTypes} String
{Category} BRules
{param} string("{name: 'Carl', program: 'BRules'}") input: json to be tested
{example} isJSON("
|
static boolean |
isPhoneNum(String _countryCode,
String _toValidate)
isPhoneNum: true if valid in accordance with country specifier; uses
strict check
{talendTypes} String
{Category} BRules
{param} string("regionCode") input: The country or region code to use
{param} string("phoneNumber") input: The phone number to check
{example} isPhoneNum("US", "(301) 555-5555") # true
|
static boolean |
isPhoneNum(String _countryCode,
String _toValidate,
boolean _loose)
isPhoneNum: true if valid in accordance with country specifier and
loose flag (false for strict)
{talendTypes} String
{Category} BRules
{param} string("regionCode") input: The country or region code to use
{param} string("phoneNumber") input: The phone number to check
{param} boolean: use loose validation (true) or strict (false)
{example} isPhoneNum("US", "(301) 555-5555") # true
|
static boolean |
isXML(String _xml)
isXML: true if the passed-in string adheres to XML well-formedness
using a UTF-8 string
{talendTypes} String
{Category} BRules
{param} string("
|
static boolean |
isXML(String _xml,
String _charset)
isXML: true if the passed-in string adheres to XML well-formedness
and the specified charset
{talendTypes} String
{Category} BRules
{param} string("
|
static String |
join(String _delim,
Object... _objects)
join: join the string representation of objects together with a
character
Appends an empty string where an element is null
{talendTypes} String
{Category} BRules
{param} object() input: a variable number of strings to join
{example} join("one", "two", "three") # "one,two,three"
|
static String |
listToString(List<?> inputList)
Forms a comma-separated list given the input java.util.List
Handles different types
Nulls are skipped, for example [A, null, B] -> A,,B
{talendTypes} String
{Category} BRules
{param} list(inputList) input: the list to convert
|
static String |
listToString(List<?> inputList,
String delimiter)
Forms a comma-separated list given the input java.util.List using the
specified delimeter
Handles different types
Nulls are skipped, for example [A, null, B] -> A,,B
{talendTypes} String
{Category} BRules
{param} list(inputList) input: the list to convert
{param} string(delimiter) input: delimiter to used in string separating
items
|
static String |
listToString(List<?> inputList,
String delimiter,
String escapeString)
Forms a comma-separated list given the input java.util.List
Handles different types
Nulls are skipped, for example [A, null, B] -> A,,B
{talendTypes} String
{Category} BRules
{param} list(inputList) input: the list to convert
{param} string(delimiter) input: delimiter to used in string separating
items
{param} string(escapeString) input: string to wrap each item
|
static boolean |
okChars(String _s,
String _charset)
okChars: true if the passed-in string is valid for the specified
character set
The supported character set values are those supported by Java.
|
static String |
ol(String _styleClass,
Object... _objects)
ol: form an html list of the specified css style from
the list of objects
null objects returns an empty list (ex, "")
{talendTypes} String
{Category} BRules
{param} styleClass : a style to apply for the toplevel list element
{param} object() input: a variable number of strings to join
{example} ol("infolist", "a", "b") # "ab"
|
static String |
p(String _styleClass,
String _text)
p: form an html paragraph of the specified css style from
the list of objects
null objects returns an empty list (ex, "
|
static String |
pad(Integer i,
int size,
char ch)
Left pads the input integer with the specified character
{talendTypes} String
{Category} BRules
{param} int(integerToPad) integerToPad: int to pad
{param} int(numPadChars) numPadChars: number of padded chars
{param} char(charToUse) charToUse: char to use as padding
{example} pad(100, 6, '0') # "000100"
|
static String |
pad(Long lng,
int size,
char ch)
Left pads the input long with the specified character
{talendTypes} String
{Category} BRules
{param} long(integerToPad) integerToPad: int to pad
{param} long(numPadChars) numPadChars: number of padded chars
{param} char(charToUse) charToUse: char to use as padding
{example} pad(100L, 6, '0') # "000100"
|
static String |
pad(String s)
Deprecated.
|
static String |
pad(String s,
int size)
Left pads the input string with spaces
{talendTypes} String
{Category} BRules
{param} string(stringToPad) stringToPad: string to pad
{param} int(numPadChars) numPadChars: number of padded chars
{example} pad("100",6) # "000100"
|
static String |
pad(String s,
int size,
char ch)
Left pads the input string with the specified character
{talendTypes} String
{Category} BRules
{param} string(stringToPad) stringToPad: string to pad
{param} int(numPadChars) numPadChars: number of padded chars
{param} char(charToUse) charToUse: char to use as padding
{example} pad("100", 6, '0') # "000100"
|
static String |
padRight(String s,
int size)
Right pads the input string with spaces
{talendTypes} String
{Category} BRules
{param} string(stringToPad) stringToPad: string to pad
{param} int(numPadChars) numPadChars: number of padded chars
{example} pad("100", 6) # "100 "
|
static String |
padRight(String s,
int size,
char ch)
Right pads the input string with the specified character
{talendTypes} String
{Category} BRules
{param} string(stringToPad) stringToPad: string to pad
{param} int(numPadChars) numPadChars: number of padded chars
{param} char(charToUse) charToUse: char to use as padding
{example} pad("100", 6, '0') # "100000"
|
static String |
toCharset(String _s)
toCharset: convert a string to the character set used by Windows Latin-1.
|
static String |
toCharset(String _s,
String _charset)
toCharset: convert a string to the specified character set
Will convert unmappable characters to a space (" ") rather than throwing
an error
For example, this will conveniently map a ™ (TM) symbol to a
Windows-recognized hex 99
Uses Java names for charsets: Cp1252, US-ASCII
{talendTypes} String
{Category} BRules
{param} string(_s) input string to convert
{param} string(_charset) character set to use for conversion
{example} toCharset("My Product™", "Cp1252") # returns "My Product "
|
static String |
toCharset(String _s,
String _charset,
String _replaceCh)
toCharset: convert a string to the specified character set
Will convert unmappable characters to a specified character
For example, this will conveniently map a ™ (TM) symbol to a
Windows-recognized hex 99
Uses Java names for charsets: Cp1252, US-ASCII, ISO-8859-1, UTF-8, UTF-16
{talendTypes} String
{Category} BRules
{param} string(_s) input string to convert
{param} string(_charset) character set to use for conversion
{param} string(_replaceCh) character to use for unmappables
{example} toCharset("My Product™", "Cp1252", "?") # returns "My Product?"
|
static String |
trimLeadingZeros(String num_s)
Take off leading zeros; assumes a number
{talendTypes} String
{Category} BRules
{param} trimLeadingZeros(string) input: The string to be divided
|
static String |
ul(String _styleClass,
Object... _objects)
ul: form an html list of the specified css style from
the list of objects
null objects returns an empty list (ex, "")
{talendTypes} String
{Category} BRules
{param} styleClass : a style to apply for the toplevel list element
{param} object() input: a variable number of strings to join
{example} ul("infolist", "a", "b") # "ab"
|
static boolean |
xor(Object... _objects)
xor: true if one and only one argument is not empty (not null for Objects,
not null, empty string, or whitespace for java.lang.String)
{talendTypes} String
{Category} BRules
{param} object() input: a variable number of params to check
{example} xor("one", "") # true
{example} xor("", "") # false
|
public static boolean isPhoneNum(String _countryCode, String _toValidate)
public static boolean isPhoneNum(String _countryCode, String _toValidate, boolean _loose)
public static boolean all(Object... _objects)
public static boolean xor(Object... _objects)
public static boolean isBlank(String _s)
public static boolean isXML(String _xml, String _charset) throws Exception
Exception
public static boolean isXML(String _xml) throws Exception
Exception
public static boolean okChars(String _s, String _charset)
public static String toCharset(String _s)
public static String toCharset(String _s, String _charset)
public static String toCharset(String _s, String _charset, String _replaceCh)
public static boolean isJSON(String _json)
public static boolean hasJSONPath(String _json, String _path) throws Exception
Exception
public static String comma(Object... _objects)
public static String join(String _delim, Object... _objects)
public static String ul(String _styleClass, Object... _objects)
public static String ol(String _styleClass, Object... _objects)
public static String p(String _styleClass, String _text)
a
"@Deprecated public static String pad(String s)
public static String pad(String s, int size)
s
- - input string to padsize
- - number of chars to padpublic static String pad(String s, int size, char ch)
s
- - input string to padsize
- - number of chars to padch
- - character to pad withpublic static String pad(Integer i, int size, char ch)
s
- - input string to padsize
- - number of chars to padch
- - character to pad withpublic static String pad(Long lng, int size, char ch)
s
- - input string to padsize
- - number of chars to padch
- - character to pad withpublic static String padRight(String s, int size)
s
- - input string to padsize
- - number of chars to padpublic static String padRight(String s, int size, char ch)
s
- - input string to padsize
- - number of chars to padch
- - character to pad withpublic static String trimLeadingZeros(String num_s)
public static Integer ageInYears(Date birthDate)
birthDate
- date of birthpublic static Integer ageInYears(Date birthDate, Date asOfDate)
birthDate
- date of birthasOfDate
- date of comparison (instead of today)public static String listToString(List<?> inputList)
inputList
- list of objects of any timepublic static String listToString(List<?> inputList, String delimiter)
inputList
- list of objects of any timepublic static String listToString(List<?> inputList, String delimiter, String escapeString)
inputList
- list of objects of any timeescapeString
- String added to start and end of each elementCopyright © 2014. All rights reserved.