|
deegree 2.1 (2007/11/08 09:57 build-328-official) | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.text.Format
org.deegree.model.csct.pt.AngleFormat
public class 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:
D
The integer part of degrees d
The fractional part of degrees M
The integer part of minutes m
The fractional part of minutes S
The integer part of seconds s
The fractional part of seconds .
The decimal separator
D
, M
and S
are for the integer
parts of degrees, minutes and seconds respectively. They must appear in this order (e.g.
"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 d
,
m
and s
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";
"D.mm
" is illegal because "m" is not the fractional part of "D").
D
, M
, S
and their
lower-case counterpart is the number of digits to format. For example, "DD.ddd" will
format angle with two digits for the integer part and three digits for the fractional
part (e.g. 4.4578 will be formatted as "04.458"). Separator characters like �
,
'
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; AngleFormat
will
still differentiate degrees, minutes and seconds fields according the pattern. For example,
"0480439
" with the pattern "DDDMMmm
" will be parsed as 48�04.39'.
Pattern Example DD�MM'SS"
48�30'00" DD�MM'
48�30' DD.ddd
48.500 DDMM
4830 DDMMSS
483000
Angle
,
Latitude
,
Longitude
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from class java.text.Format |
---|
Format.Field |
Field Summary | |
---|---|
(package private) static int |
ALTITUDE
Constante indique que le nombre � formater est une altitude. |
static int |
DEGREES_FIELD
Constant for degrees field. |
static int |
HEMISPHERE_FIELD
Constant for hemisphere field. |
(package private) static int |
LATITUDE
Constante indique que l'angle � formater est une latitude. |
(package private) static int |
LONGITUDE
Constante indique que l'angle � formater est une longitude. |
static int |
MINUTES_FIELD
Constant for minutes field. |
static int |
SECONDS_FIELD
Constant for seconds field. |
Constructor Summary | |
---|---|
AngleFormat()
Construct a new AngleFormat using
the current default locale and a default pattern. |
|
AngleFormat(String pattern)
Construct a new AngleFormat using the
current default locale and the specified pattern. |
|
AngleFormat(String pattern,
DecimalFormatSymbols symbols)
Construct a new AngleFormat
using the specified pattern and decimal symbols. |
|
AngleFormat(String pattern,
Locale locale)
Construct a new AngleFormat
using the specified pattern and locale. |
Method Summary | |
---|---|
void |
applyPattern(String pattern)
Set the pattern to use for parsing and formatting angle. |
(package private) static void |
checkComplete(String source,
ParsePosition pos,
boolean isCoordinate)
V�rifie si l'interpr�tation d'une cha�ne de caract�res a �t� compl�te. |
boolean |
equals(Object obj)
Compare this format with the specified object for equality. |
String |
format(double angle)
Format an angle. |
(package private) StringBuffer |
format(double number,
int type,
StringBuffer toAppendTo,
FieldPosition pos)
Proc�de � l'�criture d'un angle, d'une latitude ou d'une longitude. |
StringBuffer |
format(double angle,
StringBuffer toAppendTo,
FieldPosition pos)
Formats an angle and appends the resulting text to a given string buffer. |
StringBuffer |
format(Object obj,
StringBuffer toAppendTo,
FieldPosition pos)
Formats an angle, a latitude or a longitude and appends the resulting text to a given string buffer. |
int |
hashCode()
Returns a "hash value" for this object. |
Angle |
parse(String source)
Parse a string as an angle. |
Angle |
parse(String source,
ParsePosition pos)
Parse a string as an angle. |
(package private) Number |
parseNumber(String source,
ParsePosition pos)
Interpr�te une cha�ne de caract�res qui devrait repr�senter un nombre. |
Object |
parseObject(String source)
Parse a string as an object. |
Object |
parseObject(String source,
ParsePosition pos)
Parse a substring as an angle. |
String |
toPattern()
Returns the pattern used for parsing and formatting angles. |
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 |
---|
static final int LONGITUDE
static final int LATITUDE
static final int ALTITUDE
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()
AngleFormat
using
the current default locale and a default pattern.
public AngleFormat(String pattern) throws IllegalArgumentException
AngleFormat
using the
current default locale and the specified pattern.
pattern
- Pattern to use for parsing and formatting angle.
See class description for an explanation of how this pattern work.
IllegalArgumentException
- If the specified pattern is not legal.public AngleFormat(String pattern, Locale locale) throws IllegalArgumentException
AngleFormat
using the specified pattern and locale.
pattern
- Pattern to use for parsing and formatting angle.
See class description for an explanation of how this pattern work.locale
- Locale to use.
IllegalArgumentException
- If the specified pattern is not legal.public AngleFormat(String pattern, DecimalFormatSymbols symbols)
AngleFormat
using the specified pattern and decimal 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.
IllegalArgumentException
- If the specified pattern is not legal.Method Detail |
---|
public void applyPattern(String pattern) throws IllegalArgumentException
pattern
- Pattern to use for parsing and formatting angle.
IllegalArgumentException
- If the specified pattern is not legal.public String toPattern()
public final String format(double angle)
applyPattern(java.lang.String)
.
angle
- Angle to format, in degrees.
public StringBuffer format(double angle, StringBuffer toAppendTo, 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 null
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
.
toAppendTo
, with formatted text appended.public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos) throws IllegalArgumentException
applyPattern(java.lang.String)
. The argument obj
shall be an Angle
object or one of its derived class (Latitude
,
Longitude
). If obj
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 obj
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.
AngleFormat
's job. Nevertheless, this method
accept Number
objects. This capability is provided
only as a convenient way to format altitude numbers together
with longitude and latitude angles.
format
in class Format
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 null
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
.
toAppendTo
, with
formatted text appended.
IllegalArgumentException
- if obj
if not an object
of class Angle
or Number
.StringBuffer format(double number, int type, StringBuffer toAppendTo, FieldPosition pos)
type
- Type de l'angle ou du nombre:
LONGITUDE
,
LATITUDE
ou
ALTITUDE
.toAppendTo
- Buffer dans lequel �crire l'angle.pos
- En entr�, le code du champs dont on d�sire les index
(DEGREES_FIELD
,
MINUTES_FIELD
,
SECONDS_FIELD
ou
HEMISPHERE_FIELD
).
En sortie, les index du champs demand�. Ce param�tre
peut �tre nul si cette information n'est pas d�sir�e.
toAppendTo
par commodit�.public Angle parse(String source, ParsePosition pos)
48�12.34'
" even if the expected
pattern was "DDMM.mm
" (i.e. the string should have been
"4812.34
"). 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(String source) throws ParseException
source
- The string to parse.
Angle
, Latitude
or Longitude
object.
ParseException
- if the string has not been fully parsed.public Object parseObject(String source, ParsePosition pos)
parse(String, ParsePosition)
.
parseObject
in class Format
source
- A String whose beginning should be parsed.pos
- Position where to start parsing.
Angle
,
Latitude
or Longitude
object.public Object parseObject(String source) throws ParseException
parse(String)
.
parseObject
in class Format
source
- The string to parse.
Angle
, Latitude
or
Longitude
object.
ParseException
- if the string has not been fully parsed.final Number parseNumber(String source, ParsePosition pos)
source
- Cha�ne de caract�res � interpr�ter.pos
- Position � partir d'o� commencer l'interpr�tation
de la cha�ne source
.
Number
.static void checkComplete(String source, ParsePosition pos, boolean isCoordinate) throws ParseException
source
- Cha�ne de caract�res qui �tait � interpr�ter.pos
- Position � laquelle s'est termin�e l'interpr�tation de la
cha�ne source
.isCoordinate
- false
si on interpr�tait un angle,
ou true
si on interpr�tait une coordonn�e.
ParseException
- Si la cha�ne source
n'a pas �t�
interpr�t�e dans sa totalit�.public int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
equals
in class Object
public String toString()
toString
in class Object
|
deegree 2.1 (2007/11/08 09:57 build-328-official) | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://deegree.sourceforge.net