|
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||
java.lang.Object | +--com.braju.beta.format.Format
Provides true C-style printf(), scanf() etc functionality with any number of parameters.
This class is all static and there is no reason for making an instance of it.
Example 1 (only Java 1.1 and above)
import com.braju.format.*;
public class Person {
// In Java 1.1 and above we can make use of reflection. To do currPerson you
// have to put your variables in a PUBLIC class and make them PUBLIC.
// Note that they can not be hidden inside a method, they have to be
// attributes.
public String name;
public int age;
public void query() throws Exception {
Format.printf("Enter your full name: ");
// Note that the variable names to FormatReader must be inside quotas,
// i.e. given as a String. The first parameter tells FormatReader in
// which object the variables are located. In this case "this".
Format.scanf(" %[^\n]", new Parameters(this).add("name"));
Format.printf("Enter your age (in years): ");
Format.scanf("%i", new Parameters(this).add("age"));
}
public void display() {
Format.printf("Hello %s, you are %i years old.\n",
new Parameters(name).add(age));
}
public static void main(String args[]) throws Exception {
Person currPerson = new Person();
currPerson.query();
currPerson.display();
}
}
Note that if your program are supposed to run under Java1.0.2
you should use com.braju.format.Format102 instead. It works the similar.
Format102,
FormatInputStream,
FormatOutputStream,
FormatReader,
FormatWriter,
Parameters,
Variable| Field Summary | |
static FormatWriter |
err
Formatted writing to the system standard error stream is available through this FormatWriter [...]. |
static FormatReader |
in
Formatted reading from the system standard input stream is available through this FormatReader [...]. |
static FormatWriter |
out
Formatted writing to the system standard output stream is available through this FormatWriter [...]. |
| Method Summary | |
static int |
fprintf(java.io.Writer out,
FormatString fmtstr,
java.lang.Object[] obj)
Provides direct printf-formatted writing to a Writer with format specified in a String [...]. |
static int |
fprintf(java.io.Writer out,
FormatString fmtstr,
Parameters parameters)
Provides printf-formatted writing to a Writer with format specified by a (precompiled) FormatString [...]. |
static int |
fprintf(java.io.Writer out,
java.lang.String fmt)
Provides direct printf-formatted writing to a Writer with format specified in a String [...]. |
static int |
fprintf(java.io.Writer out,
java.lang.String fmt,
java.lang.Object[] obj)
Provides direct printf-formatted writing to a Writer with format specified in a String [...]. |
static int |
fprintf(java.io.Writer out,
java.lang.String fmt,
Parameters parameters)
Provides direct printf-formatted writing to a Writer with format specified in a String [...]. |
static int |
fscanf(FormatReader in,
FormatString fmtstr,
Parameters parameters)
Provides scanf-formatted reading from a Reader with format specified by a (precompiled) FormatString [...]. |
static int |
fscanf(FormatReader in,
java.lang.String fmt,
Parameters parameters)
Provides direct scanf-formatted reading from a Reader with format specified by a String [...]. |
java.lang.Exception |
getInternalException()
|
static java.lang.String |
getVersion()
|
static void |
main(java.lang.String[] args)
This is the command line version of Java printf. |
static int |
printf(FormatString fmtstr,
java.lang.Object[] obj)
Provides printf-formatted writing to the system standard output stream with format specified by a (precompiled) FormatString [...]. |
static int |
printf(FormatString fmtstr,
Parameters parameters)
Provides printf-formatted writing to the system standard output stream with format specified by a (precompiled) FormatString [...]. |
static int |
printf(java.lang.Object o)
Provides direct printf-formatted writing the specified Object to the system standard output using the toString()-method of the Object [...]. |
static int |
printf(java.lang.String s)
Provides direct printf-formatted writing the specified String to the system standard output [...]. |
static int |
printf(java.lang.String fmt,
java.lang.Object[] obj)
Provides direct printf-formatted writing to the system standard output stream with format specified in a String [...]. |
static int |
printf(java.lang.String fmt,
Parameters parameters)
Provides direct printf-formatted writing to the system standard output stream with format specified in a String [...]. |
static int |
scanf(FormatString fmtstr,
Parameters parameters)
Provides scanf-formatted reading from the system standard input stream with format specified by a (precompiled) FormatString [...]. |
static int |
scanf(java.lang.String fmt)
Provides direct scanf-formatted reading from the system standard input stream with format specified by a String [...]. |
static int |
scanf(java.lang.String fmt,
Parameters parameters)
Provides direct scanf-formatted reading from the system standard input stream with format specified by a String [...]. |
static java.lang.String |
sprintf(FormatString fmtstr,
java.lang.Object[] obj)
Provides printf-formatted writing to a String with format specified by a (precompiled) FormatString. |
static java.lang.String |
sprintf(FormatString fmtstr,
Parameters parameters)
Provides printf-formatted writing to a String with format specified by a (precompiled) FormatString [...]. |
static java.lang.String |
sprintf(java.lang.String fmt,
java.lang.Object[] obj)
Provides direct printf-formatted writing to a String with format specified in a String [...]. |
static java.lang.String |
sprintf(java.lang.String fmt,
Parameters parameters)
Provides direct printf-formatted writing to a String with format specified in a String [...]. |
static int |
sscanf(java.lang.String source,
FormatString fmtstr,
Parameters parameters)
Provides scanf-formatted reading of a String with format specified by a (precompiled) FormatString [...]. |
static int |
sscanf(java.lang.String source,
java.lang.String fmt,
Parameters parameters)
Provides direct scanf-formatted reading of a String with format specified by a String [...]. |
void |
throwInternalException()
|
static void |
version()
Print, on standard output, information about this class. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static FormatReader in
public static FormatWriter out
public static FormatWriter err
| Method Detail |
public java.lang.Exception getInternalException()
public void throwInternalException()
throws java.lang.Exception
public static int fprintf(java.io.Writer out,
FormatString fmtstr,
Parameters parameters)
public static int fprintf(java.io.Writer out,
java.lang.String fmt,
Parameters parameters)
public static int fprintf(java.io.Writer out,
FormatString fmtstr,
java.lang.Object[] obj)
public static int fprintf(java.io.Writer out,
java.lang.String fmt,
java.lang.Object[] obj)
public static int fprintf(java.io.Writer out,
java.lang.String fmt)
public static int printf(FormatString fmtstr,
Parameters parameters)
public static int printf(java.lang.String fmt,
Parameters parameters)
public static int printf(FormatString fmtstr,
java.lang.Object[] obj)
public static int printf(java.lang.String fmt,
java.lang.Object[] obj)
public static int printf(java.lang.String s)
public static int printf(java.lang.Object o)
public static java.lang.String sprintf(FormatString fmtstr,
Parameters parameters)
public static java.lang.String sprintf(java.lang.String fmt,
Parameters parameters)
public static java.lang.String sprintf(FormatString fmtstr,
java.lang.Object[] obj)
public static java.lang.String sprintf(java.lang.String fmt,
java.lang.Object[] obj)
public static int fscanf(FormatReader in,
FormatString fmtstr,
Parameters parameters)
throws ParseException,
java.io.IOException,
java.lang.NoSuchFieldException,
java.lang.IllegalAccessException
public static int fscanf(FormatReader in,
java.lang.String fmt,
Parameters parameters)
throws ParseException,
java.io.IOException,
java.lang.NoSuchFieldException,
java.lang.IllegalAccessException
public static int scanf(FormatString fmtstr,
Parameters parameters)
public static int scanf(java.lang.String fmt,
Parameters parameters)
public static int scanf(java.lang.String fmt)
public static int sscanf(java.lang.String source,
FormatString fmtstr,
Parameters parameters)
public static int sscanf(java.lang.String source,
java.lang.String fmt,
Parameters parameters)
public static java.lang.String getVersion()
public static void version()
public static void main(java.lang.String[] args)
throws java.lang.Exception
| -help | Print this message. |
| -printf | Using the next argument (fmtstr) as the format string and one or more optional parameters (param) as values to be formatted by the printf method. |
| -version | Print version information. |
|
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||