braju.com
Java printf & scanf (beta)

com.braju.beta.lang
Class StringVariable

java.lang.Object
  |
  +--com.braju.beta.lang.StringVariable
All Implemented Interfaces:
Variable

public final class StringVariable
extends java.lang.Object
implements Variable

Wraps a String and provides methods to format the contents [JDK1.0.2 compatible].


Field Summary
static int ALIGN_CENTER
          When formatting a string to a specified minimum width, this constant says that the result should be aligned to the center.
static int ALIGN_LEFT
          When formatting a string to a specified minimum width, this constant says that the result should be aligned to the left.
static int ALIGN_RIGHT
          When formatting a string to a specified minimum width, this constant says that the result should be aligned to the right.
static int NO_FLAGS
          When formatting a string to a specified minimum width, this constant says that the default format should be used [...].
static java.lang.Class TYPE
          The class of this static object [...].
 
Constructor Summary
StringVariable()
           
StringVariable(java.lang.String s)
          Wraps a string into an object just like java.lang.String does, but provides some additional methods.
 
Method Summary
 char charAt(int index)
           
 boolean equals(java.lang.Object o)
           
 java.lang.Object get()
           
static void main(java.lang.String[] args)
           
static StringVariable[] newArray(int length)
          Creates an array of length instance of this class.
 void set(java.lang.Object o)
           
 void set(java.lang.String s)
          Set a new value (String) [...].
static java.lang.String toPaddedString(java.lang.String s, int minWidth, char leftPad, char rightPad, int flags)
          With this method you can align a string to the left, to the right or towards the center with space or ANY other character inserted to the left and to the right of the original string.
 java.lang.String toString()
           
static java.lang.String toString(java.lang.String s)
          Create a String object from another String [...].
static java.lang.String toString(java.lang.String s, int minWidth, int flags)
          Create a new String with specified minimum width and alignment according to the flags-parameter [...].
static java.lang.String toUTFString(java.lang.String s)
          Convert a String into a new String in UTF-format.
static java.lang.String toUTFString(java.lang.String s, int minWidth, int flags)
          Create a new String (in UTF-format) with specified minimum width and alignment according to the flags-parameter [...].
 java.lang.String trim()
           
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_FLAGS

public static final int NO_FLAGS
When formatting a string to a specified minimum width, this constant says that the default format should be used [...]. See also ALIGN_LEFT, ALIGN_CENTER and ALIGN_RIGHT.

ALIGN_LEFT

public static final int ALIGN_LEFT
When formatting a string to a specified minimum width, this constant says that the result should be aligned to the left.

ALIGN_CENTER

public static final int ALIGN_CENTER
When formatting a string to a specified minimum width, this constant says that the result should be aligned to the center.

ALIGN_RIGHT

public static final int ALIGN_RIGHT
When formatting a string to a specified minimum width, this constant says that the result should be aligned to the right.

TYPE

public static final java.lang.Class TYPE
The class of this static object [...]. Provides a convenient way to check or compare the type.
Constructor Detail

StringVariable

public StringVariable()

StringVariable

public StringVariable(java.lang.String s)
Wraps a string into an object just like java.lang.String does, but provides some additional methods.
Method Detail

newArray

public static StringVariable[] newArray(int length)
Creates an array of length instance of this class.

set

public void set(java.lang.String s)
Set a new value (String) [...]. This is better than creating a new object all the time.

set

public void set(java.lang.Object o)
Specified by:
set in interface Variable

get

public java.lang.Object get()
Specified by:
get in interface Variable

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

charAt

public char charAt(int index)

trim

public java.lang.String trim()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toString

public static java.lang.String toString(java.lang.String s)
Create a String object from another String [...]. This method exists to make it consistent with other classes in com.braju.lang.

toString

public static java.lang.String toString(java.lang.String s,
                                        int minWidth,
                                        int flags)
Create a new String with specified minimum width and alignment according to the flags-parameter [...]. Provides an easy way to align a string to the left, the right och to the center. If flags is given the value NO_FLAGS then the string is aligned to the left.

toUTFString

public static java.lang.String toUTFString(java.lang.String s)
Convert a String into a new String in UTF-format.

toUTFString

public static java.lang.String toUTFString(java.lang.String s,
                                           int minWidth,
                                           int flags)
Create a new String (in UTF-format) with specified minimum width and alignment according to the flags-parameter [...]. Provides an easy way to align a string to the left, the right och to the center. If flags is given the value NO_FLAGS then the string is aligned to the left.

toPaddedString

public static java.lang.String toPaddedString(java.lang.String s,
                                              int minWidth,
                                              char leftPad,
                                              char rightPad,
                                              int flags)
With this method you can align a string to the left, to the right or towards the center with space or ANY other character inserted to the left and to the right of the original string.

main

public static void main(java.lang.String[] args)

braju.com
Java printf & scanf (beta)

Copyright 1997-2000, Henrik Bengtsson.