com.sigh.utils.strings.c_functions
Class Csprintf

java.lang.Object
  extended by com.sigh.utils.SIGH_license
      extended by com.sigh.utils.strings.OutputSeparatorsForDigitStrings
          extended by com.sigh.utils.strings.ThreeDigitSeparator
              extended by com.sigh.utils.strings.c_functions.Csprintf

public class Csprintf
extends ThreeDigitSeparator

Csprintf provides c format string capability as described in the Csprintf User's Manual. It emulates the c programming lanugage's sprintf description.


Constructor Summary
Csprintf()
          This is the constructor for Csprintf
To create a new instantiation of Csprintf
Csprintf csf = new Csprintf();
 
Method Summary
 java.lang.String changeSign(java.lang.String theValue2Inspect)
          changeSign --
 java.lang.String doSprintf(java.lang.String formatString, java.lang.Object[] formatValues)
          author Software Industry & General Hardware
 java.lang.String formatUnsignedLong(long value)
           
static boolean isValidFormatString(java.lang.String theFormatString)
          Checks a format string to see if it is valid and returns true if it is and false if it is not.
 java.lang.String set3DigitSeparatorString(char nxtSeparator)
          This method allows the user to set the 3-digit separator string value to whatever they want from a character values passed in.
 java.lang.String set3DigitSeparatorString(java.lang.String nxtSeparator)
          This routine allows the user to set the 3-digit separator string value to whatever they want.
static java.lang.String sprintf(java.lang.String formatString, java.lang.Object formatValue)
          This allows a static call with a single object so you can do the following: System.out.println ( Csprintf.sprintf ( "%04x", intObject ) ); author Software Industry & General Hardware
static java.lang.String sprintf(java.lang.String formatString, java.lang.Object[] anObject)
          This allows a static call with an object array so you can do the following: Object[] arrayOfIntObjects = new Object [ 4 ]; arrayOfIntObjects [ 0 ] = valueFound; arrayOfIntObjects [ 1 ] = yearValue; arrayOfIntObjects [ 2 ] = monthValue; arrayOfIntObjects [ 3 ] = dayValue; System.out.println ( Csprintf.sprintf ( "%04x @ %04d-%02d-%02d", arrayOfIntObjects ) ); author Software Industry & General Hardware
static java.lang.String sprintf(java.lang.String formatString, java.lang.Object[] anObject, int groupingCount)
          This allows a static call with an object array so you can do the following: Object[] arrayOfIntObjects = new Object [ 4 ]; arrayOfIntObjects [ 0 ] = valueFound; arrayOfIntObjects [ 1 ] = yearValue; arrayOfIntObjects [ 2 ] = monthValue; arrayOfIntObjects [ 3 ] = dayValue; System.out.println ( Csprintf.sprintf ( "%04x @ %04d-%02d-%02d", arrayOfIntObjects, 4 ) ); author Software Industry & General Hardware
static java.lang.String sprintf(java.lang.String formatString, java.lang.Object[] anObject, java.lang.String groupingSeparator)
          This allows a static call with an object array so you can do the following: Object[] arrayOfIntObjects = new Object [ 4 ]; arrayOfIntObjects [ 0 ] = valueFound; arrayOfIntObjects [ 1 ] = yearValue; arrayOfIntObjects [ 2 ] = monthValue; arrayOfIntObjects [ 3 ] = dayValue; System.out.println ( Csprintf.sprintf ( "%04x @ %04d-%02d-%02d", arrayOfIntObjects, "." ) ); author Software Industry & General Hardware
static java.lang.String sprintf(java.lang.String formatString, java.lang.Object[] anObject, java.lang.String groupingSeparator, int groupingCount)
          This allows a static call with an object array so you can do the following: Object[] arrayOfIntObjects = new Object [ 4 ]; arrayOfIntObjects [ 0 ] = valueFound; arrayOfIntObjects [ 1 ] = yearValue; arrayOfIntObjects [ 2 ] = monthValue; arrayOfIntObjects [ 3 ] = dayValue; System.out.println ( Csprintf.sprintf ( "%04x @ %04d-%02d-%02d", arrayOfIntObjects, ".", 4 ) ); author Software Industry & General Hardware
static java.lang.String sprintf(java.lang.String formatString, java.lang.Object formatValue, int groupingCount)
          This allows a static call with a single object so you can do the following: System.out.println ( Csprintf.sprintf ( "%04x", intObject, ".", 4 ) ); author Software Industry & General Hardware
static java.lang.String sprintf(java.lang.String formatString, java.lang.Object formatValue, java.lang.String groupingString)
          This allows a static call with a single object so you can do the following: System.out.println ( Csprintf.sprintf ( "%04x", intObject, "." ) ); author Software Industry & General Hardware
static java.lang.String sprintf(java.lang.String formatString, java.lang.Object formatValue, java.lang.String groupingString, int groupingCount)
          This allows a static call with a single object so you can do the following: System.out.println ( Csprintf.sprintf ( "%04x", intObject, ".", 4 ) ); author Software Industry & General Hardware
 java.lang.String stripSign(java.lang.String theValue2Strip)
          stripSign -- Removes a '-' or a '+' from the front of a String representation of a number.
