FileDocCategorySizeDatePackage
Format.javaAPI DocApache Lucene 2.2.03656Sat Jun 16 22:20:58 BST 2007org.apache.lucene.benchmark.byTask.utils

Format

public class Format extends Object
Formatting utilities (for reports).

Fields Summary
private static NumberFormat[]
numFormat
private static final String
padd
Constructors Summary
Methods Summary
public static java.lang.Stringformat(int numFracDigits, float f, java.lang.String col)
Padd a number from left.

param
numFracDigits number of digits in fraction part - must be 0 or 1 or 2.
param
f number to be formatted.
param
col column name (used for deciding on length).
return
formatted string.

  
   
    numFormat[0].setMaximumFractionDigits(0);
    numFormat[0].setMinimumFractionDigits(0);
    numFormat[1].setMaximumFractionDigits(1);
    numFormat[1].setMinimumFractionDigits(1);
    numFormat[2].setMaximumFractionDigits(2);
    numFormat[2].setMinimumFractionDigits(2);
  
    String res = padd + numFormat[numFracDigits].format(f);
    return res.substring(res.length() - col.length());
  
public static java.lang.Stringformat(int n, java.lang.String col)
Padd a number from left.

param
n number to be formatted.
param
col column name (used for deciding on length).
return
formatted string.

    String res = padd + n;
    return res.substring(res.length() - col.length());
  
public static java.lang.Stringformat(java.lang.String s, java.lang.String col)
Padd a string from right.

param
s string to be formatted.
param
col column name (used for deciding on length).
return
formatted string.

    return (s + padd).substring(0, col.length());
  
public static java.lang.StringformatPaddLeft(java.lang.String s, java.lang.String col)
Padd a string from left.

param
s string to be formatted.
param
col column name (used for deciding on length).
return
formatted string.

    String res = padd + s;
    return res.substring(res.length() - col.length());
  
public static java.lang.StringformatPaddRight(int numFracDigits, float f, java.lang.String col)
Padd a number from right.

param
numFracDigits number of digits in fraction part - must be 0 or 1 or 2.
param
f number to be formatted.
param
col column name (used for deciding on length).
return
formatted string.

    String res = numFormat[numFracDigits].format(f) + padd;
    return res.substring(0, col.length());
  
public static java.lang.StringsimpleName(java.lang.Class cls)
Extract simple class name

param
cls class whose simple name is required
return
simple class name

    String c = cls.getName();
    String p = cls.getPackage().getName();
    int k = c.lastIndexOf(p+".");
    if (k<0) {
      return c;
    }
    return c.substring(k+1+p.length());