public final class NumericShaper extends Object implements Serializable
NumericShaper
类用于将Latin-1(欧洲)其他Unicode编码的十进制数字的位数。这类用户主要是那些希望利用国家数字形状数据,但发现它代表内部使用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);
位掩码和基于Unicode范围枚举
这类支持两种不同的编程接口来表示脚本特定数字Unicode范围:位掩码为基础的,如NumericShaper.ARABIC
,和枚举型,如NumericShaper.Range.ARABIC
。多个范围可以通过口语基础常数的位掩码指定,如:
或创建一个NumericShaper.ARABIC | NumericShaper.TAMIL
Set
与
NumericShaper.Range
常数,如:
枚举的范围是一个超级组的位掩码的。EnumSet.of(NumericShaper.Scirpt.ARABIC, NumericShaper.Range.TAMIL)
如果两接口混合(包括序列化),Unicode范围值映射到他们的同行在这样的映射是可能的,如从/到NumericShaper.ARABIC
NumericShaper.Range.ARABIC
。如果指定了无法映射的范围值,如NumericShaper.Range.BALINESE
,忽略那些范围。
小数位数优先
Unicode范围可能有多个组的小数位数。如果多个小数位数设置为相同的Unicode范围指定,一组将优先考虑如下。
Unicode Range | NumericShaper Constants |
Precedence |
---|---|---|
Arabic | NumericShaper.ARABIC NumericShaper.EASTERN_ARABIC |
NumericShaper.EASTERN_ARABIC |
NumericShaper.Range.ARABIC NumericShaper.Range.EASTERN_ARABIC |
NumericShaper.Range.EASTERN_ARABIC |
|
Tai Tham | NumericShaper.Range.TAI_THAM_HORA NumericShaper.Range.TAI_THAM_THAM |
NumericShaper.Range.TAI_THAM_THAM |
Modifier and Type | Class and Description |
---|---|
static class |
NumericShaper.Range
一个
NumericShaper.Range 代表一个有自己的十进制数字脚本Unicode范围。
|
Modifier and Type | Field and Description |
---|---|
static int |
ALL_RANGES
确定所有范围,为全面的上下文塑造。
|
static int |
ARABIC
确定阿拉伯范围和十进制基数。
|
static int |
BENGALI
确定了孟加拉的范围和十进制。
|
static int |
DEVANAGARI
标识梵文范围和十进制。
|
static int |
EASTERN_ARABIC
确定阿拉伯范围和arabic_extended十进制。
|
static int |
ETHIOPIC
确定了埃塞俄比亚范围和十进制。
|
static int |
EUROPEAN
标识Latin-1(欧洲)和扩展范围,与Latin-1(欧洲)十进制。
|
static int |
GUJARATI
标识语的范围和十进制。
|
static int |
GURMUKHI
标识结合范围和十进制。
|
static int |
KANNADA
标识语的范围和十进制。
|
static int |
KHMER
标识的红色范围和十进制。
|
static int |
LAO
确定老挝范围和十进制基数。
|
static int |
MALAYALAM
标识语的范围和十进制。
|
static int |
MONGOLIAN
确定了蒙古的范围和十进制基数。
|
static int |
MYANMAR
确定缅甸范围和十进制基数。
|
static int |
ORIYA
标识奥里亚范围和十进制。
|
static int |
TAMIL
确定的泰米尔范围和十进制基地。
|
static int |
TELUGU
标识的泰卢固语的范围和十进制。
|
static int |
THAI
确定泰国范围和十进制基础。
|
static int |
TIBETAN
标识的范围和十进制基数。
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o)
返回
true 指定对象是否是
NumericShaper 实例和形状相同的这一个,无论范围表示,位掩码或枚举。
|
static NumericShaper |
getContextualShaper(int ranges)
返回Unicode范围提供上下文整形(S)。
|
static NumericShaper |
getContextualShaper(int ranges, int defaultContext)
返回Unicode范围提供上下文整形(S)。
|
static NumericShaper |
getContextualShaper(Set<NumericShaper.Range> ranges)
返回Unicode范围提供上下文整形(S)。
|
static NumericShaper |
getContextualShaper(Set<NumericShaper.Range> ranges, NumericShaper.Range defaultContext)
返回Unicode范围提供上下文整形(S)。
|
int |
getRanges()
返回一个
int ,OR一起为所有的范围,将形成价值观。
|
Set<NumericShaper.Range> |
getRangeSet()
返回一个
Set 代表所有Unicode范围在这
NumericShaper 将形。
|
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)
将在开始和开始+计数之间的文本中的数字转换。
|
void |
shape(char[] text, int start, int count, int context)
将在开始和开始+计数之间发生的文本中的数字转换,使用所提供的上下文。
|
void |
shape(char[] text, int start, int count, NumericShaper.Range context)
将数字发生
start 和
start + count 之间的文本,使用提供的
context 。
|
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
这个常量指定了所有的位掩码为基础的范围。使用EmunSet.allOf(NumericShaper.Range.class)
指定所有的枚举的范围。
public static NumericShaper getShaper(int singleRange)
singleRange
-指定的Unicode范围
IllegalArgumentException
-如果范围不是一个单一的范围
public static NumericShaper getShaper(NumericShaper.Range singleRange)
singleRange
- Unicode范围由
NumericShaper.Range
常数。
NumericShaper
。
null
singleRange
NullPointerException
public static NumericShaper getContextualShaper(int ranges)
NumericShaper.ARABIC | NumericShaper.THAI
。欧洲的整形假设为出发的语境,即如果欧洲数字都遇到过的字符串中有很强的方向性文本,语境被认为是欧洲,所以数字不会改变。
ranges
-指定的Unicode范围
public static NumericShaper getContextualShaper(Set<NumericShaper.Range> ranges)
欧洲的整形假设为出发的语境,即如果欧洲数字都遇到过的字符串中有很强的方向性文本,语境被认为是欧洲,所以数字不会改变。
ranges
-指定的Unicode范围
null
ranges
NullPointerException
。
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
开始转换
text
count
字符数转换
IndexOutOfBoundsException
如果启动或启动+算出界
NullPointerException
如果文本是空的
public void shape(char[] text, int start, int count, int context)
text
-一个字符数组
start
-指数为
text
开始转换
text
count
字符数转换
context
-语境的转换字符,如
NumericShaper.EUROPEAN
IndexOutOfBoundsException
如果启动或启动+算出界
NullPointerException
如果文本是空的
IllegalArgumentException
-如果这是一个上下文的整形和指定的
context
不是一个单一的有效范围。
public void shape(char[] text, int start, int count, NumericShaper.Range context)
start
和
start + count
之间的文本,使用提供的
context
。
Context
如果插不插忽视语境。
text
-
char
阵列
start
-指数为
text
开始转换
count
-
text
char
s数的转换
context
-语境的转换字符,如
NumericShaper.Range.EUROPEAN
IndexOutOfBoundsException
-如果
start
或
start + count
出界
NullPointerException
-如果
text
或
context
是空的
public boolean isContextual()
boolean
指示是否插齿的形状上下文。
true
如果成型机是
false
否则语境。
public int getRanges()
int
,OR一起为所有的范围,将形成价值观。
例如,检查是否插齿形状的阿拉伯语,你可以使用以下:
if ((shaper.getRanges() & shaper.ARABIC) != 0) { ...
请注意,此方法只支持基于位掩码的范围。呼唤基于enum getRangeSet()
范围。
public Set<NumericShaper.Range> getRangeSet()
Set
代表所有Unicode范围在这
NumericShaper
将形。
public int hashCode()
hashCode
方法重写,继承类
Object
Object.hashCode()
public boolean equals(Object o)
true
指定对象是否是
NumericShaper
实例和形状相同的这一个,无论范围表示,位掩码或枚举。例如,下面的代码生成
"true"
。
NumericShaper ns1 = NumericShaper.getShaper(NumericShaper.ARABIC); NumericShaper ns2 = NumericShaper.getShaper(NumericShaper.Range.ARABIC); System.out.println(ns1.equals(ns2));
equals
方法重写,继承类
Object
o
-指定的对象来比较这
NumericShaper
true
如果
o
是以同样的方式,
NumericShaper
和形状
false
否则实例。
Object.equals(java.lang.Object)
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.