static java.lang.String version()
          author Software Industry & General Hardware
 
Methods inherited from class com.sigh.utils.strings.ThreeDigitSeparator
addCommas, usage
 
Methods inherited from class com.sigh.utils.strings.OutputSeparatorsForDigitStrings
get3DigitSeparatorString, getFractionalSeparatorString, getNumberOfDigitsToSeparate, set3DigitSeparatorChar, set3DigitSeparatorChar, setFractionalSeparatorChar, setFractionalSeparatorChar, setLocalLocaleFor3DigitSeparator, setLocalLocaleForBothSeparators, setLocalLocaleForFractionalSeparator, setLocalLocaleForGroupingCount, setNumberOfDigitsToSeparate
 
Methods inherited from class com.sigh.utils.SIGH_license
license
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Csprintf

public Csprintf()
This is the constructor for Csprintf
To create a new instantiation of Csprintf
Csprintf csf = new Csprintf();

Method Detail

version

public static java.lang.String version()
author Software Industry & General Hardware

Returns:
String The version of this software package is returned as a String.

doSprintf

public java.lang.String doSprintf(java.lang.String formatString,
                                  java.lang.Object[] formatValues)
                           throws CsprintfExceptions
author Software Industry & General Hardware

Parameters:
formatString -
formatValues - an Object array with the values to insert in the format string
Returns:
StringBuffer of the formated string.
Throws:
CSprintfExceptions -
This routine emulates the sprintf function from the programming language c
CsprintfExceptions

set3DigitSeparatorString

public java.lang.String set3DigitSeparatorString(java.lang.String nxtSeparator)
This routine allows the user to set the 3-digit separator string value to whatever they want. In the United States of America this is a comma as in 123,456,789 In the United Kingdom this is a period as in 123.456.789 See setFractionalSeperatorChar for an equivalent routine to change the fractional separator. Note: The separator is a string and could be multiple characters if the user desires. Try set3DigitSeperatorChar ( "_|_" ); This change lasts until it is reset or the program is restarted (where the local locale is used as the default). author Software Industry & General Hardware

Parameters:
nxtSeparator -
Returns:
previous string value of the separator

set3DigitSeparatorString

public java.lang.String set3DigitSeparatorString(char nxtSeparator)
This method allows the user to set the 3-digit separator string value to whatever they want from a character values passed in. In the United States of America this is a comma as in 123,456,789 In the United Kingdom this is a period as in 123.456.789 See setFractionalSeperatorChar for an equivalent routine to change the fractional separator. Note: The separator is a string and could be multiple characters if the user desires. Try set3DigitSeperatorChar ( "<*>" ); This change lasts until it is reset or the program is restarted (where the local locale is used as the default). author Software Industry & General Hardware

Parameters:
nxtSeparator - A character value
Returns:
previous string value of the separator

sprintf

public static java.lang.String sprintf(java.lang.String formatString,
                                       java.lang.Object formatValue)
                                throws CsprintfExceptions
This allows a static call with a single object so you can do the following: System.out.println ( Csprintf.sprintf ( "%04x", intObject ) ); author Software Industry & General Hardware

Parameters:
formatString - String containing the c format string
formatValue - An object containing the value to be formated by the c format string.
Returns:
String of the formated value.
Throws:
CsprintfExceptions

sprintf

public static java.lang.String sprintf(java.lang.String formatString,
                                       java.lang.Object formatValue,
                                       java.lang.String groupingString)
                                throws CsprintfExceptions
This allows a static call with a single object so you can do the following: System.out.println ( Csprintf.sprintf ( "%04x", intObject, "." ) ); author Software Industry & General Hardware

Parameters:
formatString - String containing the c format string
formatValue - An object containing the value to be formated by the c format string.
groupingString - The string to be used to separate the formated value into groups. In North America this value defaults to a comma. In Europe it defaults to a period. For example in North America the commas in the string 1,234,567 would be the groupingString. For example in IPv6 2001:0db8:0000:0000:0000:0000:1428:57ab the colon is the groupingString
Returns:
String of the formated value.
Throws:
CsprintfExceptions

sprintf

public static java.lang.String sprintf(java.lang.String formatString,
                                       java.lang.Object formatValue,
                                       java.lang.String groupingString,
                                       int groupingCount)
                                throws CsprintfExceptions
This allows a static call with a single object so you can do the following: System.out.println ( Csprintf.sprintf ( "%04x", intObject, ".", 4 ) ); author Software Industry & General Hardware

Parameters:
formatString - String containing the c format string
formatValue - An object containing the value to be formated by the c format string.
groupingString - The string to be used to separate the formated value into groups. In North America this value defaults to a comma. In Europe it defaults to a period. For example in North America the commas in the string 1,234,567 would be the groupingString. For example in IPv6 2001:0db8:0000:0000:0000:0000:1428:57ab the colon is the groupingString
groupingCount - The count of digits to group together before adding a groupingString. For example in IPv6 2001:0db8:0000:0000:0000:0000:1428:57ab the groupingCount is 4
Returns:
String of the formated value.
Throws:
CsprintfExceptions

