jET
1.0beta1


prv.doman.util
Class ScaleFormat

java.lang.Object
  |
  +--java.text.Format
        |
        +--prv.doman.util.ScaleFormat
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class ScaleFormat
extends java.text.Format

Number format class for scales.

Typical scale notation is 1:x or x:1. Numbers must be positive.

See Also:
Serialized Form

Constructor Summary
ScaleFormat()
          Creates scale format.
 
Method Summary
 java.lang.String format(double number)
          Formats double value.
 java.lang.StringBuffer format(double number, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
          Formats double value and appends it to string output.
 java.lang.String format(int number)
          Formats integer value.
 java.lang.StringBuffer format(java.lang.Object obj, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
          Formats object supposed to be a number.
 java.lang.String getDelimeter()
          Gets the delimeter.
static ScaleFormat getInstance()
          Gets instance of this class.
 java.lang.Double parse(java.lang.String source, java.text.ParsePosition parsePosition)
          Parses source to find object representing scale.
 java.lang.Object parseObject(java.lang.String source, java.text.ParsePosition parsePosition)
          Parses source to find object representing scale.
 void setDelimeter(java.lang.String newDelimeter)
          Sets the delimeter.
 
Methods inherited from class java.text.Format
clone, format, formatToCharacterIterator, parseObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScaleFormat

public ScaleFormat()
Creates scale format.

Method Detail

getDelimeter

public java.lang.String getDelimeter()
Gets the delimeter.

Returns:
Delimeter.

setDelimeter

public void setDelimeter(java.lang.String newDelimeter)
Sets the delimeter. A default delimeter is :.

Parameters:
newDelimeter - The new delimeter.

getInstance

public static ScaleFormat getInstance()
Gets instance of this class.


format

public java.lang.String format(double number)
Formats double value. Note that value must be positive. Otherwise exception may be thrown.

Parameters:
number - Float number.
Returns:
String output.
Throws:
java.lang.IllegalArgumentException - Thrown when the number isn't positive.

format

public java.lang.String format(int number)
Formats integer value. Note that value must be positive. Otherwise exception may be thrown.

Parameters:
number - Integer number to format.
Returns:
String output.
Throws:
java.lang.IllegalArgumentException - Thrown when the number isn't positive.

format

public java.lang.StringBuffer format(java.lang.Object obj,
                                     java.lang.StringBuffer toAppendTo,
                                     java.text.FieldPosition pos)
Formats object supposed to be a number.

Specified by:
format in class java.text.Format
Parameters:
obj - Object to format.
toAppendTo - String buffer where append output.
pos - Field position (unused).
Returns:
String output.
Throws:
java.lang.IllegalArgumentException - Thrown when the object isn't a number nor the number is positive.

format

public java.lang.StringBuffer format(double number,
                                     java.lang.StringBuffer toAppendTo,
                                     java.text.FieldPosition pos)
Formats double value and appends it to string output.

Parameters:
number - A number to format. Must be positive.
toAppendTo - The string output to append.
pos - Field position (unused).
Returns:
String output appended to string buffer.
Throws:
java.lang.IllegalArgumentException - Thrown when number isn't positive.

parseObject

public java.lang.Object parseObject(java.lang.String source,
                                    java.text.ParsePosition parsePosition)
Parses source to find object representing scale.

Specified by:
parseObject in class java.text.Format
Parameters:
source - String to parse.
parsePosition - Parse position which tracks success or fail parsing.
Returns:
An object (double value).

parse

public java.lang.Double parse(java.lang.String source,
                              java.text.ParsePosition parsePosition)
Parses source to find object representing scale.

Parameters:
source - String to parse.
parsePosition - Parse position which tracks success or fail parsing.
Returns:
A double value wrapped in class.

jET
1.0beta1