Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
421115af
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看板
提交
421115af
编写于
4月 18, 2011
作者:
L
lana
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
2f8ccf10
0dcd86d4
变更
58
展开全部
隐藏空白更改
内联
并排
Showing
58 changed file
with
2459 addition
and
1574 deletion
+2459
-1574
make/java/java/FILES_java.gmk
make/java/java/FILES_java.gmk
+1
-1
src/share/classes/com/sun/media/sound/DLSInstrument.java
src/share/classes/com/sun/media/sound/DLSInstrument.java
+3
-2
src/share/classes/com/sun/media/sound/DLSSample.java
src/share/classes/com/sun/media/sound/DLSSample.java
+3
-2
src/share/classes/com/sun/media/sound/ModelConnectionBlock.java
...are/classes/com/sun/media/sound/ModelConnectionBlock.java
+5
-5
src/share/classes/com/sun/media/sound/SoftChannel.java
src/share/classes/com/sun/media/sound/SoftChannel.java
+3
-3
src/share/classes/com/sun/media/sound/SoftInstrument.java
src/share/classes/com/sun/media/sound/SoftInstrument.java
+5
-0
src/share/classes/com/sun/media/sound/SoftMixingDataLine.java
...share/classes/com/sun/media/sound/SoftMixingDataLine.java
+1
-1
src/share/classes/com/sun/media/sound/SoftProvider.java
src/share/classes/com/sun/media/sound/SoftProvider.java
+2
-1
src/share/classes/com/sun/media/sound/SoftTuning.java
src/share/classes/com/sun/media/sound/SoftTuning.java
+4
-1
src/share/classes/java/text/ChoiceFormat.java
src/share/classes/java/text/ChoiceFormat.java
+1
-1
src/share/classes/java/util/Locale.java
src/share/classes/java/util/Locale.java
+173
-123
src/share/classes/java/util/ResourceBundle.java
src/share/classes/java/util/ResourceBundle.java
+15
-16
src/share/classes/javax/sound/midi/MidiSystem.java
src/share/classes/javax/sound/midi/MidiSystem.java
+13
-1
src/share/classes/javax/swing/Painter.java
src/share/classes/javax/swing/Painter.java
+9
-7
src/share/classes/javax/swing/border/TitledBorder.java
src/share/classes/javax/swing/border/TitledBorder.java
+19
-17
src/share/classes/javax/swing/plaf/basic/BasicColorChooserUI.java
...e/classes/javax/swing/plaf/basic/BasicColorChooserUI.java
+1
-2
src/share/classes/javax/swing/plaf/basic/BasicDesktopIconUI.java
...re/classes/javax/swing/plaf/basic/BasicDesktopIconUI.java
+1
-2
src/share/classes/javax/swing/plaf/basic/BasicLabelUI.java
src/share/classes/javax/swing/plaf/basic/BasicLabelUI.java
+5
-1
src/share/classes/javax/swing/plaf/basic/BasicListUI.java
src/share/classes/javax/swing/plaf/basic/BasicListUI.java
+1
-2
src/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java
...are/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java
+3
-6
src/share/classes/javax/swing/plaf/basic/BasicProgressBarUI.java
...re/classes/javax/swing/plaf/basic/BasicProgressBarUI.java
+1
-2
src/share/classes/javax/swing/plaf/basic/BasicTableHeaderUI.java
...re/classes/javax/swing/plaf/basic/BasicTableHeaderUI.java
+1
-2
src/share/classes/javax/swing/plaf/basic/BasicTableUI.java
src/share/classes/javax/swing/plaf/basic/BasicTableUI.java
+2
-5
src/share/classes/javax/swing/plaf/metal/MetalComboBoxUI.java
...share/classes/javax/swing/plaf/metal/MetalComboBoxUI.java
+3
-6
src/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java
...are/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java
+1
-2
src/share/classes/javax/swing/text/GlyphPainter2.java
src/share/classes/javax/swing/text/GlyphPainter2.java
+5
-0
src/share/classes/javax/swing/text/GlyphView.java
src/share/classes/javax/swing/text/GlyphView.java
+24
-1
src/share/classes/javax/swing/text/ParagraphView.java
src/share/classes/javax/swing/text/ParagraphView.java
+28
-1
src/share/classes/javax/swing/text/Utilities.java
src/share/classes/javax/swing/text/Utilities.java
+2
-2
src/share/classes/javax/swing/text/html/CSS.java
src/share/classes/javax/swing/text/html/CSS.java
+11
-1
src/share/classes/javax/swing/text/html/parser/Parser.java
src/share/classes/javax/swing/text/html/parser/Parser.java
+6
-1
src/share/classes/sun/swing/SwingUtilities2.java
src/share/classes/sun/swing/SwingUtilities2.java
+3
-4
src/share/classes/sun/util/locale/BaseLocale.java
src/share/classes/sun/util/locale/BaseLocale.java
+147
-97
src/share/classes/sun/util/locale/Extension.java
src/share/classes/sun/util/locale/Extension.java
+15
-10
src/share/classes/sun/util/locale/InternalLocaleBuilder.java
src/share/classes/sun/util/locale/InternalLocaleBuilder.java
+165
-139
src/share/classes/sun/util/locale/LanguageTag.java
src/share/classes/sun/util/locale/LanguageTag.java
+127
-112
src/share/classes/sun/util/locale/LocaleExtensions.java
src/share/classes/sun/util/locale/LocaleExtensions.java
+58
-62
src/share/classes/sun/util/locale/LocaleObjectCache.java
src/share/classes/sun/util/locale/LocaleObjectCache.java
+19
-12
src/share/classes/sun/util/locale/LocaleSyntaxException.java
src/share/classes/sun/util/locale/LocaleSyntaxException.java
+4
-4
src/share/classes/sun/util/locale/LocaleUtils.java
src/share/classes/sun/util/locale/LocaleUtils.java
+224
-0
src/share/classes/sun/util/locale/ParseStatus.java
src/share/classes/sun/util/locale/ParseStatus.java
+15
-11
src/share/classes/sun/util/locale/StringTokenIterator.java
src/share/classes/sun/util/locale/StringTokenIterator.java
+49
-37
src/share/classes/sun/util/locale/UnicodeLocaleExtension.java
...share/classes/sun/util/locale/UnicodeLocaleExtension.java
+41
-40
src/share/classes/sun/util/resources/TimeZoneNames_pt_BR.java
...share/classes/sun/util/resources/TimeZoneNames_pt_BR.java
+802
-800
src/windows/classes/sun/awt/Win32FontManager.java
src/windows/classes/sun/awt/Win32FontManager.java
+8
-0
src/windows/classes/sun/awt/Win32GraphicsEnvironment.java
src/windows/classes/sun/awt/Win32GraphicsEnvironment.java
+0
-8
test/java/text/Bidi/Bug6665028.java
test/java/text/Bidi/Bug6665028.java
+9
-3
test/java/util/Locale/Bug4518797.java
test/java/util/Locale/Bug4518797.java
+8
-3
test/java/util/Locale/LocaleEnhanceTest.java
test/java/util/Locale/LocaleEnhanceTest.java
+37
-1
test/java/util/ResourceBundle/Control/StressTest.java
test/java/util/ResourceBundle/Control/StressTest.java
+10
-9
test/javax/swing/JComponent/6989617/bug6989617.java
test/javax/swing/JComponent/6989617/bug6989617.java
+1
-3
test/javax/swing/JLabel/6596966/bug6596966.java
test/javax/swing/JLabel/6596966/bug6596966.java
+95
-0
test/javax/swing/JLabel/7004134/bug7004134.java
test/javax/swing/JLabel/7004134/bug7004134.java
+12
-0
test/javax/swing/JMenuItem/7036148/bug7036148.java
test/javax/swing/JMenuItem/7036148/bug7036148.java
+53
-0
test/javax/swing/border/Test7034614.java
test/javax/swing/border/Test7034614.java
+77
-0
test/javax/swing/plaf/synth/7032791/bug7032791.java
test/javax/swing/plaf/synth/7032791/bug7032791.java
+48
-0
test/javax/swing/text/CSSBorder/6796710/bug6796710.java
test/javax/swing/text/CSSBorder/6796710/bug6796710.java
+7
-2
test/javax/swing/text/html/parser/Parser/7003777/bug7003777.java
...vax/swing/text/html/parser/Parser/7003777/bug7003777.java
+73
-0
未找到文件。
make/java/java/FILES_java.gmk
浏览文件 @
421115af
...
@@ -189,7 +189,6 @@ JAVA_JAVA_java = \
...
@@ -189,7 +189,6 @@ JAVA_JAVA_java = \
java/util/ListResourceBundle.java \
java/util/ListResourceBundle.java \
sun/util/EmptyListResourceBundle.java \
sun/util/EmptyListResourceBundle.java \
java/util/Locale.java \
java/util/Locale.java \
sun/util/locale/AsciiUtil.java \
sun/util/locale/BaseLocale.java \
sun/util/locale/BaseLocale.java \
sun/util/locale/Extension.java \
sun/util/locale/Extension.java \
sun/util/locale/InternalLocaleBuilder.java \
sun/util/locale/InternalLocaleBuilder.java \
...
@@ -197,6 +196,7 @@ JAVA_JAVA_java = \
...
@@ -197,6 +196,7 @@ JAVA_JAVA_java = \
sun/util/locale/LocaleExtensions.java \
sun/util/locale/LocaleExtensions.java \
sun/util/locale/LocaleObjectCache.java \
sun/util/locale/LocaleObjectCache.java \
sun/util/locale/LocaleSyntaxException.java \
sun/util/locale/LocaleSyntaxException.java \
sun/util/locale/LocaleUtils.java \
sun/util/locale/ParseStatus.java \
sun/util/locale/ParseStatus.java \
sun/util/locale/StringTokenIterator.java \
sun/util/locale/StringTokenIterator.java \
sun/util/locale/UnicodeLocaleExtension.java \
sun/util/locale/UnicodeLocaleExtension.java \
...
...
src/share/classes/com/sun/media/sound/DLSInstrument.java
浏览文件 @
421115af
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
package
com.sun.media.sound
;
package
com.sun.media.sound
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -439,10 +440,10 @@ public class DLSInstrument extends ModelInstrument {
...
@@ -439,10 +440,10 @@ public class DLSInstrument extends ModelInstrument {
}
}
public
byte
[]
getGuid
()
{
public
byte
[]
getGuid
()
{
return
guid
;
return
guid
==
null
?
null
:
Arrays
.
copyOf
(
guid
,
guid
.
length
)
;
}
}
public
void
setGuid
(
byte
[]
guid
)
{
public
void
setGuid
(
byte
[]
guid
)
{
this
.
guid
=
guid
;
this
.
guid
=
guid
==
null
?
null
:
Arrays
.
copyOf
(
guid
,
guid
.
length
)
;
}
}
}
}
src/share/classes/com/sun/media/sound/DLSSample.java
浏览文件 @
421115af
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
package
com.sun.media.sound
;
package
com.sun.media.sound
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.util.Arrays
;
import
javax.sound.midi.Soundbank
;
import
javax.sound.midi.Soundbank
;
import
javax.sound.midi.SoundbankResource
;
import
javax.sound.midi.SoundbankResource
;
import
javax.sound.sampled.AudioFormat
;
import
javax.sound.sampled.AudioFormat
;
...
@@ -113,10 +114,10 @@ public class DLSSample extends SoundbankResource {
...
@@ -113,10 +114,10 @@ public class DLSSample extends SoundbankResource {
}
}
public
byte
[]
getGuid
()
{
public
byte
[]
getGuid
()
{
return
guid
;
return
guid
==
null
?
null
:
Arrays
.
copyOf
(
guid
,
guid
.
length
)
;
}
}
public
void
setGuid
(
byte
[]
guid
)
{
public
void
setGuid
(
byte
[]
guid
)
{
this
.
guid
=
guid
;
this
.
guid
=
guid
==
null
?
null
:
Arrays
.
copyOf
(
guid
,
guid
.
length
)
;
}
}
}
}
src/share/classes/com/sun/media/sound/ModelConnectionBlock.java
浏览文件 @
421115af
...
@@ -24,6 +24,8 @@
...
@@ -24,6 +24,8 @@
*/
*/
package
com.sun.media.sound
;
package
com.sun.media.sound
;
import
java.util.Arrays
;
/**
/**
* Connection blocks are used to connect source variable
* Connection blocks are used to connect source variable
* to a destination variable.
* to a destination variable.
...
@@ -117,19 +119,17 @@ public class ModelConnectionBlock {
...
@@ -117,19 +119,17 @@ public class ModelConnectionBlock {
}
}
public
ModelSource
[]
getSources
()
{
public
ModelSource
[]
getSources
()
{
return
sources
;
return
Arrays
.
copyOf
(
sources
,
sources
.
length
)
;
}
}
public
void
setSources
(
ModelSource
[]
source
)
{
public
void
setSources
(
ModelSource
[]
source
)
{
this
.
sources
=
source
;
this
.
sources
=
source
==
null
?
no_sources
:
Arrays
.
copyOf
(
source
,
source
.
length
)
;
}
}
public
void
addSource
(
ModelSource
source
)
{
public
void
addSource
(
ModelSource
source
)
{
ModelSource
[]
oldsources
=
sources
;
ModelSource
[]
oldsources
=
sources
;
sources
=
new
ModelSource
[
oldsources
.
length
+
1
];
sources
=
new
ModelSource
[
oldsources
.
length
+
1
];
for
(
int
i
=
0
;
i
<
oldsources
.
length
;
i
++)
{
System
.
arraycopy
(
oldsources
,
0
,
sources
,
0
,
oldsources
.
length
);
sources
[
i
]
=
oldsources
[
i
];
}
sources
[
sources
.
length
-
1
]
=
source
;
sources
[
sources
.
length
-
1
]
=
source
;
}
}
}
}
src/share/classes/com/sun/media/sound/SoftChannel.java
浏览文件 @
421115af
...
@@ -503,7 +503,7 @@ public class SoftChannel implements MidiChannel, ModelDirectedPlayer {
...
@@ -503,7 +503,7 @@ public class SoftChannel implements MidiChannel, ModelDirectedPlayer {
firstVoice
=
true
;
firstVoice
=
true
;
voiceNo
=
0
;
voiceNo
=
0
;
int
tunedKey
=
(
int
)(
Math
.
round
(
tuning
.
getTuning
(
)[
noteNumber
]
/
100.0
));
int
tunedKey
=
(
int
)(
Math
.
round
(
tuning
.
getTuning
(
noteNumber
)
/
100.0
));
play_noteNumber
=
noteNumber
;
play_noteNumber
=
noteNumber
;
play_velocity
=
velocity
;
play_velocity
=
velocity
;
play_delay
=
delay
;
play_delay
=
delay
;
...
@@ -607,7 +607,7 @@ public class SoftChannel implements MidiChannel, ModelDirectedPlayer {
...
@@ -607,7 +607,7 @@ public class SoftChannel implements MidiChannel, ModelDirectedPlayer {
firstVoice
=
true
;
firstVoice
=
true
;
voiceNo
=
0
;
voiceNo
=
0
;
int
tunedKey
=
(
int
)(
Math
.
round
(
tuning
.
getTuning
(
)[
noteNumber
]
/
100.0
));
int
tunedKey
=
(
int
)(
Math
.
round
(
tuning
.
getTuning
(
noteNumber
)
/
100.0
));
play_noteNumber
=
noteNumber
;
play_noteNumber
=
noteNumber
;
play_velocity
=
lastVelocity
[
noteNumber
];
play_velocity
=
lastVelocity
[
noteNumber
];
play_releasetriggered
=
true
;
play_releasetriggered
=
true
;
...
@@ -632,7 +632,7 @@ public class SoftChannel implements MidiChannel, ModelDirectedPlayer {
...
@@ -632,7 +632,7 @@ public class SoftChannel implements MidiChannel, ModelDirectedPlayer {
int
delay
=
play_delay
;
int
delay
=
play_delay
;
boolean
releasetriggered
=
play_releasetriggered
;
boolean
releasetriggered
=
play_releasetriggered
;
SoftPerformer
p
=
current_instrument
.
getPerformer
s
()[
performerIndex
]
;
SoftPerformer
p
=
current_instrument
.
getPerformer
(
performerIndex
)
;
if
(
firstVoice
)
{
if
(
firstVoice
)
{
firstVoice
=
false
;
firstVoice
=
false
;
...
...
src/share/classes/com/sun/media/sound/SoftInstrument.java
浏览文件 @
421115af
...
@@ -76,7 +76,12 @@ public class SoftInstrument extends Instrument {
...
@@ -76,7 +76,12 @@ public class SoftInstrument extends Instrument {
return
data
;
return
data
;
}
}
/* am: currently getPerformers() is not used (replaced with getPerformer(int))
public SoftPerformer[] getPerformers() {
public SoftPerformer[] getPerformers() {
return performers;
return performers;
}
}
*/
public
SoftPerformer
getPerformer
(
int
index
)
{
return
performers
[
index
];
}
}
}
src/share/classes/com/sun/media/sound/SoftMixingDataLine.java
浏览文件 @
421115af
...
@@ -505,7 +505,7 @@ public abstract class SoftMixingDataLine implements DataLine {
...
@@ -505,7 +505,7 @@ public abstract class SoftMixingDataLine implements DataLine {
}
}
public
Control
[]
getControls
()
{
public
Control
[]
getControls
()
{
return
controls
;
return
Arrays
.
copyOf
(
controls
,
controls
.
length
)
;
}
}
public
boolean
isControlSupported
(
Type
control
)
{
public
boolean
isControlSupported
(
Type
control
)
{
...
...
src/share/classes/com/sun/media/sound/SoftProvider.java
浏览文件 @
421115af
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
*/
*/
package
com.sun.media.sound
;
package
com.sun.media.sound
;
import
java.util.Arrays
;
import
javax.sound.midi.MidiDevice
;
import
javax.sound.midi.MidiDevice
;
import
javax.sound.midi.MidiDevice.Info
;
import
javax.sound.midi.MidiDevice.Info
;
import
javax.sound.midi.spi.MidiDeviceProvider
;
import
javax.sound.midi.spi.MidiDeviceProvider
;
...
@@ -39,7 +40,7 @@ public class SoftProvider extends MidiDeviceProvider {
...
@@ -39,7 +40,7 @@ public class SoftProvider extends MidiDeviceProvider {
private
static
Info
[]
softinfos
=
{
softinfo
};
private
static
Info
[]
softinfos
=
{
softinfo
};
public
MidiDevice
.
Info
[]
getDeviceInfo
()
{
public
MidiDevice
.
Info
[]
getDeviceInfo
()
{
return
softinfos
;
return
Arrays
.
copyOf
(
softinfos
,
softinfos
.
length
)
;
}
}
public
MidiDevice
getDevice
(
MidiDevice
.
Info
info
)
{
public
MidiDevice
getDevice
(
MidiDevice
.
Info
info
)
{
...
...
src/share/classes/com/sun/media/sound/SoftTuning.java
浏览文件 @
421115af
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
package
com.sun.media.sound
;
package
com.sun.media.sound
;
import
java.io.UnsupportedEncodingException
;
import
java.io.UnsupportedEncodingException
;
import
java.util.Arrays
;
import
javax.sound.midi.Patch
;
import
javax.sound.midi.Patch
;
...
@@ -234,8 +235,10 @@ public class SoftTuning {
...
@@ -234,8 +235,10 @@ public class SoftTuning {
}
}
}
}
// am: getTuning(int) is more effective.
// currently getTuning() is used only by tests
public
double
[]
getTuning
()
{
public
double
[]
getTuning
()
{
return
tuning
;
return
Arrays
.
copyOf
(
tuning
,
tuning
.
length
)
;
}
}
public
double
getTuning
(
int
noteNumber
)
{
public
double
getTuning
(
int
noteNumber
)
{
...
...
src/share/classes/java/text/ChoiceFormat.java
浏览文件 @
421115af
...
@@ -136,8 +136,8 @@ import java.util.Arrays;
...
@@ -136,8 +136,8 @@ import java.util.Arrays;
* </pre>
* </pre>
* </blockquote>
* </blockquote>
* And the output result would be like the following:
* And the output result would be like the following:
* <pre>
* <blockquote>
* <blockquote>
* <pre>
* Format with -INF : is negative
* Format with -INF : is negative
* Format with -1.0 : is negative
* Format with -1.0 : is negative
* Format with 0 : is zero or fraction
* Format with 0 : is zero or fraction
...
...
src/share/classes/java/util/Locale.java
浏览文件 @
421115af
此差异已折叠。
点击以展开。
src/share/classes/java/util/ResourceBundle.java
浏览文件 @
421115af
/*
/*
* Copyright (c) 1996, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 201
1
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -57,7 +57,6 @@ import java.util.concurrent.ConcurrentMap;
...
@@ -57,7 +57,6 @@ import java.util.concurrent.ConcurrentMap;
import
java.util.jar.JarEntry
;
import
java.util.jar.JarEntry
;
import
sun.util.locale.BaseLocale
;
import
sun.util.locale.BaseLocale
;
import
sun.util.locale.LocaleExtensions
;
import
sun.util.locale.LocaleObjectCache
;
import
sun.util.locale.LocaleObjectCache
;
...
@@ -290,7 +289,7 @@ public abstract class ResourceBundle {
...
@@ -290,7 +289,7 @@ public abstract class ResourceBundle {
* name for compatibility with some workarounds for bug 4212439.
* name for compatibility with some workarounds for bug 4212439.
*/
*/
private
static
final
ConcurrentMap
<
CacheKey
,
BundleReference
>
cacheList
private
static
final
ConcurrentMap
<
CacheKey
,
BundleReference
>
cacheList
=
new
ConcurrentHashMap
<
CacheKey
,
BundleReference
>(
INITIAL_CACHE_SIZE
);
=
new
ConcurrentHashMap
<>(
INITIAL_CACHE_SIZE
);
/**
/**
* Queue for reference objects referring to class loaders or bundles.
* Queue for reference objects referring to class loaders or bundles.
...
@@ -1755,7 +1754,7 @@ public abstract class ResourceBundle {
...
@@ -1755,7 +1754,7 @@ public abstract class ResourceBundle {
* @since 1.6
* @since 1.6
*/
*/
public
Set
<
String
>
keySet
()
{
public
Set
<
String
>
keySet
()
{
Set
<
String
>
keys
=
new
HashSet
<
String
>();
Set
<
String
>
keys
=
new
HashSet
<>();
for
(
ResourceBundle
rb
=
this
;
rb
!=
null
;
rb
=
rb
.
parent
)
{
for
(
ResourceBundle
rb
=
this
;
rb
!=
null
;
rb
=
rb
.
parent
)
{
keys
.
addAll
(
rb
.
handleKeySet
());
keys
.
addAll
(
rb
.
handleKeySet
());
}
}
...
@@ -1783,7 +1782,7 @@ public abstract class ResourceBundle {
...
@@ -1783,7 +1782,7 @@ public abstract class ResourceBundle {
if
(
keySet
==
null
)
{
if
(
keySet
==
null
)
{
synchronized
(
this
)
{
synchronized
(
this
)
{
if
(
keySet
==
null
)
{
if
(
keySet
==
null
)
{
Set
<
String
>
keys
=
new
HashSet
<
String
>();
Set
<
String
>
keys
=
new
HashSet
<>();
Enumeration
<
String
>
enumKeys
=
getKeys
();
Enumeration
<
String
>
enumKeys
=
getKeys
();
while
(
enumKeys
.
hasMoreElements
())
{
while
(
enumKeys
.
hasMoreElements
())
{
String
key
=
enumKeys
.
nextElement
();
String
key
=
enumKeys
.
nextElement
();
...
@@ -2301,7 +2300,7 @@ public abstract class ResourceBundle {
...
@@ -2301,7 +2300,7 @@ public abstract class ResourceBundle {
if
(
baseName
==
null
)
{
if
(
baseName
==
null
)
{
throw
new
NullPointerException
();
throw
new
NullPointerException
();
}
}
return
new
ArrayList
<
Locale
>(
CANDIDATES_CACHE
.
get
(
locale
.
getBaseLocale
()));
return
new
ArrayList
<>(
CANDIDATES_CACHE
.
get
(
locale
.
getBaseLocale
()));
}
}
private
static
final
CandidateListCache
CANDIDATES_CACHE
=
new
CandidateListCache
();
private
static
final
CandidateListCache
CANDIDATES_CACHE
=
new
CandidateListCache
();
...
@@ -2327,14 +2326,14 @@ public abstract class ResourceBundle {
...
@@ -2327,14 +2326,14 @@ public abstract class ResourceBundle {
if
(
language
.
equals
(
"nb"
)
||
isNorwegianBokmal
)
{
if
(
language
.
equals
(
"nb"
)
||
isNorwegianBokmal
)
{
List
<
Locale
>
tmpList
=
getDefaultList
(
"nb"
,
script
,
region
,
variant
);
List
<
Locale
>
tmpList
=
getDefaultList
(
"nb"
,
script
,
region
,
variant
);
// Insert a locale replacing "nb" with "no" for every list entry
// Insert a locale replacing "nb" with "no" for every list entry
List
<
Locale
>
bokmalList
=
new
LinkedList
<
Locale
>();
List
<
Locale
>
bokmalList
=
new
LinkedList
<>();
for
(
Locale
l
:
tmpList
)
{
for
(
Locale
l
:
tmpList
)
{
bokmalList
.
add
(
l
);
bokmalList
.
add
(
l
);
if
(
l
.
getLanguage
().
length
()
==
0
)
{
if
(
l
.
getLanguage
().
length
()
==
0
)
{
break
;
break
;
}
}
bokmalList
.
add
(
Locale
.
getInstance
(
"no"
,
l
.
getScript
(),
l
.
getCountry
(),
bokmalList
.
add
(
Locale
.
getInstance
(
"no"
,
l
.
getScript
(),
l
.
getCountry
(),
l
.
getVariant
(),
LocaleExtensions
.
EMPTY_EXTENSIONS
));
l
.
getVariant
(),
null
));
}
}
return
bokmalList
;
return
bokmalList
;
}
else
if
(
language
.
equals
(
"nn"
)
||
isNorwegianNynorsk
)
{
}
else
if
(
language
.
equals
(
"nn"
)
||
isNorwegianNynorsk
)
{
...
@@ -2374,7 +2373,7 @@ public abstract class ResourceBundle {
...
@@ -2374,7 +2373,7 @@ public abstract class ResourceBundle {
List
<
String
>
variants
=
null
;
List
<
String
>
variants
=
null
;
if
(
variant
.
length
()
>
0
)
{
if
(
variant
.
length
()
>
0
)
{
variants
=
new
LinkedList
<
String
>();
variants
=
new
LinkedList
<>();
int
idx
=
variant
.
length
();
int
idx
=
variant
.
length
();
while
(
idx
!=
-
1
)
{
while
(
idx
!=
-
1
)
{
variants
.
add
(
variant
.
substring
(
0
,
idx
));
variants
.
add
(
variant
.
substring
(
0
,
idx
));
...
@@ -2382,32 +2381,32 @@ public abstract class ResourceBundle {
...
@@ -2382,32 +2381,32 @@ public abstract class ResourceBundle {
}
}
}
}
Li
nkedList
<
Locale
>
list
=
new
LinkedList
<
Locale
>();
Li
st
<
Locale
>
list
=
new
LinkedList
<
>();
if
(
variants
!=
null
)
{
if
(
variants
!=
null
)
{
for
(
String
v
:
variants
)
{
for
(
String
v
:
variants
)
{
list
.
add
(
Locale
.
getInstance
(
language
,
script
,
region
,
v
,
LocaleExtensions
.
EMPTY_EXTENSIONS
));
list
.
add
(
Locale
.
getInstance
(
language
,
script
,
region
,
v
,
null
));
}
}
}
}
if
(
region
.
length
()
>
0
)
{
if
(
region
.
length
()
>
0
)
{
list
.
add
(
Locale
.
getInstance
(
language
,
script
,
region
,
""
,
LocaleExtensions
.
EMPTY_EXTENSIONS
));
list
.
add
(
Locale
.
getInstance
(
language
,
script
,
region
,
""
,
null
));
}
}
if
(
script
.
length
()
>
0
)
{
if
(
script
.
length
()
>
0
)
{
list
.
add
(
Locale
.
getInstance
(
language
,
script
,
""
,
""
,
LocaleExtensions
.
EMPTY_EXTENSIONS
));
list
.
add
(
Locale
.
getInstance
(
language
,
script
,
""
,
""
,
null
));
// With script, after truncating variant, region and script,
// With script, after truncating variant, region and script,
// start over without script.
// start over without script.
if
(
variants
!=
null
)
{
if
(
variants
!=
null
)
{
for
(
String
v
:
variants
)
{
for
(
String
v
:
variants
)
{
list
.
add
(
Locale
.
getInstance
(
language
,
""
,
region
,
v
,
LocaleExtensions
.
EMPTY_EXTENSIONS
));
list
.
add
(
Locale
.
getInstance
(
language
,
""
,
region
,
v
,
null
));
}
}
}
}
if
(
region
.
length
()
>
0
)
{
if
(
region
.
length
()
>
0
)
{
list
.
add
(
Locale
.
getInstance
(
language
,
""
,
region
,
""
,
LocaleExtensions
.
EMPTY_EXTENSIONS
));
list
.
add
(
Locale
.
getInstance
(
language
,
""
,
region
,
""
,
null
));
}
}
}
}
if
(
language
.
length
()
>
0
)
{
if
(
language
.
length
()
>
0
)
{
list
.
add
(
Locale
.
getInstance
(
language
,
""
,
""
,
""
,
LocaleExtensions
.
EMPTY_EXTENSIONS
));
list
.
add
(
Locale
.
getInstance
(
language
,
""
,
""
,
""
,
null
));
}
}
// Add root locale at the end
// Add root locale at the end
list
.
add
(
Locale
.
ROOT
);
list
.
add
(
Locale
.
ROOT
);
...
...
src/share/classes/javax/sound/midi/MidiSystem.java
浏览文件 @
421115af
...
@@ -239,6 +239,12 @@ public class MidiSystem {
...
@@ -239,6 +239,12 @@ public class MidiSystem {
* If a suitable MIDI port is not available, the Receiver is
* If a suitable MIDI port is not available, the Receiver is
* retrieved from an installed synthesizer.
* retrieved from an installed synthesizer.
*
*
* <p>If a native receiver provided by the default device does not implement
* the {@code MidiDeviceReceiver} interface, it will be wrapped in a
* wrapper class that implements the {@code MidiDeviceReceiver} interface.
* The corresponding {@code Receiver} method calls will be forwarded
* to the native receiver.
*
* <p>If this method returns successfully, the {@link
* <p>If this method returns successfully, the {@link
* javax.sound.midi.MidiDevice MidiDevice} the
* javax.sound.midi.MidiDevice MidiDevice} the
* <code>Receiver</code> belongs to is opened implicitly, if it is
* <code>Receiver</code> belongs to is opened implicitly, if it is
...
@@ -284,7 +290,13 @@ public class MidiSystem {
...
@@ -284,7 +290,13 @@ public class MidiSystem {
* it is used to identify the device that provides the default transmitter.
* it is used to identify the device that provides the default transmitter.
* For details, refer to the {@link MidiSystem class description}.
* For details, refer to the {@link MidiSystem class description}.
*
*
* If this method returns successfully, the {@link
* <p>If a native transmitter provided by the default device does not implement
* the {@code MidiDeviceTransmitter} interface, it will be wrapped in a
* wrapper class that implements the {@code MidiDeviceTransmitter} interface.
* The corresponding {@code Transmitter} method calls will be forwarded
* to the native transmitter.
*
* <p>If this method returns successfully, the {@link
* javax.sound.midi.MidiDevice MidiDevice} the
* javax.sound.midi.MidiDevice MidiDevice} the
* <code>Transmitter</code> belongs to is opened implicitly, if it
* <code>Transmitter</code> belongs to is opened implicitly, if it
* is not already open. It is possible to close an implicitly
* is not already open. It is possible to close an implicitly
...
...
src/share/classes/javax/swing/Painter.java
浏览文件 @
421115af
...
@@ -45,14 +45,16 @@ import java.awt.Graphics2D;
...
@@ -45,14 +45,16 @@ import java.awt.Graphics2D;
* <code>Painter</code> that only works with subclasses of {@link java.awt.Component}.
* <code>Painter</code> that only works with subclasses of {@link java.awt.Component}.
* In that case, when the <code>Painter</code> is declared, you may declare that
* In that case, when the <code>Painter</code> is declared, you may declare that
* it requires a <code>Component</code>, allowing the paint method to be type safe. Ex:
* it requires a <code>Component</code>, allowing the paint method to be type safe. Ex:
* <pre>
<code>
* <pre>
*
Painter<Component> p = new Painter<Component>() {
*
{@code
*
public void paint(Graphics2D g, Component c, int width, int height
) {
*
Painter<Component> p = new Painter<Component>(
) {
*
g.setColor(c.getBackground());
*
public void paint(Graphics2D g, Component c, int width, int height) {
*
//and so forth
*
g.setColor(c.getBackground());
*
}
*
//and so forth
* }
* }
* </code></pre></p>
* }
* }
* </pre></p>
*
*
* <p>This interface makes no guarantees of threadsafety.</p>
* <p>This interface makes no guarantees of threadsafety.</p>
*
*
...
...
src/share/classes/javax/swing/border/TitledBorder.java
浏览文件 @
421115af
...
@@ -240,9 +240,7 @@ public class TitledBorder extends AbstractBorder
...
@@ -240,9 +240,7 @@ public class TitledBorder extends AbstractBorder
int
edge
=
(
border
instanceof
TitledBorder
)
?
0
:
EDGE_SPACING
;
int
edge
=
(
border
instanceof
TitledBorder
)
?
0
:
EDGE_SPACING
;
JLabel
label
=
getLabel
(
c
);
JLabel
label
=
getLabel
(
c
);
Dimension
size
=
label
.
getPreferredSize
();
Dimension
size
=
label
.
getPreferredSize
();
Insets
insets
=
(
border
!=
null
)
Insets
insets
=
getBorderInsets
(
border
,
c
,
new
Insets
(
0
,
0
,
0
,
0
));
?
border
.
getBorderInsets
(
c
)
:
new
Insets
(
0
,
0
,
0
,
0
);
int
borderX
=
x
+
edge
;
int
borderX
=
x
+
edge
;
int
borderY
=
y
+
edge
;
int
borderY
=
y
+
edge
;
...
@@ -348,17 +346,8 @@ public class TitledBorder extends AbstractBorder
...
@@ -348,17 +346,8 @@ public class TitledBorder extends AbstractBorder
*/
*/
public
Insets
getBorderInsets
(
Component
c
,
Insets
insets
)
{
public
Insets
getBorderInsets
(
Component
c
,
Insets
insets
)
{
Border
border
=
getBorder
();
Border
border
=
getBorder
();
if
(
border
==
null
)
{
insets
=
getBorderInsets
(
border
,
c
,
insets
);
insets
.
set
(
0
,
0
,
0
,
0
);
}
else
if
(
border
instanceof
AbstractBorder
)
{
AbstractBorder
ab
=
(
AbstractBorder
)
border
;
insets
=
ab
.
getBorderInsets
(
c
,
insets
);
}
else
{
Insets
i
=
border
.
getBorderInsets
(
c
);
insets
.
set
(
i
.
top
,
i
.
left
,
i
.
bottom
,
i
.
right
);
}
String
title
=
getTitle
();
String
title
=
getTitle
();
if
((
title
!=
null
)
&&
!
title
.
isEmpty
())
{
if
((
title
!=
null
)
&&
!
title
.
isEmpty
())
{
int
edge
=
(
border
instanceof
TitledBorder
)
?
0
:
EDGE_SPACING
;
int
edge
=
(
border
instanceof
TitledBorder
)
?
0
:
EDGE_SPACING
;
...
@@ -588,9 +577,7 @@ public class TitledBorder extends AbstractBorder
...
@@ -588,9 +577,7 @@ public class TitledBorder extends AbstractBorder
int
edge
=
(
border
instanceof
TitledBorder
)
?
0
:
EDGE_SPACING
;
int
edge
=
(
border
instanceof
TitledBorder
)
?
0
:
EDGE_SPACING
;
JLabel
label
=
getLabel
(
c
);
JLabel
label
=
getLabel
(
c
);
Dimension
size
=
label
.
getPreferredSize
();
Dimension
size
=
label
.
getPreferredSize
();
Insets
insets
=
(
border
!=
null
)
Insets
insets
=
getBorderInsets
(
border
,
c
,
new
Insets
(
0
,
0
,
0
,
0
));
?
border
.
getBorderInsets
(
c
)
:
new
Insets
(
0
,
0
,
0
,
0
);
int
baseline
=
label
.
getBaseline
(
size
.
width
,
size
.
height
);
int
baseline
=
label
.
getBaseline
(
size
.
width
,
size
.
height
);
switch
(
getPosition
())
{
switch
(
getPosition
())
{
...
@@ -728,4 +715,19 @@ public class TitledBorder extends AbstractBorder
...
@@ -728,4 +715,19 @@ public class TitledBorder extends AbstractBorder
this
.
label
.
setEnabled
(
c
.
isEnabled
());
this
.
label
.
setEnabled
(
c
.
isEnabled
());
return
this
.
label
;
return
this
.
label
;
}
}
private
static
Insets
getBorderInsets
(
Border
border
,
Component
c
,
Insets
insets
)
{
if
(
border
==
null
)
{
insets
.
set
(
0
,
0
,
0
,
0
);
}
else
if
(
border
instanceof
AbstractBorder
)
{
AbstractBorder
ab
=
(
AbstractBorder
)
border
;
insets
=
ab
.
getBorderInsets
(
c
,
insets
);
}
else
{
Insets
i
=
border
.
getBorderInsets
(
c
);
insets
.
set
(
i
.
top
,
i
.
left
,
i
.
bottom
,
i
.
right
);
}
return
insets
;
}
}
}
src/share/classes/javax/swing/plaf/basic/BasicColorChooserUI.java
浏览文件 @
421115af
...
@@ -335,9 +335,8 @@ public class BasicColorChooserUI extends ColorChooserUI
...
@@ -335,9 +335,8 @@ public class BasicColorChooserUI extends ColorChooserUI
}
}
/**
/**
* This inner class is marked "public" due to a compiler bug.
* This class should be treated as a "protected" inner class.
* This class should be treated as a "protected" inner class.
* Instantiate it only within subclasses of
<Foo>
.
* Instantiate it only within subclasses of
{@code BasicColorChooserUI}
.
*/
*/
public
class
PropertyHandler
implements
PropertyChangeListener
{
public
class
PropertyHandler
implements
PropertyChangeListener
{
public
void
propertyChange
(
PropertyChangeEvent
e
)
{
public
void
propertyChange
(
PropertyChangeEvent
e
)
{
...
...
src/share/classes/javax/swing/plaf/basic/BasicDesktopIconUI.java
浏览文件 @
421115af
...
@@ -186,9 +186,8 @@ public class BasicDesktopIconUI extends DesktopIconUI {
...
@@ -186,9 +186,8 @@ public class BasicDesktopIconUI extends DesktopIconUI {
/**
/**
* Listens for mouse movements and acts on them.
* Listens for mouse movements and acts on them.
*
*
* This inner class is marked "public" due to a compiler bug.
* This class should be treated as a "protected" inner class.
* This class should be treated as a "protected" inner class.
* Instantiate it only within subclasses of
<Foo>
.
* Instantiate it only within subclasses of
{@code BasicDesktopIconUI}
.
*/
*/
public
class
MouseInputHandler
extends
MouseInputAdapter
public
class
MouseInputHandler
extends
MouseInputAdapter
{
{
...
...
src/share/classes/javax/swing/plaf/basic/BasicLabelUI.java
浏览文件 @
421115af
...
@@ -455,6 +455,8 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
...
@@ -455,6 +455,8 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
}
}
int
dka
=
label
.
getDisplayedMnemonic
();
int
dka
=
label
.
getDisplayedMnemonic
();
inputMap
.
put
(
KeyStroke
.
getKeyStroke
(
dka
,
ActionEvent
.
ALT_MASK
,
true
),
RELEASE
);
inputMap
.
put
(
KeyStroke
.
getKeyStroke
(
dka
,
ActionEvent
.
ALT_MASK
,
true
),
RELEASE
);
// Need this when the sticky keys are enabled
inputMap
.
put
(
KeyStroke
.
getKeyStroke
(
dka
,
0
,
true
),
RELEASE
);
// Need this if ALT is released before the accelerator
// Need this if ALT is released before the accelerator
inputMap
.
put
(
KeyStroke
.
getKeyStroke
(
KeyEvent
.
VK_ALT
,
0
,
true
),
RELEASE
);
inputMap
.
put
(
KeyStroke
.
getKeyStroke
(
KeyEvent
.
VK_ALT
,
0
,
true
),
RELEASE
);
label
.
requestFocus
();
label
.
requestFocus
();
...
@@ -467,7 +469,9 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
...
@@ -467,7 +469,9 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
InputMap
inputMap
=
SwingUtilities
.
getUIInputMap
(
label
,
JComponent
.
WHEN_FOCUSED
);
InputMap
inputMap
=
SwingUtilities
.
getUIInputMap
(
label
,
JComponent
.
WHEN_FOCUSED
);
if
(
inputMap
!=
null
)
{
if
(
inputMap
!=
null
)
{
// inputMap should never be null.
// inputMap should never be null.
inputMap
.
remove
(
KeyStroke
.
getKeyStroke
(
label
.
getDisplayedMnemonic
(),
ActionEvent
.
ALT_MASK
,
true
));
int
dka
=
label
.
getDisplayedMnemonic
();
inputMap
.
remove
(
KeyStroke
.
getKeyStroke
(
dka
,
ActionEvent
.
ALT_MASK
,
true
));
inputMap
.
remove
(
KeyStroke
.
getKeyStroke
(
dka
,
0
,
true
));
inputMap
.
remove
(
KeyStroke
.
getKeyStroke
(
KeyEvent
.
VK_ALT
,
0
,
true
));
inputMap
.
remove
(
KeyStroke
.
getKeyStroke
(
KeyEvent
.
VK_ALT
,
0
,
true
));
}
}
if
(
labelFor
instanceof
Container
&&
if
(
labelFor
instanceof
Container
&&
...
...
src/share/classes/javax/swing/plaf/basic/BasicListUI.java
浏览文件 @
421115af
...
@@ -1555,9 +1555,8 @@ public class BasicListUI extends ListUI
...
@@ -1555,9 +1555,8 @@ public class BasicListUI extends ListUI
}
}
/**
/**
* This inner class is marked "public" due to a compiler bug.
* This class should be treated as a "protected" inner class.
* This class should be treated as a "protected" inner class.
* Instantiate it only within subclasses of
BasicTableUI
.
* Instantiate it only within subclasses of
{@code BasicListUI}
.
*/
*/
public
class
FocusHandler
implements
FocusListener
public
class
FocusHandler
implements
FocusListener
{
{
...
...
src/share/classes/javax/swing/plaf/basic/BasicOptionPaneUI.java
浏览文件 @
421115af
...
@@ -911,9 +911,8 @@ public class BasicOptionPaneUI extends OptionPaneUI {
...
@@ -911,9 +911,8 @@ public class BasicOptionPaneUI extends OptionPaneUI {
* right. If <code>syncAllWidths</code> is true, the widths of each
* right. If <code>syncAllWidths</code> is true, the widths of each
* component will be set to the largest preferred size width.
* component will be set to the largest preferred size width.
*
*
* This inner class is marked "public" due to a compiler bug.
* This class should be treated as a "protected" inner class.
* This class should be treated as a "protected" inner class.
* Instantiate it only within subclasses of
BasicOptionPaneUI
.
* Instantiate it only within subclasses of
{@code BasicOptionPaneUI}
.
*/
*/
public
static
class
ButtonAreaLayout
implements
LayoutManager
{
public
static
class
ButtonAreaLayout
implements
LayoutManager
{
protected
boolean
syncAllWidths
;
protected
boolean
syncAllWidths
;
...
@@ -1115,9 +1114,8 @@ public class BasicOptionPaneUI extends OptionPaneUI {
...
@@ -1115,9 +1114,8 @@ public class BasicOptionPaneUI extends OptionPaneUI {
/**
/**
* This inner class is marked "public" due to a compiler bug.
* This class should be treated as a "protected" inner class.
* This class should be treated as a "protected" inner class.
* Instantiate it only within subclasses of
BasicOptionPaneUI
.
* Instantiate it only within subclasses of
{@code BasicOptionPaneUI}
.
*/
*/
public
class
PropertyChangeHandler
implements
PropertyChangeListener
{
public
class
PropertyChangeHandler
implements
PropertyChangeListener
{
/**
/**
...
@@ -1161,9 +1159,8 @@ public class BasicOptionPaneUI extends OptionPaneUI {
...
@@ -1161,9 +1159,8 @@ public class BasicOptionPaneUI extends OptionPaneUI {
}
}
/**
/**
* This inner class is marked "public" due to a compiler bug.
* This class should be treated as a "protected" inner class.
* This class should be treated as a "protected" inner class.
* Instantiate it only within subclasses of
BasicOptionPaneUI
.
* Instantiate it only within subclasses of
{@code BasicOptionPaneUI}
.
*/
*/
public
class
ButtonActionListener
implements
ActionListener
{
public
class
ButtonActionListener
implements
ActionListener
{
protected
int
buttonIndex
;
protected
int
buttonIndex
;
...
...
src/share/classes/javax/swing/plaf/basic/BasicProgressBarUI.java
浏览文件 @
421115af
...
@@ -1211,9 +1211,8 @@ public class BasicProgressBarUI extends ProgressBarUI {
...
@@ -1211,9 +1211,8 @@ public class BasicProgressBarUI extends ProgressBarUI {
/**
/**
* This inner class is marked "public" due to a compiler bug.
* This class should be treated as a "protected" inner class.
* This class should be treated as a "protected" inner class.
* Instantiate it only within subclasses of
BasicProgressBarUI
.
* Instantiate it only within subclasses of
{@code BasicProgressBarUI}
.
*/
*/
public
class
ChangeHandler
implements
ChangeListener
{
public
class
ChangeHandler
implements
ChangeListener
{
// NOTE: This class exists only for backward compatability. All
// NOTE: This class exists only for backward compatability. All
...
...
src/share/classes/javax/swing/plaf/basic/BasicTableHeaderUI.java
浏览文件 @
421115af
...
@@ -88,9 +88,8 @@ public class BasicTableHeaderUI extends TableHeaderUI {
...
@@ -88,9 +88,8 @@ public class BasicTableHeaderUI extends TableHeaderUI {
};
};
/**
/**
* This inner class is marked "public" due to a compiler bug.
* This class should be treated as a "protected" inner class.
* This class should be treated as a "protected" inner class.
* Instantiate it only within subclasses of
BasicTableUI
.
* Instantiate it only within subclasses of
{@code BasicTableHeaderUI}
.
*/
*/
public
class
MouseInputHandler
implements
MouseInputListener
{
public
class
MouseInputHandler
implements
MouseInputListener
{
...
...
src/share/classes/javax/swing/plaf/basic/BasicTableUI.java
浏览文件 @
421115af
...
@@ -730,9 +730,8 @@ public class BasicTableUI extends TableUI
...
@@ -730,9 +730,8 @@ public class BasicTableUI extends TableUI
//
//
/**
/**
* This inner class is marked "public" due to a compiler bug.
* This class should be treated as a "protected" inner class.
* This class should be treated as a "protected" inner class.
* Instantiate it only within subclasses of
BasicTableUI
.
* Instantiate it only within subclasses of
{@code BasicTableUI}
.
* <p>As of Java 2 platform v1.3 this class is no longer used.
* <p>As of Java 2 platform v1.3 this class is no longer used.
* Instead <code>JTable</code>
* Instead <code>JTable</code>
* overrides <code>processKeyBinding</code> to dispatch the event to
* overrides <code>processKeyBinding</code> to dispatch the event to
...
@@ -761,9 +760,8 @@ public class BasicTableUI extends TableUI
...
@@ -761,9 +760,8 @@ public class BasicTableUI extends TableUI
//
//
/**
/**
* This inner class is marked "public" due to a compiler bug.
* This class should be treated as a "protected" inner class.
* This class should be treated as a "protected" inner class.
* Instantiate it only within subclasses of
BasicTableUI
.
* Instantiate it only within subclasses of
{@code BasicTableUI}
.
*/
*/
public
class
FocusHandler
implements
FocusListener
{
public
class
FocusHandler
implements
FocusListener
{
// NOTE: This class exists only for backward compatability. All
// NOTE: This class exists only for backward compatability. All
...
@@ -784,7 +782,6 @@ public class BasicTableUI extends TableUI
...
@@ -784,7 +782,6 @@ public class BasicTableUI extends TableUI
//
//
/**
/**
* This inner class is marked "public" due to a compiler bug.
* This class should be treated as a "protected" inner class.
* This class should be treated as a "protected" inner class.
* Instantiate it only within subclasses of BasicTableUI.
* Instantiate it only within subclasses of BasicTableUI.
*/
*/
...
...
src/share/classes/javax/swing/plaf/metal/MetalComboBoxUI.java
浏览文件 @
421115af
...
@@ -199,9 +199,8 @@ public class MetalComboBoxUI extends BasicComboBoxUI {
...
@@ -199,9 +199,8 @@ public class MetalComboBoxUI extends BasicComboBoxUI {
}
}
/**
/**
* This inner class is marked "public" due to a compiler bug.
* This class should be treated as a "protected" inner class.
* This class should be treated as a "protected" inner class.
* Instantiate it only within subclasses of
<FooUI>
.
* Instantiate it only within subclasses of
{@code MetalComboBoxUI}
.
*/
*/
public
class
MetalPropertyChangeListener
extends
BasicComboBoxUI
.
PropertyChangeHandler
{
public
class
MetalPropertyChangeListener
extends
BasicComboBoxUI
.
PropertyChangeHandler
{
public
void
propertyChange
(
PropertyChangeEvent
e
)
{
public
void
propertyChange
(
PropertyChangeEvent
e
)
{
...
@@ -244,9 +243,8 @@ public class MetalComboBoxUI extends BasicComboBoxUI {
...
@@ -244,9 +243,8 @@ public class MetalComboBoxUI extends BasicComboBoxUI {
}
}
/**
/**
* This inner class is marked "public" due to a compiler bug.
* This class should be treated as a "protected" inner class.
* This class should be treated as a "protected" inner class.
* Instantiate it only within subclasses of
<FooUI>
.
* Instantiate it only within subclasses of
{@code MetalComboBoxUI}
.
*/
*/
public
class
MetalComboBoxLayoutManager
extends
BasicComboBoxUI
.
ComboBoxLayoutManager
{
public
class
MetalComboBoxLayoutManager
extends
BasicComboBoxUI
.
ComboBoxLayoutManager
{
public
void
layoutContainer
(
Container
parent
)
{
public
void
layoutContainer
(
Container
parent
)
{
...
@@ -356,9 +354,8 @@ public class MetalComboBoxUI extends BasicComboBoxUI {
...
@@ -356,9 +354,8 @@ public class MetalComboBoxUI extends BasicComboBoxUI {
}
}
/**
/**
* This inner class is marked "public" due to a compiler bug.
* This class should be treated as a "protected" inner class.
* This class should be treated as a "protected" inner class.
* Instantiate it only within subclasses of
<FooUI>
.
* Instantiate it only within subclasses of
{@code MetalComboBoxUI}
.
*
*
* This class is now obsolete and doesn't do anything and
* This class is now obsolete and doesn't do anything and
* is only included for backwards API compatibility. Do not call or
* is only included for backwards API compatibility. Do not call or
...
...
src/share/classes/javax/swing/plaf/metal/MetalTabbedPaneUI.java
浏览文件 @
421115af
...
@@ -1196,9 +1196,8 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI {
...
@@ -1196,9 +1196,8 @@ public class MetalTabbedPaneUI extends BasicTabbedPaneUI {
}
}
/**
/**
* This inner class is marked "public" due to a compiler bug.
* This class should be treated as a "protected" inner class.
* This class should be treated as a "protected" inner class.
* Instantiate it only within subclasses of
MetalTabbedPaneUI
.
* Instantiate it only within subclasses of
{@code MetalTabbedPaneUI}
.
*/
*/
public
class
TabbedPaneLayout
extends
BasicTabbedPaneUI
.
TabbedPaneLayout
{
public
class
TabbedPaneLayout
extends
BasicTabbedPaneUI
.
TabbedPaneLayout
{
...
...
src/share/classes/javax/swing/text/GlyphPainter2.java
浏览文件 @
421115af
...
@@ -172,6 +172,11 @@ class GlyphPainter2 extends GlyphView.GlyphPainter {
...
@@ -172,6 +172,11 @@ class GlyphPainter2 extends GlyphView.GlyphPainter {
//italic carets and we do not.
//italic carets and we do not.
TextHitInfo
hit
=
layout
.
hitTestChar
(
x
-
(
float
)
alloc
.
getX
(),
0
);
TextHitInfo
hit
=
layout
.
hitTestChar
(
x
-
(
float
)
alloc
.
getX
(),
0
);
int
pos
=
hit
.
getInsertionIndex
();
int
pos
=
hit
.
getInsertionIndex
();
if
(
pos
==
v
.
getEndOffset
())
{
pos
--;
}
biasReturn
[
0
]
=
hit
.
isLeadingEdge
()
?
Position
.
Bias
.
Forward
:
Position
.
Bias
.
Backward
;
biasReturn
[
0
]
=
hit
.
isLeadingEdge
()
?
Position
.
Bias
.
Forward
:
Position
.
Bias
.
Backward
;
return
pos
+
v
.
getStartOffset
();
return
pos
+
v
.
getStartOffset
();
}
}
...
...
src/share/classes/javax/swing/text/GlyphView.java
浏览文件 @
421115af
...
@@ -541,7 +541,30 @@ public class GlyphView extends View implements TabableView, Cloneable {
...
@@ -541,7 +541,30 @@ public class GlyphView extends View implements TabableView, Cloneable {
*/
*/
@Override
@Override
public
float
getMinimumSpan
(
int
axis
)
{
public
float
getMinimumSpan
(
int
axis
)
{
return
super
.
getMinimumSpan
(
axis
);
switch
(
axis
)
{
case
View
.
X_AXIS
:
if
(
minimumSpan
<
0
)
{
minimumSpan
=
0
;
int
p0
=
getStartOffset
();
int
p1
=
getEndOffset
();
while
(
p1
>
p0
)
{
int
breakSpot
=
getBreakSpot
(
p0
,
p1
);
if
(
breakSpot
==
BreakIterator
.
DONE
)
{
// the rest of the view is non-breakable
breakSpot
=
p0
;
}
minimumSpan
=
Math
.
max
(
minimumSpan
,
getPartialSpan
(
breakSpot
,
p1
));
// Note: getBreakSpot returns the *last* breakspot
p1
=
breakSpot
-
1
;
}
}
return
minimumSpan
;
case
View
.
Y_AXIS
:
return
super
.
getMinimumSpan
(
axis
);
default
:
throw
new
IllegalArgumentException
(
"Invalid axis: "
+
axis
);
}
}
}
/**
/**
...
...
src/share/classes/javax/swing/text/ParagraphView.java
浏览文件 @
421115af
...
@@ -721,7 +721,34 @@ public class ParagraphView extends FlowView implements TabExpander {
...
@@ -721,7 +721,34 @@ public class ParagraphView extends FlowView implements TabExpander {
@Override
@Override
protected
SizeRequirements
calculateMinorAxisRequirements
(
int
axis
,
protected
SizeRequirements
calculateMinorAxisRequirements
(
int
axis
,
SizeRequirements
r
)
{
SizeRequirements
r
)
{
return
super
.
calculateMinorAxisRequirements
(
axis
,
r
);
r
=
super
.
calculateMinorAxisRequirements
(
axis
,
r
);
float
min
=
0
;
float
glue
=
0
;
int
n
=
getLayoutViewCount
();
for
(
int
i
=
0
;
i
<
n
;
i
++)
{
View
v
=
getLayoutView
(
i
);
float
span
=
v
.
getMinimumSpan
(
axis
);
if
(
v
.
getBreakWeight
(
axis
,
0
,
v
.
getMaximumSpan
(
axis
))
>
View
.
BadBreakWeight
)
{
// find the longest non-breakable fragments at the view edges
int
p0
=
v
.
getStartOffset
();
int
p1
=
v
.
getEndOffset
();
float
start
=
findEdgeSpan
(
v
,
axis
,
p0
,
p0
,
p1
);
float
end
=
findEdgeSpan
(
v
,
axis
,
p1
,
p0
,
p1
);
glue
+=
start
;
min
=
Math
.
max
(
min
,
Math
.
max
(
span
,
glue
));
glue
=
end
;
}
else
{
// non-breakable view
glue
+=
span
;
min
=
Math
.
max
(
min
,
glue
);
}
}
r
.
minimum
=
Math
.
max
(
r
.
minimum
,
(
int
)
min
);
r
.
preferred
=
Math
.
max
(
r
.
minimum
,
r
.
preferred
);
r
.
maximum
=
Math
.
max
(
r
.
preferred
,
r
.
maximum
);
return
r
;
}
}
/**
/**
...
...
src/share/classes/javax/swing/text/Utilities.java
浏览文件 @
421115af
...
@@ -395,10 +395,10 @@ public class Utilities {
...
@@ -395,10 +395,10 @@ public class Utilities {
// the length of the string measured as a whole may differ from
// the length of the string measured as a whole may differ from
// the sum of individual character lengths, for example if
// the sum of individual character lengths, for example if
// fractional metrics are enabled; and we must guard from this.
// fractional metrics are enabled; and we must guard from this.
while
(
metrics
.
charsWidth
(
txt
,
txtOffset
,
offset
+
1
)
>
(
x
-
x0
))
{
while
(
offset
>
0
&&
metrics
.
charsWidth
(
txt
,
txtOffset
,
offset
)
>
(
x
-
x0
))
{
offset
--;
offset
--;
}
}
return
(
offset
<
0
?
0
:
offset
)
;
return
offset
;
}
}
currX
=
nextX
;
currX
=
nextX
;
}
}
...
...
src/share/classes/javax/swing/text/html/CSS.java
浏览文件 @
421115af
...
@@ -62,7 +62,6 @@ import javax.swing.text.*;
...
@@ -62,7 +62,6 @@ import javax.swing.text.*;
* <li>background-repeat
* <li>background-repeat
* <li>background-position
* <li>background-position
* <li>background
* <li>background
* <li>background-repeat
* <li>text-decoration (with the exception of blink and overline)
* <li>text-decoration (with the exception of blink and overline)
* <li>vertical-align (only sup and super)
* <li>vertical-align (only sup and super)
* <li>text-align (justify is treated as center)
* <li>text-align (justify is treated as center)
...
@@ -75,7 +74,18 @@ import javax.swing.text.*;
...
@@ -75,7 +74,18 @@ import javax.swing.text.*;
* <li>padding-right
* <li>padding-right
* <li>padding-bottom
* <li>padding-bottom
* <li>padding-left
* <li>padding-left
* <li>padding
* <li>border-top-style
* <li>border-right-style
* <li>border-bottom-style
* <li>border-left-style
* <li>border-style (only supports inset, outset and none)
* <li>border-style (only supports inset, outset and none)
* <li>border-top-color
* <li>border-right-color
* <li>border-bottom-color
* <li>border-left-color
* <li>border-color
* <li>list-style-image
* <li>list-style-type
* <li>list-style-type
* <li>list-style-position
* <li>list-style-position
* </ul>
* </ul>
...
...
src/share/classes/javax/swing/text/html/parser/Parser.java
浏览文件 @
421115af
...
@@ -966,6 +966,9 @@ class Parser implements DTDConstants {
...
@@ -966,6 +966,9 @@ class Parser implements DTDConstants {
char
data
[]
=
{
'&'
};
char
data
[]
=
{
'&'
};
return
data
;
return
data
;
}
}
boolean
semicolon
=
false
;
switch
(
ch
)
{
switch
(
ch
)
{
case
'\n'
:
case
'\n'
:
ln
++;
ln
++;
...
@@ -985,6 +988,8 @@ class Parser implements DTDConstants {
...
@@ -985,6 +988,8 @@ class Parser implements DTDConstants {
break
;
break
;
case
';'
:
case
';'
:
semicolon
=
true
;
ch
=
readCh
();
ch
=
readCh
();
break
;
break
;
}
}
...
@@ -1006,7 +1011,7 @@ class Parser implements DTDConstants {
...
@@ -1006,7 +1011,7 @@ class Parser implements DTDConstants {
return
new
char
[
0
];
return
new
char
[
0
];
}
}
/* given that there is not a match restore the entity reference */
/* given that there is not a match restore the entity reference */
String
str
=
"&"
+
nm
+
";"
;
String
str
=
"&"
+
nm
+
(
semicolon
?
";"
:
""
)
;
char
b
[]
=
new
char
[
str
.
length
()];
char
b
[]
=
new
char
[
str
.
length
()];
str
.
getChars
(
0
,
b
.
length
,
b
,
0
);
str
.
getChars
(
0
,
b
.
length
,
b
,
0
);
...
...
src/share/classes/sun/swing/SwingUtilities2.java
浏览文件 @
421115af
...
@@ -270,11 +270,10 @@ public class SwingUtilities2 {
...
@@ -270,11 +270,10 @@ public class SwingUtilities2 {
*/
*/
public
static
int
getLeftSideBearing
(
JComponent
c
,
FontMetrics
fm
,
public
static
int
getLeftSideBearing
(
JComponent
c
,
FontMetrics
fm
,
String
string
)
{
String
string
)
{
int
res
=
0
;
if
((
string
==
null
)
||
(
string
.
length
()
==
0
))
{
if
(!
string
.
isEmpty
())
{
return
0
;
res
=
getLeftSideBearing
(
c
,
fm
,
string
.
charAt
(
0
));
}
}
return
res
;
return
getLeftSideBearing
(
c
,
fm
,
string
.
charAt
(
0
))
;
}
}
/**
/**
...
...
src/share/classes/sun/util/locale/BaseLocale.java
浏览文件 @
421115af
/*
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010,
2011,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -38,38 +38,46 @@ public final class BaseLocale {
...
@@ -38,38 +38,46 @@ public final class BaseLocale {
public
static
final
String
SEP
=
"_"
;
public
static
final
String
SEP
=
"_"
;
private
static
final
Cache
CACHE
=
new
Cache
();
private
static
final
Cache
CACHE
=
new
Cache
();
public
static
final
BaseLocale
ROOT
=
BaseLocale
.
getInstance
(
""
,
""
,
""
,
""
);
private
String
_language
=
""
;
private
final
String
language
;
private
String
_script
=
""
;
private
final
String
script
;
private
String
_region
=
""
;
private
final
String
region
;
private
String
_variant
=
""
;
private
final
String
variant
;
private
transient
volatile
int
_hash
=
0
;
private
volatile
int
hash
=
0
;
// This method must be called only when creating the Locale.* constants.
private
BaseLocale
(
String
language
,
String
region
)
{
this
.
language
=
language
;
this
.
script
=
""
;
this
.
region
=
region
;
this
.
variant
=
""
;
}
private
BaseLocale
(
String
language
,
String
script
,
String
region
,
String
variant
)
{
private
BaseLocale
(
String
language
,
String
script
,
String
region
,
String
variant
)
{
if
(
language
!=
null
)
{
this
.
language
=
(
language
!=
null
)
?
LocaleUtils
.
toLowerString
(
language
).
intern
()
:
""
;
_language
=
AsciiUtil
.
toLowerString
(
language
).
intern
()
;
this
.
script
=
(
script
!=
null
)
?
LocaleUtils
.
toTitleString
(
script
).
intern
()
:
""
;
}
this
.
region
=
(
region
!=
null
)
?
LocaleUtils
.
toUpperString
(
region
).
intern
()
:
""
;
if
(
script
!=
null
)
{
this
.
variant
=
(
variant
!=
null
)
?
variant
.
intern
()
:
""
;
_script
=
AsciiUtil
.
toTitleString
(
script
).
intern
();
}
}
if
(
region
!=
null
)
{
// Called for creating the Locale.* constants. No argument
_region
=
AsciiUtil
.
toUpperString
(
region
).
intern
();
// validation is performed.
}
public
static
BaseLocale
createInstance
(
String
language
,
String
region
)
{
if
(
variant
!=
null
)
{
BaseLocale
base
=
new
BaseLocale
(
language
,
region
);
_variant
=
variant
.
intern
(
);
CACHE
.
put
(
new
Key
(
language
,
region
),
base
);
}
return
base
;
}
}
public
static
BaseLocale
getInstance
(
String
language
,
String
script
,
String
region
,
String
variant
)
{
public
static
BaseLocale
getInstance
(
String
language
,
String
script
,
String
region
,
String
variant
)
{
// JDK uses deprecated ISO639.1 language codes for he, yi and id
// JDK uses deprecated ISO639.1 language codes for he, yi and id
if
(
language
!=
null
)
{
if
(
language
!=
null
)
{
if
(
AsciiUtil
.
caseIgnoreMatch
(
language
,
"he"
))
{
if
(
LocaleUtils
.
caseIgnoreMatch
(
language
,
"he"
))
{
language
=
"iw"
;
language
=
"iw"
;
}
else
if
(
AsciiUtil
.
caseIgnoreMatch
(
language
,
"yi"
))
{
}
else
if
(
LocaleUtils
.
caseIgnoreMatch
(
language
,
"yi"
))
{
language
=
"ji"
;
language
=
"ji"
;
}
else
if
(
AsciiUtil
.
caseIgnoreMatch
(
language
,
"id"
))
{
}
else
if
(
LocaleUtils
.
caseIgnoreMatch
(
language
,
"id"
))
{
language
=
"in"
;
language
=
"in"
;
}
}
}
}
...
@@ -80,21 +88,22 @@ public final class BaseLocale {
...
@@ -80,21 +88,22 @@ public final class BaseLocale {
}
}
public
String
getLanguage
()
{
public
String
getLanguage
()
{
return
_
language
;
return
language
;
}
}
public
String
getScript
()
{
public
String
getScript
()
{
return
_
script
;
return
script
;
}
}
public
String
getRegion
()
{
public
String
getRegion
()
{
return
_
region
;
return
region
;
}
}
public
String
getVariant
()
{
public
String
getVariant
()
{
return
_
variant
;
return
variant
;
}
}
@Override
public
boolean
equals
(
Object
obj
)
{
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
{
if
(
this
==
obj
)
{
return
true
;
return
true
;
...
@@ -103,138 +112,178 @@ public final class BaseLocale {
...
@@ -103,138 +112,178 @@ public final class BaseLocale {
return
false
;
return
false
;
}
}
BaseLocale
other
=
(
BaseLocale
)
obj
;
BaseLocale
other
=
(
BaseLocale
)
obj
;
return
hashCode
()
==
other
.
hashCode
()
return
language
==
other
.
language
&&
_language
.
equals
(
other
.
_language
)
&&
script
==
other
.
script
&&
_script
.
equals
(
other
.
_script
)
&&
region
==
other
.
region
&&
_region
.
equals
(
other
.
_region
)
&&
variant
==
other
.
variant
;
&&
_variant
.
equals
(
other
.
_variant
);
}
}
@Override
public
String
toString
()
{
public
String
toString
()
{
StringBuilder
buf
=
new
StringBuilder
();
StringBuilder
buf
=
new
StringBuilder
();
if
(
_
language
.
length
()
>
0
)
{
if
(
language
.
length
()
>
0
)
{
buf
.
append
(
"language="
);
buf
.
append
(
"language="
);
buf
.
append
(
_
language
);
buf
.
append
(
language
);
}
}
if
(
_
script
.
length
()
>
0
)
{
if
(
script
.
length
()
>
0
)
{
if
(
buf
.
length
()
>
0
)
{
if
(
buf
.
length
()
>
0
)
{
buf
.
append
(
", "
);
buf
.
append
(
", "
);
}
}
buf
.
append
(
"script="
);
buf
.
append
(
"script="
);
buf
.
append
(
_
script
);
buf
.
append
(
script
);
}
}
if
(
_
region
.
length
()
>
0
)
{
if
(
region
.
length
()
>
0
)
{
if
(
buf
.
length
()
>
0
)
{
if
(
buf
.
length
()
>
0
)
{
buf
.
append
(
", "
);
buf
.
append
(
", "
);
}
}
buf
.
append
(
"region="
);
buf
.
append
(
"region="
);
buf
.
append
(
_
region
);
buf
.
append
(
region
);
}
}
if
(
_
variant
.
length
()
>
0
)
{
if
(
variant
.
length
()
>
0
)
{
if
(
buf
.
length
()
>
0
)
{
if
(
buf
.
length
()
>
0
)
{
buf
.
append
(
", "
);
buf
.
append
(
", "
);
}
}
buf
.
append
(
"variant="
);
buf
.
append
(
"variant="
);
buf
.
append
(
_
variant
);
buf
.
append
(
variant
);
}
}
return
buf
.
toString
();
return
buf
.
toString
();
}
}
@Override
public
int
hashCode
()
{
public
int
hashCode
()
{
int
h
=
_
hash
;
int
h
=
hash
;
if
(
h
==
0
)
{
if
(
h
==
0
)
{
// Generating a hash value from language, script, region and variant
// Generating a hash value from language, script, region and variant
for
(
int
i
=
0
;
i
<
_language
.
length
();
i
++)
{
h
=
language
.
hashCode
();
h
=
31
*
h
+
_language
.
charAt
(
i
);
h
=
31
*
h
+
script
.
hashCode
();
}
h
=
31
*
h
+
region
.
hashCode
();
for
(
int
i
=
0
;
i
<
_script
.
length
();
i
++)
{
h
=
31
*
h
+
variant
.
hashCode
();
h
=
31
*
h
+
_script
.
charAt
(
i
);
hash
=
h
;
}
for
(
int
i
=
0
;
i
<
_region
.
length
();
i
++)
{
h
=
31
*
h
+
_region
.
charAt
(
i
);
}
for
(
int
i
=
0
;
i
<
_variant
.
length
();
i
++)
{
h
=
31
*
h
+
_variant
.
charAt
(
i
);
}
_hash
=
h
;
}
}
return
h
;
return
h
;
}
}
private
static
class
Key
implements
Comparable
<
Key
>
{
private
static
final
class
Key
implements
Comparable
<
Key
>
{
private
String
_lang
=
""
;
private
final
String
lang
;
private
String
_scrt
=
""
;
private
final
String
scrt
;
private
String
_regn
=
""
;
private
final
String
regn
;
private
String
_vart
=
""
;
private
final
String
vart
;
private
final
boolean
normalized
;
private
final
int
hash
;
/**
* Creates a Key. language and region must be normalized
* (intern'ed in the proper case).
*/
private
Key
(
String
language
,
String
region
)
{
assert
language
.
intern
()
==
language
&&
region
.
intern
()
==
region
;
private
volatile
int
_hash
;
// Default to 0
lang
=
language
;
scrt
=
""
;
regn
=
region
;
vart
=
""
;
this
.
normalized
=
true
;
int
h
=
language
.
hashCode
();
if
(
region
!=
""
)
{
int
len
=
region
.
length
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
h
=
31
*
h
+
LocaleUtils
.
toLower
(
region
.
charAt
(
i
));
}
}
hash
=
h
;
}
public
Key
(
String
language
,
String
script
,
String
region
,
String
variant
)
{
public
Key
(
String
language
,
String
script
,
String
region
,
String
variant
)
{
this
(
language
,
script
,
region
,
variant
,
false
);
}
private
Key
(
String
language
,
String
script
,
String
region
,
String
variant
,
boolean
normalized
)
{
int
h
=
0
;
if
(
language
!=
null
)
{
if
(
language
!=
null
)
{
_lang
=
language
;
lang
=
language
;
int
len
=
language
.
length
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
h
=
31
*
h
+
LocaleUtils
.
toLower
(
language
.
charAt
(
i
));
}
}
else
{
lang
=
""
;
}
}
if
(
script
!=
null
)
{
if
(
script
!=
null
)
{
_scrt
=
script
;
scrt
=
script
;
int
len
=
script
.
length
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
h
=
31
*
h
+
LocaleUtils
.
toLower
(
script
.
charAt
(
i
));
}
}
else
{
scrt
=
""
;
}
}
if
(
region
!=
null
)
{
if
(
region
!=
null
)
{
_regn
=
region
;
regn
=
region
;
int
len
=
region
.
length
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
h
=
31
*
h
+
LocaleUtils
.
toLower
(
region
.
charAt
(
i
));
}
}
else
{
regn
=
""
;
}
}
if
(
variant
!=
null
)
{
if
(
variant
!=
null
)
{
_vart
=
variant
;
vart
=
variant
;
int
len
=
variant
.
length
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
h
=
31
*
h
+
variant
.
charAt
(
i
);
}
}
else
{
vart
=
""
;
}
}
hash
=
h
;
this
.
normalized
=
normalized
;
}
}
@Override
public
boolean
equals
(
Object
obj
)
{
public
boolean
equals
(
Object
obj
)
{
return
(
this
==
obj
)
||
return
(
this
==
obj
)
||
(
obj
instanceof
Key
)
(
obj
instanceof
Key
)
&&
AsciiUtil
.
caseIgnoreMatch
(((
Key
)
obj
).
_lang
,
this
.
_lang
)
&&
this
.
hash
==
((
Key
)
obj
).
hash
&&
AsciiUtil
.
caseIgnoreMatch
(((
Key
)
obj
).
_scrt
,
this
.
_scrt
)
&&
LocaleUtils
.
caseIgnoreMatch
(((
Key
)
obj
).
lang
,
this
.
lang
)
&&
AsciiUtil
.
caseIgnoreMatch
(((
Key
)
obj
).
_regn
,
this
.
_regn
)
&&
LocaleUtils
.
caseIgnoreMatch
(((
Key
)
obj
).
scrt
,
this
.
scrt
)
&&
((
Key
)
obj
).
_vart
.
equals
(
_vart
);
// variant is case sensitive in JDK!
&&
LocaleUtils
.
caseIgnoreMatch
(((
Key
)
obj
).
regn
,
this
.
regn
)
&&
((
Key
)
obj
).
vart
.
equals
(
vart
);
// variant is case sensitive in JDK!
}
}
@Override
public
int
compareTo
(
Key
other
)
{
public
int
compareTo
(
Key
other
)
{
int
res
=
AsciiUtil
.
caseIgnoreCompare
(
this
.
_lang
,
other
.
_
lang
);
int
res
=
LocaleUtils
.
caseIgnoreCompare
(
this
.
lang
,
other
.
lang
);
if
(
res
==
0
)
{
if
(
res
==
0
)
{
res
=
AsciiUtil
.
caseIgnoreCompare
(
this
.
_scrt
,
other
.
_
scrt
);
res
=
LocaleUtils
.
caseIgnoreCompare
(
this
.
scrt
,
other
.
scrt
);
if
(
res
==
0
)
{
if
(
res
==
0
)
{
res
=
AsciiUtil
.
caseIgnoreCompare
(
this
.
_regn
,
other
.
_
regn
);
res
=
LocaleUtils
.
caseIgnoreCompare
(
this
.
regn
,
other
.
regn
);
if
(
res
==
0
)
{
if
(
res
==
0
)
{
res
=
this
.
_vart
.
compareTo
(
other
.
_
vart
);
res
=
this
.
vart
.
compareTo
(
other
.
vart
);
}
}
}
}
}
}
return
res
;
return
res
;
}
}
@Override
public
int
hashCode
()
{
public
int
hashCode
()
{
int
h
=
_hash
;
return
hash
;
if
(
h
==
0
)
{
// Generating a hash value from language, script, region and variant
for
(
int
i
=
0
;
i
<
_lang
.
length
();
i
++)
{
h
=
31
*
h
+
AsciiUtil
.
toLower
(
_lang
.
charAt
(
i
));
}
for
(
int
i
=
0
;
i
<
_scrt
.
length
();
i
++)
{
h
=
31
*
h
+
AsciiUtil
.
toLower
(
_scrt
.
charAt
(
i
));
}
for
(
int
i
=
0
;
i
<
_regn
.
length
();
i
++)
{
h
=
31
*
h
+
AsciiUtil
.
toLower
(
_regn
.
charAt
(
i
));
}
for
(
int
i
=
0
;
i
<
_vart
.
length
();
i
++)
{
h
=
31
*
h
+
_vart
.
charAt
(
i
);
}
_hash
=
h
;
}
return
h
;
}
}
public
static
Key
normalize
(
Key
key
)
{
public
static
Key
normalize
(
Key
key
)
{
String
lang
=
AsciiUtil
.
toLowerString
(
key
.
_lang
).
intern
();
if
(
key
.
normalized
)
{
String
scrt
=
AsciiUtil
.
toTitleString
(
key
.
_scrt
).
intern
();
return
key
;
String
regn
=
AsciiUtil
.
toUpperString
(
key
.
_regn
).
intern
();
}
String
vart
=
key
.
_vart
.
intern
();
// preserve upper/lower cases
return
new
Key
(
lang
,
scrt
,
regn
,
vart
);
String
lang
=
LocaleUtils
.
toLowerString
(
key
.
lang
).
intern
();
String
scrt
=
LocaleUtils
.
toTitleString
(
key
.
scrt
).
intern
();
String
regn
=
LocaleUtils
.
toUpperString
(
key
.
regn
).
intern
();
String
vart
=
key
.
vart
.
intern
();
// preserve upper/lower cases
return
new
Key
(
lang
,
scrt
,
regn
,
vart
,
true
);
}
}
}
}
...
@@ -243,13 +292,14 @@ public final class BaseLocale {
...
@@ -243,13 +292,14 @@ public final class BaseLocale {
public
Cache
()
{
public
Cache
()
{
}
}
@Override
protected
Key
normalizeKey
(
Key
key
)
{
protected
Key
normalizeKey
(
Key
key
)
{
return
Key
.
normalize
(
key
);
return
Key
.
normalize
(
key
);
}
}
@Override
protected
BaseLocale
createObject
(
Key
key
)
{
protected
BaseLocale
createObject
(
Key
key
)
{
return
new
BaseLocale
(
key
.
_lang
,
key
.
_scrt
,
key
.
_regn
,
key
.
_
vart
);
return
new
BaseLocale
(
key
.
lang
,
key
.
scrt
,
key
.
regn
,
key
.
vart
);
}
}
}
}
}
}
src/share/classes/sun/util/locale/Extension.java
浏览文件 @
421115af
/*
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010,
2011,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -32,29 +32,34 @@
...
@@ -32,29 +32,34 @@
package
sun.util.locale
;
package
sun.util.locale
;
public
class
Extension
{
class
Extension
{
private
char
_
key
;
private
final
char
key
;
pr
otected
String
_value
;
pr
ivate
String
value
,
id
;
protected
Extension
(
char
key
)
{
protected
Extension
(
char
key
)
{
_
key
=
key
;
this
.
key
=
key
;
}
}
Extension
(
char
key
,
String
value
)
{
Extension
(
char
key
,
String
value
)
{
_key
=
key
;
this
.
key
=
key
;
_value
=
value
;
setValue
(
value
);
}
protected
void
setValue
(
String
value
)
{
this
.
value
=
value
;
this
.
id
=
key
+
LanguageTag
.
SEP
+
value
;
}
}
public
char
getKey
()
{
public
char
getKey
()
{
return
_
key
;
return
key
;
}
}
public
String
getValue
()
{
public
String
getValue
()
{
return
_
value
;
return
value
;
}
}
public
String
getID
()
{
public
String
getID
()
{
return
_key
+
LanguageTag
.
SEP
+
_value
;
return
id
;
}
}
public
String
toString
()
{
public
String
toString
()
{
...
...
src/share/classes/sun/util/locale/InternalLocaleBuilder.java
浏览文件 @
421115af
此差异已折叠。
点击以展开。
src/share/classes/sun/util/locale/LanguageTag.java
浏览文件 @
421115af
...
@@ -44,25 +44,25 @@ public class LanguageTag {
...
@@ -44,25 +44,25 @@ public class LanguageTag {
//
//
public
static
final
String
SEP
=
"-"
;
public
static
final
String
SEP
=
"-"
;
public
static
final
String
PRIVATEUSE
=
"x"
;
public
static
final
String
PRIVATEUSE
=
"x"
;
public
static
String
UNDETERMINED
=
"und"
;
public
static
final
String
UNDETERMINED
=
"und"
;
public
static
final
String
PRIVUSE_VARIANT_PREFIX
=
"lvariant"
;
public
static
final
String
PRIVUSE_VARIANT_PREFIX
=
"lvariant"
;
//
//
// Language subtag fields
// Language subtag fields
//
//
private
String
_
language
=
""
;
// language subtag
private
String
language
=
""
;
// language subtag
private
String
_
script
=
""
;
// script subtag
private
String
script
=
""
;
// script subtag
private
String
_
region
=
""
;
// region subtag
private
String
region
=
""
;
// region subtag
private
String
_
privateuse
=
""
;
// privateuse
private
String
privateuse
=
""
;
// privateuse
private
List
<
String
>
_
extlangs
=
Collections
.
emptyList
();
// extlang subtags
private
List
<
String
>
extlangs
=
Collections
.
emptyList
();
// extlang subtags
private
List
<
String
>
_
variants
=
Collections
.
emptyList
();
// variant subtags
private
List
<
String
>
variants
=
Collections
.
emptyList
();
// variant subtags
private
List
<
String
>
_
extensions
=
Collections
.
emptyList
();
// extensions
private
List
<
String
>
extensions
=
Collections
.
emptyList
();
// extensions
// Map contains grandfathered tags and its preferred mappings from
// Map contains grandfathered tags and its preferred mappings from
// http://www.ietf.org/rfc/rfc5646.txt
// http://www.ietf.org/rfc/rfc5646.txt
private
static
final
Map
<
AsciiUtil
.
CaseInsensitiveKey
,
String
[]>
GRANDFATHERED
=
// Keys are lower-case strings.
new
HashMap
<
AsciiUtil
.
CaseInsensitiveKey
,
String
[]
>();
private
static
final
Map
<
String
,
String
[]>
GRANDFATHERED
=
new
HashMap
<
>();
static
{
static
{
// grandfathered = irregular ; non-redundant tags registered
// grandfathered = irregular ; non-redundant tags registered
...
@@ -126,7 +126,7 @@ public class LanguageTag {
...
@@ -126,7 +126,7 @@ public class LanguageTag {
{
"zh-xiang"
,
"hsn"
},
{
"zh-xiang"
,
"hsn"
},
};
};
for
(
String
[]
e
:
entries
)
{
for
(
String
[]
e
:
entries
)
{
GRANDFATHERED
.
put
(
new
AsciiUtil
.
CaseInsensitiveKey
(
e
[
0
]),
e
);
GRANDFATHERED
.
put
(
LocaleUtils
.
toLowerString
(
e
[
0
]),
e
);
}
}
}
}
...
@@ -188,7 +188,7 @@ public class LanguageTag {
...
@@ -188,7 +188,7 @@ public class LanguageTag {
StringTokenIterator
itr
;
StringTokenIterator
itr
;
// Check if the tag is grandfathered
// Check if the tag is grandfathered
String
[]
gfmap
=
GRANDFATHERED
.
get
(
new
AsciiUtil
.
CaseInsensitiveKey
(
languageTag
));
String
[]
gfmap
=
GRANDFATHERED
.
get
(
LocaleUtils
.
toLowerString
(
languageTag
));
if
(
gfmap
!=
null
)
{
if
(
gfmap
!=
null
)
{
// use preferred mapping
// use preferred mapping
itr
=
new
StringTokenIterator
(
gfmap
[
1
],
SEP
);
itr
=
new
StringTokenIterator
(
gfmap
[
1
],
SEP
);
...
@@ -210,11 +210,11 @@ public class LanguageTag {
...
@@ -210,11 +210,11 @@ public class LanguageTag {
if
(!
itr
.
isDone
()
&&
!
sts
.
isError
())
{
if
(!
itr
.
isDone
()
&&
!
sts
.
isError
())
{
String
s
=
itr
.
current
();
String
s
=
itr
.
current
();
sts
.
_
errorIndex
=
itr
.
currentStart
();
sts
.
errorIndex
=
itr
.
currentStart
();
if
(
s
.
length
()
==
0
)
{
if
(
s
.
length
()
==
0
)
{
sts
.
_
errorMsg
=
"Empty subtag"
;
sts
.
errorMsg
=
"Empty subtag"
;
}
else
{
}
else
{
sts
.
_
errorMsg
=
"Invalid subtag: "
+
s
;
sts
.
errorMsg
=
"Invalid subtag: "
+
s
;
}
}
}
}
...
@@ -235,8 +235,8 @@ public class LanguageTag {
...
@@ -235,8 +235,8 @@ public class LanguageTag {
String
s
=
itr
.
current
();
String
s
=
itr
.
current
();
if
(
isLanguage
(
s
))
{
if
(
isLanguage
(
s
))
{
found
=
true
;
found
=
true
;
_
language
=
s
;
language
=
s
;
sts
.
_
parseLength
=
itr
.
currentEnd
();
sts
.
parseLength
=
itr
.
currentEnd
();
itr
.
next
();
itr
.
next
();
}
}
...
@@ -256,14 +256,14 @@ public class LanguageTag {
...
@@ -256,14 +256,14 @@ public class LanguageTag {
break
;
break
;
}
}
found
=
true
;
found
=
true
;
if
(
_
extlangs
.
isEmpty
())
{
if
(
extlangs
.
isEmpty
())
{
_extlangs
=
new
ArrayList
<
String
>(
3
);
extlangs
=
new
ArrayList
<
>(
3
);
}
}
_
extlangs
.
add
(
s
);
extlangs
.
add
(
s
);
sts
.
_
parseLength
=
itr
.
currentEnd
();
sts
.
parseLength
=
itr
.
currentEnd
();
itr
.
next
();
itr
.
next
();
if
(
_
extlangs
.
size
()
==
3
)
{
if
(
extlangs
.
size
()
==
3
)
{
// Maximum 3 extlangs
// Maximum 3 extlangs
break
;
break
;
}
}
...
@@ -282,8 +282,8 @@ public class LanguageTag {
...
@@ -282,8 +282,8 @@ public class LanguageTag {
String
s
=
itr
.
current
();
String
s
=
itr
.
current
();
if
(
isScript
(
s
))
{
if
(
isScript
(
s
))
{
found
=
true
;
found
=
true
;
_
script
=
s
;
script
=
s
;
sts
.
_
parseLength
=
itr
.
currentEnd
();
sts
.
parseLength
=
itr
.
currentEnd
();
itr
.
next
();
itr
.
next
();
}
}
...
@@ -300,8 +300,8 @@ public class LanguageTag {
...
@@ -300,8 +300,8 @@ public class LanguageTag {
String
s
=
itr
.
current
();
String
s
=
itr
.
current
();
if
(
isRegion
(
s
))
{
if
(
isRegion
(
s
))
{
found
=
true
;
found
=
true
;
_
region
=
s
;
region
=
s
;
sts
.
_
parseLength
=
itr
.
currentEnd
();
sts
.
parseLength
=
itr
.
currentEnd
();
itr
.
next
();
itr
.
next
();
}
}
...
@@ -321,11 +321,11 @@ public class LanguageTag {
...
@@ -321,11 +321,11 @@ public class LanguageTag {
break
;
break
;
}
}
found
=
true
;
found
=
true
;
if
(
_
variants
.
isEmpty
())
{
if
(
variants
.
isEmpty
())
{
_variants
=
new
ArrayList
<
String
>(
3
);
variants
=
new
ArrayList
<
>(
3
);
}
}
_
variants
.
add
(
s
);
variants
.
add
(
s
);
sts
.
_
parseLength
=
itr
.
currentEnd
();
sts
.
parseLength
=
itr
.
currentEnd
();
itr
.
next
();
itr
.
next
();
}
}
...
@@ -351,23 +351,23 @@ public class LanguageTag {
...
@@ -351,23 +351,23 @@ public class LanguageTag {
s
=
itr
.
current
();
s
=
itr
.
current
();
if
(
isExtensionSubtag
(
s
))
{
if
(
isExtensionSubtag
(
s
))
{
sb
.
append
(
SEP
).
append
(
s
);
sb
.
append
(
SEP
).
append
(
s
);
sts
.
_
parseLength
=
itr
.
currentEnd
();
sts
.
parseLength
=
itr
.
currentEnd
();
}
else
{
}
else
{
break
;
break
;
}
}
itr
.
next
();
itr
.
next
();
}
}
if
(
sts
.
_
parseLength
<=
start
)
{
if
(
sts
.
parseLength
<=
start
)
{
sts
.
_
errorIndex
=
start
;
sts
.
errorIndex
=
start
;
sts
.
_
errorMsg
=
"Incomplete extension '"
+
singleton
+
"'"
;
sts
.
errorMsg
=
"Incomplete extension '"
+
singleton
+
"'"
;
break
;
break
;
}
}
if
(
_extensions
.
size
()
==
0
)
{
if
(
extensions
.
isEmpty
()
)
{
_extensions
=
new
ArrayList
<
String
>(
4
);
extensions
=
new
ArrayList
<
>(
4
);
}
}
_
extensions
.
add
(
sb
.
toString
());
extensions
.
add
(
sb
.
toString
());
found
=
true
;
found
=
true
;
}
else
{
}
else
{
break
;
break
;
...
@@ -395,17 +395,17 @@ public class LanguageTag {
...
@@ -395,17 +395,17 @@ public class LanguageTag {
break
;
break
;
}
}
sb
.
append
(
SEP
).
append
(
s
);
sb
.
append
(
SEP
).
append
(
s
);
sts
.
_
parseLength
=
itr
.
currentEnd
();
sts
.
parseLength
=
itr
.
currentEnd
();
itr
.
next
();
itr
.
next
();
}
}
if
(
sts
.
_
parseLength
<=
start
)
{
if
(
sts
.
parseLength
<=
start
)
{
// need at least 1 private subtag
// need at least 1 private subtag
sts
.
_
errorIndex
=
start
;
sts
.
errorIndex
=
start
;
sts
.
_
errorMsg
=
"Incomplete privateuse"
;
sts
.
errorMsg
=
"Incomplete privateuse"
;
}
else
{
}
else
{
_
privateuse
=
sb
.
toString
();
privateuse
=
sb
.
toString
();
found
=
true
;
found
=
true
;
}
}
}
}
...
@@ -425,9 +425,8 @@ public class LanguageTag {
...
@@ -425,9 +425,8 @@ public class LanguageTag {
String
privuseVar
=
null
;
// store ill-formed variant subtags
String
privuseVar
=
null
;
// store ill-formed variant subtags
if
(
language
.
length
()
>
0
&&
isLanguage
(
language
))
{
if
(
isLanguage
(
language
))
{
// Convert a deprecated language code used by Java to
// Convert a deprecated language code to its new code
// a new code
if
(
language
.
equals
(
"iw"
))
{
if
(
language
.
equals
(
"iw"
))
{
language
=
"he"
;
language
=
"he"
;
}
else
if
(
language
.
equals
(
"ji"
))
{
}
else
if
(
language
.
equals
(
"ji"
))
{
...
@@ -435,22 +434,22 @@ public class LanguageTag {
...
@@ -435,22 +434,22 @@ public class LanguageTag {
}
else
if
(
language
.
equals
(
"in"
))
{
}
else
if
(
language
.
equals
(
"in"
))
{
language
=
"id"
;
language
=
"id"
;
}
}
tag
.
_
language
=
language
;
tag
.
language
=
language
;
}
}
if
(
script
.
length
()
>
0
&&
isScript
(
script
))
{
if
(
isScript
(
script
))
{
tag
.
_
script
=
canonicalizeScript
(
script
);
tag
.
script
=
canonicalizeScript
(
script
);
hasSubtag
=
true
;
hasSubtag
=
true
;
}
}
if
(
region
.
length
()
>
0
&&
isRegion
(
region
))
{
if
(
isRegion
(
region
))
{
tag
.
_
region
=
canonicalizeRegion
(
region
);
tag
.
region
=
canonicalizeRegion
(
region
);
hasSubtag
=
true
;
hasSubtag
=
true
;
}
}
// Special handling for no_NO_NY - use nn_NO for language tag
// Special handling for no_NO_NY - use nn_NO for language tag
if
(
tag
.
_language
.
equals
(
"no"
)
&&
tag
.
_
region
.
equals
(
"NO"
)
&&
variant
.
equals
(
"NY"
))
{
if
(
tag
.
language
.
equals
(
"no"
)
&&
tag
.
region
.
equals
(
"NO"
)
&&
variant
.
equals
(
"NY"
))
{
tag
.
_
language
=
"nn"
;
tag
.
language
=
"nn"
;
variant
=
""
;
variant
=
""
;
}
}
...
@@ -463,13 +462,13 @@ public class LanguageTag {
...
@@ -463,13 +462,13 @@ public class LanguageTag {
break
;
break
;
}
}
if
(
variants
==
null
)
{
if
(
variants
==
null
)
{
variants
=
new
ArrayList
<
String
>();
variants
=
new
ArrayList
<>();
}
}
variants
.
add
(
var
);
// Do not canonicalize!
variants
.
add
(
var
);
// Do not canonicalize!
varitr
.
next
();
varitr
.
next
();
}
}
if
(
variants
!=
null
)
{
if
(
variants
!=
null
)
{
tag
.
_
variants
=
variants
;
tag
.
variants
=
variants
;
hasSubtag
=
true
;
hasSubtag
=
true
;
}
}
if
(!
varitr
.
isDone
())
{
if
(!
varitr
.
isDone
())
{
...
@@ -496,21 +495,23 @@ public class LanguageTag {
...
@@ -496,21 +495,23 @@ public class LanguageTag {
List
<
String
>
extensions
=
null
;
List
<
String
>
extensions
=
null
;
String
privateuse
=
null
;
String
privateuse
=
null
;
Set
<
Character
>
locextKeys
=
localeExtensions
.
getKeys
();
if
(
localeExtensions
!=
null
)
{
for
(
Character
locextKey
:
locextKeys
)
{
Set
<
Character
>
locextKeys
=
localeExtensions
.
getKeys
();
Extension
ext
=
localeExtensions
.
getExtension
(
locextKey
);
for
(
Character
locextKey
:
locextKeys
)
{
if
(
isPrivateusePrefixChar
(
locextKey
.
charValue
()))
{
Extension
ext
=
localeExtensions
.
getExtension
(
locextKey
);
privateuse
=
ext
.
getValue
();
if
(
isPrivateusePrefixChar
(
locextKey
))
{
}
else
{
privateuse
=
ext
.
getValue
();
if
(
extensions
==
null
)
{
}
else
{
extensions
=
new
ArrayList
<
String
>();
if
(
extensions
==
null
)
{
extensions
=
new
ArrayList
<>();
}
extensions
.
add
(
locextKey
.
toString
()
+
SEP
+
ext
.
getValue
());
}
}
extensions
.
add
(
locextKey
.
toString
()
+
SEP
+
ext
.
getValue
());
}
}
}
}
if
(
extensions
!=
null
)
{
if
(
extensions
!=
null
)
{
tag
.
_
extensions
=
extensions
;
tag
.
extensions
=
extensions
;
hasSubtag
=
true
;
hasSubtag
=
true
;
}
}
...
@@ -519,19 +520,20 @@ public class LanguageTag {
...
@@ -519,19 +520,20 @@ public class LanguageTag {
if
(
privateuse
==
null
)
{
if
(
privateuse
==
null
)
{
privateuse
=
PRIVUSE_VARIANT_PREFIX
+
SEP
+
privuseVar
;
privateuse
=
PRIVUSE_VARIANT_PREFIX
+
SEP
+
privuseVar
;
}
else
{
}
else
{
privateuse
=
privateuse
+
SEP
+
PRIVUSE_VARIANT_PREFIX
+
SEP
+
privuseVar
.
replace
(
BaseLocale
.
SEP
,
SEP
);
privateuse
=
privateuse
+
SEP
+
PRIVUSE_VARIANT_PREFIX
+
SEP
+
privuseVar
.
replace
(
BaseLocale
.
SEP
,
SEP
);
}
}
}
}
if
(
privateuse
!=
null
)
{
if
(
privateuse
!=
null
)
{
tag
.
_
privateuse
=
privateuse
;
tag
.
privateuse
=
privateuse
;
}
}
if
(
tag
.
_
language
.
length
()
==
0
&&
(
hasSubtag
||
privateuse
==
null
))
{
if
(
tag
.
language
.
length
()
==
0
&&
(
hasSubtag
||
privateuse
==
null
))
{
// use lang "und" when 1) no language is available AND
// use lang "und" when 1) no language is available AND
// 2) any of other subtags other than private use are available or
// 2) any of other subtags other than private use are available or
// no private use tag is available
// no private use tag is available
tag
.
_
language
=
UNDETERMINED
;
tag
.
language
=
UNDETERMINED
;
}
}
return
tag
;
return
tag
;
...
@@ -542,31 +544,40 @@ public class LanguageTag {
...
@@ -542,31 +544,40 @@ public class LanguageTag {
//
//
public
String
getLanguage
()
{
public
String
getLanguage
()
{
return
_
language
;
return
language
;
}
}
public
List
<
String
>
getExtlangs
()
{
public
List
<
String
>
getExtlangs
()
{
return
Collections
.
unmodifiableList
(
_extlangs
);
if
(
extlangs
.
isEmpty
())
{
return
Collections
.
emptyList
();
}
return
Collections
.
unmodifiableList
(
extlangs
);
}
}
public
String
getScript
()
{
public
String
getScript
()
{
return
_
script
;
return
script
;
}
}
public
String
getRegion
()
{
public
String
getRegion
()
{
return
_
region
;
return
region
;
}
}
public
List
<
String
>
getVariants
()
{
public
List
<
String
>
getVariants
()
{
return
Collections
.
unmodifiableList
(
_variants
);
if
(
variants
.
isEmpty
())
{
return
Collections
.
emptyList
();
}
return
Collections
.
unmodifiableList
(
variants
);
}
}
public
List
<
String
>
getExtensions
()
{
public
List
<
String
>
getExtensions
()
{
return
Collections
.
unmodifiableList
(
_extensions
);
if
(
extensions
.
isEmpty
())
{
return
Collections
.
emptyList
();
}
return
Collections
.
unmodifiableList
(
extensions
);
}
}
public
String
getPrivateuse
()
{
public
String
getPrivateuse
()
{
return
_
privateuse
;
return
privateuse
;
}
}
//
//
...
@@ -579,25 +590,26 @@ public class LanguageTag {
...
@@ -579,25 +590,26 @@ public class LanguageTag {
// ; extended language subtags
// ; extended language subtags
// / 4ALPHA ; or reserved for future use
// / 4ALPHA ; or reserved for future use
// / 5*8ALPHA ; or registered language subtag
// / 5*8ALPHA ; or registered language subtag
return
(
s
.
length
()
>=
2
)
&&
(
s
.
length
()
<=
8
)
&&
AsciiUtil
.
isAlphaString
(
s
);
int
len
=
s
.
length
();
return
(
len
>=
2
)
&&
(
len
<=
8
)
&&
LocaleUtils
.
isAlphaString
(
s
);
}
}
public
static
boolean
isExtlang
(
String
s
)
{
public
static
boolean
isExtlang
(
String
s
)
{
// extlang = 3ALPHA ; selected ISO 639 codes
// extlang = 3ALPHA ; selected ISO 639 codes
// *2("-" 3ALPHA) ; permanently reserved
// *2("-" 3ALPHA) ; permanently reserved
return
(
s
.
length
()
==
3
)
&&
AsciiUtil
.
isAlphaString
(
s
);
return
(
s
.
length
()
==
3
)
&&
LocaleUtils
.
isAlphaString
(
s
);
}
}
public
static
boolean
isScript
(
String
s
)
{
public
static
boolean
isScript
(
String
s
)
{
// script = 4ALPHA ; ISO 15924 code
// script = 4ALPHA ; ISO 15924 code
return
(
s
.
length
()
==
4
)
&&
AsciiUtil
.
isAlphaString
(
s
);
return
(
s
.
length
()
==
4
)
&&
LocaleUtils
.
isAlphaString
(
s
);
}
}
public
static
boolean
isRegion
(
String
s
)
{
public
static
boolean
isRegion
(
String
s
)
{
// region = 2ALPHA ; ISO 3166-1 code
// region = 2ALPHA ; ISO 3166-1 code
// / 3DIGIT ; UN M.49 code
// / 3DIGIT ; UN M.49 code
return
((
s
.
length
()
==
2
)
&&
AsciiUtil
.
isAlphaString
(
s
))
return
((
s
.
length
()
==
2
)
&&
LocaleUtils
.
isAlphaString
(
s
))
||
((
s
.
length
()
==
3
)
&&
AsciiUtil
.
isNumericString
(
s
));
||
((
s
.
length
()
==
3
)
&&
LocaleUtils
.
isNumericString
(
s
));
}
}
public
static
boolean
isVariant
(
String
s
)
{
public
static
boolean
isVariant
(
String
s
)
{
...
@@ -605,13 +617,13 @@ public class LanguageTag {
...
@@ -605,13 +617,13 @@ public class LanguageTag {
// / (DIGIT 3alphanum)
// / (DIGIT 3alphanum)
int
len
=
s
.
length
();
int
len
=
s
.
length
();
if
(
len
>=
5
&&
len
<=
8
)
{
if
(
len
>=
5
&&
len
<=
8
)
{
return
AsciiUtil
.
isAlphaNumericString
(
s
);
return
LocaleUtils
.
isAlphaNumericString
(
s
);
}
}
if
(
len
==
4
)
{
if
(
len
==
4
)
{
return
AsciiUtil
.
isNumeric
(
s
.
charAt
(
0
))
return
LocaleUtils
.
isNumeric
(
s
.
charAt
(
0
))
&&
AsciiUtil
.
isAlphaNumeric
(
s
.
charAt
(
1
))
&&
LocaleUtils
.
isAlphaNumeric
(
s
.
charAt
(
1
))
&&
AsciiUtil
.
isAlphaNumeric
(
s
.
charAt
(
2
))
&&
LocaleUtils
.
isAlphaNumeric
(
s
.
charAt
(
2
))
&&
AsciiUtil
.
isAlphaNumeric
(
s
.
charAt
(
3
));
&&
LocaleUtils
.
isAlphaNumeric
(
s
.
charAt
(
3
));
}
}
return
false
;
return
false
;
}
}
...
@@ -624,8 +636,8 @@ public class LanguageTag {
...
@@ -624,8 +636,8 @@ public class LanguageTag {
// / %x79-7A ; y - z
// / %x79-7A ; y - z
return
(
s
.
length
()
==
1
)
return
(
s
.
length
()
==
1
)
&&
AsciiUtil
.
isAlphaString
(
s
)
&&
LocaleUtils
.
isAlphaString
(
s
)
&&
!
AsciiUtil
.
caseIgnoreMatch
(
PRIVATEUSE
,
s
);
&&
!
LocaleUtils
.
caseIgnoreMatch
(
PRIVATEUSE
,
s
);
}
}
public
static
boolean
isExtensionSingletonChar
(
char
c
)
{
public
static
boolean
isExtensionSingletonChar
(
char
c
)
{
...
@@ -634,22 +646,24 @@ public class LanguageTag {
...
@@ -634,22 +646,24 @@ public class LanguageTag {
public
static
boolean
isExtensionSubtag
(
String
s
)
{
public
static
boolean
isExtensionSubtag
(
String
s
)
{
// extension = singleton 1*("-" (2*8alphanum))
// extension = singleton 1*("-" (2*8alphanum))
return
(
s
.
length
()
>=
2
)
&&
(
s
.
length
()
<=
8
)
&&
AsciiUtil
.
isAlphaNumericString
(
s
);
int
len
=
s
.
length
();
return
(
len
>=
2
)
&&
(
len
<=
8
)
&&
LocaleUtils
.
isAlphaNumericString
(
s
);
}
}
public
static
boolean
isPrivateusePrefix
(
String
s
)
{
public
static
boolean
isPrivateusePrefix
(
String
s
)
{
// privateuse = "x" 1*("-" (1*8alphanum))
// privateuse = "x" 1*("-" (1*8alphanum))
return
(
s
.
length
()
==
1
)
return
(
s
.
length
()
==
1
)
&&
AsciiUtil
.
caseIgnoreMatch
(
PRIVATEUSE
,
s
);
&&
LocaleUtils
.
caseIgnoreMatch
(
PRIVATEUSE
,
s
);
}
}
public
static
boolean
isPrivateusePrefixChar
(
char
c
)
{
public
static
boolean
isPrivateusePrefixChar
(
char
c
)
{
return
(
AsciiUtil
.
caseIgnoreMatch
(
PRIVATEUSE
,
String
.
valueOf
(
c
)));
return
(
LocaleUtils
.
caseIgnoreMatch
(
PRIVATEUSE
,
String
.
valueOf
(
c
)));
}
}
public
static
boolean
isPrivateuseSubtag
(
String
s
)
{
public
static
boolean
isPrivateuseSubtag
(
String
s
)
{
// privateuse = "x" 1*("-" (1*8alphanum))
// privateuse = "x" 1*("-" (1*8alphanum))
return
(
s
.
length
()
>=
1
)
&&
(
s
.
length
()
<=
8
)
&&
AsciiUtil
.
isAlphaNumericString
(
s
);
int
len
=
s
.
length
();
return
(
len
>=
1
)
&&
(
len
<=
8
)
&&
LocaleUtils
.
isAlphaNumericString
(
s
);
}
}
//
//
...
@@ -657,76 +671,77 @@ public class LanguageTag {
...
@@ -657,76 +671,77 @@ public class LanguageTag {
//
//
public
static
String
canonicalizeLanguage
(
String
s
)
{
public
static
String
canonicalizeLanguage
(
String
s
)
{
return
AsciiUtil
.
toLowerString
(
s
);
return
LocaleUtils
.
toLowerString
(
s
);
}
}
public
static
String
canonicalizeExtlang
(
String
s
)
{
public
static
String
canonicalizeExtlang
(
String
s
)
{
return
AsciiUtil
.
toLowerString
(
s
);
return
LocaleUtils
.
toLowerString
(
s
);
}
}
public
static
String
canonicalizeScript
(
String
s
)
{
public
static
String
canonicalizeScript
(
String
s
)
{
return
AsciiUtil
.
toTitleString
(
s
);
return
LocaleUtils
.
toTitleString
(
s
);
}
}
public
static
String
canonicalizeRegion
(
String
s
)
{
public
static
String
canonicalizeRegion
(
String
s
)
{
return
AsciiUtil
.
toUpperString
(
s
);
return
LocaleUtils
.
toUpperString
(
s
);
}
}
public
static
String
canonicalizeVariant
(
String
s
)
{
public
static
String
canonicalizeVariant
(
String
s
)
{
return
AsciiUtil
.
toLowerString
(
s
);
return
LocaleUtils
.
toLowerString
(
s
);
}
}
public
static
String
canonicalizeExtension
(
String
s
)
{
public
static
String
canonicalizeExtension
(
String
s
)
{
return
AsciiUtil
.
toLowerString
(
s
);
return
LocaleUtils
.
toLowerString
(
s
);
}
}
public
static
String
canonicalizeExtensionSingleton
(
String
s
)
{
public
static
String
canonicalizeExtensionSingleton
(
String
s
)
{
return
AsciiUtil
.
toLowerString
(
s
);
return
LocaleUtils
.
toLowerString
(
s
);
}
}
public
static
String
canonicalizeExtensionSubtag
(
String
s
)
{
public
static
String
canonicalizeExtensionSubtag
(
String
s
)
{
return
AsciiUtil
.
toLowerString
(
s
);
return
LocaleUtils
.
toLowerString
(
s
);
}
}
public
static
String
canonicalizePrivateuse
(
String
s
)
{
public
static
String
canonicalizePrivateuse
(
String
s
)
{
return
AsciiUtil
.
toLowerString
(
s
);
return
LocaleUtils
.
toLowerString
(
s
);
}
}
public
static
String
canonicalizePrivateuseSubtag
(
String
s
)
{
public
static
String
canonicalizePrivateuseSubtag
(
String
s
)
{
return
AsciiUtil
.
toLowerString
(
s
);
return
LocaleUtils
.
toLowerString
(
s
);
}
}
@Override
public
String
toString
()
{
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
if
(
_
language
.
length
()
>
0
)
{
if
(
language
.
length
()
>
0
)
{
sb
.
append
(
_
language
);
sb
.
append
(
language
);
for
(
String
extlang
:
_
extlangs
)
{
for
(
String
extlang
:
extlangs
)
{
sb
.
append
(
SEP
).
append
(
extlang
);
sb
.
append
(
SEP
).
append
(
extlang
);
}
}
if
(
_
script
.
length
()
>
0
)
{
if
(
script
.
length
()
>
0
)
{
sb
.
append
(
SEP
).
append
(
_
script
);
sb
.
append
(
SEP
).
append
(
script
);
}
}
if
(
_
region
.
length
()
>
0
)
{
if
(
region
.
length
()
>
0
)
{
sb
.
append
(
SEP
).
append
(
_
region
);
sb
.
append
(
SEP
).
append
(
region
);
}
}
for
(
String
variant
:
_extlang
s
)
{
for
(
String
variant
:
variant
s
)
{
sb
.
append
(
SEP
).
append
(
variant
);
sb
.
append
(
SEP
).
append
(
variant
);
}
}
for
(
String
extension
:
_
extensions
)
{
for
(
String
extension
:
extensions
)
{
sb
.
append
(
SEP
).
append
(
extension
);
sb
.
append
(
SEP
).
append
(
extension
);
}
}
}
}
if
(
_
privateuse
.
length
()
>
0
)
{
if
(
privateuse
.
length
()
>
0
)
{
if
(
sb
.
length
()
>
0
)
{
if
(
sb
.
length
()
>
0
)
{
sb
.
append
(
SEP
);
sb
.
append
(
SEP
);
}
}
sb
.
append
(
_
privateuse
);
sb
.
append
(
privateuse
);
}
}
return
sb
.
toString
();
return
sb
.
toString
();
...
...
src/share/classes/sun/util/locale/LocaleExtensions.java
浏览文件 @
421115af
/*
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010,
2011,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -36,6 +36,7 @@ import java.util.Map;
...
@@ -36,6 +36,7 @@ import java.util.Map;
import
java.util.Map.Entry
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.SortedMap
;
import
java.util.SortedMap
;
import
java.util.SortedSet
;
import
java.util.TreeMap
;
import
java.util.TreeMap
;
import
java.util.TreeSet
;
import
java.util.TreeSet
;
...
@@ -45,55 +46,45 @@ import sun.util.locale.InternalLocaleBuilder.CaseInsensitiveString;
...
@@ -45,55 +46,45 @@ import sun.util.locale.InternalLocaleBuilder.CaseInsensitiveString;
public
class
LocaleExtensions
{
public
class
LocaleExtensions
{
private
SortedMap
<
Character
,
Extension
>
_m
ap
;
private
final
Map
<
Character
,
Extension
>
extensionM
ap
;
private
String
_
id
;
private
final
String
id
;
private
static
final
SortedMap
<
Character
,
Extension
>
EMPTY_MAP
=
public
static
final
LocaleExtensions
CALENDAR_JAPANESE
Collections
.
unmodifiableSortedMap
(
new
TreeMap
<
Character
,
Extension
>());
=
new
LocaleExtensions
(
"u-ca-japanese"
,
UnicodeLocaleExtension
.
SINGLETON
,
UnicodeLocaleExtension
.
CA_JAPANESE
);
public
static
final
LocaleExtensions
EMPTY_EXTENSIONS
;
public
static
final
LocaleExtensions
NUMBER_THAI
public
static
final
LocaleExtensions
CALENDAR_JAPANESE
;
=
new
LocaleExtensions
(
"u-nu-thai"
,
public
static
final
LocaleExtensions
NUMBER_THAI
;
UnicodeLocaleExtension
.
SINGLETON
,
UnicodeLocaleExtension
.
NU_THAI
);
static
{
private
LocaleExtensions
(
String
id
,
Character
key
,
Extension
value
)
{
EMPTY_EXTENSIONS
=
new
LocaleExtensions
();
this
.
id
=
id
;
EMPTY_EXTENSIONS
.
_id
=
""
;
this
.
extensionMap
=
Collections
.
singletonMap
(
key
,
value
);
EMPTY_EXTENSIONS
.
_map
=
EMPTY_MAP
;
CALENDAR_JAPANESE
=
new
LocaleExtensions
();
CALENDAR_JAPANESE
.
_id
=
"u-ca-japanese"
;
CALENDAR_JAPANESE
.
_map
=
new
TreeMap
<
Character
,
Extension
>();
CALENDAR_JAPANESE
.
_map
.
put
(
Character
.
valueOf
(
UnicodeLocaleExtension
.
SINGLETON
),
UnicodeLocaleExtension
.
CA_JAPANESE
);
NUMBER_THAI
=
new
LocaleExtensions
();
NUMBER_THAI
.
_id
=
"u-nu-thai"
;
NUMBER_THAI
.
_map
=
new
TreeMap
<
Character
,
Extension
>();
NUMBER_THAI
.
_map
.
put
(
Character
.
valueOf
(
UnicodeLocaleExtension
.
SINGLETON
),
UnicodeLocaleExtension
.
NU_THAI
);
}
private
LocaleExtensions
()
{
}
}
/*
/*
* Package
local
constructor, only used by InternalLocaleBuilder.
* Package
private
constructor, only used by InternalLocaleBuilder.
*/
*/
LocaleExtensions
(
Map
<
CaseInsensitiveChar
,
String
>
extensions
,
LocaleExtensions
(
Map
<
CaseInsensitiveChar
,
String
>
extensions
,
Set
<
CaseInsensitiveString
>
uattributes
,
Map
<
CaseInsensitiveString
,
String
>
ukeywords
)
{
Set
<
CaseInsensitiveString
>
uattributes
,
boolean
hasExtension
=
(
extensions
!=
null
&&
extensions
.
size
()
>
0
);
Map
<
CaseInsensitiveString
,
String
>
ukeywords
)
{
boolean
hasUAttributes
=
(
uattributes
!=
null
&&
uattributes
.
size
()
>
0
);
boolean
hasExtension
=
!
LocaleUtils
.
isEmpty
(
extensions
);
boolean
hasUKeywords
=
(
ukeywords
!=
null
&&
ukeywords
.
size
()
>
0
);
boolean
hasUAttributes
=
!
LocaleUtils
.
isEmpty
(
uattributes
);
boolean
hasUKeywords
=
!
LocaleUtils
.
isEmpty
(
ukeywords
);
if
(!
hasExtension
&&
!
hasUAttributes
&&
!
hasUKeywords
)
{
if
(!
hasExtension
&&
!
hasUAttributes
&&
!
hasUKeywords
)
{
_map
=
EMPTY_MAP
;
id
=
""
;
_id
=
""
;
extensionMap
=
Collections
.
emptyMap
()
;
return
;
return
;
}
}
// Build extension map
// Build extension map
_map
=
new
TreeMap
<
Character
,
Extension
>();
SortedMap
<
Character
,
Extension
>
map
=
new
TreeMap
<
>();
if
(
hasExtension
)
{
if
(
hasExtension
)
{
for
(
Entry
<
CaseInsensitiveChar
,
String
>
ext
:
extensions
.
entrySet
())
{
for
(
Entry
<
CaseInsensitiveChar
,
String
>
ext
:
extensions
.
entrySet
())
{
char
key
=
AsciiUtil
.
toLower
(
ext
.
getKey
().
value
());
char
key
=
LocaleUtils
.
toLower
(
ext
.
getKey
().
value
());
String
value
=
ext
.
getValue
();
String
value
=
ext
.
getValue
();
if
(
LanguageTag
.
isPrivateusePrefixChar
(
key
))
{
if
(
LanguageTag
.
isPrivateusePrefixChar
(
key
))
{
...
@@ -104,54 +95,57 @@ public class LocaleExtensions {
...
@@ -104,54 +95,57 @@ public class LocaleExtensions {
}
}
}
}
Extension
e
=
new
Extension
(
key
,
AsciiUtil
.
toLowerString
(
value
));
map
.
put
(
key
,
new
Extension
(
key
,
LocaleUtils
.
toLowerString
(
value
)));
_map
.
put
(
Character
.
valueOf
(
key
),
e
);
}
}
}
}
if
(
hasUAttributes
||
hasUKeywords
)
{
if
(
hasUAttributes
||
hasUKeywords
)
{
Tree
Set
<
String
>
uaset
=
null
;
Sorted
Set
<
String
>
uaset
=
null
;
Tree
Map
<
String
,
String
>
ukmap
=
null
;
Sorted
Map
<
String
,
String
>
ukmap
=
null
;
if
(
hasUAttributes
)
{
if
(
hasUAttributes
)
{
uaset
=
new
TreeSet
<
String
>();
uaset
=
new
TreeSet
<>();
for
(
CaseInsensitiveString
cis
:
uattributes
)
{
for
(
CaseInsensitiveString
cis
:
uattributes
)
{
uaset
.
add
(
AsciiUtil
.
toLowerString
(
cis
.
value
()));
uaset
.
add
(
LocaleUtils
.
toLowerString
(
cis
.
value
()));
}
}
}
}
if
(
hasUKeywords
)
{
if
(
hasUKeywords
)
{
ukmap
=
new
TreeMap
<
String
,
String
>();
ukmap
=
new
TreeMap
<>();
for
(
Entry
<
CaseInsensitiveString
,
String
>
kwd
:
ukeywords
.
entrySet
())
{
for
(
Entry
<
CaseInsensitiveString
,
String
>
kwd
:
ukeywords
.
entrySet
())
{
String
key
=
AsciiUtil
.
toLowerString
(
kwd
.
getKey
().
value
());
String
key
=
LocaleUtils
.
toLowerString
(
kwd
.
getKey
().
value
());
String
type
=
AsciiUtil
.
toLowerString
(
kwd
.
getValue
());
String
type
=
LocaleUtils
.
toLowerString
(
kwd
.
getValue
());
ukmap
.
put
(
key
,
type
);
ukmap
.
put
(
key
,
type
);
}
}
}
}
UnicodeLocaleExtension
ule
=
new
UnicodeLocaleExtension
(
uaset
,
ukmap
);
UnicodeLocaleExtension
ule
=
new
UnicodeLocaleExtension
(
uaset
,
ukmap
);
_map
.
put
(
Character
.
valueOf
(
UnicodeLocaleExtension
.
SINGLETON
)
,
ule
);
map
.
put
(
UnicodeLocaleExtension
.
SINGLETON
,
ule
);
}
}
if
(
_map
.
size
()
==
0
)
{
if
(
map
.
isEmpty
()
)
{
// this could happen when only privuateuse with special variant
// this could happen when only privuateuse with special variant
_map
=
EMPTY_MAP
;
id
=
""
;
_id
=
""
;
extensionMap
=
Collections
.
emptyMap
()
;
}
else
{
}
else
{
_id
=
toID
(
_map
);
id
=
toID
(
map
);
extensionMap
=
map
;
}
}
}
}
public
Set
<
Character
>
getKeys
()
{
public
Set
<
Character
>
getKeys
()
{
return
Collections
.
unmodifiableSet
(
_map
.
keySet
());
if
(
extensionMap
.
isEmpty
())
{
return
Collections
.
emptySet
();
}
return
Collections
.
unmodifiableSet
(
extensionMap
.
keySet
());
}
}
public
Extension
getExtension
(
Character
key
)
{
public
Extension
getExtension
(
Character
key
)
{
return
_map
.
get
(
Character
.
valueOf
(
AsciiUtil
.
toLower
(
key
.
charValue
())
));
return
extensionMap
.
get
(
LocaleUtils
.
toLower
(
key
));
}
}
public
String
getExtensionValue
(
Character
key
)
{
public
String
getExtensionValue
(
Character
key
)
{
Extension
ext
=
_map
.
get
(
Character
.
valueOf
(
AsciiUtil
.
toLower
(
key
.
charValue
())
));
Extension
ext
=
extensionMap
.
get
(
LocaleUtils
.
toLower
(
key
));
if
(
ext
==
null
)
{
if
(
ext
==
null
)
{
return
null
;
return
null
;
}
}
...
@@ -159,7 +153,7 @@ public class LocaleExtensions {
...
@@ -159,7 +153,7 @@ public class LocaleExtensions {
}
}
public
Set
<
String
>
getUnicodeLocaleAttributes
()
{
public
Set
<
String
>
getUnicodeLocaleAttributes
()
{
Extension
ext
=
_map
.
get
(
Character
.
valueOf
(
UnicodeLocaleExtension
.
SINGLETON
)
);
Extension
ext
=
extensionMap
.
get
(
UnicodeLocaleExtension
.
SINGLETON
);
if
(
ext
==
null
)
{
if
(
ext
==
null
)
{
return
Collections
.
emptySet
();
return
Collections
.
emptySet
();
}
}
...
@@ -168,7 +162,7 @@ public class LocaleExtensions {
...
@@ -168,7 +162,7 @@ public class LocaleExtensions {
}
}
public
Set
<
String
>
getUnicodeLocaleKeys
()
{
public
Set
<
String
>
getUnicodeLocaleKeys
()
{
Extension
ext
=
_map
.
get
(
Character
.
valueOf
(
UnicodeLocaleExtension
.
SINGLETON
)
);
Extension
ext
=
extensionMap
.
get
(
UnicodeLocaleExtension
.
SINGLETON
);
if
(
ext
==
null
)
{
if
(
ext
==
null
)
{
return
Collections
.
emptySet
();
return
Collections
.
emptySet
();
}
}
...
@@ -177,16 +171,16 @@ public class LocaleExtensions {
...
@@ -177,16 +171,16 @@ public class LocaleExtensions {
}
}
public
String
getUnicodeLocaleType
(
String
unicodeLocaleKey
)
{
public
String
getUnicodeLocaleType
(
String
unicodeLocaleKey
)
{
Extension
ext
=
_map
.
get
(
Character
.
valueOf
(
UnicodeLocaleExtension
.
SINGLETON
)
);
Extension
ext
=
extensionMap
.
get
(
UnicodeLocaleExtension
.
SINGLETON
);
if
(
ext
==
null
)
{
if
(
ext
==
null
)
{
return
null
;
return
null
;
}
}
assert
(
ext
instanceof
UnicodeLocaleExtension
);
assert
(
ext
instanceof
UnicodeLocaleExtension
);
return
((
UnicodeLocaleExtension
)
ext
).
getUnicodeLocaleType
(
AsciiUtil
.
toLowerString
(
unicodeLocaleKey
));
return
((
UnicodeLocaleExtension
)
ext
).
getUnicodeLocaleType
(
LocaleUtils
.
toLowerString
(
unicodeLocaleKey
));
}
}
public
boolean
isEmpty
()
{
public
boolean
isEmpty
()
{
return
_m
ap
.
isEmpty
();
return
extensionM
ap
.
isEmpty
();
}
}
public
static
boolean
isValidKey
(
char
c
)
{
public
static
boolean
isValidKey
(
char
c
)
{
...
@@ -201,7 +195,7 @@ public class LocaleExtensions {
...
@@ -201,7 +195,7 @@ public class LocaleExtensions {
StringBuilder
buf
=
new
StringBuilder
();
StringBuilder
buf
=
new
StringBuilder
();
Extension
privuse
=
null
;
Extension
privuse
=
null
;
for
(
Entry
<
Character
,
Extension
>
entry
:
map
.
entrySet
())
{
for
(
Entry
<
Character
,
Extension
>
entry
:
map
.
entrySet
())
{
char
singleton
=
entry
.
getKey
()
.
charValue
()
;
char
singleton
=
entry
.
getKey
();
Extension
extension
=
entry
.
getValue
();
Extension
extension
=
entry
.
getValue
();
if
(
LanguageTag
.
isPrivateusePrefixChar
(
singleton
))
{
if
(
LanguageTag
.
isPrivateusePrefixChar
(
singleton
))
{
privuse
=
extension
;
privuse
=
extension
;
...
@@ -221,19 +215,21 @@ public class LocaleExtensions {
...
@@ -221,19 +215,21 @@ public class LocaleExtensions {
return
buf
.
toString
();
return
buf
.
toString
();
}
}
@Override
public
String
toString
()
{
public
String
toString
()
{
return
_
id
;
return
id
;
}
}
public
String
getID
()
{
public
String
getID
()
{
return
_
id
;
return
id
;
}
}
@Override
public
int
hashCode
()
{
public
int
hashCode
()
{
return
_
id
.
hashCode
();
return
id
.
hashCode
();
}
}
@Override
public
boolean
equals
(
Object
other
)
{
public
boolean
equals
(
Object
other
)
{
if
(
this
==
other
)
{
if
(
this
==
other
)
{
return
true
;
return
true
;
...
@@ -241,6 +237,6 @@ public class LocaleExtensions {
...
@@ -241,6 +237,6 @@ public class LocaleExtensions {
if
(!(
other
instanceof
LocaleExtensions
))
{
if
(!(
other
instanceof
LocaleExtensions
))
{
return
false
;
return
false
;
}
}
return
this
.
_id
.
equals
(((
LocaleExtensions
)
other
).
_
id
);
return
id
.
equals
(((
LocaleExtensions
)
other
).
id
);
}
}
}
}
src/share/classes/sun/util/locale/LocaleObjectCache.java
浏览文件 @
421115af
/*
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010,
2011,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -34,24 +34,25 @@ package sun.util.locale;
...
@@ -34,24 +34,25 @@ package sun.util.locale;
import
java.lang.ref.ReferenceQueue
;
import
java.lang.ref.ReferenceQueue
;
import
java.lang.ref.SoftReference
;
import
java.lang.ref.SoftReference
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentMap
;
public
abstract
class
LocaleObjectCache
<
K
,
V
>
{
public
abstract
class
LocaleObjectCache
<
K
,
V
>
{
private
Concurrent
HashMap
<
K
,
CacheEntry
<
K
,
V
>>
_
map
;
private
Concurrent
Map
<
K
,
CacheEntry
<
K
,
V
>>
map
;
private
ReferenceQueue
<
V
>
_queue
=
new
ReferenceQueue
<
V
>();
private
ReferenceQueue
<
V
>
queue
=
new
ReferenceQueue
<
>();
public
LocaleObjectCache
()
{
public
LocaleObjectCache
()
{
this
(
16
,
0.75f
,
16
);
this
(
16
,
0.75f
,
16
);
}
}
public
LocaleObjectCache
(
int
initialCapacity
,
float
loadFactor
,
int
concurrencyLevel
)
{
public
LocaleObjectCache
(
int
initialCapacity
,
float
loadFactor
,
int
concurrencyLevel
)
{
_map
=
new
ConcurrentHashMap
<
K
,
CacheEntry
<
K
,
V
>
>(
initialCapacity
,
loadFactor
,
concurrencyLevel
);
map
=
new
ConcurrentHashMap
<
>(
initialCapacity
,
loadFactor
,
concurrencyLevel
);
}
}
public
V
get
(
K
key
)
{
public
V
get
(
K
key
)
{
V
value
=
null
;
V
value
=
null
;
cleanStaleEntries
();
cleanStaleEntries
();
CacheEntry
<
K
,
V
>
entry
=
_
map
.
get
(
key
);
CacheEntry
<
K
,
V
>
entry
=
map
.
get
(
key
);
if
(
entry
!=
null
)
{
if
(
entry
!=
null
)
{
value
=
entry
.
get
();
value
=
entry
.
get
();
}
}
...
@@ -63,11 +64,11 @@ public abstract class LocaleObjectCache<K, V> {
...
@@ -63,11 +64,11 @@ public abstract class LocaleObjectCache<K, V> {
return
null
;
return
null
;
}
}
CacheEntry
<
K
,
V
>
newEntry
=
new
CacheEntry
<
K
,
V
>(
key
,
newVal
,
_
queue
);
CacheEntry
<
K
,
V
>
newEntry
=
new
CacheEntry
<
>(
key
,
newVal
,
queue
);
while
(
value
==
null
)
{
while
(
value
==
null
)
{
cleanStaleEntries
();
cleanStaleEntries
();
entry
=
_
map
.
putIfAbsent
(
key
,
newEntry
);
entry
=
map
.
putIfAbsent
(
key
,
newEntry
);
if
(
entry
==
null
)
{
if
(
entry
==
null
)
{
value
=
newVal
;
value
=
newVal
;
break
;
break
;
...
@@ -79,11 +80,17 @@ public abstract class LocaleObjectCache<K, V> {
...
@@ -79,11 +80,17 @@ public abstract class LocaleObjectCache<K, V> {
return
value
;
return
value
;
}
}
protected
V
put
(
K
key
,
V
value
)
{
CacheEntry
<
K
,
V
>
entry
=
new
CacheEntry
<>(
key
,
value
,
queue
);
CacheEntry
<
K
,
V
>
oldEntry
=
map
.
put
(
key
,
entry
);
return
(
oldEntry
==
null
)
?
null
:
oldEntry
.
get
();
}
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
private
void
cleanStaleEntries
()
{
private
void
cleanStaleEntries
()
{
CacheEntry
<
K
,
V
>
entry
;
CacheEntry
<
K
,
V
>
entry
;
while
((
entry
=
(
CacheEntry
<
K
,
V
>)
_
queue
.
poll
())
!=
null
)
{
while
((
entry
=
(
CacheEntry
<
K
,
V
>)
queue
.
poll
())
!=
null
)
{
_
map
.
remove
(
entry
.
getKey
());
map
.
remove
(
entry
.
getKey
());
}
}
}
}
...
@@ -94,15 +101,15 @@ public abstract class LocaleObjectCache<K, V> {
...
@@ -94,15 +101,15 @@ public abstract class LocaleObjectCache<K, V> {
}
}
private
static
class
CacheEntry
<
K
,
V
>
extends
SoftReference
<
V
>
{
private
static
class
CacheEntry
<
K
,
V
>
extends
SoftReference
<
V
>
{
private
K
_
key
;
private
K
key
;
CacheEntry
(
K
key
,
V
value
,
ReferenceQueue
<
V
>
queue
)
{
CacheEntry
(
K
key
,
V
value
,
ReferenceQueue
<
V
>
queue
)
{
super
(
value
,
queue
);
super
(
value
,
queue
);
_
key
=
key
;
this
.
key
=
key
;
}
}
K
getKey
()
{
K
getKey
()
{
return
_
key
;
return
key
;
}
}
}
}
}
}
src/share/classes/sun/util/locale/LocaleSyntaxException.java
浏览文件 @
421115af
/*
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010,
2011,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -35,7 +35,7 @@ public class LocaleSyntaxException extends Exception {
...
@@ -35,7 +35,7 @@ public class LocaleSyntaxException extends Exception {
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
private
int
_
index
=
-
1
;
private
int
index
=
-
1
;
public
LocaleSyntaxException
(
String
msg
)
{
public
LocaleSyntaxException
(
String
msg
)
{
this
(
msg
,
0
);
this
(
msg
,
0
);
...
@@ -43,10 +43,10 @@ public class LocaleSyntaxException extends Exception {
...
@@ -43,10 +43,10 @@ public class LocaleSyntaxException extends Exception {
public
LocaleSyntaxException
(
String
msg
,
int
errorIndex
)
{
public
LocaleSyntaxException
(
String
msg
,
int
errorIndex
)
{
super
(
msg
);
super
(
msg
);
_
index
=
errorIndex
;
index
=
errorIndex
;
}
}
public
int
getErrorIndex
()
{
public
int
getErrorIndex
()
{
return
_
index
;
return
index
;
}
}
}
}
src/share/classes/sun/util/locale/LocaleUtils.java
0 → 100644
浏览文件 @
421115af
/*
* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
*******************************************************************************
* Copyright (C) 2009, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*/
package
sun.util.locale
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
/**
* Collection of static utility methods for Locale support. The
* methods which manipulate characters or strings support ASCII only.
*/
public
final
class
LocaleUtils
{
private
LocaleUtils
()
{
}
/**
* Compares two ASCII Strings s1 and s2, ignoring case.
*/
public
static
boolean
caseIgnoreMatch
(
String
s1
,
String
s2
)
{
if
(
s1
==
s2
)
{
return
true
;
}
int
len
=
s1
.
length
();
if
(
len
!=
s2
.
length
())
{
return
false
;
}
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
char
c1
=
s1
.
charAt
(
i
);
char
c2
=
s2
.
charAt
(
i
);
if
(
c1
!=
c2
&&
toLower
(
c1
)
!=
toLower
(
c2
))
{
return
false
;
}
}
return
true
;
}
static
int
caseIgnoreCompare
(
String
s1
,
String
s2
)
{
if
(
s1
==
s2
)
{
return
0
;
}
return
toLowerString
(
s1
).
compareTo
(
toLowerString
(
s2
));
}
static
char
toUpper
(
char
c
)
{
return
isLower
(
c
)
?
(
char
)(
c
-
0x20
)
:
c
;
}
static
char
toLower
(
char
c
)
{
return
isUpper
(
c
)
?
(
char
)(
c
+
0x20
)
:
c
;
}
/**
* Converts the given ASCII String to lower-case.
*/
public
static
String
toLowerString
(
String
s
)
{
int
len
=
s
.
length
();
int
idx
=
0
;
for
(;
idx
<
len
;
idx
++)
{
if
(
isUpper
(
s
.
charAt
(
idx
)))
{
break
;
}
}
if
(
idx
==
len
)
{
return
s
;
}
char
[]
buf
=
new
char
[
len
];
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
char
c
=
s
.
charAt
(
i
);
buf
[
i
]
=
(
i
<
idx
)
?
c
:
toLower
(
c
);
}
return
new
String
(
buf
);
}
static
String
toUpperString
(
String
s
)
{
int
len
=
s
.
length
();
int
idx
=
0
;
for
(;
idx
<
len
;
idx
++)
{
if
(
isLower
(
s
.
charAt
(
idx
)))
{
break
;
}
}
if
(
idx
==
len
)
{
return
s
;
}
char
[]
buf
=
new
char
[
len
];
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
char
c
=
s
.
charAt
(
i
);
buf
[
i
]
=
(
i
<
idx
)
?
c
:
toUpper
(
c
);
}
return
new
String
(
buf
);
}
static
String
toTitleString
(
String
s
)
{
int
len
;
if
((
len
=
s
.
length
())
==
0
)
{
return
s
;
}
int
idx
=
0
;
if
(!
isLower
(
s
.
charAt
(
idx
)))
{
for
(
idx
=
1
;
idx
<
len
;
idx
++)
{
if
(
isUpper
(
s
.
charAt
(
idx
)))
{
break
;
}
}
}
if
(
idx
==
len
)
{
return
s
;
}
char
[]
buf
=
new
char
[
len
];
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
char
c
=
s
.
charAt
(
i
);
if
(
i
==
0
&&
idx
==
0
)
{
buf
[
i
]
=
toUpper
(
c
);
}
else
if
(
i
<
idx
)
{
buf
[
i
]
=
c
;
}
else
{
buf
[
i
]
=
toLower
(
c
);
}
}
return
new
String
(
buf
);
}
private
static
boolean
isUpper
(
char
c
)
{
return
c
>=
'A'
&&
c
<=
'Z'
;
}
private
static
boolean
isLower
(
char
c
)
{
return
c
>=
'a'
&&
c
<=
'z'
;
}
static
boolean
isAlpha
(
char
c
)
{
return
(
c
>=
'A'
&&
c
<=
'Z'
)
||
(
c
>=
'a'
&&
c
<=
'z'
);
}
static
boolean
isAlphaString
(
String
s
)
{
int
len
=
s
.
length
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
if
(!
isAlpha
(
s
.
charAt
(
i
)))
{
return
false
;
}
}
return
true
;
}
static
boolean
isNumeric
(
char
c
)
{
return
(
c
>=
'0'
&&
c
<=
'9'
);
}
static
boolean
isNumericString
(
String
s
)
{
int
len
=
s
.
length
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
if
(!
isNumeric
(
s
.
charAt
(
i
)))
{
return
false
;
}
}
return
true
;
}
static
boolean
isAlphaNumeric
(
char
c
)
{
return
isAlpha
(
c
)
||
isNumeric
(
c
);
}
static
boolean
isAlphaNumericString
(
String
s
)
{
int
len
=
s
.
length
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
if
(!
isAlphaNumeric
(
s
.
charAt
(
i
)))
{
return
false
;
}
}
return
true
;
}
static
boolean
isEmpty
(
String
str
)
{
return
str
==
null
||
str
.
length
()
==
0
;
}
static
boolean
isEmpty
(
Set
<?>
set
)
{
return
set
==
null
||
set
.
isEmpty
();
}
static
boolean
isEmpty
(
Map
<?,
?>
map
)
{
return
map
==
null
||
map
.
isEmpty
();
}
static
boolean
isEmpty
(
List
<?>
list
)
{
return
list
==
null
||
list
.
isEmpty
();
}
}
src/share/classes/sun/util/locale/ParseStatus.java
浏览文件 @
421115af
/*
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010,
2011,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -32,29 +32,33 @@
...
@@ -32,29 +32,33 @@
package
sun.util.locale
;
package
sun.util.locale
;
public
class
ParseStatus
{
public
class
ParseStatus
{
int
_parseLength
=
0
;
int
parseLength
;
int
_errorIndex
=
-
1
;
int
errorIndex
;
String
_errorMsg
=
null
;
String
errorMsg
;
public
ParseStatus
()
{
reset
();
}
public
void
reset
()
{
public
void
reset
()
{
_
parseLength
=
0
;
parseLength
=
0
;
_
errorIndex
=
-
1
;
errorIndex
=
-
1
;
_
errorMsg
=
null
;
errorMsg
=
null
;
}
}
public
boolean
isError
()
{
public
boolean
isError
()
{
return
(
_
errorIndex
>=
0
);
return
(
errorIndex
>=
0
);
}
}
public
int
getErrorIndex
()
{
public
int
getErrorIndex
()
{
return
_
errorIndex
;
return
errorIndex
;
}
}
public
int
getParseLength
()
{
public
int
getParseLength
()
{
return
_
parseLength
;
return
parseLength
;
}
}
public
String
getErrorMessage
()
{
public
String
getErrorMessage
()
{
return
_
errorMsg
;
return
errorMsg
;
}
}
}
}
src/share/classes/sun/util/locale/StringTokenIterator.java
浏览文件 @
421115af
/*
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010,
2011,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -31,87 +31,99 @@
...
@@ -31,87 +31,99 @@
package
sun.util.locale
;
package
sun.util.locale
;
public
class
StringTokenIterator
{
public
class
StringTokenIterator
{
private
String
_text
;
private
String
text
;
private
String
_dlms
;
private
String
dlms
;
// null if a single char delimiter
private
char
delimiterChar
;
// delimiter if a single char delimiter
private
String
_
token
;
private
String
token
;
private
int
_
start
;
private
int
start
;
private
int
_
end
;
private
int
end
;
private
boolean
_
done
;
private
boolean
done
;
public
StringTokenIterator
(
String
text
,
String
dlms
)
{
public
StringTokenIterator
(
String
text
,
String
dlms
)
{
_text
=
text
;
this
.
text
=
text
;
_dlms
=
dlms
;
if
(
dlms
.
length
()
==
1
)
{
delimiterChar
=
dlms
.
charAt
(
0
);
}
else
{
this
.
dlms
=
dlms
;
}
setStart
(
0
);
setStart
(
0
);
}
}
public
String
first
()
{
public
String
first
()
{
setStart
(
0
);
setStart
(
0
);
return
_
token
;
return
token
;
}
}
public
String
current
()
{
public
String
current
()
{
return
_
token
;
return
token
;
}
}
public
int
currentStart
()
{
public
int
currentStart
()
{
return
_
start
;
return
start
;
}
}
public
int
currentEnd
()
{
public
int
currentEnd
()
{
return
_
end
;
return
end
;
}
}
public
boolean
isDone
()
{
public
boolean
isDone
()
{
return
_
done
;
return
done
;
}
}
public
String
next
()
{
public
String
next
()
{
if
(
hasNext
())
{
if
(
hasNext
())
{
_start
=
_
end
+
1
;
start
=
end
+
1
;
_end
=
nextDelimiter
(
_
start
);
end
=
nextDelimiter
(
start
);
_token
=
_text
.
substring
(
_start
,
_
end
);
token
=
text
.
substring
(
start
,
end
);
}
else
{
}
else
{
_start
=
_
end
;
start
=
end
;
_
token
=
null
;
token
=
null
;
_
done
=
true
;
done
=
true
;
}
}
return
_
token
;
return
token
;
}
}
public
boolean
hasNext
()
{
public
boolean
hasNext
()
{
return
(
_end
<
_
text
.
length
());
return
(
end
<
text
.
length
());
}
}
public
StringTokenIterator
setStart
(
int
offset
)
{
public
StringTokenIterator
setStart
(
int
offset
)
{
if
(
offset
>
_
text
.
length
())
{
if
(
offset
>
text
.
length
())
{
throw
new
IndexOutOfBoundsException
();
throw
new
IndexOutOfBoundsException
();
}
}
_
start
=
offset
;
start
=
offset
;
_end
=
nextDelimiter
(
_
start
);
end
=
nextDelimiter
(
start
);
_token
=
_text
.
substring
(
_start
,
_
end
);
token
=
text
.
substring
(
start
,
end
);
_
done
=
false
;
done
=
false
;
return
this
;
return
this
;
}
}
public
StringTokenIterator
setText
(
String
text
)
{
public
StringTokenIterator
setText
(
String
text
)
{
_
text
=
text
;
this
.
text
=
text
;
setStart
(
0
);
setStart
(
0
);
return
this
;
return
this
;
}
}
private
int
nextDelimiter
(
int
start
)
{
private
int
nextDelimiter
(
int
start
)
{
int
idx
=
start
;
int
textlen
=
this
.
text
.
length
();
outer:
while
(
idx
<
_text
.
length
())
{
if
(
dlms
==
null
)
{
char
c
=
_text
.
charAt
(
idx
);
for
(
int
idx
=
start
;
idx
<
textlen
;
idx
++)
{
for
(
int
i
=
0
;
i
<
_dlms
.
length
();
i
++)
{
if
(
text
.
charAt
(
idx
)
==
delimiterChar
)
{
if
(
c
==
_dlms
.
charAt
(
i
))
{
return
idx
;
break
outer
;
}
}
}
else
{
int
dlmslen
=
dlms
.
length
();
for
(
int
idx
=
start
;
idx
<
textlen
;
idx
++)
{
char
c
=
text
.
charAt
(
idx
);
for
(
int
i
=
0
;
i
<
dlmslen
;
i
++)
{
if
(
c
==
dlms
.
charAt
(
i
))
{
return
idx
;
}
}
}
}
}
idx
++;
}
}
return
idx
;
return
textlen
;
}
}
}
}
src/share/classes/sun/util/locale/UnicodeLocaleExtension.java
浏览文件 @
421115af
/*
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010,
2011,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -32,56 +33,48 @@
...
@@ -32,56 +33,48 @@
package
sun.util.locale
;
package
sun.util.locale
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.SortedMap
;
import
java.util.SortedMap
;
import
java.util.SortedSet
;
import
java.util.SortedSet
;
import
java.util.TreeMap
;
import
java.util.TreeSet
;
public
class
UnicodeLocaleExtension
extends
Extension
{
public
class
UnicodeLocaleExtension
extends
Extension
{
public
static
final
char
SINGLETON
=
'u'
;
public
static
final
char
SINGLETON
=
'u'
;
private
static
final
SortedSet
<
String
>
EMPTY_SORTED_SET
=
new
TreeSet
<
String
>();
private
final
Set
<
String
>
attributes
;
private
static
final
SortedMap
<
String
,
String
>
EMPTY_SORTED_MAP
=
new
TreeMap
<
String
,
String
>();
private
final
Map
<
String
,
String
>
keywords
;
private
SortedSet
<
String
>
_attributes
=
EMPTY_SORTED_SET
;
private
SortedMap
<
String
,
String
>
_keywords
=
EMPTY_SORTED_MAP
;
public
static
final
UnicodeLocaleExtension
CA_JAPANESE
;
public
static
final
UnicodeLocaleExtension
NU_THAI
;
static
{
public
static
final
UnicodeLocaleExtension
CA_JAPANESE
CA_JAPANESE
=
new
UnicodeLocaleExtension
();
=
new
UnicodeLocaleExtension
(
"ca"
,
"japanese"
);
CA_JAPANESE
.
_keywords
=
new
TreeMap
<
String
,
String
>();
public
static
final
UnicodeLocaleExtension
NU_THAI
CA_JAPANESE
.
_keywords
.
put
(
"ca"
,
"japanese"
);
=
new
UnicodeLocaleExtension
(
"nu"
,
"thai"
);
CA_JAPANESE
.
_value
=
"ca-japanese"
;
NU_THAI
=
new
UnicodeLocaleExtension
();
private
UnicodeLocaleExtension
(
String
key
,
String
value
)
{
NU_THAI
.
_keywords
=
new
TreeMap
<
String
,
String
>();
super
(
SINGLETON
,
key
+
"-"
+
value
);
NU_THAI
.
_keywords
.
put
(
"nu"
,
"thai"
);
attributes
=
Collections
.
emptySet
();
NU_THAI
.
_value
=
"nu-thai"
;
keywords
=
Collections
.
singletonMap
(
key
,
value
);
}
private
UnicodeLocaleExtension
()
{
super
(
SINGLETON
);
}
}
UnicodeLocaleExtension
(
SortedSet
<
String
>
attributes
,
SortedMap
<
String
,
String
>
keywords
)
{
UnicodeLocaleExtension
(
SortedSet
<
String
>
attributes
,
SortedMap
<
String
,
String
>
keywords
)
{
this
();
super
(
SINGLETON
);
if
(
attributes
!=
null
&&
attributes
.
size
()
>
0
)
{
if
(
attributes
!=
null
)
{
_attributes
=
attributes
;
this
.
attributes
=
attributes
;
}
else
{
this
.
attributes
=
Collections
.
emptySet
();
}
}
if
(
keywords
!=
null
&&
keywords
.
size
()
>
0
)
{
if
(
keywords
!=
null
)
{
_keywords
=
keywords
;
this
.
keywords
=
keywords
;
}
else
{
this
.
keywords
=
Collections
.
emptyMap
();
}
}
if
(
_attributes
.
size
()
>
0
||
_keywords
.
size
()
>
0
)
{
if
(
!
this
.
attributes
.
isEmpty
()
||
!
this
.
keywords
.
isEmpty
()
)
{
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
for
(
String
attribute
:
_
attributes
)
{
for
(
String
attribute
:
this
.
attributes
)
{
sb
.
append
(
LanguageTag
.
SEP
).
append
(
attribute
);
sb
.
append
(
LanguageTag
.
SEP
).
append
(
attribute
);
}
}
for
(
Entry
<
String
,
String
>
keyword
:
_
keywords
.
entrySet
())
{
for
(
Entry
<
String
,
String
>
keyword
:
this
.
keywords
.
entrySet
())
{
String
key
=
keyword
.
getKey
();
String
key
=
keyword
.
getKey
();
String
value
=
keyword
.
getValue
();
String
value
=
keyword
.
getValue
();
...
@@ -90,38 +83,46 @@ public class UnicodeLocaleExtension extends Extension {
...
@@ -90,38 +83,46 @@ public class UnicodeLocaleExtension extends Extension {
sb
.
append
(
LanguageTag
.
SEP
).
append
(
value
);
sb
.
append
(
LanguageTag
.
SEP
).
append
(
value
);
}
}
}
}
_value
=
sb
.
substring
(
1
);
// skip leading '-'
setValue
(
sb
.
substring
(
1
)
);
// skip leading '-'
}
}
}
}
public
Set
<
String
>
getUnicodeLocaleAttributes
()
{
public
Set
<
String
>
getUnicodeLocaleAttributes
()
{
return
Collections
.
unmodifiableSet
(
_attributes
);
if
(
attributes
==
Collections
.
EMPTY_SET
)
{
return
attributes
;
}
return
Collections
.
unmodifiableSet
(
attributes
);
}
}
public
Set
<
String
>
getUnicodeLocaleKeys
()
{
public
Set
<
String
>
getUnicodeLocaleKeys
()
{
return
Collections
.
unmodifiableSet
(
_keywords
.
keySet
());
if
(
keywords
==
Collections
.
EMPTY_MAP
)
{
return
Collections
.
emptySet
();
}
return
Collections
.
unmodifiableSet
(
keywords
.
keySet
());
}
}
public
String
getUnicodeLocaleType
(
String
unicodeLocaleKey
)
{
public
String
getUnicodeLocaleType
(
String
unicodeLocaleKey
)
{
return
_
keywords
.
get
(
unicodeLocaleKey
);
return
keywords
.
get
(
unicodeLocaleKey
);
}
}
public
static
boolean
isSingletonChar
(
char
c
)
{
public
static
boolean
isSingletonChar
(
char
c
)
{
return
(
SINGLETON
==
AsciiUtil
.
toLower
(
c
));
return
(
SINGLETON
==
LocaleUtils
.
toLower
(
c
));
}
}
public
static
boolean
isAttribute
(
String
s
)
{
public
static
boolean
isAttribute
(
String
s
)
{
// 3*8alphanum
// 3*8alphanum
return
(
s
.
length
()
>=
3
)
&&
(
s
.
length
()
<=
8
)
&&
AsciiUtil
.
isAlphaNumericString
(
s
);
int
len
=
s
.
length
();
return
(
len
>=
3
)
&&
(
len
<=
8
)
&&
LocaleUtils
.
isAlphaNumericString
(
s
);
}
}
public
static
boolean
isKey
(
String
s
)
{
public
static
boolean
isKey
(
String
s
)
{
// 2alphanum
// 2alphanum
return
(
s
.
length
()
==
2
)
&&
AsciiUtil
.
isAlphaNumericString
(
s
);
return
(
s
.
length
()
==
2
)
&&
LocaleUtils
.
isAlphaNumericString
(
s
);
}
}
public
static
boolean
isTypeSubtag
(
String
s
)
{
public
static
boolean
isTypeSubtag
(
String
s
)
{
// 3*8alphanum
// 3*8alphanum
return
(
s
.
length
()
>=
3
)
&&
(
s
.
length
()
<=
8
)
&&
AsciiUtil
.
isAlphaNumericString
(
s
);
int
len
=
s
.
length
();
return
(
len
>=
3
)
&&
(
len
<=
8
)
&&
LocaleUtils
.
isAlphaNumericString
(
s
);
}
}
}
}
src/share/classes/sun/util/resources/TimeZoneNames_pt_BR.java
浏览文件 @
421115af
此差异已折叠。
点击以展开。
src/windows/classes/sun/awt/Win32FontManager.java
浏览文件 @
421115af
...
@@ -103,6 +103,14 @@ public class Win32FontManager extends SunFontManager {
...
@@ -103,6 +103,14 @@ public class Win32FontManager extends SunFontManager {
});
});
}
}
/**
* Whether registerFontFile expects absolute or relative
* font file names.
*/
protected
boolean
useAbsoluteFontFileNames
()
{
return
false
;
}
/* Unlike the shared code version, this expects a base file name -
/* Unlike the shared code version, this expects a base file name -
* not a full path name.
* not a full path name.
* The font configuration file has base file names and the FontConfiguration
* The font configuration file has base file names and the FontConfiguration
...
...
src/windows/classes/sun/awt/Win32GraphicsEnvironment.java
浏览文件 @
421115af
...
@@ -202,14 +202,6 @@ public class Win32GraphicsEnvironment
...
@@ -202,14 +202,6 @@ public class Win32GraphicsEnvironment
* ----END DISPLAY CHANGE SUPPORT----
* ----END DISPLAY CHANGE SUPPORT----
*/
*/
/**
* Whether registerFontFile expects absolute or relative
* font file names.
*/
protected
boolean
useAbsoluteFontFileNames
()
{
return
false
;
}
protected
GraphicsDevice
makeScreenDevice
(
int
screennum
)
{
protected
GraphicsDevice
makeScreenDevice
(
int
screennum
)
{
GraphicsDevice
device
=
null
;
GraphicsDevice
device
=
null
;
if
(
WindowsFlags
.
isD3DEnabled
())
{
if
(
WindowsFlags
.
isD3DEnabled
())
{
...
...
test/java/text/Bidi/Bug6665028.java
浏览文件 @
421115af
/*
/*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007,
2011,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
* that this test case fails without the fix in some different ways,
* that this test case fails without the fix in some different ways,
* including timeout, due to the memory corruption.
* including timeout, due to the memory corruption.
* @build Bug6665028
* @build Bug6665028
* @run main/othervm
/timeout=60 -Xmx16m Bug6665028
* @run main/othervm
-Xmx16m Bug6665028 10
*/
*/
import
java.awt.font.TextAttribute
;
import
java.awt.font.TextAttribute
;
...
@@ -36,6 +36,7 @@ import java.text.AttributedString;
...
@@ -36,6 +36,7 @@ import java.text.AttributedString;
import
java.text.Bidi
;
import
java.text.Bidi
;
// test1() and test2() were derived from BidiEmbeddingTest.
// test1() and test2() were derived from BidiEmbeddingTest.
// Usage: java Bug6665028 [duration]
public
class
Bug6665028
{
public
class
Bug6665028
{
private
static
boolean
runrun
=
true
;
private
static
boolean
runrun
=
true
;
...
@@ -50,6 +51,11 @@ public class Bug6665028 {
...
@@ -50,6 +51,11 @@ public class Bug6665028 {
}
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
int
duration
=
45
;
if
(
args
.
length
==
1
)
{
duration
=
Math
.
max
(
1
,
Math
.
min
(
Integer
.
parseInt
(
args
[
0
]),
45
));
}
Test
[]
tests
=
new
Test
[
4
];
Test
[]
tests
=
new
Test
[
4
];
for
(
int
i
=
0
;
i
<
tests
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
tests
.
length
;
i
++)
{
Test
t
=
new
Test
();
Test
t
=
new
Test
();
...
@@ -58,7 +64,7 @@ public class Bug6665028 {
...
@@ -58,7 +64,7 @@ public class Bug6665028 {
}
}
try
{
try
{
Thread
.
sleep
(
45
000
);
Thread
.
sleep
(
duration
*
1
000
);
}
catch
(
InterruptedException
e
)
{
}
catch
(
InterruptedException
e
)
{
}
}
...
...
test/java/util/Locale/Bug4518797.java
浏览文件 @
421115af
/*
/*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007,
2011,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -24,17 +24,22 @@
...
@@ -24,17 +24,22 @@
* @test
* @test
* @bug 4518797
* @bug 4518797
* @summary Make sure that hashCode() and read/writeObject() are thread-safe.
* @summary Make sure that hashCode() and read/writeObject() are thread-safe.
* @run main
/timeout=200 Bug4518797
* @run main
Bug4518797 10
*/
*/
import
java.util.*
;
import
java.util.*
;
import
java.io.*
;
import
java.io.*
;
// Usage: java Bug4518797 [duration]
public
class
Bug4518797
{
public
class
Bug4518797
{
static
volatile
boolean
runrun
=
true
;
static
volatile
boolean
runrun
=
true
;
static
volatile
String
message
=
null
;
static
volatile
String
message
=
null
;
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
int
duration
=
180
;
if
(
args
.
length
==
1
)
{
duration
=
Math
.
max
(
5
,
Integer
.
parseInt
(
args
[
0
]));
}
final
Locale
loc
=
new
Locale
(
"ja"
,
"US"
);
final
Locale
loc
=
new
Locale
(
"ja"
,
"US"
);
final
int
hashcode
=
loc
.
hashCode
();
final
int
hashcode
=
loc
.
hashCode
();
...
@@ -84,7 +89,7 @@ public class Bug4518797 {
...
@@ -84,7 +89,7 @@ public class Bug4518797 {
t1
.
start
();
t1
.
start
();
t2
.
start
();
t2
.
start
();
try
{
try
{
for
(
int
i
=
0
;
runrun
&&
i
<
180
;
i
++)
{
for
(
int
i
=
0
;
runrun
&&
i
<
duration
;
i
++)
{
Thread
.
sleep
(
1000
);
Thread
.
sleep
(
1000
);
}
}
runrun
=
false
;
runrun
=
false
;
...
...
test/java/util/Locale/LocaleEnhanceTest.java
浏览文件 @
421115af
...
@@ -33,8 +33,10 @@ import java.io.ObjectInputStream;
...
@@ -33,8 +33,10 @@ import java.io.ObjectInputStream;
import
java.io.ObjectOutputStream
;
import
java.io.ObjectOutputStream
;
import
java.net.URISyntaxException
;
import
java.net.URISyntaxException
;
import
java.net.URL
;
import
java.net.URL
;
import
java.text.DecimalFormatSymbols
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Calendar
;
import
java.util.IllformedLocaleException
;
import
java.util.IllformedLocaleException
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Locale
;
...
@@ -43,8 +45,10 @@ import java.util.Set;
...
@@ -43,8 +45,10 @@ import java.util.Set;
/**
/**
* @test
* @test
* @bug 6875847 6992272 7002320 7015500 7023613
* @bug 6875847 6992272 7002320 7015500 7023613
7032820 7033504
* @summary test API changes to Locale
* @summary test API changes to Locale
* @compile LocaleEnhanceTest.java
* @run main/othervm -esa LocaleEnhanceTest
*/
*/
public
class
LocaleEnhanceTest
extends
LocaleTestFmwk
{
public
class
LocaleEnhanceTest
extends
LocaleTestFmwk
{
...
@@ -593,6 +597,9 @@ public class LocaleEnhanceTest extends LocaleTestFmwk {
...
@@ -593,6 +597,9 @@ public class LocaleEnhanceTest extends LocaleTestFmwk {
assertEquals
(
"extension"
,
"aa-00-bb-01"
,
locale
.
getExtension
(
'd'
));
assertEquals
(
"extension"
,
"aa-00-bb-01"
,
locale
.
getExtension
(
'd'
));
assertEquals
(
"extension c"
,
"1234"
,
locale
.
getExtension
(
'c'
));
assertEquals
(
"extension c"
,
"1234"
,
locale
.
getExtension
(
'c'
));
locale
=
Locale
.
forLanguageTag
(
"und-U-ca-gregory-u-ca-japanese"
);
assertEquals
(
"Unicode extension"
,
"ca-gregory"
,
locale
.
getExtension
(
Locale
.
UNICODE_LOCALE_EXTENSION
));
// redundant Unicode locale keys in an extension are ignored
// redundant Unicode locale keys in an extension are ignored
locale
=
Locale
.
forLanguageTag
(
"und-u-aa-000-bb-001-bB-002-cc-003-c-1234"
);
locale
=
Locale
.
forLanguageTag
(
"und-u-aa-000-bb-001-bB-002-cc-003-c-1234"
);
assertEquals
(
"Unicode keywords"
,
"aa-000-bb-001-cc-003"
,
locale
.
getExtension
(
Locale
.
UNICODE_LOCALE_EXTENSION
));
assertEquals
(
"Unicode keywords"
,
"aa-000-bb-001-cc-003"
,
locale
.
getExtension
(
Locale
.
UNICODE_LOCALE_EXTENSION
));
...
@@ -1275,6 +1282,35 @@ public class LocaleEnhanceTest extends LocaleTestFmwk {
...
@@ -1275,6 +1282,35 @@ public class LocaleEnhanceTest extends LocaleTestFmwk {
}
}
}
}
/*
* 7033504: (lc) incompatible behavior change for ja_JP_JP and th_TH_TH locales
*/
public
void
testBug7033504
()
{
checkCalendar
(
new
Locale
(
"ja"
,
"JP"
,
"jp"
),
"java.util.GregorianCalendar"
);
checkCalendar
(
new
Locale
(
"ja"
,
"jp"
,
"jp"
),
"java.util.GregorianCalendar"
);
checkCalendar
(
new
Locale
(
"ja"
,
"JP"
,
"JP"
),
"java.util.JapaneseImperialCalendar"
);
checkCalendar
(
new
Locale
(
"ja"
,
"jp"
,
"JP"
),
"java.util.JapaneseImperialCalendar"
);
checkCalendar
(
Locale
.
forLanguageTag
(
"en-u-ca-japanese"
),
"java.util.JapaneseImperialCalendar"
);
checkDigit
(
new
Locale
(
"th"
,
"TH"
,
"th"
),
'0'
);
checkDigit
(
new
Locale
(
"th"
,
"th"
,
"th"
),
'0'
);
checkDigit
(
new
Locale
(
"th"
,
"TH"
,
"TH"
),
'\u0e50'
);
checkDigit
(
new
Locale
(
"th"
,
"TH"
,
"TH"
),
'\u0e50'
);
checkDigit
(
Locale
.
forLanguageTag
(
"en-u-nu-thai"
),
'\u0e50'
);
}
private
void
checkCalendar
(
Locale
loc
,
String
expected
)
{
Calendar
cal
=
Calendar
.
getInstance
(
loc
);
assertEquals
(
"Wrong calendar"
,
expected
,
cal
.
getClass
().
getName
());
}
private
void
checkDigit
(
Locale
loc
,
Character
expected
)
{
DecimalFormatSymbols
dfs
=
DecimalFormatSymbols
.
getInstance
(
loc
);
Character
zero
=
dfs
.
getZeroDigit
();
assertEquals
(
"Wrong digit zero char"
,
expected
,
zero
);
}
///
///
/// utility asserts
/// utility asserts
///
///
...
...
test/java/util/ResourceBundle/Control/StressTest.java
浏览文件 @
421115af
/*
/*
* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007,
2011,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -24,12 +24,13 @@
...
@@ -24,12 +24,13 @@
* @test
* @test
* @bug 5102289
* @bug 5102289
* @summary Stress test for ResourceBundle.getBundle with ResourceBundle.Control.
* @summary Stress test for ResourceBundle.getBundle with ResourceBundle.Control.
* @run main/
timeout=300/othervm -esa StressTest
* @run main/
othervm -esa StressTest 2 15
*/
*/
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.atomic.*
;
import
java.util.concurrent.atomic.*
;
// Usage: java StressTest [threadsFactor [duration]]
public
class
StressTest
{
public
class
StressTest
{
static
final
Locale
ROOT_LOCALE
=
new
Locale
(
""
);
static
final
Locale
ROOT_LOCALE
=
new
Locale
(
""
);
static
final
Random
rand
=
new
Random
();
static
final
Random
rand
=
new
Random
();
...
@@ -60,16 +61,16 @@ public class StressTest {
...
@@ -60,16 +61,16 @@ public class StressTest {
static
volatile
boolean
runrun
=
true
;
static
volatile
boolean
runrun
=
true
;
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
int
nThreads
=
2
;
int
threadsFactor
=
2
;
if
(
args
.
length
>
0
)
{
if
(
args
.
length
>
0
)
{
nThreads
=
Math
.
max
(
Integer
.
parseInt
(
args
[
0
]),
2
);
threadsFactor
=
Math
.
max
(
2
,
Integer
.
parseInt
(
args
[
0
])
);
}
}
int
nSeconds
=
180
;
int
duration
=
180
;
if
(
args
.
length
>
1
)
{
if
(
args
.
length
>
1
)
{
nSeconds
=
Integer
.
parseInt
(
args
[
1
]
);
duration
=
Math
.
max
(
5
,
Integer
.
parseInt
(
args
[
1
])
);
}
}
Locale
.
setDefault
(
Locale
.
US
);
Locale
.
setDefault
(
Locale
.
US
);
Thread
[]
tasks
=
new
Thread
[
locales
.
length
*
nThreads
];
Thread
[]
tasks
=
new
Thread
[
locales
.
length
*
threadsFactor
];
counters
=
new
AtomicIntegerArray
(
tasks
.
length
);
counters
=
new
AtomicIntegerArray
(
tasks
.
length
);
for
(
int
i
=
0
;
i
<
tasks
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
tasks
.
length
;
i
++)
{
...
@@ -84,8 +85,8 @@ public class StressTest {
...
@@ -84,8 +85,8 @@ public class StressTest {
System
.
out
.
printf
(
"%d processors, intervalForCounterCheck = %d [sec]%n"
,
System
.
out
.
printf
(
"%d processors, intervalForCounterCheck = %d [sec]%n"
,
nProcessors
,
intervalForCounterCheck
);
nProcessors
,
intervalForCounterCheck
);
try
{
try
{
for
(
int
i
=
0
;
runrun
&&
i
<
nSeconds
;
i
++)
{
for
(
int
i
=
0
;
runrun
&&
i
<
duration
;
i
++)
{
Thread
.
sleep
(
1000
);
// 1 second
s
Thread
.
sleep
(
1000
);
// 1 second
if
((
i
%
intervalForCounterCheck
)
==
0
)
{
if
((
i
%
intervalForCounterCheck
)
==
0
)
{
checkCounters
();
checkCounters
();
}
}
...
...
test/javax/swing/JComponent/6989617/bug6989617.java
浏览文件 @
421115af
...
@@ -59,9 +59,7 @@ public class bug6989617 {
...
@@ -59,9 +59,7 @@ public class bug6989617 {
toolkit
.
realSync
();
toolkit
.
realSync
();
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
public
void
run
()
{
if
(
panel
.
getPaintRectangle
()
!=
null
)
{
panel
.
resetPaintRectangle
();
throw
new
RuntimeException
(
"paint rectangle is not null"
);
}
button
.
repaint
();
button
.
repaint
();
}
}
});
});
...
...
test/javax/swing/
text/GlyphView/6539700/bug6539700
.java
→
test/javax/swing/
JLabel/6596966/bug6596966
.java
浏览文件 @
421115af
/*
/*
* Copyright (c) 20
09
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 20
11
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -21,94 +21,75 @@
...
@@ -21,94 +21,75 @@
* questions.
* questions.
*/
*/
/*
/* @test
* @test
@bug 6596966
* @bug 6539700
@summary Some JFileChooser mnemonics do not work with sticky keys
* @summary test that the long space-less lines are correctly soft-wrapped
* @library ../../regtesthelpers
* @author Sergey Groznyh
* @build Util
* @run main bug6539700
@run main bug6596966
*/
@author Pavel Porvatov
*/
import
javax.swing.JEditorPane
;
import
javax.swing.JFrame
;
import
javax.swing.SwingUtilities
;
import
javax.swing.text.ParagraphView
;
import
javax.swing.text.View
;
public
class
bug6539700
{
static
JFrame
f
;
static
JEditorPane
ep
;
static
String
text
=
"AAAAAAAA<b>AAAAAA</b>AAAAAAAA<b>AAAAAAAAA</b>"
+
"AA<b>AAA</b>AAAAAAAAA"
;
static
int
size
=
100
;
static
Class
rowClass
=
null
;
static
void
createContentPane
()
{
ep
=
new
JEditorPane
();
ep
.
setContentType
(
"text/html"
);
ep
.
setEditable
(
false
);
ep
.
setText
(
text
);
f
=
new
JFrame
();
f
.
setSize
(
size
,
2
*
size
);
f
.
add
(
ep
);
f
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
f
.
setVisible
(
true
);
}
static
void
checkRows
(
View
v
,
boolean
last
)
{
import
javax.swing.*
;
int
width
=
(
int
)
v
.
getPreferredSpan
(
View
.
X_AXIS
);
import
java.awt.*
;
import
java.awt.event.KeyEvent
;
if
(
v
.
getClass
()
==
rowClass
)
{
public
class
bug6596966
{
// Row width shouldn't exceed the container width
private
static
JFrame
frame
;
if
(
width
>
size
)
{
throw
new
RuntimeException
(
"too long row: "
+
width
);
}
// Row shouldn't be too short (except for the last one)
private
static
JLabel
label
;
if
(!
last
)
{
private
static
JButton
button
;
if
(
width
<
size
*
2
/
3
)
{
private
static
JComboBox
comboBox
;
throw
new
RuntimeException
(
"too short row: "
+
width
);
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
}
Robot
robot
=
new
Robot
();
}
int
n
=
v
.
getViewCount
();
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
if
(
n
>
0
)
{
public
void
run
()
{
for
(
int
i
=
0
;
i
<
n
;
i
++)
{
button
=
new
JButton
(
"Button"
);
View
c
=
v
.
getView
(
i
);
comboBox
=
new
JComboBox
();
checkRows
(
c
,
i
==
n
-
1
);
label
=
new
JLabel
(
"Label"
);
label
.
setDisplayedMnemonic
(
'L'
);
label
.
setLabelFor
(
comboBox
);
JPanel
pnContent
=
new
JPanel
();
pnContent
.
add
(
button
);
pnContent
.
add
(
label
);
pnContent
.
add
(
comboBox
);
frame
=
new
JFrame
();
frame
.
add
(
pnContent
);
frame
.
pack
();
frame
.
setVisible
(
true
);
}
}
}
});
}
Util
.
blockTillDisplayed
(
frame
);
robot
.
keyPress
(
KeyEvent
.
VK_ALT
);
robot
.
keyPress
(
KeyEvent
.
VK_L
);
robot
.
waitForIdle
();
Toolkit
.
getDefaultToolkit
().
getSystemEventQueue
().
postEvent
(
new
KeyEvent
(
label
,
KeyEvent
.
KEY_RELEASED
,
EventQueue
.
getMostRecentEventTime
(),
0
,
KeyEvent
.
VK_L
,
'L'
));
robot
.
waitForIdle
();
public
static
void
main
(
String
[]
argv
)
{
try
{
try
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
public
void
run
()
{
createContentPane
();
if
(!
comboBox
.
isFocusOwner
())
{
throw
new
RuntimeException
(
"comboBox isn't focus owner"
);
}
}
}
});
});
}
catch
(
Exception
ex
)
{
}
finally
{
throw
new
RuntimeException
(
ex
);
robot
.
keyRelease
(
KeyEvent
.
VK_ALT
);
}
}
Class
[]
pvchildren
=
ParagraphView
.
class
.
getDeclaredClasses
();
for
(
Class
c
:
pvchildren
)
{
if
(
c
.
getName
().
equals
(
"javax.swing.text.ParagraphView$Row"
))
{
rowClass
=
c
;
break
;
}
}
if
(
rowClass
==
null
)
{
throw
new
RuntimeException
(
"can't find ParagraphView.Row class"
);
}
SwingUtilities
.
invokeLater
(
new
Runnable
()
{
public
void
run
()
{
checkRows
(
ep
.
getUI
().
getRootView
(
ep
),
true
);
}
});
System
.
out
.
println
(
"OK"
);
}
}
}
}
test/javax/swing/JLabel/7004134/bug7004134.java
浏览文件 @
421115af
...
@@ -52,7 +52,13 @@ public class bug7004134 {
...
@@ -52,7 +52,13 @@ public class bug7004134 {
frame
.
add
(
label
);
frame
.
add
(
label
);
frame
.
pack
();
frame
.
pack
();
frame
.
setVisible
(
true
);
frame
.
setVisible
(
true
);
}
});
((
SunToolkit
)
SunToolkit
.
getDefaultToolkit
()).
realSync
();
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
ToolTipManager
toolTipManager
=
ToolTipManager
.
sharedInstance
();
ToolTipManager
toolTipManager
=
ToolTipManager
.
sharedInstance
();
toolTipManager
.
setInitialDelay
(
0
);
toolTipManager
.
setInitialDelay
(
0
);
...
@@ -83,7 +89,13 @@ public class bug7004134 {
...
@@ -83,7 +89,13 @@ public class bug7004134 {
frame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
frame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
frame
.
pack
();
frame
.
pack
();
frame
.
setVisible
(
true
);
frame
.
setVisible
(
true
);
}
});
((
SunToolkit
)
SunToolkit
.
getDefaultToolkit
()).
realSync
();
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
ToolTipManager
toolTipManager
=
ToolTipManager
.
sharedInstance
();
ToolTipManager
toolTipManager
=
ToolTipManager
.
sharedInstance
();
toolTipManager
.
setInitialDelay
(
0
);
toolTipManager
.
setInitialDelay
(
0
);
...
...
test/javax/swing/JMenuItem/7036148/bug7036148.java
0 → 100644
浏览文件 @
421115af
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7036148
* @summary NullPointerException with null JMenu name
* @author Alexander Potochkin
* @run main bug7036148
*/
import
javax.swing.*
;
import
java.awt.event.ActionEvent
;
public
class
bug7036148
extends
JFrame
{
public
bug7036148
()
{
JMenuBar
bar
=
new
JMenuBar
();
Action
menuAction
=
new
AbstractAction
(
null
,
null
){
public
void
actionPerformed
(
ActionEvent
e
)
{
}
};
JMenu
menu
=
new
JMenu
(
menuAction
);
menu
.
add
(
new
JMenuItem
(
"test"
));
bar
.
add
(
menu
);
setJMenuBar
(
bar
);
pack
();
}
public
static
void
main
(
String
[]
args
)
{
new
bug7036148
();
}
}
test/javax/swing/border/Test7034614.java
0 → 100644
浏览文件 @
421115af
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 7034614
* @summary Tests that TitledBorder does not modify Insets
* @author Sergey Malenkov
*/
import
java.awt.Component
;
import
java.awt.Graphics
;
import
java.awt.Insets
;
import
java.awt.image.BufferedImage
;
import
javax.swing.border.Border
;
import
javax.swing.border.TitledBorder
;
public
class
Test7034614
{
public
static
void
main
(
String
[]
args
)
{
Graphics
g
=
new
BufferedImage
(
9
,
9
,
9
).
getGraphics
();
BrokenBorder
broken
=
new
BrokenBorder
();
TitledBorder
titled
=
new
TitledBorder
(
broken
,
broken
.
getClass
().
getName
());
Insets
insets
=
(
Insets
)
broken
.
getBorderInsets
(
broken
).
clone
();
titled
.
getBorderInsets
(
broken
);
broken
.
validate
(
insets
);
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
titled
.
paintBorder
(
broken
,
g
,
0
,
0
,
i
,
i
);
broken
.
validate
(
insets
);
titled
.
getBaseline
(
broken
,
i
,
i
);
broken
.
validate
(
insets
);
}
}
private
static
class
BrokenBorder
extends
Component
implements
Border
{
private
Insets
insets
=
new
Insets
(
1
,
2
,
3
,
4
);
private
void
validate
(
Insets
insets
)
{
if
(!
this
.
insets
.
equals
(
insets
))
{
throw
new
Error
(
"unexpected change"
);
}
}
public
Insets
getBorderInsets
(
Component
c
)
{
return
this
.
insets
;
}
public
boolean
isBorderOpaque
()
{
return
false
;
}
public
void
paintBorder
(
Component
c
,
Graphics
g
,
int
x
,
int
y
,
int
w
,
int
h
)
{
}
}
}
test/javax/swing/plaf/synth/7032791/bug7032791.java
0 → 100644
浏览文件 @
421115af
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* @test
* @bug 7032791
* @author Alexander Potochkin
* @summary TableCellRenderer.getTableCellRendererComponent() doesn't accept null JTable with GTK+ L&F
*/
import
javax.swing.*
;
import
javax.swing.plaf.synth.SynthLookAndFeel
;
import
javax.swing.table.TableCellRenderer
;
public
class
bug7032791
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
UIManager
.
setLookAndFeel
(
new
SynthLookAndFeel
());
Object
value
=
"Test value"
;
JTable
table
=
new
JTable
(
1
,
1
);
TableCellRenderer
renderer
=
table
.
getDefaultRenderer
(
Object
.
class
);
renderer
.
getTableCellRendererComponent
(
null
,
value
,
true
,
true
,
0
,
0
);
System
.
out
.
println
(
"OK"
);
}
}
test/javax/swing/text/CSSBorder/6796710/bug6796710.java
浏览文件 @
421115af
...
@@ -31,6 +31,8 @@
...
@@ -31,6 +31,8 @@
@run main bug6796710
@run main bug6796710
*/
*/
import
sun.awt.SunToolkit
;
import
javax.swing.*
;
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.*
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.BufferedImage
;
...
@@ -91,7 +93,7 @@ public class bug6796710 {
...
@@ -91,7 +93,7 @@ public class bug6796710 {
}
}
});
});
robot
.
waitForIdle
();
((
SunToolkit
)
SunToolkit
.
getDefaultToolkit
()).
realSync
();
BufferedImage
bufferedImage
=
getPnBottomImage
();
BufferedImage
bufferedImage
=
getPnBottomImage
();
...
@@ -101,7 +103,10 @@ public class bug6796710 {
...
@@ -101,7 +103,10 @@ public class bug6796710 {
}
}
});
});
robot
.
waitForIdle
();
((
SunToolkit
)
SunToolkit
.
getDefaultToolkit
()).
realSync
();
// On Linux platforms realSync doesn't guaranties setSize completion
Thread
.
sleep
(
1000
);
if
(!
Util
.
compareBufferedImages
(
bufferedImage
,
getPnBottomImage
()))
{
if
(!
Util
.
compareBufferedImages
(
bufferedImage
,
getPnBottomImage
()))
{
throw
new
RuntimeException
(
"The test failed"
);
throw
new
RuntimeException
(
"The test failed"
);
...
...
test/javax/swing/text/html/parser/Parser/7003777/bug7003777.java
0 → 100644
浏览文件 @
421115af
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
@bug 7003777
@summary Nonexistent html entities not parsed properly.
@author Pavel Porvatov
*/
import
javax.swing.*
;
import
javax.swing.text.BadLocationException
;
public
class
bug7003777
{
private
static
final
String
[]
TEST_STRINGS
=
{
"&a"
,
"&aa"
,
"&a;"
,
"&aa;"
,
};
public
static
void
main
(
String
[]
args
)
throws
Exception
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
JTextPane
pane
=
new
JTextPane
();
pane
.
setContentType
(
"text/html"
);
for
(
String
testString
:
TEST_STRINGS
)
{
pane
.
setText
(
testString
);
String
parsedText
;
try
{
parsedText
=
pane
.
getDocument
().
getText
(
0
,
pane
.
getDocument
().
getLength
());
}
catch
(
BadLocationException
e
)
{
throw
new
RuntimeException
(
"The test failed."
,
e
);
}
if
(
parsedText
.
charAt
(
0
)
!=
'\n'
)
{
throw
new
RuntimeException
(
"The first char should be \\n"
);
}
parsedText
=
parsedText
.
substring
(
1
);
if
(!
testString
.
equals
(
parsedText
))
{
throw
new
RuntimeException
(
"The '"
+
testString
+
"' string wasn't parsed correctly. Parsed value is '"
+
parsedText
+
"'"
);
}
}
}
});
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录