|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.text.Format
org.deegree_impl.model.pt.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 inherited from class java.text.Format |
java.text.Format.Field |
Field Summary | |
(package private) static int |
ALTITUDE
Constante indique que le nombre à formater est une altitude. |
private boolean |
decimalSeparator
Indique s'il faut utiliser le séparateur décimal pour séparer la partie entière de la partie fractionnaire. |
static int |
DEGREES_FIELD
Constant for degrees field. |
private java.text.FieldPosition |
dummy
Objet à transmetre aux méthodes DecimalFormat.format .
|
private static char |
EAST
Caractère représentant l'hémisphère est. |
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. |
private static char |
NORTH
Caractère représentant l'hémisphère nord. |
private java.text.DecimalFormat |
numberFormat
Format à utiliser pour écrire les nombres (degrés, minutes ou secondes) à l'intérieur de l'écriture d'un angle. |
private java.lang.String |
prefix
Caractères à insérer au début ( prefix ) et à la
suite des degrés, minutes et secondes (suffix0..2 ).
|
private static int |
PREFIX_FIELD
A constant for the symbol to appears before the degrees fields. |
static int |
SECONDS_FIELD
Constant for seconds field. |
private static char |
SOUTH
Caractère représentant l'hémisphère sud. |
private java.lang.String |
suffix0
Caractères à insérer au début ( prefix ) et à la
suite des degrés, minutes et secondes (suffix0..2 ).
|
private java.lang.String |
suffix1
Caractères à insérer au début ( prefix ) et à la
suite des degrés, minutes et secondes (suffix0..2 ).
|
private java.lang.String |
suffix2
Caractères à insérer au début ( prefix ) et à la
suite des degrés, minutes et secondes (suffix0..2 ).
|
private static char[] |
SYMBOLS
Symboles représentant les degrés (0), minutes (1) et les secondes (2). |
private static char |
WEST
Caractère représentant l'hémisphère ouest. |
private int |
width0
Nombre minimal d'espaces que doivent occuper les parties entières des degrés (0), minutes (1) et secondes (2). |
private int |
width1
Nombre minimal d'espaces que doivent occuper les parties entières des degrés (0), minutes (1) et secondes (2). |
private int |
width2
Nombre minimal d'espaces que doivent occuper les parties entières des degrés (0), minutes (1) et secondes (2). |
private int |
widthDecimal
Nombre minimal d'espaces que doivent occuper les parties entières des degrés (0), minutes (1) et secondes (2). |
Fields inherited from class java.text.Format |
|
Constructor Summary | |
AngleFormat()
Construct a new AngleFormat using
the current default locale and a default pattern. |
|
AngleFormat(java.lang.String pattern)
Construct a new AngleFormat using the
current default locale and the specified pattern. |
|
AngleFormat(java.lang.String pattern,
java.text.DecimalFormatSymbols symbols)
Construct a new AngleFormat
using the specified pattern and decimal symbols. |
|
AngleFormat(java.lang.String pattern,
java.util.Locale locale)
Construct a new AngleFormat
using the specified pattern and locale. |
Method Summary | |
void |
applyPattern(java.lang.String pattern)
Set the pattern to use for parsing and formatting angle. |
(package private) static void |
checkComplete(java.lang.String source,
java.text.ParsePosition pos,
boolean isCoordinate)
Vérifie si l'interprétation d'une chaîne de caractères a été complète. |
boolean |
equals(java.lang.Object obj)
Compare this format with the specified object for equality. |
java.lang.String |
format(double angle)
Format an angle. |
(package private) java.lang.StringBuffer |
format(double number,
int type,
java.lang.StringBuffer toAppendTo,
java.text.FieldPosition pos)
Procède à l'écriture d'un angle, d'une latitude ou d'une longitude. |
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. |
private java.lang.StringBuffer |
format(double angle,
java.lang.StringBuffer toAppendTo,
java.text.FieldPosition pos,
char north,
char south)
Procède à l'écriture d'un angle suivit d'un suffix 'N','S','E' ou 'W'. |
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. |
private java.lang.StringBuffer |
formatField(double value,
java.lang.StringBuffer toAppendTo,
java.text.FieldPosition pos,
int w,
boolean last,
java.lang.String s)
Procède à l'écriture d'un champ de l'angle. |
private java.lang.String |
getSuffix(int index)
Returns the suffix for the specified field. |
private int |
getWidth(int index)
Returns the width of the specified field. |
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. |
private Angle |
parse(java.lang.String source,
java.text.ParsePosition pos,
boolean spaceAsSeparator)
Interprète une chaîne de caractères représentant un angle. |
(package private) java.lang.Number |
parseNumber(java.lang.String source,
java.text.ParsePosition pos)
Interprète une chaîne de caractères qui devrait représenter un nombre. |
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. |
private void |
readObject(java.io.ObjectInputStream in)
Restore fields after deserialization. |
private void |
setSuffix(int index,
java.lang.String s)
Set the suffix for the specified field. |
private void |
setWidth(int index,
int width)
Set the width for the specified field. |
private int |
skipSuffix(java.lang.String source,
java.text.ParsePosition pos,
int field)
Ignore le suffix d'un nombre. |
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 |
private static final char NORTH
private static final char SOUTH
private static final char EAST
private static final char WEST
static final int LONGITUDE
static final int LATITUDE
static final int ALTITUDE
private static final int PREFIX_FIELD
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.
private static final char[] SYMBOLS
private int width0
widthDecimal
indique la largeur fixe
que doit avoir la partie décimale. Il s'appliquera au
dernier champs non-zero dans width0..2
.
private int width1
widthDecimal
indique la largeur fixe
que doit avoir la partie décimale. Il s'appliquera au
dernier champs non-zero dans width0..2
.
private int width2
widthDecimal
indique la largeur fixe
que doit avoir la partie décimale. Il s'appliquera au
dernier champs non-zero dans width0..2
.
private int widthDecimal
widthDecimal
indique la largeur fixe
que doit avoir la partie décimale. Il s'appliquera au
dernier champs non-zero dans width0..2
.
private java.lang.String prefix
prefix
) et à la
suite des degrés, minutes et secondes (suffix0..2
).
Ces champs doivent être null
s'il n'y a rien à insérer.
private java.lang.String suffix0
prefix
) et à la
suite des degrés, minutes et secondes (suffix0..2
).
Ces champs doivent être null
s'il n'y a rien à insérer.
private java.lang.String suffix1
prefix
) et à la
suite des degrés, minutes et secondes (suffix0..2
).
Ces champs doivent être null
s'il n'y a rien à insérer.
private java.lang.String suffix2
prefix
) et à la
suite des degrés, minutes et secondes (suffix0..2
).
Ces champs doivent être null
s'il n'y a rien à insérer.
private boolean decimalSeparator
false
indique
que les parties entières et fractionnaires doivent être écrites ensembles
(par exemple 34867 pour 34.867). La valeur par défaut est true
.
private final java.text.DecimalFormat numberFormat
private transient java.text.FieldPosition dummy
DecimalFormat.format
.
Ce paramètre existe simplement pour éviter de créer cet objet trop
souvent, alors qu'on ne s'y intéresse pas.
Constructor Detail |
public AngleFormat()
AngleFormat
using
the current default locale and a default pattern.
public AngleFormat(java.lang.String pattern) throws java.lang.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.
java.lang.IllegalArgumentException
- If the specified pattern is not legal.public AngleFormat(java.lang.String pattern, java.util.Locale locale) throws java.lang.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.
java.lang.IllegalArgumentException
- If the specified pattern is not legal.public AngleFormat(java.lang.String pattern, java.text.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.
java.lang.IllegalArgumentException
- If the specified pattern is not legal.Method Detail |
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
private int getWidth(int index)
private void setWidth(int index, int width)
private java.lang.String getSuffix(int index)
private void setSuffix(int index, java.lang.String s)
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 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.private java.lang.StringBuffer formatField(double value, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos, int w, boolean last, java.lang.String s)
value
- Valeur à écrire.toAppendTo
- Buffer dans lequel écrire le champs.pos
- Objet dans lequel mémoriser les index des premiers
et derniers caractères écrits, ou null
pour ne pas mémoriser ces index.w
- Nombre de minimal caractères de la partie entière.last
- true
si ce champs est le dernier,
et qu'il faut donc écrire la partie décimale.s
- Suffix à écrire après le nombre (peut être nul).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 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.
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.
java.lang.IllegalArgumentException
- if obj
if not an object
of class Angle
or Number
.java.lang.StringBuffer format(double number, int type, java.lang.StringBuffer toAppendTo, java.text.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é.private java.lang.StringBuffer format(double angle, java.lang.StringBuffer toAppendTo, java.text.FieldPosition pos, char north, char south)
applyPattern(java.lang.String)
.
angle
- Angle à écrire, en degrés.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.north
- Caractères à écrire si l'angle est positif ou nul.south
- Caractères à écrire si l'angle est négatif.
toAppendTo
par commodité.private int skipSuffix(java.lang.String source, java.text.ParsePosition pos, int field)
parse(java.lang.String, java.text.ParsePosition)
pour savoir quel champs il vient de lire. Par exemple si
l'on vient de lire les degrés dans "48°12'", alors cette méthode extraira
le "°" et retournera 0 pour indiquer que l'on vient de lire des degrés.
Cette méthode se chargera d'ignorer les espaces qui précèdent le suffix.
Elle tentera ensuite de d'abord interpréter le suffix selon les symboles
du patron (spécifié avec applyPattern(java.lang.String)
. Si le suffix n'a pas été
reconnus, elle tentera ensuite de le comparer aux symboles standards
(° ' ").
source
- Chaîne dans laquelle on doit sauter le suffix.pos
- En entré, l'index du premier caractère à considérer dans la
chaîne pos
. En sortie, l'index du premier caractère
suivant le suffix (c'est-à-dire index à partir d'où continuer la
lecture après l'appel de cette méthode). Si le suffix n'a pas été
reconnu, alors cette méthode retourne par convention SYMBOLS.length
.field
- Champs à vérifier de préférences. Par exemple la valeur 1 signifie que les
suffix des minutes et des secondes devront être vérifiés avant celui des degrés.
SYMBOLS.length
.public Angle parse(java.lang.String source, java.text.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.private Angle parse(java.lang.String source, java.text.ParsePosition pos, boolean spaceAsSeparator)
Latitude
. S'il est plutot suivit d'un symbole "E" ou "W", alors l'objet
retourné sera de la classe Longitude
. Sinon, il sera de la classe
Angle
.
source
- Chaîne de caractères à lire.pos
- Position à partir d'où interpréter la chaîne.spaceAsSeparator
- Indique si l'espace est accepté comme séparateur
à l'intérieur d'un angle. La valeur true
fait que l'angle "45 30" sera interprété comme "45°30".
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.final java.lang.Number parseNumber(java.lang.String source, java.text.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(java.lang.String source, java.text.ParsePosition pos, boolean isCoordinate) throws java.text.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.
java.text.ParseException
- Si la chaîne source
n'a pas été
interprétée dans sa totalité.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 |