sprintf

public static java.lang.String sprintf(java.lang.String formatString,
                                       java.lang.Object formatValue,
                                       int groupingCount)
                                throws CsprintfExceptions
This allows a static call with a single object so you can do the following: System.out.println ( Csprintf.sprintf ( "%04x", intObject, ".", 4 ) ); author Software Industry & General Hardware

Parameters:
formatString - String containing the c format string
formatValue - An object containing the value to be formated by the c format string.
groupingCount - The count of digits to group together before adding a groupingString. For example in IPv6 2001:0db8:0000:0000:0000:0000:1428:57ab the groupingCount is 4
Returns:
String of the formated value.
Throws:
CsprintfExceptions

sprintf

public static java.lang.String sprintf(java.lang.String formatString,
                                       java.lang.Object[] anObject)
                                throws CsprintfExceptions
This allows a static call with an object array so you can do the following: Object[] arrayOfIntObjects = new Object [ 4 ]; arrayOfIntObjects [ 0 ] = valueFound; arrayOfIntObjects [ 1 ] = yearValue; arrayOfIntObjects [ 2 ] = monthValue; arrayOfIntObjects [ 3 ] = dayValue; System.out.println ( Csprintf.sprintf ( "%04x @ %04d-%02d-%02d", arrayOfIntObjects ) ); author Software Industry & General Hardware

Parameters:
formatString -
anObject -
Returns:
String of the formated value.
Throws:
CsprintfExceptions

sprintf

public static java.lang.String sprintf(java.lang.String formatString,
                                       java.lang.Object[] anObject,
                                       java.lang.String groupingSeparator,
                                       int groupingCount)
                                throws CsprintfExceptions
This allows a static call with an object array so you can do the following: Object[] arrayOfIntObjects = new Object [ 4 ]; arrayOfIntObjects [ 0 ] = valueFound; arrayOfIntObjects [ 1 ] = yearValue; arrayOfIntObjects [ 2 ] = monthValue; arrayOfIntObjects [ 3 ] = dayValue; System.out.println ( Csprintf.sprintf ( "%04x @ %04d-%02d-%02d", arrayOfIntObjects, ".", 4 ) ); author Software Industry & General Hardware

Parameters:
formatString -
anObject -
groupingSeparator -
groupingCount -
Returns:
String of the formated value.
Throws:
CsprintfExceptions

sprintf

public static java.lang.String sprintf(java.lang.String formatString,
                                       java.lang.Object[] anObject,
                                       java.lang.String groupingSeparator)
                                throws CsprintfExceptions
This allows a static call with an object array so you can do the following: Object[] arrayOfIntObjects = new Object [ 4 ]; arrayOfIntObjects [ 0 ] = valueFound; arrayOfIntObjects [ 1 ] = yearValue; arrayOfIntObjects [ 2 ] = monthValue; arrayOfIntObjects [ 3 ] = dayValue; System.out.println ( Csprintf.sprintf ( "%04x @ %04d-%02d-%02d", arrayOfIntObjects, "." ) ); author Software Industry & General Hardware

Parameters:
formatString -
anObject -
groupingSeparator -
Returns:
String of the formated value.
Throws:
CsprintfExceptions

sprintf

public static java.lang.String sprintf(java.lang.String formatString,
                                       java.lang.Object[] anObject,
                                       int groupingCount)
                                throws CsprintfExceptions
This allows a static call with an object array so you can do the following: Object[] arrayOfIntObjects = new Object [ 4 ]; arrayOfIntObjects [ 0 ] = valueFound; arrayOfIntObjects [ 1 ] = yearValue; arrayOfIntObjects [ 2 ] = monthValue; arrayOfIntObjects [ 3 ] = dayValue; System.out.println ( Csprintf.sprintf ( "%04x @ %04d-%02d-%02d", arrayOfIntObjects, 4 ) ); author Software Industry & General Hardware

Parameters:
formatString -
anObject -
groupingCount -
Returns:
String of the formated value.
Throws:
CsprintfExceptions

isValidFormatString

public static boolean isValidFormatString(java.lang.String theFormatString)
Checks a format string to see if it is valid and returns true if it is and false if it is not.

Parameters:
theFormatString -
Returns:
boolean true if this is a valid format string else false.

stripSign

public java.lang.String stripSign(java.lang.String theValue2Strip)
stripSign -- Removes a '-' or a '+' from the front of a String representation of a number.

Parameters:
theValue2Strip -
Returns:
String

changeSign

public java.lang.String changeSign(java.lang.String theValue2Inspect)
changeSign --

Parameters:
theValue2Inspect -
Returns:
String

formatUnsignedLong

public java.lang.String formatUnsignedLong(long value)