Servertec DString
Documentation
Conventions
Command Line
Java API
AccessLogEntry
DString
ErrorLogEntry
EventLogEntry
iws
Logger
ServletManager
Utils

Servlet API
Servlets
Config Files
Classes
Directory Tree

Return

 

java.lang.Object
 |
 +--stec.lang.DString

public final class DString

Methods to manipulate delimited strings.

Methods

Method Description
change Changes the first occurence 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.
pad Returns a fixed string with the given value justified and padded with the specified delimiter.
replace Replaces all occurences of the given string in the specified string.
trim Returns a string where all leading, trailing and redundant spaces have been removed.

change

Changes the first occurence of the given string in the specified string.

Syntax

public final static String change(String string, String old, String new)

Parameters

string the string to change.
old the substring to change.
new the substring 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 final 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 final 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 final 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);

pad

Returns a fixed string with the given value justified and padded with the specified delimiter.

Syntax

public final 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 occurences of the given string in the specified string.

Syntax

public final static String replace(String string, String old, String new)

Parameters

string the string to change.
old the substring to replace.
new the substring 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 redundant spaces have been removed.

Syntax

public final 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 © 1998-2005 Servertec. All rights reserved.
Privacy Statement.
Last Modified: Mon Sep 05 14:25:45 EDT 2005