java.awt.font

Class NumericShaper

Implemented Interfaces:
Serializable

public final class NumericShaper
extends Object
implements Serializable

This class handles numeric shaping. A shaper can either be contextual or not. A non-contextual shaper will always translate ASCII digits in its input into the target Unicode range. A contextual shaper will change the target Unicode range depending on the characters it has previously processed.
Since:
1.4
See Also:
Serialized Form

Field Summary

static int
ALL_RANGES
Convenience constant representing all the valid Unicode ranges.
static int
ARABIC
Constant representing the Unicode ARABIC range.
static int
BENGALI
Constant representing the Unicode BENGALI range.
static int
DEVANAGARI
Constant representing the Unicode DEVANAGARI range.
static int
EASTERN_ARABIC
Constant representing the Unicode extended arabic range.
static int
ETHIOPIC
Constant representing the Unicode ETHIOPIC range.
static int
EUROPEAN
Constant representing the Unicode EUROPEAN range.
static int
GUJARATI
Constant representing the Unicode GUJARATI range.
static int
GURMUKHI
Constant representing the Unicode GURMUKHI range.
static int
KANNADA
Constant representing the Unicode KANNADA range.
static int
KHMER
Constant representing the Unicode KHMER range.
static int
LAO
Constant representing the Unicode LAO range.
static int
MALAYALAM
Constant representing the Unicode MALAYALAM range.
static int
MONGOLIAN
Constant representing the Unicode MONGOLIAN range.
static int
MYANMAR
Constant representing the Unicode MYANMAR range.
static int
ORIYA
Constant representing the Unicode ORIYA range.
static int
TAMIL
Constant representing the Unicode TAMIL range.
static int
TELUGU
Constant representing the Unicode TELUGU range.
static int
THAI
Constant representing the Unicode THAI range.
static int
TIBETAN
Constant representing the Unicode TIBETAN range.

Method Summary

boolean
equals(Object obj)
static NumericShaper
getContextualShaper(int ranges)
Return a contextual shaper which can shape to any of the indicated languages.
static NumericShaper
getContextualShaper(int ranges, int defaultContext)
Return a contextual shaper which can shape to any of the indicated languages.
int
getRanges()
Return an integer representing all the languages for which this shaper will shape.
static NumericShaper
getShaper(int singleRange)
Return a non-contextual shaper which can shape to a single range.
int
hashCode()
boolean
isContextual()
Return true if this shaper is contextual, false if it is not.
void
shape(char[] text, int start, int count)
Shape the text in the given array.
void
shape(char[] text, int start, int count, int context)
Shape the given text, using the indicated initial context.
String
toString()

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

ALL_RANGES

public static final int ALL_RANGES
Convenience constant representing all the valid Unicode ranges.
Field Value:
524287

ARABIC

public static final int ARABIC
Constant representing the Unicode ARABIC range. Shaping done using this range will translate to the arabic decimal characters. Use EASTERN_ARABIC if you want to shape to the eastern arabic (also known as the extended arabic) decimal characters.
Field Value:
2

BENGALI

public static final int BENGALI
Constant representing the Unicode BENGALI range.
Field Value:
16

DEVANAGARI

public static final int DEVANAGARI
Constant representing the Unicode DEVANAGARI range.
Field Value:
8

EASTERN_ARABIC

public static final int EASTERN_ARABIC
Constant representing the Unicode extended arabic range. In Unicode there are two different sets of arabic digits; this selects the extended or eastern set.
Field Value:
4

ETHIOPIC

public static final int ETHIOPIC
Constant representing the Unicode ETHIOPIC range. Note that there is no digit zero in this range; an ASCII digit zero is left unchanged when shaping to this range.
Field Value:
65536

EUROPEAN

public static final int EUROPEAN
Constant representing the Unicode EUROPEAN range. For contextual shaping purposes, characters in the various extended Latin character blocks are recognized as EUROPEAN.
Field Value:
1

