|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.text.Format org.geotools.measure.AngleFormat
Parse and format angle according a specified pattern. The pattern is a string containing any characters, with a special meaning for the following characters:
The integer part of degrees The fractional part of degrees The integer part of minutes The fractional part of minutes The integer part of seconds The fractional part of seconds The decimal separator
M'D
" is illegal because "M" and "S" are inverted; "D?S
" is
illegal too because there is no "M" between "D" and "S"). Lower-case letters ,
and are for fractional parts of degrees, minutes and seconds
respectively. Only one of those may appears in a pattern, and it must be the last special
symbol (e.g. "D.dd?MM'
" is illegal because "d" is followed by "M";
"" is illegal because "m" is not the fractional part of "D").
?
,
'
and "
and inserted "as-is" in the formatted string (except the
decimal separator dot (""), which is replaced by the local-dependent decimal
separator). Separator characters may be completely omitted; will
still differentiate degrees, minutes and seconds fields according the pattern. For example,
"" with the pattern "" will be parsed as 48?04.39'.
Pattern Example DD?MM'SS"
48?30'00" DD?MM'
48?30' 48.500 4830 483000
Angle
,
Latitude
,
Longitude
,
Serialized FormNested Class Summary |
Nested classes inherited from class java.text.Format |
java.text.Format.Field |
Field Summary | |
static int |
DEGREES_FIELD
Constant for degrees field. |
static int |
HEMISPHERE_FIELD
Constant for hemisphere field. |
static int |
MINUTES_FIELD
Constant for minutes field. |
static int |
SECONDS_FIELD
Constant for seconds field. |
Constructor Summary | |
AngleFormat()
Construct a new using the current default locale and a default pattern. |
|
AngleFormat(java.lang.String pattern)
Construct a new using the current default locale and the specified pattern. |
|
AngleFormat(java.lang.String pattern,
java.text.DecimalFormatSymbols symbols)
Construct a new using the specified pattern and decimal symbols. |
|
AngleFormat(java.lang.String pattern,
java.util.Locale locale)
Construct a new using the specified pattern and locale. |
Method Summary | |
void |
applyPattern(java.lang.String pattern)
Set the pattern to use for parsing and formatting angle. |
boolean |
equals(java.lang.Object obj)
Compare this format with the specified object for equality. |
java.lang.String |
format(double angle)
Format an angle. |
java.lang.StringBuffer |
format(double angle,
java.lang.StringBuffer toAppendTo,
java.text.FieldPosition pos)
Formats an angle and appends the resulting text to a given string buffer. |
java.lang.StringBuffer |
format(java.lang.Object obj,
java.lang.StringBuffer toAppendTo,
java.text.FieldPosition pos)
Formats an angle, a latitude or a longitude and appends the resulting text to a given string buffer. |
static AngleFormat |
getInstance(java.util.Locale locale)
Construct a new for the specified locale. |
int |
hashCode()
Returns a "hash value" for this object. |
Angle |
parse(java.lang.String source)
Parse a string as an angle. |
Angle |
parse(java.lang.String source,
java.text.ParsePosition pos)
Parse a string as an angle. |
java.lang.Object |
parseObject(java.lang.String source)
Parse a string as an object. |
java.lang.Object |
parseObject(java.lang.String source,
java.text.ParsePosition pos)
Parse a substring as an angle. |
java.lang.String |
toPattern()
Returns the pattern used for parsing and formatting angles. |
java.lang.String |
toString()
Returns a string representation of this object. |
Methods inherited from class java.text.Format |
clone, format, formatToCharacterIterator |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int DEGREES_FIELD
FieldPosition
constructor in order to
get the bounding index where degrees have been written.
public static final int MINUTES_FIELD
FieldPosition
constructor in order to
get the bounding index where minutes have been written.
public static final int SECONDS_FIELD
FieldPosition
constructor in order to
get the bounding index where seconds have been written.
public static final int HEMISPHERE_FIELD
FieldPosition
constructor in order to
get the bounding index where the hemisphere synbol has been written.
Constructor Detail |
public AngleFormat()
public AngleFormat(java.lang.String pattern) throws java.lang.IllegalArgumentException
pattern
- Pattern to use for parsing and formatting angle.
See class description for an explanation of how this pattern work.
java.lang.IllegalArgumentException
- If the specified pattern is not legal.public AngleFormat(java.lang.String pattern, java.util.Locale locale) throws java.lang.IllegalArgumentException
pattern
- Pattern to use for parsing and formatting angle.
See class description for an explanation of how this pattern work.locale
- Locale to use.
java.lang.IllegalArgumentException
- If the specified pattern is not legal.public AngleFormat(java.lang.String pattern, java.text.DecimalFormatSymbols symbols)
pattern
- Pattern to use for parsing and formatting angle.
See class description for an explanation of how this pattern work.symbols
- The symbols to use for parsing and formatting numbers.
java.lang.IllegalArgumentException
- If the specified pattern is not legal.Method Detail |
public static AngleFormat getInstance(java.util.Locale locale)
public void applyPattern(java.lang.String pattern) throws java.lang.IllegalArgumentException
pattern
- Pattern to use for parsing and formatting angle.
java.lang.IllegalArgumentException
- If the specified pattern is not legal.public java.lang.String toPattern()
public final java.lang.String format(double angle)
applyPattern(java.lang.String)
.
angle
- Angle to format, in degrees.
public java.lang.StringBuffer format(double angle, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos)
applyPattern(java.lang.String)
.
angle
- Angle to format, in degrees.toAppendTo
- Where the text is to be appended.pos
- An optional FieldPosition
identifying a field
in the formatted text, or if this
information is not wanted. This field position shall
be constructed with one of the following constants:
DEGREES_FIELD
,
MINUTES_FIELD
,
SECONDS_FIELD
or
HEMISPHERE_FIELD
.
public java.lang.StringBuffer format(java.lang.Object obj, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos) throws java.lang.IllegalArgumentException
applyPattern(java.lang.String)
. The argument
shall be an Angle
object or one of its derived class (Latitude
,
Longitude
). If is a Latitude
object, then a
symbol "N" or "S" will be appended to the end of the string (the symbol will
be choosen according the angle's sign). Otherwise, if is a
Longitude
object, then a symbol "E" or "W" will be appended to the
end of the string. Otherwise, no hemisphere symbol will be appended.
Number
objects. This capability is provided
only as a convenient way to format altitude numbers together
with longitude and latitude angles.
obj
- Angle
or Number
object to format.toAppendTo
- Where the text is to be appended.pos
- An optional FieldPosition
identifying a field
in the formatted text, or if this
information is not wanted. This field position shall
be constructed with one of the following constants:
DEGREES_FIELD
,
MINUTES_FIELD
,
SECONDS_FIELD
or
HEMISPHERE_FIELD
.
java.lang.IllegalArgumentException
- if if not an object
of class Angle
or Number
.public Angle parse(java.lang.String source, java.text.ParsePosition pos)
48?12.34'
" even if the expected
pattern was "" (i.e. the string should have been
""). Spaces between degrees, minutes and secondes
are ignored. If the string ends with an hemisphere symbol "N" or "S",
then this method returns an object of class Latitude
. Otherwise,
if the string ends with an hemisphere symbol "E" or "W", then this method
returns an object of class Longitude
. Otherwise, this method
returns an object of class Angle
.
source
- A String whose beginning should be parsed.pos
- Position where to start parsing.
Angle
, Latitude
or Longitude
object.public Angle parse(java.lang.String source) throws java.text.ParseException
source
- The string to parse.
Angle
, Latitude
or Longitude
object.
java.text.ParseException
- if the string has not been fully parsed.public java.lang.Object parseObject(java.lang.String source, java.text.ParsePosition pos)
parse(String, ParsePosition)
.
source
- A String whose beginning should be parsed.pos
- Position where to start parsing.
Angle
,
Latitude
or Longitude
object.public java.lang.Object parseObject(java.lang.String source) throws java.text.ParseException
parse(String)
.
source
- The string to parse.
Angle
, Latitude
or
Longitude
object.
java.text.ParseException
- if the string has not been fully parsed.public int hashCode()
public boolean equals(java.lang.Object obj)
public java.lang.String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |