Show / Hide Table of Contents

Class StringUtils

Miscellaneuos utility methods for string manipulation.

Inheritance
object
StringUtils
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Tangosol.Util
Assembly: Coherence.dll
Syntax
public abstract class StringUtils

Methods

BreakLines(string, int, string)

Breaks the specified string into a multi-line string.

Declaration
public static string BreakLines(string text, int width, string indent)
Parameters
Type Name Description
string text

The string to break.

int width

The max width of resulting lines (including the indent).

string indent

A string used to indent each line.

Returns
Type Description
string

The string, broken and indented.

BreakLines(string, int, string, bool)

Breaks the specified string into a multi-line string.

Declaration
public static string BreakLines(string text, int width, string indent, bool isFirstLine)
Parameters
Type Name Description
string text

The string to break.

int width

The max width of resulting lines (including the indent).

string indent

A string used to indent each line.

bool isFirstLine

If true indents all lines; otherwise indents all but the first.

Returns
Type Description
string

The string, broken and indented.

ByteArrayToHexString(byte[])

Convert a byte array to a hex string of 2 hex digits per byte.

Declaration
public static string ByteArrayToHexString(byte[] array)
Parameters
Type Name Description
byte[] array

The byte array to convert.

Returns
Type Description
string

The hex string.

Dup(char, int)

Create a String of the specified length containing the specified character.

Declaration
public static string Dup(char ch, int length)
Parameters
Type Name Description
char ch

The character to fill the String with.

int length

The length of the String.

Returns
Type Description
string

A String containing the character ch repeated length times.

Dup(string, int)

Create a String which is a duplicate of the specified number of the passed String.

Declaration
public static string Dup(string text, int count)
Parameters
Type Name Description
string text

The String to fill the new String with.

int count

The number of duplicates to put into the new String.

Returns
Type Description
string

A String containing the String text repeated count times.

Escape(char, char[], int)

Format a char to a printable escape if necessary, putting the result into the passed array.

Declaration
public static int Escape(char ch, char[] ach, int of)
Parameters
Type Name Description
char ch

The character to format.

char[] ach

The array of characters to format into.

int of

The offset in the array to format at.

Returns
Type Description
int

The number of characters used to format the char.

Remarks

The array must be large enough to accept six characters.

HexStringToByteArray(string)

Convert a hex string to a byte array.

Declaration
public static byte[] HexStringToByteArray(string hexString)
Parameters
Type Name Description
string hexString

The hex string to convert.

Returns
Type Description
byte[]

The byte array.

IsNullOrEmpty(string)

Returns true if specified string is null or empty, false otherwise.

Declaration
public static bool IsNullOrEmpty(string stringValue)
Parameters
Type Name Description
string stringValue

Value to check.

Returns
Type Description
bool

true if specified string is null or empty, false otherwise.

ToBandwidthString(long, bool)

Format the passed bandwidth (in bytes per second) as a String.

Declaration
public static string ToBandwidthString(long bps, bool isExact)
Parameters
Type Name Description
long bps

The number of bytes per second.

bool isExact

true if the String representation must be exact, or false if it can be an approximation.

Returns
Type Description
string

A String representation of the given bandwidth.

Remarks

This method will possibly round the memory size for purposes of producing a more-easily read String value unless the isExact parameter is passed as true.

ToCharEscape(char)

Format a char to a printable escape if necessary.

Declaration
public static string ToCharEscape(char ch)
Parameters
Type Name Description
char ch

The char.

Returns
Type Description
string

A printable string representing the passed char.

ToDecString(int, int)

Format the passed integer as a fixed-length decimal string.

Declaration
public static string ToDecString(int n, int digits)
Parameters
Type Name Description
int n

The integer value.

int digits

The length of the resulting decimal string.

Returns
Type Description
string

The decimal value formated to the specified length string.

ToMemorySizeString(long, bool)

Format the passed memory size (in bytes) as a String.

Declaration
public static string ToMemorySizeString(long memorySize, bool isExact)
Parameters
Type Name Description
long memorySize

The number of bytes of memory.

bool isExact

true if the String representation must be exact, or false if it can be an approximation.

Returns
Type Description
string

A String representation of the given memory size.

Remarks

This method will possibly round the memory size for purposes of producing a more-easily read String value unless the isExact parameter is passed as true.

ToOracleVersion(Version)

Convert a .NET Version object to an Oracle version string. Oracle version number can have 5 numbers (N.N.N.N.N) while .NET version number can only have up to 4 numbers (N.N.N.N). So to represent Oracle version in .NET version format, the 4th .NET version number is a combination of the 4th and 5th Oracle version numbers as follows:

4th .NET number = 4th Oracle number * 1000 + 5th Oracle number;

4th Oracle number = int (4th .NET number / 1000); 5th Oracle number = 4th .NET number - 4th Oracle number * 1000;

e.g. 12.1.2.1 (.NET) ==> 12.1.2.0.1 (Oracle) 12.1.2.1001 (.NET) ==> 12.1.2.1.1 (Oracle) 12.1.2 (.NET) ==> 12.1.2.0.0 (Oracle)

Declaration
public static string ToOracleVersion(Version dotnetVersion)
Parameters
Type Name Description
Version dotnetVersion

The .NET Version object.

Returns
Type Description
string

The Oracle version string.

In this article
Back to top Copyright © 2000, 2024, Oracle and/or its affiliates.