Method of formatting values in a fixed number of spaces...

Data processing: database and file management or data structures – Database design – Data structure types

Reexamination Certificate

Rate now

  [ 0.00 ] – not rated yet Voters 0   Comments 0

Details

C707S793000, C707S793000, C707S793000, C717S114000, C717S118000, C715S252000, C715S252000, C715S252000

Reexamination Certificate

active

06708177

ABSTRACT:

FIELD OF THE INVENTION
The present invention relates generally to a method and apparatus of formatting values; and more particularly, to such a method and apparatus using the Java programming language. Still more particularly, the present invention relates to a method and apparatus to format values in a fixed number of spaces having leading or trailing characters using the Java programming language.
BACKGROUND ART
Java is a programming language designed to generate applications capable of executing on all hardware platforms without modification. Java was originally developed in 1991 by Sun Microsystems, Inc. as a language for embedded applications. Java is an interpreted language wherein the source code is compiled into an intermediate language called bytecode. The bytecode is converted or interpreted into machine code at runtime. Thus, Java programs are not dependent on any specific hardware and run in any computer having a Java virtual machine. The Java programming language includes similar functionality of other programming languages, e.g., C or C++; however, Java does not provide a method to print out formatted lines, e.g., if a programmer wants to print out a table of numbers with several columns with each column of numbers lining up. Currently, this only works if each number uses the same number of columns. If the numbers use differing numbers of columns, the columns of numbers will not line up. For example, the number “3” uses a single column; however, the number “1234” requires four columns. This leads to inconsistent and unpleasant formatting of output, as in Column A of Listing 1 below.
Column A
Column B
12345
12345
2345
02345
345
00345
45
00045
5
00005
Column B is a formatted output of numeric values wherein the numeric values occupy the same number of digits or spaces, i.e., five spaces in this example. It is important to note that the values in column B which are less than five digits long are padded with zeroes to make them equal lengths.
It is known in the art to use a format string in the C programming language to obtain the above-described format and functionality. For example, to print out a number using five spaces or columns with leading zeroes using the C programming language, a programmer would use the formatting string, “%05d”, resulting in the output as shown in Column B of Listing 1. Unfortunately, the present inventor is unaware of any method in the Java programming language for obtaining such functionality using already existing formatting statements. In the context of this document, method and function are used interchangeably.
Instead, to obtain such functionality other approaches have been used including using a series of nested if statements or a looping mechanism; however, these methods are more time consuming, i.e., more processing time is required. The other approaches require a variable amount of time depending on the implementation.
A pseudo code-based example of using nested if statements is shown in Listing 2 below.
If (number=0)
Print 6 zeroes
Else if (number<10)
Print 5 zeroes
Else if (number<100)
Print 4 zeroes
. . .
Listing 2
With respect to Listing 2, “number” is a variable storing the numerical value of the number to be formatted. Listing 2 operates to format the printed version of a numeric value to use a total of six digits or columns, e.g., a value of 55 is to be formatted as 000055 and a value of 5 as 000005. Each pseudo code if statement tests the size of the value of the number in order to format the printed output. For example, if the number is less than the value ten, then only five zeroes need to precede the number in an output to format it as a six digit value because the number is only a single digit, or column, wide. As shown in Listing 2, for small numbers, i.e., numbers having few digits, only a small portion of the if statements are executed. However, for larger numbers, it is possible that each of the if statements may need to be executed to properly format the output. This is problematic as it requires a variable amount of processing time.
Use of a looping mechanism is similarly flawed requiring an unknown amount of processing to format a number. In using a loop structure, the number of zeroes to precede the number is determined by subtracting the size in characters of the number to be printed from the number of columns or digits desired in the formatted output. A loop would then be executed a number of iterations equal to the number of zeroes determined and during each pass through the loop the character “0” is added to a target string. Once the loop completes execution, the original number, as a character, is appended to the target string, as well.
A pseudo code-based example of using a loop is shown in Listing 3 below.
Num_of_zeroes=num_of_cols_to_use−size_(in_chars)_of_num_to_print
Loop for Num_of_zeroes iterations copying a “0” char to a target_string
Append num_to_print to target_string . . .
Listing 3
Num_of_zeroes is a variable containing a numeric value representing the number of zeroes to be output before the number to be printed. Num_of_cols_to_use is a variable containing a numeric value representing the number of output columns to be used by the formatted number. Size_(in_chars)_of_num_to_print is the character-based size of the numeric value to be printed or output. Target string is a string storing the formatted output number. As with the nested if statements approach described above, a variable amount of processing time is required to execute the loop-based formatting approach. Therefore, there is a need in the art for a method of printing formatted lines using the Java language requiring a predetermined amount of processing time.
Another approach has been to use or “callout” a separate function or library programmed in a different language, e.g., the C programming language, to execute the formatting statement, i.e., the C format “%05d” statement described above. However, because there is a large amount of overhead or additional processing required to setup and perform such a callout in the Java language, there is a large performance and resource penalty. It is known to be very inefficient to callout to a separate function or library from within Java in comparison to performing the same function in Java. Thus, there is a need in the art for a Java-based formatting function requiring minimal additional processing overhead.
When resources, e.g., processor time and memory, are constrained, it is important to minimize the resource requirements. For example, in a web site or web server environment, the resources used to format printing reduces the resources available for serving customers or traffic to a web site. This means it is important to reduce the resource usage of the formatting function.
DISCLOSURE/SUMMARY OF THE INVENTION
It is therefore an object of the present invention to provide a method of printing formatted lines using the Java language requiring a predetermined amount of processing time.
Another object of the present invention is to provide a Java-based formatting function requiring minimal additional processing overhead.
The above described objects are fulfilled by a computer implemented method of and apparatus for printing values in a fixed number of column spaces using Java. A value desired to be formatted to a predetermined length string and an indexed lookup table having predetermined formatted string entries are used. An index based on the number of characters needed to represent the value is calculated and then used to locate a desired length formatted string entry in the lookup table. The desired length formatted string entry is then combined with a string representation of the value to form a predetermined length string.
A computer implemented Java-based method aspect of formatting a value to a predetermined length string uses a lookup table. An index is calculated based on the number of characters required to represent the value. A desired length formatted string is obtained from the lookup table using the index. The desired length formatted s

LandOfFree

Say what you really think

Search LandOfFree.com for the USA inventors and patents. Rate them and share your experience with other people.

Rating

Method of formatting values in a fixed number of spaces... does not yet have a rating. At this time, there are no reviews or comments for this patent.

If you have personal experience with Method of formatting values in a fixed number of spaces..., we encourage you to share that experience with our LandOfFree.com community. Your opinion is very important and Method of formatting values in a fixed number of spaces... will most certainly appreciate the feedback.

Rate now

     

Profile ID: LFUS-PAI-O-3278716

  Search
All data on this website is collected from public sources. Our data reflects the most accurate information available at the time of publication.