StrFunc

———-

StrFunc is a string manipulation library. This class cannot be instantiated. It defines only static functions.

————————————————————–

@param String @return Boolean To check for empty String @return Boolean is empty or length 0, return true, otherwise return false StrFunc.isNull(” “); Return false StrFunc. IsNULL (NULL); Returns true

If (StrFunc isNull (userStr)) {

Throw new Exception(" No user or role assigned!") );

}

CompareStr: compareStr: compareStr: compareStr: compareStr: compareStr: compareStr @ param str1 to compare @ param str2 string to compare returns true @ the return string is empty, is not empty and content also return true, otherwise it returns false use, for example: the if (! StrFunc.compareStr(oldUpid, upId)){

...

}

There are several other methods for comparing strings: CompareStrigNoRecase (final String str1, final String str2) compareStrigNoReBlank (final String str1, final String str2) Final String str2) String contents always return true, otherwise false. When compared to ignore the difference between “” and null compareStrIgnoreBlankAndCase (final String str1, Final String str2) when compared to ignore the difference between “” and null, ignore case compareStrInt (final strings str1, final String str2) to compare the size of the String, if the str1 > str2, return positive integers; If str1=str2, return 0; If str1

Invisible characters are characters that have special meanings in Java such as: newline (” \n “), carriage return (” \r “), etc. @param String @return String returns A visible String Example: StrFunc. Str2Text (“A B C”); The return value is: A\u20B\tC

text2Str: Str2Text @param String @return String converts the text \r,\n,\t from the String TXT into the corresponding characters. Example: StrFunc. Text2Str (” A \ u20B \ tC “); The return values are: A B C

Date2str: Format a date object as a string parameter Description: @Param dat Calendar type, Date to convert @Param FMT Format to convert @Return date string

  1. Y is the year, M is the month, and D is the day
  2. Y/M/D is an Arabic numeral (123), and Y/M/D is a Chinese character (1, 2, 3).
  3. In 2006, “YY year” returns “06 year”; For “YYYY year”, return “2006”.
  4. H/N/S respectively corresponds to hours, minutes and seconds; Q, QQ, Q, QQ, represents the quarter
  5. MMM stands for displaying months in English

Calendar c = Calendar.getInstance(); C.s. et (2013, 6, 2); StrFunc. Date2str (c, “YYYY MM month DD date “); The content returned is: July 2, 2013

Date2str (Object dat, String FMT) Formats the Date Object as a String. The Object can be passed: Date,Timestamp,Calendar

Double2Str: This function converts a floating point number to a string for display. If d is double.NaN, return a string of length 0. If d is double.NaN, return a string of length 0. If Double.POSITIVE_INFINITY, return infinity; If it’s Double. Negative_infinity, it returns minus infinity; @Param mindeclen sets the minimum number of decimal places allowed @Param maxdeclen sets the maximum number of decimal places allowed @Param groupNum Whether to apply this format to groups (integer parts, This method can only be converted to a string with a value that is guaranteed to have a maximum of 15 or 16 significant bits

Examples of use: StrFunc. Double2str (22222.1449,3,3,false); It returns: 22222.145

StrFunc. Double2str (345678.12345, 0, 4, true); It returns: -345,678.1235

StrFunc. Double2str (81.1468032741434, 3, 5, true); It returns: 81.1468

Overloaded method: double2str(final double d) The minimum number of decimal places allowed is 0, and the maximum number of decimal places allowed is 10

EnsureEndWith: Ensures that the string ends with the string END, leaving it unchanged if R is already END or END is NULL

@param r string @param end string @return If r string ends with end or end is null, return r; If the string does not end with end, and end is not null, return r+end. Examples: StrFunc. EnsureEndWith (file, “.tmp”); StrFunc.ensureEndWith(folder, File.separator); EnsureStarTendWith (Final String S, Final String Start, Final String End) EnsureStarTendWith (Final String R, Final String End) Final String start, final String end) determines whether r begins with start and ends with end, and returns true /false

ParseBoolean: Parses a string to a Boolean value. Parameter description: @param STR to be converted to a Boolean string @param def returns the default value if the conversion is not successful def @return returns the corresponding Boolean value if given a string true, t, 1, yes, ignore case, Returns false if the string is false, f, 0, or no, regardless of case

Examples of use: strFunc.parseBoolean (“trUE”, false); Returns true strfunc.parseboolean (“dsfdgedf”, false); Returns the default value false

@Param o to convert to an object of type int @Param def is not successful @Param def is not successful @Param def is not successful @Param def is not successful @Param def is not successful

Int PageSize = strFunc.str2Int (req.getParameter(” PageSize “), PageSize);

@param STR object @return A string of length 0 if STR is null, otherwise STR is returned

Examples of use:

return “dsn/showdsnplugin.do? group=”+StrFunc.null2blank(group);

Null2Default (final String STR, final String def) If STR is empty, replace it with the value of def

Format2HtmlStr: Convert a string into a character that can be displayed in HTML @Param ignoreBlank ignores whitespace processing @Param ignoreBlank So what we do with whitespace is we convert it to character output @Param quateit whether we add double quotes to the result we return @Param totextArea whether we print the result to a TextArea, StrFunc. Format2HtmlStr (““);

Parameter description: @Param message need to convert the string @Return after processing the string

Example use: strfunc.format2htmlstr (” “);

Format2HTMLStr_ignoreBlank (final String S) Ignores whitespace, that is, whitespace is not converted to the output as it is. The rest of the processing is consistent with format2HtmlStr

format2HtmlStr(final String message, final boolean ignoreBlank, final boolean quateit, Final Boolean TotextArea QuateIt whether to add double quotes to the returned result TotextArea whether to output the result into the text edit box TextArea, if so, there is no need to convert the return line feed and TAB characters. If false is passed, the newline returns to

. Otherwise, \r returns \r and \n returns \n.

Contains: Determines whether a string is in an array of strings

@Param Element @Param Element @Param Element @Param Element @Param Element @Param Element @Param Element @Param Element @Param Element @Param Element

Contains (new String[]{“dfa”,”asdfds”,”c”}, “asdfds”); Returns true

If (StrFunc. The contains (dataBbh getUpids (), BBH. GetId ())) {… }

IsNumber: determines whether a string is a string of numeric type, including int,double

@param s @return s is a string of numeric type that returns true, or false if it is null or of length 0

Example use: strfunc. isNumber(“0x7F”); Return false StrFunc. IsNumber (cl.getProperty(“x”))? Integer.parseInt(cl.getProperty(“x”)) : -1; Bold bold