public final class NumericShaper extends Object implements Serializable
NumericShaper
クラスは、Latin-1 (ヨーロッパ言語)の数字をほかのUnicode 10進数に変換するために使用します。このクラスは主に、データの提示に各国の数字の形状を使いながら内部的にはLatin-1 (ヨーロッパ言語)の数字を使ったほうが便利な場合に使用します。非推奨の数字形状セレクタ文字(U+206E)は解釈しません。
NumericShaper
のインスタンスは通常、TextAttribute
クラスのNUMERIC_SHAPING
属性を持つテキストの属性として適用されます。たとえば次のコード部分では、アラビア語のコンテキスト内ではTextLayout
のヨーロッパ言語の数字をアラビア語の数字に変換します。
Map map = new HashMap(); map.put(TextAttribute.NUMERIC_SHAPING, NumericShaper.getContextualShaper(NumericShaper.ARABIC)); FontRenderContext frc = ...; TextLayout layout = new TextLayout(text, map, frc); layout.draw(g2d, x, y);
NumericShaper
のインスタンスを使用して数字の形状決定を明示的に行うこともできます。char[] text = ...; // shape all EUROPEAN digits (except zero) to ARABIC digits NumericShaper shaper = NumericShaper.getShaper(NumericShaper.ARABIC); shaper.shape(text, start, count); // shape European digits to ARABIC digits if preceding text is Arabic, or // shape European digits to TAMIL digits if preceding text is Tamil, or // leave European digits alone if there is no preceding text, or // preceding text is neither Arabic nor Tamil NumericShaper shaper = NumericShaper.getContextualShaper(NumericShaper.ARABIC | NumericShaper.TAMIL, NumericShaper.EUROPEAN); shaper.shape(text, start, count);
ビット・マスクベースおよびenumベースのUnicode範囲
このクラスは、スクリプト固有の数字のUnicode範囲を表すために異なる2つのプログラミング・インタフェースをサポートしています。つまり、NumericShaper.ARABIC
のようなビット・マスクベースのものと、NumericShaper.Range.ARABIC
のようなenumベースのものです。複数の範囲を指定するには、次のようにビット・マスクベースの定数の論理和を使用します。
あるいは、次のようにNumericShaper.ARABIC | NumericShaper.TAMIL
NumericShaper.Range
定数を使用してSet
を作成します。
enumベースの範囲は、ビット・マスクベースの範囲のスーパー・セットです。EnumSet.of(NumericShaper.Scirpt.ARABIC, NumericShaper.Range.TAMIL)
2つのインタフェースが混在する場合(直列化も含む)、マッピングが可能であれば、Unicode範囲の値は互いに対応する値にマップされます。たとえば、NumericShaper.Range.ARABIC
とNumericShaper.ARABIC
がマップされます。NumericShaper.Range.BALINESE
などのマップできない範囲値が指定された場合、そのような範囲は無視されます。
10進数の優先順位
1つのUnicode範囲に10進数のセットが複数含まれることがあります。同じUnicode範囲に10進数のセットが複数指定されている場合は、次のようにセットの1つが優先されます。
修飾子と型 | クラスと説明 |
---|---|
static class |
NumericShaper.Range
NumericShaper.Range は固有の10進数を持つスクリプトのUnicode範囲を表します。 |
修飾子と型 | フィールドと説明 |
---|---|
static int |
ALL_RANGES
すべての範囲を識別します。完全なコンテキスト依存の形状決定に使用します。
|
static int |
ARABIC
ARABICの範囲と10進数を識別します。
|
static int |
BENGALI
BENGALIの範囲と10進数を識別します。
|
static int |
DEVANAGARI
DEVANAGARIの範囲と10進数を識別します。
|
static int |
EASTERN_ARABIC
ARABICの範囲とARABIC_EXTENDEDの10進数を識別します。
|
static int |
ETHIOPIC
ETHIOPICの範囲と10進数を識別します。
|
static int |
EUROPEAN
Latin-1 (ヨーロッパ言語)と拡張範囲、およびLatin-1 (ヨーロッパ言語)の10進数を識別します。
|
static int |
GUJARATI
GUJARATIの範囲と10進数を識別します。
|
static int |
GURMUKHI
GURMUKHIの範囲と10進数を識別します。
|
static int |
KANNADA
KANNADAの範囲と10進数を識別します。
|
static int |
KHMER
KHMERの範囲と10進数を識別します。
|
static int |
LAO
LAOの範囲と10進数を識別します。
|
static int |
MALAYALAM
MALAYALAMの範囲と10進数を識別します。
|
static int |
MONGOLIAN
MONGOLIANの範囲と10進数を識別します。
|
static int |
MYANMAR
MYANMARの範囲と10進数を識別します。
|
static int |
ORIYA
ORIYAの範囲と10進数を識別します。
|
static int |
TAMIL
TAMILの範囲と10進数を識別します。
|
static int |
TELUGU
TELUGUの範囲と10進数を識別します。
|
static int |
THAI
THAIの範囲と10進数を識別します。
|
static int |
TIBETAN
TIBETANの範囲と10進数を識別します。
|
修飾子と型 | メソッドと説明 |
---|---|
boolean |
equals(Object o)
指定されたオブジェクトが
NumericShaper のインスタンスで、範囲表現、ビット・マスク、または列挙と関係なく、これと同じ方法で形状決定を行う場合はtrue を返します。 |
static NumericShaper |
getContextualShaper(int ranges)
指定されたUnicodeの1つまたは複数の範囲に対する、コンテキスト依存の形状決定要因を返します。
|
static NumericShaper |
getContextualShaper(int ranges, int defaultContext)
指定されたUnicodeの1つまたは複数の範囲に対する、コンテキスト依存の形状決定要因を返します。
|
static NumericShaper |
getContextualShaper(Set<NumericShaper.Range> ranges)
指定されたUnicodeの1つまたは複数の範囲に対する、コンテキスト依存の形状決定要因を返します。
|
static NumericShaper |
getContextualShaper(Set<NumericShaper.Range> ranges, NumericShaper.Range defaultContext)
指定されたUnicodeの1つまたは複数の範囲に対する、コンテキスト依存の形状決定要因を返します。
|
int |
getRanges()
形状決定を行うすべての範囲に対する値の論理和を求める
int を返します。 |
Set<NumericShaper.Range> |
getRangeSet()
形状決定を行うこの
NumericShaper のすべてのUnicode範囲を表すSet を返します。 |
static NumericShaper |
getShaper(int singleRange)
指定されたUnicodeの範囲に対する形状決定要因を返します。
|
static NumericShaper |
getShaper(NumericShaper.Range singleRange)
指定されたUnicodeの範囲に対する形状決定要因を返します。
|
int |
hashCode()
この形状決定要因のハッシュ・コードを返します。
|
boolean |
isContextual()
この形状決定要因がコンテキスト依存かどうかを示す
boolean を返します。 |
void |
shape(char[] text, int start, int count)
startとstart+countの間に出現する、テキスト内の数字を変換します。
|
void |
shape(char[] text, int start, int count, int context)
指定されたコンテキストを使用して、startとstart+countの間に出現するテキスト内の数字を変換します。
|
void |
shape(char[] text, int start, int count, NumericShaper.Range context)
指定された
context を使用して、start とstart+count の間に出現するテキスト内の数字を変換します。 |
String |
toString()
この形状決定要因を記述する
String を返します。 |
public static final int EUROPEAN
public static final int ARABIC
public static final int EASTERN_ARABIC
public static final int DEVANAGARI
public static final int BENGALI
public static final int GURMUKHI
public static final int GUJARATI
public static final int ORIYA
public static final int TAMIL
public static final int TELUGU
public static final int KANNADA
public static final int MALAYALAM
public static final int THAI
public static final int LAO
public static final int TIBETAN
public static final int MYANMAR
public static final int ETHIOPIC
public static final int KHMER
public static final int MONGOLIAN
public static final int ALL_RANGES
この定数は、ビット・マスクベースのすべての範囲を指定します。enumベースのすべての範囲を指定するには、EmunSet.allOf(NumericShaper.Range.class)
を使用してください。
public static NumericShaper getShaper(int singleRange)
singleRange
- 指定されたUnicodeの範囲IllegalArgumentException
- 範囲が1つでない場合public static NumericShaper getShaper(NumericShaper.Range singleRange)
singleRange
- NumericShaper.Range
定数で指定されたUnicode範囲。NumericShaper
。NullPointerException
- singleRange
がnull
である場合public static NumericShaper getContextualShaper(int ranges)
NumericShaper.ARABIC|NumericShaper.THAI
のように、値の論理和によって表されます。形状決定要因は、EUROPEANを開始コンテキストとして想定します。つまり、文字列内で方向性の強いテキストの前にEUROPEANの数字が検出された場合、コンテキストはEUROPEANであると見なされ、数字は形状決定されません。ranges
- 指定されたUnicodeの範囲public static NumericShaper getContextualShaper(Set<NumericShaper.Range> ranges)
形状決定要因は、EUROPEANを開始コンテキストとして想定します。つまり、文字列内で方向性の強いテキストの前にEUROPEANの数字が検出された場合、コンテキストはEUROPEANであると見なされ、数字は形状決定されません。
ranges
- 指定されたUnicodeの範囲NullPointerException
- ranges
がnull
である場合。public static NumericShaper getContextualShaper(int ranges, int defaultContext)
NumericShaper.ARABIC|NumericShaper.THAI
のように、値の論理和によって表されます。形状決定要因は、defaultContextを開始コンテキストとして使います。ranges
- 指定されたUnicodeの範囲defaultContext
- 次のような開始コンテキスト: NumericShaper.EUROPEAN
IllegalArgumentException
- 指定されたdefaultContext
が単一の有効な範囲でない場合。public static NumericShaper getContextualShaper(Set<NumericShaper.Range> ranges, NumericShaper.Range defaultContext)
defaultContext
を開始コンテキストとして使います。ranges
- 指定されたUnicodeの範囲defaultContext
- 次のような開始コンテキスト: NumericShaper.Range.EUROPEAN
NullPointerException
- ranges
またはdefaultContext
がnull
の場合public void shape(char[] text, int start, int count)
text
- 変換する文字の配列start
- 変換を開始するtext
内のインデックスcount
- text
内の変換する文字数IndexOutOfBoundsException
- startまたはstart+countが範囲外の場合NullPointerException
- textがnullの場合public void shape(char[] text, int start, int count, int context)
text
- 文字の配列start
- 変換を開始するtext
内のインデックスcount
- text
内の変換する文字数context
- 次のような文字の変換先のコンテキスト: NumericShaper.EUROPEAN
IndexOutOfBoundsException
- startまたはstart+countが範囲外の場合NullPointerException
- textがnullの場合IllegalArgumentException
- これがコンテキスト依存の形状決定要因であり、指定されたcontext
が単一の有効な範囲でない場合。public void shape(char[] text, int start, int count, NumericShaper.Range context)
context
を使用して、start
とstart+count
の間に出現するテキスト内の数字を変換します。形状決定要因がコンテキスト依存でない場合、Context
は無視されます。text
- char
配列start
- 変換を開始するtext
内のインデックスcount
- text
内の変換するchar
の数context
- 次のような文字の変換先のコンテキスト: NumericShaper.Range.EUROPEAN
IndexOutOfBoundsException
- start
またはstart+count
が範囲外にある場合NullPointerException
- text
またはcontext
がnullの場合public boolean isContextual()
boolean
を返します。true
、そうでない場合はfalse
。public int getRanges()
int
を返します。
たとえば、アラビア語への形状決定が行われるかどうかを調べるには、次のようにします。
if ((shaper.getRanges() & shaper.ARABIC) != 0) { ...
このメソッドはビット・マスクベースの範囲だけをサポートしています。enumベースの範囲の場合はgetRangeSet()
を呼び出してください。
public Set<NumericShaper.Range> getRangeSet()
NumericShaper
のすべてのUnicode範囲を表すSet
を返します。public int hashCode()
hashCode
、クラス: Object
Object.hashCode()
public boolean equals(Object o)
NumericShaper
のインスタンスで、範囲表現、ビット・マスク、または列挙と関係なく、これと同じ方法で形状決定を行う場合はtrue
を返します。たとえば、次のコードでは"true"
が生成されます。
NumericShaper ns1 = NumericShaper.getShaper(NumericShaper.ARABIC); NumericShaper ns2 = NumericShaper.getShaper(NumericShaper.Range.ARABIC); System.out.println(ns1.equals(ns2));
equals
、クラス: Object
o
- 次と比較する、指定されたオブジェクト: NumericShaper
o
がNumericShaper
のインスタンスであり、同じ方法で形状決定を行う場合はtrue
、そうでない場合はfalse
。Object.equals(java.lang.Object)
バグまたは機能を送信
詳細なAPIリファレンスおよび開発者ドキュメントについては、Java SEのドキュメントを参照してください。そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright © 1993, 2016, Oracle and/or its affiliates. All rights reserved.Use is subject to license termsDocumentation Redistribution Policyも参照してください。