braju.com
Java printf & scanf (beta)

com.braju.beta.format
Class Parameters

java.lang.Object
  |
  +--com.braju.beta.format.Parameters

public class Parameters
extends java.lang.Object

Provides arbitrary number of parameters of any type to any method [JDK1.0.2 compatible].

This class was written to be used for methods such as printf and scanf, but it probably useful in other situations as well.
If you would like to have arbitrary number of parameters in a method call your method should look like

  public void foo(int bar, String woo, Parameters parameters) {
    // Reach the parameters by the toVector()-method.
    Vector params = parameters.toVector();
    // In the Vector they exists in a natural order.
    Object currParam;
    for (int i=0; i
To make a call to this method you do like this
  foo(13, "doda", new Parameters(12).add("my world").add(43.22)) {
There is no way to do type checking in-prior to execution, i.e. no type-checking is performed during compilation. Be aware of this!

See Also:
Format, Format102, FormatInputStream,

Constructor Summary
Parameters()
          Creates an empty parameter list with auto-reset turned on by default [...].
Parameters(boolean b)
          Creates a parameter list with the given boolean inserted [...].
Parameters(byte b)
          Creates a parameter list with the given byte inserted [...].
Parameters(char ch)
          Creates a parameter list with the given char inserted [...].
Parameters(double d)
          Creates a parameter list with the given double inserted [...].
Parameters(float f)
          Creates a parameter list with the given float inserted [...].
Parameters(int i)
          Creates a parameter list with the given integer inserted [...].
Parameters(long l)
          Creates a parameter list with the given long inserted [...].
Parameters(java.lang.Object obj)
          Creates a parameter list with the given object inserted [...].
Parameters(short sh)
          Creates a parameter list with the given short inserted [...].
Parameters(java.lang.String s)
          Creates a parameter list with the given string inserted [...].
Parameters(java.util.Vector vector)
          Creates a parameter list from a java.util,Vector [...].
 
Method Summary
 Parameters add(boolean b)
          Add a boolean to the list [...].
 Parameters add(byte b)
          Add an byte to the list [...].
 Parameters add(char ch)
          Add a char to the list [...].
 Parameters add(double d)
          Add a double to the list [...].
 Parameters add(float f)
          Add a float to the list [...].
 Parameters add(int i)
          Add an integer to the list [...].
 Parameters add(long l)
          Add a long to the list [...].
 Parameters add(java.lang.Object obj)
          Add an object to the list [...].
 Parameters add(short sh)
          Add an short to the list [...].
 Parameters add(java.lang.String s)
          Add a string to the list [...].
 Parameters autoClear(boolean clear)
          Set or unset auto reset.
 Parameters autoReset(boolean status)
          Set or unset auto reset.
 Parameters clear()
          Remove all parameters from the list [...].
 boolean isAutoClear()
          Checks if there is a ParameterAutoClear object at the first position [used internally by methods with arbitrary number of parameters] [...].
 boolean isAutoReset()
          Checks if auto reset is set or not [used internally by methods with arbitrary number of parameters] [...].
 Parameters mark()
          Put a mark at the current position the the list of parameters [...].
 Parameters reset()
          Reset the list of parameters, i.e.
 int size()
          Return the number of parameters in this object [used internally by methods with arbitrary number of parameters] [...].
 java.lang.String toDebugString()
          Remove all parameters from the list [...].
 java.util.Vector toVector()
          Return the list of parameters as a java.util,Vector [used internally by methods with arbitrary number of parameters] [...].
 Parameters unmark()
          If there exists a mark it will be removed, otherwise nothing happens.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Parameters

public Parameters()
Creates an empty parameter list with auto-reset turned on by default [...]. Auto reset is turned on by default.

Parameters

public Parameters(boolean b)
Creates a parameter list with the given boolean inserted [...]. The boolean is wrapped in a Boolean object. Auto reset is turned on by default.

Parameters

public Parameters(char ch)
Creates a parameter list with the given char inserted [...]. The char is wrapped in a Character object. Auto reset is turned on by default.

Parameters

public Parameters(byte b)
Creates a parameter list with the given byte inserted [...]. The byte is wrapped in a Byte object. Auto reset is turned on by default. Note: Not in the Java 1.0.2 version the wrapper class is com.braju.format.Byte.

Parameters

public Parameters(short sh)
Creates a parameter list with the given short inserted [...]. The short is wrapped in a Short object. Auto reset is turned on by default. Note: Not in the Java 1.0.2 version the wrapper class is com.braju.format.Short.

Parameters

public Parameters(int i)
Creates a parameter list with the given integer inserted [...]. The integer is wrapped in a Integer object. Auto reset is turned on by default.

Parameters

public Parameters(long l)
Creates a parameter list with the given long inserted [...]. The long is wrapped in a Long object. Auto reset is turned on by default.

Parameters

public Parameters(float f)
Creates a parameter list with the given float inserted [...]. The float is wrapped in a Float object. Auto reset is turned on by default.

Parameters

public Parameters(double d)
Creates a parameter list with the given double inserted [...]. The double is wrapped in a Double object. Auto reset is turned on by default.

Parameters

public Parameters(java.lang.String s)
Creates a parameter list with the given string inserted [...]. Auto reset is turned on by default.

Parameters

public Parameters(java.lang.Object obj)
Creates a parameter list with the given object inserted [...]. Auto reset is turned on by default.

Parameters

public Parameters(java.util.Vector vector)
Creates a parameter list from a java.util,Vector [...]. Very rarely needed.
Method Detail

size

public int size()
Return the number of parameters in this object [used internally by methods with arbitrary number of parameters] [...].
Returns:
the number of parameters in this object.

mark

public Parameters mark()
Put a mark at the current position the the list of parameters [...]. When printf() and scanf() reset the parameter list after usage all the variables before the mark will remain.
Returns:
A reference to the object itself.

unmark

public Parameters unmark()
If there exists a mark it will be removed, otherwise nothing happens.
Returns:
A reference to the object itself.

reset

public Parameters reset()
Reset the list of parameters, i.e. remove all added parameters and if a mark is set only the parameters after the mark will be removed [...]. Also, if an ParameterAutoClear object exists it is kept. [used internally by methods with arbitrary number of parameters]
Returns:
A reference to the object itself.

toVector

public java.util.Vector toVector()
Return the list of parameters as a java.util,Vector [used internally by methods with arbitrary number of parameters] [...].

add

public Parameters add(boolean b)
Add a boolean to the list [...]. The boolean is wrapped in a Boolean object.
Returns:
A reference to the object itself.

add

public Parameters add(char ch)
Add a char to the list [...]. The char is wrapped in a Character object.
Returns:
A reference to the object itself.

add

public Parameters add(byte b)
Add an byte to the list [...]. The byte is wrapped in a Byte object.
Note: Not in the Java 1.0.2 version the wrapper class is com.braju.lang.Byte.
Returns:
A reference to the object itself.

add

public Parameters add(short sh)
Add an short to the list [...]. The short is wrapped in a Short object.
Note: Not in the Java 1.0.2 version the wrapper class is com.braju.lang.Short.
Returns:
A reference to the object itself.

add

public Parameters add(int i)
Add an integer to the list [...]. The integer is wrapped in a Integer object.
Returns:
A reference to the object itself.

add

public Parameters add(long l)
Add a long to the list [...]. The long is wrapped in a Long object.
Returns:
A reference to the object itself.

add

public Parameters add(float f)
Add a float to the list [...]. The float is wrapped in a Float object.
Returns:
A reference to the object itself.

add

public Parameters add(double d)
Add a double to the list [...]. The double is wrapped in a Double object.
Returns:
A reference to the object itself.

add

public Parameters add(java.lang.String s)
Add a string to the list [...].
Returns:
A reference to the object itself.

add

public Parameters add(java.lang.Object obj)
Add an object to the list [...].
Returns:
A reference to the object itself.

autoClear

public Parameters autoClear(boolean clear)
Set or unset auto reset.
Returns:
A reference to the object itself.

isAutoClear

public boolean isAutoClear()
Checks if there is a ParameterAutoClear object at the first position [used internally by methods with arbitrary number of parameters] [...].
Returns:
True if a ParameterAutoClear object exists, otherwise false.

autoReset

public Parameters autoReset(boolean status)
Set or unset auto reset.
Returns:
A reference to the object itself.

isAutoReset

public boolean isAutoReset()
Checks if auto reset is set or not [used internally by methods with arbitrary number of parameters] [...].
Returns:
True if a auto reset, otherwise false.

clear

public Parameters clear()
Remove all parameters from the list [...]. [used internally by methods with arbitrary number of parameters]
Returns:
A reference to the object itself.

toDebugString

public java.lang.String toDebugString()
Remove all parameters from the list [...]. If an ParameterAutoClear object exists it is keept.
Returns:
A reference to the object itself.

braju.com
Java printf & scanf (beta)

Copyright 1997-2000, Henrik Bengtsson.