Servertec DString
Content
Introduction
Release Notes
Features
FAQs
Requirements
Installation
Add-ons
How To
Change Log
Future Plans
Knowledge Base
Documentation
Conventions
Command Line
Administrator
Localization
Programming
Security
Performance
Deployment
Java API
AccessLogEntry
Codecs
Connection
ConnectionPool...
DString
ErrorLogEntry
EventLogEntry
FileCache
FileUpload
IOHandler
IOManager
iws
Logger
MonitorEvent...
MultiPartForm
QuickSort
Realm
RealmAdmin...
RealmManager
ServletContextImpl
ServletContext...
ServletImpl
ServletManager
SocketHandler
Utils

Servlet API
CGI
SSI
Servlets
Config Files
Log Files
Classes
Directory Tree
Samples
Legal
Contact Us

 

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.
find Returns the occurence within the given delimited string where the specified substring if found.
findIgnoreCase Returns the occurence 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 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);

find

Returns the occurence within the given delimited string where the specified substring was found.

Syntax

public final static int find(String string,
                             String delimiter,
                             String substring)

public final 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 occurence 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 occurence within the given delimited string where the specified substring if found ignoring case.

Syntax

public final static int findIgnoreCase(String string,
                                       String delimiter,
                                       String substring)


public final static int 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 occurence 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 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: Sun Sep 04 14:56:49 EDT 2005