Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
66c77730
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
66c77730
编写于
11月 12, 2009
作者:
A
alanb
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6898124: Bidi should not require AWT to be present
Reviewed-by: okutsu
上级
42b7e6b1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
112 addition
and
7 deletion
+112
-7
src/share/classes/sun/text/bidi/BidiBase.java
src/share/classes/sun/text/bidi/BidiBase.java
+112
-7
未找到文件。
src/share/classes/sun/text/bidi/BidiBase.java
浏览文件 @
66c77730
...
...
@@ -52,10 +52,11 @@
package
sun.text.bidi
;
import
java.awt.font.TextAttribute
;
import
java.awt.font.NumericShaper
;
import
java.io.IOException
;
import
java.lang.reflect.Array
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.InvocationTargetException
;
import
java.text.AttributedCharacterIterator
;
import
java.text.Bidi
;
import
java.util.Arrays
;
...
...
@@ -2689,12 +2690,13 @@ public class BidiBase {
public
void
setPara
(
AttributedCharacterIterator
paragraph
)
{
byte
paraLvl
;
Boolean
runDirection
=
(
Boolean
)
paragraph
.
getAttribute
(
TextAttribute
.
RUN_DIRECTION
);
NumericShaper
shaper
=
(
NumericShaper
)
paragraph
.
getAttribute
(
TextAttribute
.
NUMERIC_SHAPING
);
Boolean
runDirection
=
(
Boolean
)
paragraph
.
getAttribute
(
TextAttributeConstants
.
RUN_DIRECTION
);
Object
shaper
=
paragraph
.
getAttribute
(
TextAttributeConstants
.
NUMERIC_SHAPING
);
if
(
runDirection
==
null
)
{
paraLvl
=
INTERNAL_LEVEL_DEFAULT_LTR
;
}
else
{
paraLvl
=
(
runDirection
.
equals
(
TextAttribute
.
RUN_DIRECTION_LTR
))
?
paraLvl
=
(
runDirection
.
equals
(
TextAttribute
Constants
.
RUN_DIRECTION_LTR
))
?
(
byte
)
Bidi
.
DIRECTION_LEFT_TO_RIGHT
:
(
byte
)
Bidi
.
DIRECTION_RIGHT_TO_LEFT
;
}
...
...
@@ -2706,7 +2708,8 @@ public class BidiBase {
char
ch
=
paragraph
.
first
();
while
(
ch
!=
AttributedCharacterIterator
.
DONE
)
{
txt
[
i
]
=
ch
;
Integer
embedding
=
(
Integer
)
paragraph
.
getAttribute
(
TextAttribute
.
BIDI_EMBEDDING
);
Integer
embedding
=
(
Integer
)
paragraph
.
getAttribute
(
TextAttributeConstants
.
BIDI_EMBEDDING
);
if
(
embedding
!=
null
)
{
byte
level
=
embedding
.
byteValue
();
if
(
level
==
0
)
{
...
...
@@ -2724,7 +2727,7 @@ public class BidiBase {
}
if
(
shaper
!=
null
)
{
shaper
.
shape
(
txt
,
0
,
len
);
NumericShapings
.
shape
(
shaper
,
txt
,
0
,
len
);
}
setPara
(
txt
,
paraLvl
,
lvls
);
}
...
...
@@ -3441,4 +3444,106 @@ public class BidiBase {
return
buf
.
toString
();
}
/**
* A class that provides access to constants defined by
* java.awt.font.TextAttribute without creating a static dependency.
*/
private
static
class
TextAttributeConstants
{
private
static
final
Class
<?>
clazz
=
getClass
(
"java.awt.font.TextAttribute"
);
/**
* TextAttribute instances (or a fake Attribute type if
* java.awt.font.TextAttribute is not present)
*/
static
final
AttributedCharacterIterator
.
Attribute
RUN_DIRECTION
=
getTextAttribute
(
"RUN_DIRECTION"
);
static
final
Boolean
RUN_DIRECTION_LTR
=
(
Boolean
)
getStaticField
(
clazz
,
"RUN_DIRECTION_LTR"
);
static
final
AttributedCharacterIterator
.
Attribute
NUMERIC_SHAPING
=
getTextAttribute
(
"NUMERIC_SHAPING"
);
static
final
AttributedCharacterIterator
.
Attribute
BIDI_EMBEDDING
=
getTextAttribute
(
"BIDI_EMBEDDING"
);
private
static
Class
<?>
getClass
(
String
name
)
{
try
{
return
Class
.
forName
(
name
,
true
,
null
);
}
catch
(
ClassNotFoundException
e
)
{
return
null
;
}
}
private
static
Object
getStaticField
(
Class
<?>
clazz
,
String
name
)
{
if
(
clazz
==
null
)
{
// fake attribute
return
new
AttributedCharacterIterator
.
Attribute
(
name
)
{
};
}
else
{
try
{
Field
f
=
clazz
.
getField
(
name
);
return
f
.
get
(
null
);
}
catch
(
NoSuchFieldException
x
)
{
throw
new
AssertionError
(
x
);
}
catch
(
IllegalAccessException
x
)
{
throw
new
AssertionError
(
x
);
}
}
}
private
static
AttributedCharacterIterator
.
Attribute
getTextAttribute
(
String
name
)
{
return
(
AttributedCharacterIterator
.
Attribute
)
getStaticField
(
clazz
,
name
);
}
}
/**
* A class that provides access to java.awt.font.NumericShaping without
* creating a static dependency.
*/
private
static
class
NumericShapings
{
private
static
final
Class
<?>
clazz
=
getClass
(
"java.awt.font.NumericShaper"
);
private
static
final
Method
shapeMethod
=
getMethod
(
clazz
,
"shape"
,
char
[].
class
,
int
.
class
,
int
.
class
);
private
static
Class
<?>
getClass
(
String
name
)
{
try
{
return
Class
.
forName
(
name
,
true
,
null
);
}
catch
(
ClassNotFoundException
e
)
{
return
null
;
}
}
private
static
Method
getMethod
(
Class
<?>
clazz
,
String
name
,
Class
<?>...
paramTypes
)
{
if
(
clazz
!=
null
)
{
try
{
return
clazz
.
getMethod
(
name
,
paramTypes
);
}
catch
(
NoSuchMethodException
e
)
{
throw
new
AssertionError
(
e
);
}
}
else
{
return
null
;
}
}
/**
* Invokes NumericShaping shape(text,start,count) method.
*/
static
void
shape
(
Object
shaper
,
char
[]
text
,
int
start
,
int
count
)
{
if
(
shapeMethod
==
null
)
throw
new
AssertionError
(
"Should not get here"
);
try
{
shapeMethod
.
invoke
(
shaper
,
text
,
start
,
count
);
}
catch
(
InvocationTargetException
e
)
{
Throwable
cause
=
e
.
getCause
();
if
(
cause
instanceof
RuntimeException
)
throw
(
RuntimeException
)
cause
;
throw
new
AssertionError
(
e
);
}
catch
(
IllegalAccessException
iae
)
{
throw
new
AssertionError
(
iae
);
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录