Servertec | DString

Content Introduction Release Notes Features FAQs Requirements Installation Add-ons How To Change Log Future Plans Knowledge Base Documentation Conventions Users Reference iServer API AccessLogEntry Codecs Connection ConnectionPool... DString ErrorLogEntry EventLogEntry FileCache FileUpload IOHandler IOManager iws Logger MultiPartForm QuickSort Realm RealmAdmin... ServletManager Utils Servlet API CGI SSI Servlets Config Files Log Files Classes Directory Tree Samples Sales Legal Feedback |
    java.lang.Object
     |
     +--stec.lang.DString
public class DString Methods to manipulate delimited strings. #### Methods
Method | Description
change | Changes the first occurance of the given string in the specified string.
count | Returns the number of times the given delimiter was found in the specified string.
dcount | Returns the number of delimited strings.
extract | Returns the specified string.
find | Returns the occurance within the given delimited string where the specified substring if found.
findIgnoreCase | Returns the occurance within the given delimited string where the specified substring if found ignoring case.
pad | Returns a fixed string with the given value justified and padded with the specified delimiter.
replace | Replaces all occurances of the given string in the specified string.
trim | Returns a string where all leading, trailing and redunant spaces have been removed.
### change Changes the first occurance of the given string in the specified string. #### Syntax public static String change(String string, String old, String new) #### Parameters
string | the string to change.
old | the substing to change.
new | the substing to change to.
#### Returns
String | the resultant string.
#### Throws
Nothing
#### Example input = DString.change(input, "http://", ""); ### count Returns the number of times the given delimiter was found in the specified string. #### Syntax public static int count(String string, String delimiter) #### Parameters
string | the string to use.
delimiter | the delimiter to count.
#### Returns
int | the number of times that the given delimited was found in the specified string.
#### Throws
Nothing
#### Example int numberSpaces = DString.count(input, " "); ### dcount Returns the number of delimited strings. #### Syntax public static int dcount(String string, String delimiter) #### Parameters
string | the string to use.
delimiter | the delimiter.
#### Returns
int | the number of delimited strings. 0 if the string is empty or 1 if the delimited was not found and the string was not empty.
#### Throws
Nothing
#### Example int lines = DString.dcount(input, "\n"); ### extract Returns the specified string. #### Syntax public static String extract(String string, String delimiter, int index) #### Parameters
string | the string to use.
delimiter | the delimiter.
index | the index of the string to return.
#### Returns
String | the string at the specified index. null is index exceeds number of strings.
#### Throws
Nothing
#### Example String line = DString.extract(script, "\n", index); ### find Returns the occurance within the given delimited string where the specified substring was found. #### Syntax
    public static int find(String string,
                           String delimiter,
                           String substring)

    public static int find(String string,
                           String delimiter,
                           int startingIndex,
                           String substring)
#### Parameters
string | the string to search.
delimiter | the delimiter.
substring | the string to find.
startingOffset | the starting index.
#### Returns
int | the occurance within the given delimited string where the specified substring was found, -1 if not found.
#### Throws
Nothing
#### Example int index = DString.find(hosts, ",", host); ### findIgnoreCase Returns the occurance within the given delimited string where the specified substring if found ignoring case. #### Syntax
    public static String findIgnoreCase(String string,
                                        String delimiter,
                                        String substring)

    public static String findIgnoreCase(String string,
                                        String delimiter,
                                        int startingIndex,
                                        String substring)
#### Parameters
string | the string to search.
delimiter | the delimiter.
substring | the string to find.
startingOffset | the starting index.
#### Returns
int | the occurance within the given delimited string where the specified substring was found, -1 if not found.
#### Throws
Nothing
#### Example int index = DString.findIgnoreCase(hosts, ",", host); ### pad Returns a fixed string with the given value justified and padded with the specified delimiter. #### Syntax
    public static String pad(String string,
                             String delimiter,
                             int size,
                             char justification)
#### Parameters
string | the string to pad.
delimiter | the delimiter to pad with.
size | the padded string size.
justification | the justification, r for right and l for left.
#### Returns
String | the padded string,
#### Throws
Nothing
#### Example String output = DString.pad(input, " ", ); ### replace Replaces all occurances of the given string in the specified string. #### Syntax public static String replace(String string, String old, String new) #### Parameters
string | the string to change.
old | the substing to replace.
new | the substing to change to.
#### Returns
String | the resultant string.
#### Throws
Nothing
#### Example System.out.println(DString.replace(message, "\n", " ")); ### trim Returns a string where all leading, trailing and redunant spaces have been removed. #### Syntax public static String trim(String string) #### Parameters
string | the string to trim.
#### Returns
String | the resultant string.
#### Throws
Nothing
#### Example String command = DString.trim(message);
top of page
| Copyright © 1997-2000 Servertec. All rights reserved. Last Modified: Sun Jan 09 19:34:12 EST 2000