GUJARATI

public static final int GUJARATI
Constant representing the Unicode GUJARATI range.
Field Value:
64

GURMUKHI

public static final int GURMUKHI
Constant representing the Unicode GURMUKHI range.
Field Value:
32

KANNADA

public static final int KANNADA
Constant representing the Unicode KANNADA range.
Field Value:
1024

KHMER

public static final int KHMER
Constant representing the Unicode KHMER range.
Field Value:
131072

LAO

public static final int LAO
Constant representing the Unicode LAO range.
Field Value:
8192

MALAYALAM

public static final int MALAYALAM
Constant representing the Unicode MALAYALAM range.
Field Value:
2048

MONGOLIAN

public static final int MONGOLIAN
Constant representing the Unicode MONGOLIAN range.
Field Value:
262144

MYANMAR

public static final int MYANMAR
Constant representing the Unicode MYANMAR range.
Field Value:
32768

ORIYA

public static final int ORIYA
Constant representing the Unicode ORIYA range.
Field Value:
128

TAMIL

public static final int TAMIL
Constant representing the Unicode TAMIL range. Note that there is no digit zero in this range; an ASCII digit zero is left unchanged when shaping to this range.
Field Value:
256

TELUGU

public static final int TELUGU
Constant representing the Unicode TELUGU range.
Field Value:
512

THAI

public static final int THAI
Constant representing the Unicode THAI range.
Field Value:
4096

TIBETAN

public static final int TIBETAN
Constant representing the Unicode TIBETAN range.
Field Value:
16384

Method Details

equals

public boolean equals(Object obj)
Overrides:
equals in interface Object

getContextualShaper

public static NumericShaper getContextualShaper(int ranges)
Return a contextual shaper which can shape to any of the indicated languages. The default initial context for this shaper is EUROPEAN.
Parameters:
ranges - the ranges to shape to
Returns:
a contextual shaper which will target any of these ranges
Throws:
IllegalArgumentException - if the argument specifies an unrecognized range

getContextualShaper

public static NumericShaper getContextualShaper(int ranges,
                                                int defaultContext)
Return a contextual shaper which can shape to any of the indicated languages. The default initial context for this shaper is given as an argument.
Parameters:
ranges - the ranges to shape to
defaultContext - the default initial context
Returns:
a contextual shaper which will target any of these ranges
Throws:
IllegalArgumentException - if the ranges argument specifies an unrecognized range, or if the defaultContext argument does not specify a single valid range

getRanges

public int getRanges()
Return an integer representing all the languages for which this shaper will shape. The result is taken by "or"ing together the constants representing the various languages.

getShaper

public static NumericShaper getShaper(int singleRange)
Return a non-contextual shaper which can shape to a single range. All ASCII digits in the input text are translated to this language.
Parameters:
singleRange - the target language
Returns:
a non-contextual shaper for this language
Throws:
IllegalArgumentException - if the argument does not name a single language, as specified by the constants declared in this class

hashCode

public int hashCode()
Overrides:
hashCode in interface Object

isContextual

public boolean isContextual()
Return true if this shaper is contextual, false if it is not.

shape

public void shape(char[] text,
                  int start,
                  int count)
Shape the text in the given array. The starting context will be the context passed to the shaper at creation time.
Parameters:
text - the text to shape
start - the index of the starting character of the array
count - the number of characters in the array

shape

public void shape(char[] text,
                  int start,
                  int count,
                  int context)
Shape the given text, using the indicated initial context. If this shaper is not a contextual shaper, then the given context will be ignored.
Parameters:
text - the text to shape
start - the index of the first character of the text to shape
count - the number of characters to shape in the text
context - the initial context
Throws:
IllegalArgumentException - if the initial context is invalid

toString

public String toString()
Overrides:
toString in interface Object

NumericShaper.java Copyright (C) 2003 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.