Merge
This commit is contained in:
commit
494f86c1f7
.hgtags-top-repo
common/autoconf
corba
hotspot
jaxp
.hgtags
src/java.xml/share/classes
com/sun/org/apache
xalan/internal/xsltc
compiler
trax
xerces/internal
dom
impl
PropertyManager.javaXML11EntityScanner.javaXMLDTDScannerImpl.javaXMLDocumentFragmentScannerImpl.javaXMLDocumentScannerImpl.javaXMLEntityManager.javaXMLEntityScanner.javaXMLScanner.java
xs
jaxp/validation
parsers
xml/internal
jdk/xml/internal
test
jdk
.hgtags
make
copy
launcher
lib
src
java.base/share
classes
java
io
lang
net
security
time
util
jdk/internal/loader
sun
lib/security
java.desktop
macosx
classes
com/apple/laf
sun
native/libawt_lwawt/awt
share/classes/com/sun
beans
imageio/plugins/tiff
java/swing
@ -388,3 +388,4 @@ f64afae7f1a5608e438585bbf0bc23785e69cba0 jdk-9+141
|
||||
1fc62b1c629fb80fdaa639d3b59452a184f0d705 jdk-9+143
|
||||
8d337fd6333e28c48aa87880144b840aad82baaf jdk-9+144
|
||||
ff98aa9ec9fae991e426ce5926fc9036d25f5562 jdk-9+145
|
||||
a22e2671d88f6b22a4aa82e3966986542ed2a381 jdk-9+146
|
||||
|
@ -1048,7 +1048,9 @@ AC_DEFUN_ONCE([BASIC_SETUP_COMPLEX_TOOLS],
|
||||
# These tools might not be installed by default,
|
||||
# need hint on how to install them.
|
||||
BASIC_REQUIRE_PROGS(UNZIP, unzip)
|
||||
BASIC_REQUIRE_PROGS(ZIP, zip)
|
||||
# Since zip uses "ZIP" as a environment variable for passing options, we need
|
||||
# to name our variable differently, hence ZIPEXE.
|
||||
BASIC_REQUIRE_PROGS(ZIPEXE, zip)
|
||||
|
||||
# Non-required basic tools
|
||||
|
||||
|
@ -311,7 +311,11 @@ AC_DEFUN([FLAGS_SETUP_COMPILER_FLAGS_FOR_LIBS],
|
||||
SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=[$]1'
|
||||
fi
|
||||
elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
|
||||
PICFLAG="-KPIC"
|
||||
if test "x$OPENJDK_TARGET_CPU" = xsparcv9; then
|
||||
PICFLAG="-xcode=pic32"
|
||||
else
|
||||
PICFLAG="-KPIC"
|
||||
fi
|
||||
C_FLAG_REORDER='-xF'
|
||||
CXX_FLAG_REORDER='-xF'
|
||||
SHARED_LIBRARY_FLAGS="-G"
|
||||
@ -838,7 +842,6 @@ AC_DEFUN([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK_HELPER],
|
||||
fastdebug | slowdebug )
|
||||
$2CFLAGS_JDK="[$]$2CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS $CFLAGS_DEBUG_OPTIONS"
|
||||
$2CXXFLAGS_JDK="[$]$2CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS $CXXFLAGS_DEBUG_OPTIONS"
|
||||
JAVAC_FLAGS="$JAVAC_FLAGS -g"
|
||||
;;
|
||||
release )
|
||||
;;
|
||||
@ -894,12 +897,12 @@ AC_DEFUN([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK_HELPER],
|
||||
# Set some additional per-OS defines.
|
||||
if test "x$OPENJDK_$1_OS" = xlinux; then
|
||||
$2JVM_CFLAGS="[$]$2JVM_CFLAGS -DLINUX"
|
||||
$2JVM_CFLAGS="[$]$2JVM_CFLAGS -pipe -fPIC -fno-rtti -fno-exceptions \
|
||||
$2JVM_CFLAGS="[$]$2JVM_CFLAGS -pipe $PICFLAG -fno-rtti -fno-exceptions \
|
||||
-fvisibility=hidden -fno-strict-aliasing -fno-omit-frame-pointer"
|
||||
elif test "x$OPENJDK_$1_OS" = xsolaris; then
|
||||
$2JVM_CFLAGS="[$]$2JVM_CFLAGS -DSOLARIS"
|
||||
$2JVM_CFLAGS="[$]$2JVM_CFLAGS -template=no%extdef -features=no%split_init \
|
||||
-D_Crun_inline_placement -library=%none -KPIC -mt -features=no%except"
|
||||
-D_Crun_inline_placement -library=%none $PICFLAG -mt -features=no%except"
|
||||
elif test "x$OPENJDK_$1_OS" = xmacosx; then
|
||||
$2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
|
||||
$2JVM_CFLAGS="[$]$2JVM_CFLAGS -D_ALLBSD_SOURCE"
|
||||
@ -1310,7 +1313,7 @@ BASIC_DEFUN_NAMED([FLAGS_COMPILER_CHECK_ARGUMENTS],
|
||||
AC_MSG_CHECKING([if both compilers support "ARG_ARGUMENT"])
|
||||
supports=no
|
||||
if test "x$C_COMP_SUPPORTS" = "xyes" -a "x$CXX_COMP_SUPPORTS" = "xyes"; then supports=yes; fi
|
||||
|
||||
|
||||
AC_MSG_RESULT([$supports])
|
||||
if test "x$supports" = "xyes" ; then
|
||||
:
|
||||
|
@ -945,7 +945,7 @@ HG
|
||||
READELF
|
||||
OTOOL
|
||||
LDD
|
||||
ZIP
|
||||
ZIPEXE
|
||||
UNZIP
|
||||
TAR_SUPPORTS_TRANSFORM
|
||||
TAR_INCLUDE_PARAM
|
||||
@ -1292,7 +1292,7 @@ CPIO
|
||||
NICE
|
||||
MAKE
|
||||
UNZIP
|
||||
ZIP
|
||||
ZIPEXE
|
||||
LDD
|
||||
OTOOL
|
||||
READELF
|
||||
@ -2236,7 +2236,7 @@ Some influential environment variables:
|
||||
NICE Override default value for NICE
|
||||
MAKE Override default value for MAKE
|
||||
UNZIP Override default value for UNZIP
|
||||
ZIP Override default value for ZIP
|
||||
ZIPEXE Override default value for ZIPEXE
|
||||
LDD Override default value for LDD
|
||||
OTOOL Override default value for OTOOL
|
||||
READELF Override default value for READELF
|
||||
@ -5093,7 +5093,7 @@ VS_SDK_PLATFORM_NAME_2013=
|
||||
#CUSTOM_AUTOCONF_INCLUDE
|
||||
|
||||
# Do not change or remove the following line, it is needed for consistency checks:
|
||||
DATE_WHEN_GENERATED=1479120453
|
||||
DATE_WHEN_GENERATED=1479997904
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
@ -21373,13 +21373,15 @@ $as_echo "$tool_specified" >&6; }
|
||||
fi
|
||||
|
||||
|
||||
# Since zip uses "ZIP" as a environment variable for passing options, we need
|
||||
# to name our variable differently, hence ZIPEXE.
|
||||
|
||||
|
||||
|
||||
# Publish this variable in the help.
|
||||
|
||||
|
||||
if [ -z "${ZIP+x}" ]; then
|
||||
if [ -z "${ZIPEXE+x}" ]; then
|
||||
# The variable is not set by user, try to locate tool using the code snippet
|
||||
for ac_prog in zip
|
||||
do
|
||||
@ -21387,12 +21389,12 @@ do
|
||||
set dummy $ac_prog; ac_word=$2
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
|
||||
$as_echo_n "checking for $ac_word... " >&6; }
|
||||
if ${ac_cv_path_ZIP+:} false; then :
|
||||
if ${ac_cv_path_ZIPEXE+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
case $ZIP in
|
||||
case $ZIPEXE in
|
||||
[\\/]* | ?:[\\/]*)
|
||||
ac_cv_path_ZIP="$ZIP" # Let the user override the test with a path.
|
||||
ac_cv_path_ZIPEXE="$ZIPEXE" # Let the user override the test with a path.
|
||||
;;
|
||||
*)
|
||||
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
||||
@ -21402,7 +21404,7 @@ do
|
||||
test -z "$as_dir" && as_dir=.
|
||||
for ac_exec_ext in '' $ac_executable_extensions; do
|
||||
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
|
||||
ac_cv_path_ZIP="$as_dir/$ac_word$ac_exec_ext"
|
||||
ac_cv_path_ZIPEXE="$as_dir/$ac_word$ac_exec_ext"
|
||||
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
|
||||
break 2
|
||||
fi
|
||||
@ -21413,30 +21415,30 @@ IFS=$as_save_IFS
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
ZIP=$ac_cv_path_ZIP
|
||||
if test -n "$ZIP"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ZIP" >&5
|
||||
$as_echo "$ZIP" >&6; }
|
||||
ZIPEXE=$ac_cv_path_ZIPEXE
|
||||
if test -n "$ZIPEXE"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ZIPEXE" >&5
|
||||
$as_echo "$ZIPEXE" >&6; }
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
|
||||
test -n "$ZIP" && break
|
||||
test -n "$ZIPEXE" && break
|
||||
done
|
||||
|
||||
else
|
||||
# The variable is set, but is it from the command line or the environment?
|
||||
|
||||
# Try to remove the string !ZIP! from our list.
|
||||
try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!ZIP!/}
|
||||
# Try to remove the string !ZIPEXE! from our list.
|
||||
try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!ZIPEXE!/}
|
||||
if test "x$try_remove_var" = "x$CONFIGURE_OVERRIDDEN_VARIABLES"; then
|
||||
# If it failed, the variable was not from the command line. Ignore it,
|
||||
# but warn the user (except for BASH, which is always set by the calling BASH).
|
||||
if test "xZIP" != xBASH; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of ZIP from the environment. Use command line variables instead." >&5
|
||||
$as_echo "$as_me: WARNING: Ignoring value of ZIP from the environment. Use command line variables instead." >&2;}
|
||||
if test "xZIPEXE" != xBASH; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of ZIPEXE from the environment. Use command line variables instead." >&5
|
||||
$as_echo "$as_me: WARNING: Ignoring value of ZIPEXE from the environment. Use command line variables instead." >&2;}
|
||||
fi
|
||||
# Try to locate tool using the code snippet
|
||||
for ac_prog in zip
|
||||
@ -21445,12 +21447,12 @@ do
|
||||
set dummy $ac_prog; ac_word=$2
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
|
||||
$as_echo_n "checking for $ac_word... " >&6; }
|
||||
if ${ac_cv_path_ZIP+:} false; then :
|
||||
if ${ac_cv_path_ZIPEXE+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
case $ZIP in
|
||||
case $ZIPEXE in
|
||||
[\\/]* | ?:[\\/]*)
|
||||
ac_cv_path_ZIP="$ZIP" # Let the user override the test with a path.
|
||||
ac_cv_path_ZIPEXE="$ZIPEXE" # Let the user override the test with a path.
|
||||
;;
|
||||
*)
|
||||
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
||||
@ -21460,7 +21462,7 @@ do
|
||||
test -z "$as_dir" && as_dir=.
|
||||
for ac_exec_ext in '' $ac_executable_extensions; do
|
||||
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
|
||||
ac_cv_path_ZIP="$as_dir/$ac_word$ac_exec_ext"
|
||||
ac_cv_path_ZIPEXE="$as_dir/$ac_word$ac_exec_ext"
|
||||
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
|
||||
break 2
|
||||
fi
|
||||
@ -21471,17 +21473,17 @@ IFS=$as_save_IFS
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
ZIP=$ac_cv_path_ZIP
|
||||
if test -n "$ZIP"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ZIP" >&5
|
||||
$as_echo "$ZIP" >&6; }
|
||||
ZIPEXE=$ac_cv_path_ZIPEXE
|
||||
if test -n "$ZIPEXE"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ZIPEXE" >&5
|
||||
$as_echo "$ZIPEXE" >&6; }
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
|
||||
test -n "$ZIP" && break
|
||||
test -n "$ZIPEXE" && break
|
||||
done
|
||||
|
||||
else
|
||||
@ -21493,31 +21495,31 @@ done
|
||||
CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var"
|
||||
|
||||
# Check if we try to supply an empty value
|
||||
if test "x$ZIP" = x; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: Setting user supplied tool ZIP= (no value)" >&5
|
||||
$as_echo "$as_me: Setting user supplied tool ZIP= (no value)" >&6;}
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ZIP" >&5
|
||||
$as_echo_n "checking for ZIP... " >&6; }
|
||||
if test "x$ZIPEXE" = x; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: Setting user supplied tool ZIPEXE= (no value)" >&5
|
||||
$as_echo "$as_me: Setting user supplied tool ZIPEXE= (no value)" >&6;}
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ZIPEXE" >&5
|
||||
$as_echo_n "checking for ZIPEXE... " >&6; }
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5
|
||||
$as_echo "disabled" >&6; }
|
||||
else
|
||||
# Check if the provided tool contains a complete path.
|
||||
tool_specified="$ZIP"
|
||||
tool_specified="$ZIPEXE"
|
||||
tool_basename="${tool_specified##*/}"
|
||||
if test "x$tool_basename" = "x$tool_specified"; then
|
||||
# A command without a complete path is provided, search $PATH.
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: Will search for user supplied tool ZIP=$tool_basename" >&5
|
||||
$as_echo "$as_me: Will search for user supplied tool ZIP=$tool_basename" >&6;}
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: Will search for user supplied tool ZIPEXE=$tool_basename" >&5
|
||||
$as_echo "$as_me: Will search for user supplied tool ZIPEXE=$tool_basename" >&6;}
|
||||
# Extract the first word of "$tool_basename", so it can be a program name with args.
|
||||
set dummy $tool_basename; ac_word=$2
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
|
||||
$as_echo_n "checking for $ac_word... " >&6; }
|
||||
if ${ac_cv_path_ZIP+:} false; then :
|
||||
if ${ac_cv_path_ZIPEXE+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
case $ZIP in
|
||||
case $ZIPEXE in
|
||||
[\\/]* | ?:[\\/]*)
|
||||
ac_cv_path_ZIP="$ZIP" # Let the user override the test with a path.
|
||||
ac_cv_path_ZIPEXE="$ZIPEXE" # Let the user override the test with a path.
|
||||
;;
|
||||
*)
|
||||
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
||||
@ -21527,7 +21529,7 @@ do
|
||||
test -z "$as_dir" && as_dir=.
|
||||
for ac_exec_ext in '' $ac_executable_extensions; do
|
||||
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
|
||||
ac_cv_path_ZIP="$as_dir/$ac_word$ac_exec_ext"
|
||||
ac_cv_path_ZIPEXE="$as_dir/$ac_word$ac_exec_ext"
|
||||
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
|
||||
break 2
|
||||
fi
|
||||
@ -21538,29 +21540,29 @@ IFS=$as_save_IFS
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
ZIP=$ac_cv_path_ZIP
|
||||
if test -n "$ZIP"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ZIP" >&5
|
||||
$as_echo "$ZIP" >&6; }
|
||||
ZIPEXE=$ac_cv_path_ZIPEXE
|
||||
if test -n "$ZIPEXE"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ZIPEXE" >&5
|
||||
$as_echo "$ZIPEXE" >&6; }
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
|
||||
if test "x$ZIP" = x; then
|
||||
if test "x$ZIPEXE" = x; then
|
||||
as_fn_error $? "User supplied tool $tool_basename could not be found" "$LINENO" 5
|
||||
fi
|
||||
else
|
||||
# Otherwise we believe it is a complete path. Use it as it is.
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: Will use user supplied tool ZIP=$tool_specified" >&5
|
||||
$as_echo "$as_me: Will use user supplied tool ZIP=$tool_specified" >&6;}
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ZIP" >&5
|
||||
$as_echo_n "checking for ZIP... " >&6; }
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: Will use user supplied tool ZIPEXE=$tool_specified" >&5
|
||||
$as_echo "$as_me: Will use user supplied tool ZIPEXE=$tool_specified" >&6;}
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ZIPEXE" >&5
|
||||
$as_echo_n "checking for ZIPEXE... " >&6; }
|
||||
if test ! -x "$tool_specified"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
|
||||
$as_echo "not found" >&6; }
|
||||
as_fn_error $? "User supplied tool ZIP=$tool_specified does not exist or is not executable" "$LINENO" 5
|
||||
as_fn_error $? "User supplied tool ZIPEXE=$tool_specified does not exist or is not executable" "$LINENO" 5
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tool_specified" >&5
|
||||
$as_echo "$tool_specified" >&6; }
|
||||
@ -21572,8 +21574,8 @@ $as_echo "$tool_specified" >&6; }
|
||||
|
||||
|
||||
|
||||
if test "x$ZIP" = x; then
|
||||
as_fn_error $? "Could not find required tool for ZIP" "$LINENO" 5
|
||||
if test "x$ZIPEXE" = x; then
|
||||
as_fn_error $? "Could not find required tool for ZIPEXE" "$LINENO" 5
|
||||
fi
|
||||
|
||||
|
||||
@ -49101,7 +49103,11 @@ $as_echo "$ac_cv_c_bigendian" >&6; }
|
||||
SET_SHARED_LIBRARY_MAPFILE='-Wl,-version-script=$1'
|
||||
fi
|
||||
elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
|
||||
PICFLAG="-KPIC"
|
||||
if test "x$OPENJDK_TARGET_CPU" = xsparcv9; then
|
||||
PICFLAG="-xcode=pic32"
|
||||
else
|
||||
PICFLAG="-KPIC"
|
||||
fi
|
||||
C_FLAG_REORDER='-xF'
|
||||
CXX_FLAG_REORDER='-xF'
|
||||
SHARED_LIBRARY_FLAGS="-G"
|
||||
@ -50020,7 +50026,6 @@ $as_echo "$as_me: GCC >= 6 detected; adding ${NO_DELETE_NULL_POINTER_CHECKS_CFLA
|
||||
fastdebug | slowdebug )
|
||||
CFLAGS_JDK="$CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS $CFLAGS_DEBUG_OPTIONS"
|
||||
CXXFLAGS_JDK="$CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS $CXXFLAGS_DEBUG_OPTIONS"
|
||||
JAVAC_FLAGS="$JAVAC_FLAGS -g"
|
||||
;;
|
||||
release )
|
||||
;;
|
||||
@ -50076,12 +50081,12 @@ $as_echo "$as_me: GCC >= 6 detected; adding ${NO_DELETE_NULL_POINTER_CHECKS_CFLA
|
||||
# Set some additional per-OS defines.
|
||||
if test "x$OPENJDK_TARGET_OS" = xlinux; then
|
||||
JVM_CFLAGS="$JVM_CFLAGS -DLINUX"
|
||||
JVM_CFLAGS="$JVM_CFLAGS -pipe -fPIC -fno-rtti -fno-exceptions \
|
||||
JVM_CFLAGS="$JVM_CFLAGS -pipe $PICFLAG -fno-rtti -fno-exceptions \
|
||||
-fvisibility=hidden -fno-strict-aliasing -fno-omit-frame-pointer"
|
||||
elif test "x$OPENJDK_TARGET_OS" = xsolaris; then
|
||||
JVM_CFLAGS="$JVM_CFLAGS -DSOLARIS"
|
||||
JVM_CFLAGS="$JVM_CFLAGS -template=no%extdef -features=no%split_init \
|
||||
-D_Crun_inline_placement -library=%none -KPIC -mt -features=no%except"
|
||||
-D_Crun_inline_placement -library=%none $PICFLAG -mt -features=no%except"
|
||||
elif test "x$OPENJDK_TARGET_OS" = xmacosx; then
|
||||
COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
|
||||
JVM_CFLAGS="$JVM_CFLAGS -D_ALLBSD_SOURCE"
|
||||
@ -50844,7 +50849,6 @@ $as_echo "$as_me: GCC >= 6 detected; adding ${NO_DELETE_NULL_POINTER_CHECKS_CFLA
|
||||
fastdebug | slowdebug )
|
||||
OPENJDK_BUILD_CFLAGS_JDK="$OPENJDK_BUILD_CFLAGS_JDK $CFLAGS_DEBUG_SYMBOLS $CFLAGS_DEBUG_OPTIONS"
|
||||
OPENJDK_BUILD_CXXFLAGS_JDK="$OPENJDK_BUILD_CXXFLAGS_JDK $CXXFLAGS_DEBUG_SYMBOLS $CXXFLAGS_DEBUG_OPTIONS"
|
||||
JAVAC_FLAGS="$JAVAC_FLAGS -g"
|
||||
;;
|
||||
release )
|
||||
;;
|
||||
@ -50900,12 +50904,12 @@ $as_echo "$as_me: GCC >= 6 detected; adding ${NO_DELETE_NULL_POINTER_CHECKS_CFLA
|
||||
# Set some additional per-OS defines.
|
||||
if test "x$OPENJDK_BUILD_OS" = xlinux; then
|
||||
OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -DLINUX"
|
||||
OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -pipe -fPIC -fno-rtti -fno-exceptions \
|
||||
OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -pipe $PICFLAG -fno-rtti -fno-exceptions \
|
||||
-fvisibility=hidden -fno-strict-aliasing -fno-omit-frame-pointer"
|
||||
elif test "x$OPENJDK_BUILD_OS" = xsolaris; then
|
||||
OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -DSOLARIS"
|
||||
OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -template=no%extdef -features=no%split_init \
|
||||
-D_Crun_inline_placement -library=%none -KPIC -mt -features=no%except"
|
||||
-D_Crun_inline_placement -library=%none $PICFLAG -mt -features=no%except"
|
||||
elif test "x$OPENJDK_BUILD_OS" = xmacosx; then
|
||||
OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK="$OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK -D_ALLBSD_SOURCE -D_DARWIN_UNLIMITED_SELECT"
|
||||
OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -D_ALLBSD_SOURCE"
|
||||
|
@ -657,8 +657,7 @@ TOUCH:=@TOUCH@
|
||||
UNIQ:=@UNIQ@
|
||||
WC:=@WC@
|
||||
XARGS:=@XARGS@
|
||||
ZIPEXE:=@ZIP@
|
||||
ZIP:=@ZIP@
|
||||
ZIPEXE:=@ZIPEXE@
|
||||
UNZIP:=@UNZIP@
|
||||
MT:=@FIXPATH@ @MT@
|
||||
RC:=@FIXPATH@ @RC@
|
||||
|
@ -388,3 +388,4 @@ b32f998da32b488ec7c4e9dbb3c750841b48e74d jdk-9+141
|
||||
6211236ef15ec796806357608b1dd1b70c258ece jdk-9+143
|
||||
d4f1dae174098e799c48948e866054c52e11a186 jdk-9+144
|
||||
a44b156ae7f06bf41b9bece30df7775e482395dd jdk-9+145
|
||||
ecd74b41ab65bf228837b5bdf99690638d55425c jdk-9+146
|
||||
|
@ -548,3 +548,4 @@ fec31089c2ef5a12dd64f401b0bf2e00f56ee0d0 jdk-9+140
|
||||
d87d5d430c42342f0320ca7f5cbe0cbd1f9d62ba jdk-9+143
|
||||
6187b582d02aee38341dc8ce4011906e9b364e9f jdk-9+144
|
||||
61e7ea56312351657e69198c503a6f7bf865af83 jdk-9+145
|
||||
a82cb5350cad96a0b4de496afebe3ded89f27efa jdk-9+146
|
||||
|
@ -130,8 +130,6 @@ $(JVMTI_OUTPUTDIR)/jvmtiEnvRecommended.cpp: $(JVMTI_SRCDIR)/jvmtiEnv.cpp \
|
||||
TARGETS += $(JVMTI_OUTPUTDIR)/jvmtiEnvRecommended.cpp
|
||||
|
||||
################################################################################
|
||||
# Disable copy of jvmti.h from hotspot until this has been cleared up. The file
|
||||
# is currently being copied from the jdk repository. See JDK-8167078.
|
||||
# Copy jvmti.h to include dir
|
||||
|
||||
# The file is the same regardless of jvm variant. Only let one do the copy.
|
||||
|
@ -129,7 +129,7 @@ ifneq ($(OPENJDK_TARGET_OS), windows)
|
||||
ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
|
||||
$(LIB_OUTPUTDIR)/$1/$(LIBRARY_PREFIX)jsig.diz: \
|
||||
$(LIB_OUTPUTDIR)/$1/$(LIBRARY_PREFIX)jsig$(DEBUG_INFO_SUFFIX)
|
||||
$(CD) $$(@D) && $(ZIP) -q -y $$@ $$(basename $$(@F))$(DEBUG_INFO_SUFFIX)
|
||||
$(CD) $$(@D) && $(ZIPEXE) -q -y $$@ $$(basename $$(@F))$(DEBUG_INFO_SUFFIX)
|
||||
|
||||
TARGETS += $(LIB_OUTPUTDIR)/$1/$(LIBRARY_PREFIX)jsig.diz
|
||||
endif
|
||||
|
@ -50,7 +50,7 @@ TEE = tee
|
||||
UNAME = uname
|
||||
UNIQ = uniq
|
||||
WC = wc
|
||||
ZIP = zip
|
||||
ZIPEXE = zip
|
||||
|
||||
define NEWLINE
|
||||
|
||||
@ -213,7 +213,7 @@ endif
|
||||
ZIP_UP_RESULTS = ( $(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)` \
|
||||
&& $(CD) $(ABS_TEST_OUTPUT_DIR) \
|
||||
&& $(CHMOD) -R a+r . \
|
||||
&& $(ZIP) -q -r $(ARCHIVE_BUNDLE) . )
|
||||
&& $(ZIPEXE) -q -r $(ARCHIVE_BUNDLE) . )
|
||||
|
||||
# important results files
|
||||
SUMMARY_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport/text/summary.txt")
|
||||
@ -327,7 +327,7 @@ ifdef NUM_CORES
|
||||
else ifeq ($(shell expr $(CONCURRENCY) \> 12), 1)
|
||||
CONCURRENCY := 12
|
||||
endif
|
||||
else
|
||||
else
|
||||
CONCURRENCY := 1
|
||||
endif
|
||||
JTREG_BASIC_OPTIONS += -concurrency:$(CONCURRENCY)
|
||||
|
@ -388,3 +388,4 @@ bdafa0cc34a97a2f8db4847a4efd34b407943591 jdk-9+142
|
||||
ce81d03ad7320dca3d673374c1a33bc0efd9136a jdk-9+143
|
||||
99be33734ff62b75116b1202d49a4d4e1bda4226 jdk-9+144
|
||||
71558b38bad786f11350790cef7d2c6409813e91 jdk-9+145
|
||||
09eda28b98e4b9cae1d29e94f0cf1a01cc42c207 jdk-9+146
|
||||
|
@ -530,6 +530,10 @@ public class Parser implements Constants, ContentHandler {
|
||||
XMLSecurityManager.printWarning(reader.getClass().getName(), lastProperty, se);
|
||||
}
|
||||
|
||||
// try setting other JDK-impl properties, ignore if not supported
|
||||
JdkXmlUtils.setXMLReaderPropertyIfSupport(reader, JdkXmlUtils.CDATA_CHUNK_SIZE,
|
||||
_xsltc.getProperty(JdkXmlUtils.CDATA_CHUNK_SIZE), false);
|
||||
|
||||
return(parse(reader, input));
|
||||
}
|
||||
catch (ParserConfigurationException e) {
|
||||
@ -1342,12 +1346,14 @@ public class Parser implements Constants, ContentHandler {
|
||||
}
|
||||
else {
|
||||
SyntaxTreeNode parent = _parentStack.peek();
|
||||
|
||||
if (element.getClass().isAssignableFrom(Import.class) &&
|
||||
parent.notTypeOf(Import.class)) {
|
||||
ErrorMsg err = new ErrorMsg(ErrorMsg.IMPORT_PRECEDE_OTHERS_ERR,
|
||||
prefix+':'+localname);
|
||||
throw new SAXException(err.toString());
|
||||
}
|
||||
|
||||
parent.addElement(element);
|
||||
element.setParent(parent);
|
||||
}
|
||||
|
@ -43,12 +43,14 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Properties;
|
||||
import java.util.Vector;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.jar.Manifest;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.catalog.CatalogFeatures;
|
||||
import jdk.xml.internal.JdkXmlFeatures;
|
||||
import jdk.xml.internal.JdkXmlUtils;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.XMLReader;
|
||||
|
||||
@ -116,8 +118,8 @@ public final class XSLTC {
|
||||
private File _destDir = null; // -d <directory-name>
|
||||
private int _outputType = FILE_OUTPUT; // by default
|
||||
|
||||
private Vector _classes;
|
||||
private Vector _bcelClasses;
|
||||
private ArrayList<ByteArrayOutputStream> _classes;
|
||||
private ArrayList<JavaClass> _bcelClasses;
|
||||
private boolean _callsNodeset = false;
|
||||
private boolean _multiDocument = false;
|
||||
private boolean _hasIdCall = false;
|
||||
@ -160,13 +162,18 @@ public final class XSLTC {
|
||||
/**
|
||||
* HashMap with the loaded classes
|
||||
*/
|
||||
private final Map<String, Class> _externalExtensionFunctions;
|
||||
private final Map<String, Class<?>> _externalExtensionFunctions;
|
||||
|
||||
/**
|
||||
* Catalog features
|
||||
*/
|
||||
CatalogFeatures _catalogFeatures;
|
||||
|
||||
/**
|
||||
* CDATA chunk size
|
||||
*/
|
||||
int _cdataChunkSize;
|
||||
|
||||
/**
|
||||
* XSLTC compiler constructor
|
||||
*/
|
||||
@ -230,6 +237,8 @@ public final class XSLTC {
|
||||
return _extensionClassLoader;
|
||||
} else if (JdkXmlFeatures.CATALOG_FEATURES.equals(name)) {
|
||||
return _catalogFeatures;
|
||||
} else if (JdkXmlUtils.CDATA_CHUNK_SIZE.equals(name)) {
|
||||
return _cdataChunkSize;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -254,6 +263,8 @@ public final class XSLTC {
|
||||
_externalExtensionFunctions.clear();
|
||||
} else if (JdkXmlFeatures.CATALOG_FEATURES.equals(name)) {
|
||||
_catalogFeatures = (CatalogFeatures)value;
|
||||
} else if (JdkXmlUtils.CDATA_CHUNK_SIZE.equals(name)) {
|
||||
_cdataChunkSize = Integer.parseInt((String)value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -284,11 +295,11 @@ public final class XSLTC {
|
||||
public void init() {
|
||||
reset();
|
||||
_reader = null;
|
||||
_classes = new Vector();
|
||||
_bcelClasses = new Vector();
|
||||
_classes = new ArrayList<>();
|
||||
_bcelClasses = new ArrayList<>();
|
||||
}
|
||||
|
||||
private void setExternalExtensionFunctions(String name, Class clazz) {
|
||||
private void setExternalExtensionFunctions(String name, Class<?> clazz) {
|
||||
if (_isSecureProcessing && clazz != null && !_externalExtensionFunctions.containsKey(name)) {
|
||||
_externalExtensionFunctions.put(name, clazz);
|
||||
}
|
||||
@ -319,7 +330,7 @@ public final class XSLTC {
|
||||
* Returns unmodifiable view of HashMap with loaded external extension
|
||||
* functions - will be needed for the TransformerImpl
|
||||
*/
|
||||
public Map<String, Class> getExternalExtensionFunctions() {
|
||||
public Map<String, Class<?>> getExternalExtensionFunctions() {
|
||||
return Collections.unmodifiableMap(_externalExtensionFunctions);
|
||||
}
|
||||
|
||||
@ -563,7 +574,7 @@ public final class XSLTC {
|
||||
final int count = _classes.size();
|
||||
final byte[][] result = new byte[count][1];
|
||||
for (int i = 0; i < count; i++)
|
||||
result[i] = (byte[])_classes.elementAt(i);
|
||||
result[i] = _classes.get(i).toByteArray();
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -907,7 +918,7 @@ public final class XSLTC {
|
||||
getOutputFile(clazz.getClassName()))));
|
||||
break;
|
||||
case JAR_OUTPUT:
|
||||
_bcelClasses.addElement(clazz);
|
||||
_bcelClasses.add(clazz);
|
||||
break;
|
||||
case BYTEARRAY_OUTPUT:
|
||||
case BYTEARRAY_AND_FILE_OUTPUT:
|
||||
@ -915,13 +926,13 @@ public final class XSLTC {
|
||||
case CLASSLOADER_OUTPUT:
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream(2048);
|
||||
clazz.dump(out);
|
||||
_classes.addElement(out.toByteArray());
|
||||
_classes.add(out);
|
||||
|
||||
if (_outputType == BYTEARRAY_AND_FILE_OUTPUT)
|
||||
clazz.dump(new BufferedOutputStream(
|
||||
new FileOutputStream(getOutputFile(clazz.getClassName()))));
|
||||
else if (_outputType == BYTEARRAY_AND_JAR_OUTPUT)
|
||||
_bcelClasses.addElement(clazz);
|
||||
_bcelClasses.add(clazz);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -945,30 +956,24 @@ public final class XSLTC {
|
||||
// create the manifest
|
||||
final Manifest manifest = new Manifest();
|
||||
final java.util.jar.Attributes atrs = manifest.getMainAttributes();
|
||||
atrs.put(java.util.jar.Attributes.Name.MANIFEST_VERSION,"1.2");
|
||||
atrs.put(java.util.jar.Attributes.Name.MANIFEST_VERSION, "1.2");
|
||||
|
||||
final Map map = manifest.getEntries();
|
||||
final Map<String, Attributes> map = manifest.getEntries();
|
||||
// create manifest
|
||||
Enumeration classes = _bcelClasses.elements();
|
||||
final String now = (new Date()).toString();
|
||||
final java.util.jar.Attributes.Name dateAttr =
|
||||
new java.util.jar.Attributes.Name("Date");
|
||||
while (classes.hasMoreElements()) {
|
||||
final JavaClass clazz = (JavaClass)classes.nextElement();
|
||||
final String className = clazz.getClassName().replace('.','/');
|
||||
final java.util.jar.Attributes attr = new java.util.jar.Attributes();
|
||||
attr.put(dateAttr, now);
|
||||
map.put(className+".class", attr);
|
||||
}
|
||||
|
||||
final File jarFile = new File(_destDir, _jarFileName);
|
||||
final JarOutputStream jos =
|
||||
new JarOutputStream(new FileOutputStream(jarFile), manifest);
|
||||
classes = _bcelClasses.elements();
|
||||
while (classes.hasMoreElements()) {
|
||||
final JavaClass clazz = (JavaClass)classes.nextElement();
|
||||
final String className = clazz.getClassName().replace('.','/');
|
||||
jos.putNextEntry(new JarEntry(className+".class"));
|
||||
|
||||
for (JavaClass clazz : _bcelClasses) {
|
||||
final String className = clazz.getClassName().replace('.', '/');
|
||||
final java.util.jar.Attributes attr = new java.util.jar.Attributes();
|
||||
attr.put(dateAttr, now);
|
||||
map.put(className + ".class", attr);
|
||||
jos.putNextEntry(new JarEntry(className + ".class"));
|
||||
final ByteArrayOutputStream out = new ByteArrayOutputStream(2048);
|
||||
clazz.dump(out); // dump() closes it's output stream
|
||||
out.writeTo(jos);
|
||||
|
@ -165,14 +165,14 @@ public final class TemplatesImpl implements Templates, Serializable {
|
||||
};
|
||||
|
||||
static final class TransletClassLoader extends ClassLoader {
|
||||
private final Map<String,Class> _loadedExternalExtensionFunctions;
|
||||
private final Map<String, Class<?>> _loadedExternalExtensionFunctions;
|
||||
|
||||
TransletClassLoader(ClassLoader parent) {
|
||||
super(parent);
|
||||
_loadedExternalExtensionFunctions = null;
|
||||
}
|
||||
|
||||
TransletClassLoader(ClassLoader parent,Map<String, Class> mapEF) {
|
||||
TransletClassLoader(ClassLoader parent, Map<String, Class<?>> mapEF) {
|
||||
super(parent);
|
||||
_loadedExternalExtensionFunctions = mapEF;
|
||||
}
|
||||
@ -215,7 +215,7 @@ public final class TemplatesImpl implements Templates, Serializable {
|
||||
/**
|
||||
* Create an XSLTC template object from the translet class definition(s).
|
||||
*/
|
||||
protected TemplatesImpl(Class[] transletClasses, String transletName,
|
||||
protected TemplatesImpl(Class<?>[] transletClasses, String transletName,
|
||||
Properties outputProperties, int indentNumber,
|
||||
TransformerFactoryImpl tfactory)
|
||||
{
|
||||
@ -481,6 +481,7 @@ public final class TemplatesImpl implements Templates, Serializable {
|
||||
|
||||
// the module needs access to runtime classes
|
||||
Module thisModule = TemplatesImpl.class.getModule();
|
||||
|
||||
Arrays.asList(Constants.PKGS_USED_BY_TRANSLET_CLASSES).forEach(p -> {
|
||||
thisModule.addExports(p, m);
|
||||
});
|
||||
|
@ -222,7 +222,8 @@ public class TransformerFactoryImpl
|
||||
private boolean _useServicesMechanism;
|
||||
|
||||
/**
|
||||
* protocols allowed for external references set by the stylesheet processing instruction, Import and Include element.
|
||||
* protocols allowed for external references set by the stylesheet
|
||||
* processing instruction, Import and Include element.
|
||||
*/
|
||||
private String _accessExternalStylesheet = XalanConstants.EXTERNAL_ACCESS_DEFAULT;
|
||||
/**
|
||||
@ -240,7 +241,7 @@ public class TransformerFactoryImpl
|
||||
// Unmodifiable view of external extension function from xslt compiler
|
||||
// It will be populated by user-specified extension functions during the
|
||||
// type checking
|
||||
private Map<String, Class> _xsltcExtensionFunctions;
|
||||
private Map<String, Class<?>> _xsltcExtensionFunctions;
|
||||
|
||||
CatalogResolver _catalogUriResolver;
|
||||
CatalogFeatures _catalogFeatures;
|
||||
@ -251,6 +252,8 @@ public class TransformerFactoryImpl
|
||||
String _catalogPrefer = null;
|
||||
String _catalogResolve = null;
|
||||
|
||||
int _cdataChunkSize = JdkXmlUtils.CDATA_CHUNK_SIZE_DEFAULT;
|
||||
|
||||
/**
|
||||
* javax.xml.transform.sax.TransformerFactory implementation.
|
||||
*/
|
||||
@ -283,7 +286,7 @@ public class TransformerFactoryImpl
|
||||
_xsltcExtensionFunctions = null;
|
||||
}
|
||||
|
||||
public Map<String,Class> getExternalExtensionsMap() {
|
||||
public Map<String, Class<?>> getExternalExtensionsMap() {
|
||||
return _xsltcExtensionFunctions;
|
||||
}
|
||||
|
||||
@ -367,6 +370,8 @@ public class TransformerFactoryImpl
|
||||
return _catalogResolve;
|
||||
} else if (JdkXmlFeatures.CATALOG_FEATURES.equals(name)) {
|
||||
return buildCatalogFeatures();
|
||||
} else if (JdkXmlUtils.CDATA_CHUNK_SIZE.equals(name)) {
|
||||
return _cdataChunkSize;
|
||||
}
|
||||
|
||||
/** Check to see if the property is managed by the security manager **/
|
||||
@ -507,6 +512,9 @@ public class TransformerFactoryImpl
|
||||
_catalogResolve = (String) value;
|
||||
cfBuilder = CatalogFeatures.builder().with(Feature.RESOLVE, _catalogResolve);
|
||||
return;
|
||||
} else if (JdkXmlUtils.CDATA_CHUNK_SIZE.equals(name)) {
|
||||
_cdataChunkSize = JdkXmlUtils.getValue(value, _cdataChunkSize);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_xmlSecurityManager != null &&
|
||||
@ -896,10 +904,10 @@ public class TransformerFactoryImpl
|
||||
transletName = _packageName + "." + transletName;
|
||||
|
||||
try {
|
||||
final Class clazz = ObjectFactory.findProviderClass(transletName, true);
|
||||
final Class<?> clazz = ObjectFactory.findProviderClass(transletName, true);
|
||||
resetTransientAttributes();
|
||||
|
||||
templates = new TemplatesImpl(new Class[]{clazz}, transletName, null, _indentNumber, this);
|
||||
templates = new TemplatesImpl(new Class<?>[]{clazz}, transletName, null, _indentNumber, this);
|
||||
if (_uriResolver != null) {
|
||||
templates.setURIResolver(_uriResolver);
|
||||
}
|
||||
|
@ -230,6 +230,7 @@ public final class TransformerImpl extends Transformer
|
||||
// Catalog is enabled by default
|
||||
boolean _useCatalog = true;
|
||||
|
||||
int _cdataChunkSize = JdkXmlUtils.CDATA_CHUNK_SIZE_DEFAULT;
|
||||
|
||||
/**
|
||||
* This class wraps an ErrorListener into a MessageHandler in order to
|
||||
@ -284,6 +285,9 @@ public final class TransformerImpl extends Transformer
|
||||
_readerManager.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, _accessExternalDTD);
|
||||
_readerManager.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, _isSecureProcessing);
|
||||
_readerManager.setProperty(XalanConstants.SECURITY_MANAGER, _securityManager);
|
||||
_cdataChunkSize = JdkXmlUtils.getValue(_tfactory.getAttribute(JdkXmlUtils.CDATA_CHUNK_SIZE),
|
||||
JdkXmlUtils.CDATA_CHUNK_SIZE_DEFAULT);
|
||||
_readerManager.setProperty(JdkXmlUtils.CDATA_CHUNK_SIZE, _cdataChunkSize);
|
||||
|
||||
_useCatalog = _tfactory.getFeature(XMLConstants.USE_CATALOG);
|
||||
if (_useCatalog) {
|
||||
|
@ -137,13 +137,11 @@ public final class Util {
|
||||
reader.setFeature
|
||||
("http://xml.org/sax/features/namespace-prefixes",false);
|
||||
|
||||
try {
|
||||
reader.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD,
|
||||
xsltc.getProperty(XMLConstants.ACCESS_EXTERNAL_DTD));
|
||||
} catch (SAXNotRecognizedException e) {
|
||||
XMLSecurityManager.printWarning(reader.getClass().getName(),
|
||||
XMLConstants.ACCESS_EXTERNAL_DTD, e);
|
||||
}
|
||||
JdkXmlUtils.setXMLReaderPropertyIfSupport(reader, XMLConstants.ACCESS_EXTERNAL_DTD,
|
||||
xsltc.getProperty(XMLConstants.ACCESS_EXTERNAL_DTD), true);
|
||||
|
||||
JdkXmlUtils.setXMLReaderPropertyIfSupport(reader, JdkXmlUtils.CDATA_CHUNK_SIZE,
|
||||
xsltc.getProperty(JdkXmlUtils.CDATA_CHUNK_SIZE), false);
|
||||
|
||||
String lastProperty = "";
|
||||
try {
|
||||
|
@ -292,7 +292,8 @@ public class DOMConfigurationImpl extends ParserConfigurationSettings
|
||||
JdkXmlUtils.CATALOG_DEFER,
|
||||
JdkXmlUtils.CATALOG_FILES,
|
||||
JdkXmlUtils.CATALOG_PREFER,
|
||||
JdkXmlUtils.CATALOG_RESOLVE
|
||||
JdkXmlUtils.CATALOG_RESOLVE,
|
||||
JdkXmlUtils.CDATA_CHUNK_SIZE
|
||||
};
|
||||
addRecognizedProperties(recognizedProperties);
|
||||
|
||||
@ -368,6 +369,8 @@ public class DOMConfigurationImpl extends ParserConfigurationSettings
|
||||
for( CatalogFeatures.Feature f : CatalogFeatures.Feature.values()) {
|
||||
setProperty(f.getPropertyName(), null);
|
||||
}
|
||||
|
||||
setProperty(JdkXmlUtils.CDATA_CHUNK_SIZE, JdkXmlUtils.CDATA_CHUNK_SIZE_DEFAULT);
|
||||
} // <init>(SymbolTable)
|
||||
|
||||
|
||||
|
@ -144,6 +144,8 @@ public class PropertyManager {
|
||||
for( CatalogFeatures.Feature f : CatalogFeatures.Feature.values()) {
|
||||
supportedProps.put(f.getPropertyName(), null);
|
||||
}
|
||||
|
||||
supportedProps.put(JdkXmlUtils.CDATA_CHUNK_SIZE, JdkXmlUtils.CDATA_CHUNK_SIZE_DEFAULT);
|
||||
}
|
||||
|
||||
private void initWriterProps(){
|
||||
|
@ -1041,14 +1041,14 @@ public class XML11EntityScanner
|
||||
*
|
||||
* @param delimiter The string that signifies the end of the character
|
||||
* data to be scanned.
|
||||
* @param data The data structure to fill.
|
||||
* @param buffer The data structure to fill.
|
||||
* @param chunkLimit the size limit of the data to be scanned
|
||||
*
|
||||
* @return Returns true if there is more data to scan, false otherwise.
|
||||
*
|
||||
* @throws IOException Thrown if i/o error occurs.
|
||||
* @throws EOFException Thrown on end of file.
|
||||
*/
|
||||
protected boolean scanData(String delimiter, XMLStringBuffer buffer)
|
||||
protected boolean scanData(String delimiter, XMLStringBuffer buffer, int chunkLimit)
|
||||
throws IOException {
|
||||
|
||||
boolean done = false;
|
||||
@ -1152,82 +1152,50 @@ public class XML11EntityScanner
|
||||
}
|
||||
|
||||
// iterate over buffer looking for delimiter
|
||||
if (external) {
|
||||
OUTER: while (fCurrentEntity.position < fCurrentEntity.count) {
|
||||
c = fCurrentEntity.ch[fCurrentEntity.position++];
|
||||
if (c == charAt0) {
|
||||
// looks like we just hit the delimiter
|
||||
int delimOffset = fCurrentEntity.position - 1;
|
||||
for (int i = 1; i < delimLen; i++) {
|
||||
if (fCurrentEntity.position == fCurrentEntity.count) {
|
||||
fCurrentEntity.position -= i;
|
||||
break OUTER;
|
||||
}
|
||||
c = fCurrentEntity.ch[fCurrentEntity.position++];
|
||||
if (delimiter.charAt(i) != c) {
|
||||
fCurrentEntity.position--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (fCurrentEntity.position == delimOffset + delimLen) {
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (c == '\n' || c == '\r' || c == 0x85 || c == 0x2028) {
|
||||
fCurrentEntity.position--;
|
||||
break;
|
||||
}
|
||||
// In external entities control characters cannot appear
|
||||
// as literals so do not skip over them.
|
||||
else if (!XML11Char.isXML11ValidLiteral(c)) {
|
||||
fCurrentEntity.position--;
|
||||
int length = fCurrentEntity.position - offset;
|
||||
fCurrentEntity.columnNumber += length - newlines;
|
||||
checkEntityLimit(NameType.COMMENT, fCurrentEntity, offset, length);
|
||||
buffer.append(fCurrentEntity.ch, offset, length);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
OUTER: while (fCurrentEntity.position < fCurrentEntity.count) {
|
||||
c = fCurrentEntity.ch[fCurrentEntity.position++];
|
||||
if (c == charAt0) {
|
||||
// looks like we just hit the delimiter
|
||||
int delimOffset = fCurrentEntity.position - 1;
|
||||
for (int i = 1; i < delimLen; i++) {
|
||||
if (fCurrentEntity.position == fCurrentEntity.count) {
|
||||
fCurrentEntity.position -= i;
|
||||
break OUTER;
|
||||
}
|
||||
c = fCurrentEntity.ch[fCurrentEntity.position++];
|
||||
if (delimiter.charAt(i) != c) {
|
||||
fCurrentEntity.position--;
|
||||
break;
|
||||
}
|
||||
OUTER: while (fCurrentEntity.position < fCurrentEntity.count) {
|
||||
c = fCurrentEntity.ch[fCurrentEntity.position++];
|
||||
if (c == charAt0) {
|
||||
// looks like we just hit the delimiter
|
||||
int delimOffset = fCurrentEntity.position - 1;
|
||||
for (int i = 1; i < delimLen; i++) {
|
||||
if (fCurrentEntity.position == fCurrentEntity.count) {
|
||||
fCurrentEntity.position -= i;
|
||||
break OUTER;
|
||||
}
|
||||
if (fCurrentEntity.position == delimOffset + delimLen) {
|
||||
done = true;
|
||||
c = fCurrentEntity.ch[fCurrentEntity.position++];
|
||||
if (delimiter.charAt(i) != c) {
|
||||
fCurrentEntity.position--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (c == '\n') {
|
||||
fCurrentEntity.position--;
|
||||
}
|
||||
if (fCurrentEntity.position == delimOffset + delimLen) {
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
// Control characters are allowed to appear as literals
|
||||
// in internal entities.
|
||||
else if (!XML11Char.isXML11Valid(c)) {
|
||||
fCurrentEntity.position--;
|
||||
int length = fCurrentEntity.position - offset;
|
||||
fCurrentEntity.columnNumber += length - newlines;
|
||||
checkEntityLimit(NameType.COMMENT, fCurrentEntity, offset, length);
|
||||
buffer.append(fCurrentEntity.ch, offset, length);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((external && (c == '\n' || c == '\r' || c == 0x85 || c == 0x2028))
|
||||
|| (!external && c == '\n')) {
|
||||
fCurrentEntity.position--;
|
||||
break;
|
||||
}
|
||||
// In external entities control characters cannot appear
|
||||
// as literals so do not skip over them.
|
||||
else if ((external && !XML11Char.isXML11ValidLiteral(c))
|
||||
// Control characters are allowed to appear as literals in internal entities.
|
||||
|| (!external && !XML11Char.isXML11Valid(c))) {
|
||||
fCurrentEntity.position--;
|
||||
int length = fCurrentEntity.position - offset;
|
||||
fCurrentEntity.columnNumber += length - newlines;
|
||||
checkEntityLimit(NameType.COMMENT, fCurrentEntity, offset, length);
|
||||
buffer.append(fCurrentEntity.ch, offset, length);
|
||||
return true;
|
||||
}
|
||||
if (chunkLimit > 0 &&
|
||||
(buffer.length + fCurrentEntity.position - offset) >= chunkLimit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int length = fCurrentEntity.position - offset;
|
||||
fCurrentEntity.columnNumber += length - newlines;
|
||||
checkEntityLimit(NameType.COMMENT, fCurrentEntity, offset, length);
|
||||
@ -1236,8 +1204,10 @@ public class XML11EntityScanner
|
||||
}
|
||||
buffer.append(fCurrentEntity.ch, offset, length);
|
||||
|
||||
// return true if string was skipped
|
||||
} while (!done);
|
||||
if (chunkLimit > 0 && buffer.length >= chunkLimit) {
|
||||
break;
|
||||
}
|
||||
} while (!done && chunkLimit == 0);
|
||||
return !done;
|
||||
|
||||
} // scanData(String,XMLString)
|
||||
|
@ -388,7 +388,7 @@ implements XMLDTDScanner, XMLComponent, XMLEntityHandler {
|
||||
return false;
|
||||
|
||||
fStringBuffer.clear();
|
||||
while (fEntityScanner.scanData("]", fStringBuffer)) {
|
||||
while (fEntityScanner.scanData("]", fStringBuffer, 0)) {
|
||||
int c = fEntityScanner.peekChar();
|
||||
if (c != -1) {
|
||||
if (XMLChar.isHighSurrogate(c)) {
|
||||
|
@ -200,7 +200,8 @@ public class XMLDocumentFragmentScannerImpl
|
||||
JdkXmlUtils.CATALOG_DEFER,
|
||||
JdkXmlUtils.CATALOG_FILES,
|
||||
JdkXmlUtils.CATALOG_PREFER,
|
||||
JdkXmlUtils.CATALOG_RESOLVE
|
||||
JdkXmlUtils.CATALOG_RESOLVE,
|
||||
JdkXmlUtils.CDATA_CHUNK_SIZE
|
||||
};
|
||||
|
||||
/** Property defaults. */
|
||||
@ -212,7 +213,8 @@ public class XMLDocumentFragmentScannerImpl
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
null,
|
||||
JdkXmlUtils.CDATA_CHUNK_SIZE_DEFAULT
|
||||
};
|
||||
|
||||
|
||||
@ -269,6 +271,9 @@ public class XMLDocumentFragmentScannerImpl
|
||||
/** SubScanner state: inside scanContent method. */
|
||||
protected boolean fInScanContent = false;
|
||||
protected boolean fLastSectionWasCData = false;
|
||||
protected boolean fCDataStart = false;
|
||||
protected boolean fInCData = false;
|
||||
protected boolean fCDataEnd = false;
|
||||
protected boolean fLastSectionWasEntityReference = false;
|
||||
protected boolean fLastSectionWasCharacterData = false;
|
||||
|
||||
@ -318,6 +323,11 @@ public class XMLDocumentFragmentScannerImpl
|
||||
/** Xerces Feature: Disallow doctype declaration. */
|
||||
protected boolean fDisallowDoctype = false;
|
||||
|
||||
/**
|
||||
* CDATA chunk size limit
|
||||
*/
|
||||
private int fChunkSize;
|
||||
|
||||
/**
|
||||
* comma-delimited list of protocols that are allowed for the purpose
|
||||
* of accessing external dtd or entity references
|
||||
@ -490,12 +500,18 @@ public class XMLDocumentFragmentScannerImpl
|
||||
//therefore we don't need to take care of anything here. So Just break;
|
||||
break;
|
||||
case XMLStreamConstants.CDATA:
|
||||
fEntityScanner.checkNodeCount(fEntityScanner.fCurrentEntity);
|
||||
fDocumentHandler.startCDATA(null);
|
||||
//xxx: check if CDATA values comes from getCharacterData() function
|
||||
fEntityScanner.checkNodeCount(fEntityScanner.fCurrentEntity);
|
||||
if (fCDataStart) {
|
||||
fDocumentHandler.startCDATA(null);
|
||||
fCDataStart = false;
|
||||
fInCData = true;
|
||||
}
|
||||
|
||||
fDocumentHandler.characters(getCharacterData(),null);
|
||||
fDocumentHandler.endCDATA(null);
|
||||
//System.out.println(" in CDATA of the XMLNSDocumentScannerImpl");
|
||||
if (fCDataEnd) {
|
||||
fDocumentHandler.endCDATA(null);
|
||||
fCDataEnd = false;
|
||||
}
|
||||
break;
|
||||
case XMLStreamConstants.NOTATION_DECLARATION :
|
||||
break;
|
||||
@ -603,6 +619,8 @@ public class XMLDocumentFragmentScannerImpl
|
||||
fAccessExternalDTD = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);
|
||||
|
||||
fStrictURI = componentManager.getFeature(STANDARD_URI_CONFORMANT, false);
|
||||
fChunkSize = JdkXmlUtils.getValue(componentManager.getProperty(JdkXmlUtils.CDATA_CHUNK_SIZE),
|
||||
JdkXmlUtils.CDATA_CHUNK_SIZE_DEFAULT);
|
||||
|
||||
resetCommon();
|
||||
//fEntityManager.test();
|
||||
@ -647,6 +665,8 @@ public class XMLDocumentFragmentScannerImpl
|
||||
fAccessExternalDTD = spm.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);
|
||||
|
||||
fSecurityManager = (XMLSecurityManager)propertyManager.getProperty(Constants.SECURITY_MANAGER);
|
||||
fChunkSize = JdkXmlUtils.getValue(propertyManager.getProperty(JdkXmlUtils.CDATA_CHUNK_SIZE),
|
||||
JdkXmlUtils.CDATA_CHUNK_SIZE_DEFAULT);
|
||||
resetCommon();
|
||||
} // reset(XMLComponentManager)
|
||||
|
||||
@ -1665,34 +1685,11 @@ public class XMLDocumentFragmentScannerImpl
|
||||
|
||||
while (true) {
|
||||
//scanData will fill the contentBuffer
|
||||
if (!fEntityScanner.scanData("]]>", contentBuffer)) {
|
||||
if (!fEntityScanner.scanData("]]>", contentBuffer, fChunkSize)) {
|
||||
fInCData = false;
|
||||
fCDataEnd = true;
|
||||
fMarkupDepth--;
|
||||
break ;
|
||||
/** We dont need all this code if we pass ']]>' as delimeter..
|
||||
* int brackets = 2;
|
||||
* while (fEntityScanner.skipChar(']')) {
|
||||
* brackets++;
|
||||
* }
|
||||
*
|
||||
* //When we find more than 2 square brackets
|
||||
* if (fDocumentHandler != null && brackets > 2) {
|
||||
* //we dont need to clear the buffer..
|
||||
* //contentBuffer.clear();
|
||||
* for (int i = 2; i < brackets; i++) {
|
||||
* contentBuffer.append(']');
|
||||
* }
|
||||
* fDocumentHandler.characters(contentBuffer, null);
|
||||
* }
|
||||
*
|
||||
* if (fEntityScanner.skipChar('>')) {
|
||||
* break;
|
||||
* }
|
||||
* if (fDocumentHandler != null) {
|
||||
* //we dont need to clear the buffer now..
|
||||
* //contentBuffer.clear();
|
||||
* contentBuffer.append("]]");
|
||||
* fDocumentHandler.characters(contentBuffer, null);
|
||||
* }
|
||||
**/
|
||||
} else {
|
||||
int c = fEntityScanner.peekChar();
|
||||
if (c != -1 && isInvalidLiteral(c)) {
|
||||
@ -1705,6 +1702,9 @@ public class XMLDocumentFragmentScannerImpl
|
||||
new Object[]{Integer.toString(c,16)});
|
||||
fEntityScanner.scanChar(null);
|
||||
}
|
||||
} else {
|
||||
//CData partially returned due to the size limit
|
||||
break;
|
||||
}
|
||||
//by this time we have also read surrogate contents if any...
|
||||
if (fDocumentHandler != null) {
|
||||
@ -1712,16 +1712,6 @@ public class XMLDocumentFragmentScannerImpl
|
||||
}
|
||||
}
|
||||
}
|
||||
fMarkupDepth--;
|
||||
|
||||
if (fDocumentHandler != null && contentBuffer.length > 0) {
|
||||
//fDocumentHandler.characters(contentBuffer, null);
|
||||
}
|
||||
|
||||
// call handler
|
||||
if (fDocumentHandler != null) {
|
||||
//fDocumentHandler.endCDATA(null);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -2635,6 +2625,7 @@ public class XMLDocumentFragmentScannerImpl
|
||||
}
|
||||
setScannerState(SCANNER_STATE_COMMENT);
|
||||
} else if (fEntityScanner.skipString(cdata)) {
|
||||
fCDataStart = true;
|
||||
setScannerState(SCANNER_STATE_CDATA );
|
||||
} else if (!scanForDoctypeHook()) {
|
||||
reportFatalError("MarkupNotRecognizedInContent",
|
||||
@ -3015,9 +3006,11 @@ public class XMLDocumentFragmentScannerImpl
|
||||
//xxx: What if CDATA is the first event
|
||||
//<foo><![CDATA[hello<><>]]>append</foo>
|
||||
|
||||
//we should not clear the buffer only when the last state was either SCANNER_STATE_REFERENCE or
|
||||
//we should not clear the buffer only when the last state was
|
||||
//either SCANNER_STATE_REFERENCE or
|
||||
//SCANNER_STATE_CHARACTER_DATA or SCANNER_STATE_REFERENCE
|
||||
if(fIsCoalesce && ( fLastSectionWasEntityReference || fLastSectionWasCData || fLastSectionWasCharacterData)){
|
||||
if(fIsCoalesce && ( fLastSectionWasEntityReference ||
|
||||
fLastSectionWasCData || fLastSectionWasCharacterData)){
|
||||
fLastSectionWasCData = true ;
|
||||
fLastSectionWasEntityReference = false;
|
||||
fLastSectionWasCharacterData = false;
|
||||
@ -3026,7 +3019,7 @@ public class XMLDocumentFragmentScannerImpl
|
||||
fContentBuffer.clear();
|
||||
}
|
||||
fUsebuffer = true;
|
||||
//CDATA section is completely read in all the case.
|
||||
//CDATA section is read up to the chunk size limit
|
||||
scanCDATASection(fContentBuffer , true);
|
||||
setScannerState(SCANNER_STATE_CONTENT);
|
||||
//1. if fIsCoalesce is set to true we set the variable fLastSectionWasCData to true
|
||||
@ -3036,13 +3029,16 @@ public class XMLDocumentFragmentScannerImpl
|
||||
//2. Check if application has set for reporting CDATA event
|
||||
//3. if the application has neither set the fIsCoalesce to true nor fReportCdataEvent
|
||||
//return the cdata event as characters.
|
||||
if(fIsCoalesce){
|
||||
if (fIsCoalesce) {
|
||||
fLastSectionWasCData = true ;
|
||||
//there might be more data to coalesce.
|
||||
continue;
|
||||
}else if(fReportCdataEvent){
|
||||
} else if(fReportCdataEvent) {
|
||||
if (!fCDataEnd) {
|
||||
setScannerState(SCANNER_STATE_CDATA);
|
||||
}
|
||||
return XMLEvent.CDATA;
|
||||
} else{
|
||||
} else {
|
||||
return XMLEvent.CHARACTERS;
|
||||
}
|
||||
}
|
||||
@ -3051,9 +3047,11 @@ public class XMLDocumentFragmentScannerImpl
|
||||
fMarkupDepth++;
|
||||
foundBuiltInRefs = false;
|
||||
|
||||
//we should not clear the buffer only when the last state was either CDATA or
|
||||
//we should not clear the buffer only when the last state was
|
||||
//either CDATA or
|
||||
//SCANNER_STATE_CHARACTER_DATA or SCANNER_STATE_REFERENCE
|
||||
if(fIsCoalesce && ( fLastSectionWasEntityReference || fLastSectionWasCData || fLastSectionWasCharacterData)){
|
||||
if(fIsCoalesce && ( fLastSectionWasEntityReference ||
|
||||
fLastSectionWasCData || fLastSectionWasCharacterData)){
|
||||
//fLastSectionWasEntityReference or fLastSectionWasCData are only
|
||||
//used when fIsCoalesce is set to true.
|
||||
fLastSectionWasEntityReference = true ;
|
||||
|
2
jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java
2
jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentScannerImpl.java
@ -968,9 +968,11 @@ public class XMLDocumentScannerImpl
|
||||
case SCANNER_STATE_CONTENT: {
|
||||
reportFatalError("ContentIllegalInProlog", null);
|
||||
fEntityScanner.scanChar(null);
|
||||
return -1;
|
||||
}
|
||||
case SCANNER_STATE_REFERENCE: {
|
||||
reportFatalError("ReferenceIllegalInProlog", null);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -217,7 +217,8 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
JdkXmlUtils.CATALOG_DEFER,
|
||||
JdkXmlUtils.CATALOG_FILES,
|
||||
JdkXmlUtils.CATALOG_PREFER,
|
||||
JdkXmlUtils.CATALOG_RESOLVE
|
||||
JdkXmlUtils.CATALOG_RESOLVE,
|
||||
JdkXmlUtils.CDATA_CHUNK_SIZE
|
||||
};
|
||||
|
||||
/** Property defaults. */
|
||||
@ -232,7 +233,8 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
null,
|
||||
JdkXmlUtils.CDATA_CHUNK_SIZE_DEFAULT
|
||||
};
|
||||
|
||||
private static final String XMLEntity = "[xml]".intern();
|
||||
|
@ -1350,13 +1350,15 @@ public class XMLEntityScanner implements XMLLocator {
|
||||
* @param delimiter The string that signifies the end of the character
|
||||
* data to be scanned.
|
||||
* @param buffer The XMLStringBuffer to fill.
|
||||
* @param chunkLimit the size limit of the data to be scanned. Zero by default
|
||||
* indicating no limit.
|
||||
*
|
||||
* @return Returns true if there is more data to scan, false otherwise.
|
||||
*
|
||||
* @throws IOException Thrown if i/o error occurs.
|
||||
* @throws EOFException Thrown on end of file.
|
||||
*/
|
||||
protected boolean scanData(String delimiter, XMLStringBuffer buffer)
|
||||
protected boolean scanData(String delimiter, XMLStringBuffer buffer, int chunkLimit)
|
||||
throws IOException {
|
||||
|
||||
boolean done = false;
|
||||
@ -1505,6 +1507,10 @@ public class XMLEntityScanner implements XMLLocator {
|
||||
buffer.append(fCurrentEntity.ch, offset, length);
|
||||
return true;
|
||||
}
|
||||
if (chunkLimit > 0 &&
|
||||
(buffer.length + fCurrentEntity.position - offset) >= chunkLimit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
int length = fCurrentEntity.position - offset;
|
||||
fCurrentEntity.columnNumber += length - newlines;
|
||||
@ -1520,7 +1526,10 @@ public class XMLEntityScanner implements XMLLocator {
|
||||
print();
|
||||
System.out.println(" -> " + done);
|
||||
}
|
||||
} while (!done);
|
||||
if (chunkLimit > 0 && buffer.length >= chunkLimit) {
|
||||
break;
|
||||
}
|
||||
} while (!done && chunkLimit == 0);
|
||||
return !done;
|
||||
|
||||
} // scanData(String, XMLStringBuffer)
|
||||
|
@ -760,7 +760,7 @@ public abstract class XMLScanner
|
||||
// since scanData appends the parsed data to the buffer passed
|
||||
// a while loop would append the whole of parsed data to the buffer(data:XMLStringBuffer)
|
||||
//until all of the data is buffered.
|
||||
if (fEntityScanner.scanData("?>", data)) {
|
||||
if (fEntityScanner.scanData("?>", data, 0)) {
|
||||
do {
|
||||
int c = fEntityScanner.peekChar();
|
||||
if (c != -1) {
|
||||
@ -772,7 +772,7 @@ public abstract class XMLScanner
|
||||
fEntityScanner.scanChar(null);
|
||||
}
|
||||
}
|
||||
} while (fEntityScanner.scanData("?>", data));
|
||||
} while (fEntityScanner.scanData("?>", data, 0));
|
||||
}
|
||||
|
||||
} // scanPIData(String,XMLString)
|
||||
@ -797,7 +797,7 @@ public abstract class XMLScanner
|
||||
// text
|
||||
// REVISIT: handle invalid character, eof
|
||||
text.clear();
|
||||
while (fEntityScanner.scanData("--", text)) {
|
||||
while (fEntityScanner.scanData("--", text, 0)) {
|
||||
int c = fEntityScanner.peekChar();
|
||||
|
||||
//System.out.println( "XMLScanner#scanComment#text.toString() == " + text.toString() );
|
||||
|
@ -250,7 +250,8 @@ XSLoader, DOMConfiguration {
|
||||
JdkXmlUtils.CATALOG_DEFER,
|
||||
JdkXmlUtils.CATALOG_FILES,
|
||||
JdkXmlUtils.CATALOG_PREFER,
|
||||
JdkXmlUtils.CATALOG_RESOLVE
|
||||
JdkXmlUtils.CATALOG_RESOLVE,
|
||||
JdkXmlUtils.CDATA_CHUNK_SIZE
|
||||
};
|
||||
|
||||
// Data
|
||||
@ -282,7 +283,7 @@ XSLoader, DOMConfiguration {
|
||||
private XSDDescription fXSDDescription = new XSDDescription();
|
||||
private String faccessExternalSchema = Constants.EXTERNAL_ACCESS_DEFAULT;
|
||||
|
||||
private WeakHashMap fJAXPCache;
|
||||
private WeakHashMap<Object, SchemaGrammar> fJAXPCache;
|
||||
private Locale fLocale = Locale.getDefault();
|
||||
|
||||
// XSLoader attributes
|
||||
@ -366,7 +367,7 @@ XSLoader, DOMConfiguration {
|
||||
}
|
||||
fCMBuilder = builder;
|
||||
fSchemaHandler = new XSDHandler(fGrammarBucket);
|
||||
fJAXPCache = new WeakHashMap();
|
||||
fJAXPCache = new WeakHashMap<>();
|
||||
|
||||
fSettingsChanged = true;
|
||||
}
|
||||
@ -377,7 +378,7 @@ XSLoader, DOMConfiguration {
|
||||
* are recognized.
|
||||
*/
|
||||
public String[] getRecognizedFeatures() {
|
||||
return (String[])(RECOGNIZED_FEATURES.clone());
|
||||
return RECOGNIZED_FEATURES.clone();
|
||||
} // getRecognizedFeatures(): String[]
|
||||
|
||||
/**
|
||||
@ -419,7 +420,7 @@ XSLoader, DOMConfiguration {
|
||||
* are recognized.
|
||||
*/
|
||||
public String[] getRecognizedProperties() {
|
||||
return (String[])(RECOGNIZED_PROPERTIES.clone());
|
||||
return RECOGNIZED_PROPERTIES.clone();
|
||||
} // getRecognizedProperties(): String[]
|
||||
|
||||
/**
|
||||
@ -568,7 +569,7 @@ XSLoader, DOMConfiguration {
|
||||
desc.setBaseSystemId(source.getBaseSystemId());
|
||||
desc.setLiteralSystemId( source.getSystemId());
|
||||
// none of the other fields make sense for preparsing
|
||||
Map locationPairs = new HashMap();
|
||||
Map<String, LocationArray> locationPairs = new HashMap<>();
|
||||
// Process external schema location properties.
|
||||
// We don't call tokenizeSchemaLocationStr here, because we also want
|
||||
// to check whether the values are valid URI.
|
||||
@ -665,7 +666,7 @@ XSLoader, DOMConfiguration {
|
||||
|
||||
// add external schema locations to the location pairs
|
||||
public static void processExternalHints(String sl, String nsl,
|
||||
Map<String, XMLSchemaLoader.LocationArray> locations,
|
||||
Map<String, LocationArray> locations,
|
||||
XMLErrorReporter er) {
|
||||
if (sl != null) {
|
||||
try {
|
||||
@ -694,9 +695,10 @@ XSLoader, DOMConfiguration {
|
||||
if (nsl != null) {
|
||||
try {
|
||||
// similarly for no ns schema location property
|
||||
XSAttributeDecl attrDecl = SchemaGrammar.SG_XSI.getGlobalAttributeDecl(SchemaSymbols.XSI_NONAMESPACESCHEMALOCATION);
|
||||
XSAttributeDecl attrDecl = SchemaGrammar.SG_XSI.getGlobalAttributeDecl(
|
||||
SchemaSymbols.XSI_NONAMESPACESCHEMALOCATION);
|
||||
attrDecl.fType.validate(nsl, null, null);
|
||||
LocationArray la = ((LocationArray)locations.get(XMLSymbols.EMPTY_STRING));
|
||||
LocationArray la = locations.get(XMLSymbols.EMPTY_STRING);
|
||||
if(la == null) {
|
||||
la = new LocationArray();
|
||||
locations.put(XMLSymbols.EMPTY_STRING, la);
|
||||
@ -763,14 +765,14 @@ XSLoader, DOMConfiguration {
|
||||
return;
|
||||
}
|
||||
|
||||
Class componentType = fJAXPSource.getClass().getComponentType();
|
||||
Class<?> componentType = fJAXPSource.getClass().getComponentType();
|
||||
XMLInputSource xis = null;
|
||||
String sid = null;
|
||||
if (componentType == null) {
|
||||
// Not an array
|
||||
if (fJAXPSource instanceof InputStream ||
|
||||
fJAXPSource instanceof InputSource) {
|
||||
SchemaGrammar g = (SchemaGrammar)fJAXPCache.get(fJAXPSource);
|
||||
SchemaGrammar g = fJAXPCache.get(fJAXPSource);
|
||||
if (g != null) {
|
||||
fGrammarBucket.putGrammar(g);
|
||||
return;
|
||||
@ -823,7 +825,7 @@ XSLoader, DOMConfiguration {
|
||||
for (int i = 0; i < objArr.length; i++) {
|
||||
if (objArr[i] instanceof InputStream ||
|
||||
objArr[i] instanceof InputSource) {
|
||||
SchemaGrammar g = (SchemaGrammar)fJAXPCache.get(objArr[i]);
|
||||
SchemaGrammar g = fJAXPCache.get(objArr[i]);
|
||||
if (g != null) {
|
||||
fGrammarBucket.putGrammar(g);
|
||||
continue;
|
||||
|
17
jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java
17
jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/xs/XMLSchemaValidator.java
@ -344,13 +344,14 @@ public class XMLSchemaValidator
|
||||
JdkXmlUtils.CATALOG_DEFER,
|
||||
JdkXmlUtils.CATALOG_FILES,
|
||||
JdkXmlUtils.CATALOG_PREFER,
|
||||
JdkXmlUtils.CATALOG_RESOLVE
|
||||
JdkXmlUtils.CATALOG_RESOLVE,
|
||||
JdkXmlUtils.CDATA_CHUNK_SIZE
|
||||
};
|
||||
|
||||
/** Property defaults. */
|
||||
private static final Object[] PROPERTY_DEFAULTS =
|
||||
{ null, null, null, null, null, null, null, null, null, null, null, null,
|
||||
null, null, null, null};
|
||||
null, null, null, null, JdkXmlUtils.CDATA_CHUNK_SIZE_DEFAULT };
|
||||
|
||||
// this is the number of valuestores of each kind
|
||||
// we expect an element to have. It's almost
|
||||
@ -358,10 +359,14 @@ public class XMLSchemaValidator
|
||||
protected static final int ID_CONSTRAINT_NUM = 1;
|
||||
|
||||
// xsi:* attribute declarations
|
||||
static final XSAttributeDecl XSI_TYPE = SchemaGrammar.SG_XSI.getGlobalAttributeDecl(SchemaSymbols.XSI_TYPE);
|
||||
static final XSAttributeDecl XSI_NIL = SchemaGrammar.SG_XSI.getGlobalAttributeDecl(SchemaSymbols.XSI_NIL);
|
||||
static final XSAttributeDecl XSI_SCHEMALOCATION = SchemaGrammar.SG_XSI.getGlobalAttributeDecl(SchemaSymbols.XSI_SCHEMALOCATION);
|
||||
static final XSAttributeDecl XSI_NONAMESPACESCHEMALOCATION = SchemaGrammar.SG_XSI.getGlobalAttributeDecl(SchemaSymbols.XSI_NONAMESPACESCHEMALOCATION);
|
||||
static final XSAttributeDecl XSI_TYPE =
|
||||
SchemaGrammar.SG_XSI.getGlobalAttributeDecl(SchemaSymbols.XSI_TYPE);
|
||||
static final XSAttributeDecl XSI_NIL =
|
||||
SchemaGrammar.SG_XSI.getGlobalAttributeDecl(SchemaSymbols.XSI_NIL);
|
||||
static final XSAttributeDecl XSI_SCHEMALOCATION =
|
||||
SchemaGrammar.SG_XSI.getGlobalAttributeDecl(SchemaSymbols.XSI_SCHEMALOCATION);
|
||||
static final XSAttributeDecl XSI_NONAMESPACESCHEMALOCATION =
|
||||
SchemaGrammar.SG_XSI.getGlobalAttributeDecl(SchemaSymbols.XSI_NONAMESPACESCHEMALOCATION);
|
||||
|
||||
//
|
||||
// Data
|
||||
|
@ -336,7 +336,8 @@ public class SchemaParsingConfig extends BasicParserConfiguration
|
||||
JdkXmlUtils.CATALOG_DEFER,
|
||||
JdkXmlUtils.CATALOG_FILES,
|
||||
JdkXmlUtils.CATALOG_PREFER,
|
||||
JdkXmlUtils.CATALOG_RESOLVE
|
||||
JdkXmlUtils.CATALOG_RESOLVE,
|
||||
JdkXmlUtils.CDATA_CHUNK_SIZE
|
||||
};
|
||||
addRecognizedProperties(recognizedProperties);
|
||||
|
||||
@ -368,6 +369,7 @@ public class SchemaParsingConfig extends BasicParserConfiguration
|
||||
|
||||
fValidationManager = new ValidationManager();
|
||||
fProperties.put(VALIDATION_MANAGER, fValidationManager);
|
||||
fProperties.put(JdkXmlUtils.CDATA_CHUNK_SIZE, JdkXmlUtils.CDATA_CHUNK_SIZE_DEFAULT);
|
||||
|
||||
fVersionDetector = new XMLVersionDetector();
|
||||
|
||||
|
@ -350,7 +350,7 @@ public class XSDHandler {
|
||||
|
||||
// This map's job is to act as a link between the Schema Element and its
|
||||
// XSDocumentInfo object.
|
||||
private Map fDoc2XSDocumentMap = new HashMap();
|
||||
private Map<Element, XSDocumentInfo> fDoc2XSDocumentMap = new HashMap<>();
|
||||
|
||||
// map between <redefine> elements and the XSDocumentInfo
|
||||
// objects that correspond to the documents being redefined.
|
||||
@ -1104,10 +1104,12 @@ public class XSDHandler {
|
||||
fSchemaGrammarDescription.setTargetNamespace(callerTNS);
|
||||
|
||||
boolean alreadyTraversed = false;
|
||||
XMLInputSource schemaSource = resolveSchemaSource(fSchemaGrammarDescription, mustResolve, child, true);
|
||||
XMLInputSource schemaSource =
|
||||
resolveSchemaSource(fSchemaGrammarDescription, mustResolve, child, true);
|
||||
if (fNamespaceGrowth && refType == XSDDescription.CONTEXT_INCLUDE) {
|
||||
try {
|
||||
final String schemaId = XMLEntityManager.expandSystemId(schemaSource.getSystemId(), schemaSource.getBaseSystemId(), false);
|
||||
final String schemaId = XMLEntityManager.expandSystemId(
|
||||
schemaSource.getSystemId(), schemaSource.getBaseSystemId(), false);
|
||||
alreadyTraversed = sg.getDocumentLocations().contains(schemaId);
|
||||
}
|
||||
catch(MalformedURIException e) {
|
||||
@ -1133,10 +1135,11 @@ public class XSDHandler {
|
||||
// To handle mutual <include>s
|
||||
XSDocumentInfo newSchemaInfo = null;
|
||||
if (fLastSchemaWasDuplicate) {
|
||||
newSchemaInfo = newSchemaRoot == null ? null : (XSDocumentInfo)fDoc2XSDocumentMap.get(newSchemaRoot);
|
||||
newSchemaInfo = newSchemaRoot == null ? null : fDoc2XSDocumentMap.get(newSchemaRoot);
|
||||
}
|
||||
else {
|
||||
newSchemaInfo = constructTrees(newSchemaRoot, schemaHint, fSchemaGrammarDescription, importCollision);
|
||||
newSchemaInfo = constructTrees(newSchemaRoot, schemaHint,
|
||||
fSchemaGrammarDescription, importCollision);
|
||||
}
|
||||
|
||||
if (localName.equals(SchemaSymbols.ELT_REDEFINE) &&
|
||||
@ -3552,9 +3555,11 @@ public class XSDHandler {
|
||||
// than checking its value. Don't set the ERROR_HANDLER
|
||||
// or LOCALE properties unless they've actually changed.
|
||||
if (fErrorHandler != fSchemaParser.getProperty(ERROR_HANDLER)) {
|
||||
fSchemaParser.setProperty(ERROR_HANDLER, (fErrorHandler != null) ? fErrorHandler : new DefaultErrorHandler());
|
||||
fSchemaParser.setProperty(ERROR_HANDLER,
|
||||
(fErrorHandler != null) ? fErrorHandler : new DefaultErrorHandler());
|
||||
if (fAnnotationValidator != null) {
|
||||
fAnnotationValidator.setProperty(ERROR_HANDLER, (fErrorHandler != null) ? fErrorHandler : new DefaultErrorHandler());
|
||||
fAnnotationValidator.setProperty(ERROR_HANDLER,
|
||||
(fErrorHandler != null) ? fErrorHandler : new DefaultErrorHandler());
|
||||
}
|
||||
}
|
||||
if (fLocale != fSchemaParser.getProperty(LOCALE)) {
|
||||
@ -3567,7 +3572,8 @@ public class XSDHandler {
|
||||
catch (XMLConfigurationException e) {}
|
||||
|
||||
try {
|
||||
fSchemaParser.setFeature(CONTINUE_AFTER_FATAL_ERROR, fErrorReporter.getFeature(CONTINUE_AFTER_FATAL_ERROR));
|
||||
fSchemaParser.setFeature(CONTINUE_AFTER_FATAL_ERROR,
|
||||
fErrorReporter.getFeature(CONTINUE_AFTER_FATAL_ERROR));
|
||||
} catch (XMLConfigurationException e) {}
|
||||
|
||||
try {
|
||||
@ -3601,13 +3607,16 @@ public class XSDHandler {
|
||||
}
|
||||
} catch (XMLConfigurationException e) {}
|
||||
|
||||
fSecurityPropertyMgr = (XMLSecurityPropertyManager) componentManager.getProperty(XML_SECURITY_PROPERTY_MANAGER);
|
||||
fSecurityPropertyMgr = (XMLSecurityPropertyManager)
|
||||
componentManager.getProperty(XML_SECURITY_PROPERTY_MANAGER);
|
||||
|
||||
//Passing on the setting to the parser
|
||||
fSchemaParser.setProperty(XML_SECURITY_PROPERTY_MANAGER, fSecurityPropertyMgr);
|
||||
|
||||
fAccessExternalDTD = fSecurityPropertyMgr.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);
|
||||
fAccessExternalSchema = fSecurityPropertyMgr.getValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA);
|
||||
fAccessExternalDTD = fSecurityPropertyMgr.getValue(
|
||||
XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD);
|
||||
fAccessExternalSchema = fSecurityPropertyMgr.getValue(
|
||||
XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA);
|
||||
|
||||
// Passing the Catalog settings to the parser
|
||||
fUseCatalog = componentManager.getFeature(XMLConstants.USE_CATALOG);
|
||||
@ -3620,9 +3629,16 @@ public class XSDHandler {
|
||||
fResolve = (String)componentManager.getProperty(JdkXmlUtils.CATALOG_RESOLVE);
|
||||
|
||||
for( CatalogFeatures.Feature f : CatalogFeatures.Feature.values()) {
|
||||
fSchemaParser.setProperty(f.getPropertyName(), componentManager.getProperty(f.getPropertyName()));
|
||||
fEntityManager.setProperty(f.getPropertyName(), componentManager.getProperty(f.getPropertyName()));
|
||||
fSchemaParser.setProperty(f.getPropertyName(),
|
||||
componentManager.getProperty(f.getPropertyName()));
|
||||
fEntityManager.setProperty(f.getPropertyName(),
|
||||
componentManager.getProperty(f.getPropertyName()));
|
||||
}
|
||||
|
||||
fSchemaParser.setProperty(JdkXmlUtils.CDATA_CHUNK_SIZE,
|
||||
componentManager.getProperty(JdkXmlUtils.CDATA_CHUNK_SIZE));
|
||||
fEntityManager.setProperty(JdkXmlUtils.CDATA_CHUNK_SIZE,
|
||||
componentManager.getProperty(JdkXmlUtils.CDATA_CHUNK_SIZE));
|
||||
} // reset(XMLComponentManager)
|
||||
|
||||
|
||||
@ -3635,11 +3651,10 @@ public class XSDHandler {
|
||||
|
||||
for (int i = 0; i < fLocalElemStackPos; i++) {
|
||||
Element currElem = fLocalElementDecl[i];
|
||||
//XSDocumentInfo currSchema = (XSDocumentInfo)fDoc2XSDocumentMap.get(DOMUtil.getDocument(currElem));
|
||||
//XSDocumentInfo currSchema = (XSDocumentInfo)fDoc2XSDocumentMap.get(DOMUtil.getRoot(DOMUtil.getDocument(currElem)));
|
||||
XSDocumentInfo currSchema = fLocalElementDecl_schema[i];
|
||||
SchemaGrammar currGrammar = fGrammarBucket.getGrammar(currSchema.fTargetNamespace);
|
||||
fElementTraverser.traverseLocal (fParticle[i], currElem, currSchema, currGrammar, fAllContext[i], fParent[i], fLocalElemNamespaceContext[i]);
|
||||
fElementTraverser.traverseLocal (fParticle[i], currElem, currSchema,
|
||||
currGrammar, fAllContext[i], fParent[i], fLocalElemNamespaceContext[i]);
|
||||
// If it's an empty particle, remove it from the containing component.
|
||||
if (fParticle[i].fType == XSParticleDecl.PARTICLE_EMPTY) {
|
||||
XSModelGroupImpl group = null;
|
||||
@ -4065,7 +4080,8 @@ public class XSDHandler {
|
||||
Element decl, XSDocumentInfo decl_Doc) {
|
||||
|
||||
if (DEBUG_NODE_POOL) {
|
||||
System.out.println("DOCUMENT NS:"+ currSchema.fTargetNamespace+" hashcode:"+ ((Object)currSchema.fSchemaElement).hashCode());
|
||||
System.out.println("DOCUMENT NS:" + currSchema.fTargetNamespace + " hashcode:" +
|
||||
((Object)currSchema.fSchemaElement).hashCode());
|
||||
}
|
||||
Object temp = decl_Doc;
|
||||
if (temp == null) {
|
||||
@ -4091,7 +4107,8 @@ public class XSDHandler {
|
||||
|
||||
// returns whether more than <annotation>s occur in children of elem
|
||||
private boolean nonAnnotationContent(Element elem) {
|
||||
for(Element child = DOMUtil.getFirstChildElement(elem); child != null; child = DOMUtil.getNextSiblingElement(child)) {
|
||||
for(Element child = DOMUtil.getFirstChildElement(elem); child != null;
|
||||
child = DOMUtil.getNextSiblingElement(child)) {
|
||||
if(!(DOMUtil.getLocalName(child).equals(SchemaSymbols.ELT_ANNOTATION))) return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
@ -17,7 +17,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.sun.org.apache.xerces.internal.jaxp.validation;
|
||||
|
||||
import com.sun.org.apache.xerces.internal.impl.Constants;
|
||||
@ -47,7 +46,8 @@ import jdk.xml.internal.JdkXmlUtils;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* <p>A validator helper for <code>StreamSource</code>s.</p>
|
||||
* <p>
|
||||
* A validator helper for <code>StreamSource</code>s.</p>
|
||||
*
|
||||
* @author Michael Glavassevich, IBM
|
||||
* @author <a href="mailto:Sunitha.Reddy@Sun.com">Sunitha Reddy</a>
|
||||
@ -55,74 +55,98 @@ import org.xml.sax.SAXException;
|
||||
final class StreamValidatorHelper implements ValidatorHelper {
|
||||
|
||||
// feature identifiers
|
||||
|
||||
/** Feature identifier: parser settings. */
|
||||
private static final String PARSER_SETTINGS =
|
||||
Constants.XERCES_FEATURE_PREFIX + Constants.PARSER_SETTINGS;
|
||||
/**
|
||||
* Feature identifier: parser settings.
|
||||
*/
|
||||
private static final String PARSER_SETTINGS
|
||||
= Constants.XERCES_FEATURE_PREFIX + Constants.PARSER_SETTINGS;
|
||||
|
||||
// property identifiers
|
||||
/**
|
||||
* Property identifier: entity resolver.
|
||||
*/
|
||||
private static final String ENTITY_RESOLVER
|
||||
= Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_RESOLVER_PROPERTY;
|
||||
|
||||
/** Property identifier: entity resolver. */
|
||||
private static final String ENTITY_RESOLVER =
|
||||
Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_RESOLVER_PROPERTY;
|
||||
/**
|
||||
* Property identifier: error handler.
|
||||
*/
|
||||
private static final String ERROR_HANDLER
|
||||
= Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_HANDLER_PROPERTY;
|
||||
|
||||
/** Property identifier: error handler. */
|
||||
private static final String ERROR_HANDLER =
|
||||
Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_HANDLER_PROPERTY;
|
||||
/**
|
||||
* Property identifier: error reporter.
|
||||
*/
|
||||
private static final String ERROR_REPORTER
|
||||
= Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY;
|
||||
|
||||
/** Property identifier: error reporter. */
|
||||
private static final String ERROR_REPORTER =
|
||||
Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY;
|
||||
/**
|
||||
* Property identifier: XML Schema validator.
|
||||
*/
|
||||
private static final String SCHEMA_VALIDATOR
|
||||
= Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_VALIDATOR_PROPERTY;
|
||||
|
||||
/** Property identifier: XML Schema validator. */
|
||||
private static final String SCHEMA_VALIDATOR =
|
||||
Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_VALIDATOR_PROPERTY;
|
||||
/**
|
||||
* Property identifier: symbol table.
|
||||
*/
|
||||
private static final String SYMBOL_TABLE
|
||||
= Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
|
||||
|
||||
/** Property identifier: symbol table. */
|
||||
private static final String SYMBOL_TABLE =
|
||||
Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
|
||||
/**
|
||||
* Property identifier: validation manager.
|
||||
*/
|
||||
private static final String VALIDATION_MANAGER
|
||||
= Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATION_MANAGER_PROPERTY;
|
||||
|
||||
/** Property identifier: validation manager. */
|
||||
private static final String VALIDATION_MANAGER =
|
||||
Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATION_MANAGER_PROPERTY;
|
||||
private static final String DEFAULT_TRANSFORMER_IMPL
|
||||
= "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl";
|
||||
|
||||
private static final String DEFAULT_TRANSFORMER_IMPL = "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl";
|
||||
|
||||
/** Property id: security manager. */
|
||||
private static final String SECURITY_MANAGER =
|
||||
Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;
|
||||
/**
|
||||
* Property id: security manager.
|
||||
*/
|
||||
private static final String SECURITY_MANAGER
|
||||
= Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;
|
||||
|
||||
//
|
||||
// Data
|
||||
//
|
||||
/**
|
||||
* SoftReference to parser configuration. *
|
||||
*/
|
||||
private SoftReference<XMLParserConfiguration> fConfiguration = new SoftReference<>(null);
|
||||
|
||||
/** SoftReference to parser configuration. **/
|
||||
private SoftReference fConfiguration = new SoftReference(null);
|
||||
|
||||
/** Schema validator. **/
|
||||
/**
|
||||
* Schema validator. *
|
||||
*/
|
||||
private com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator fSchemaValidator;
|
||||
|
||||
/** Component manager. **/
|
||||
/**
|
||||
* Component manager. *
|
||||
*/
|
||||
private XMLSchemaValidatorComponentManager fComponentManager;
|
||||
|
||||
private ValidatorHandlerImpl handler = null;
|
||||
|
||||
public StreamValidatorHelper(XMLSchemaValidatorComponentManager componentManager) {
|
||||
fComponentManager = componentManager;
|
||||
fSchemaValidator = (com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator) fComponentManager.getProperty(SCHEMA_VALIDATOR);
|
||||
fSchemaValidator = (com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator)
|
||||
fComponentManager.getProperty(SCHEMA_VALIDATOR);
|
||||
}
|
||||
|
||||
public void validate(Source source, Result result)
|
||||
throws SAXException, IOException {
|
||||
throws SAXException, IOException {
|
||||
if (result == null || result instanceof StreamResult) {
|
||||
final StreamSource streamSource = (StreamSource) source;
|
||||
TransformerHandler identityTransformerHandler ;
|
||||
TransformerHandler identityTransformerHandler;
|
||||
|
||||
if( result!=null ) {
|
||||
if (result != null) {
|
||||
try {
|
||||
SAXTransformerFactory tf = fComponentManager.getFeature(Constants.ORACLE_FEATURE_SERVICE_MECHANISM) ?
|
||||
(SAXTransformerFactory)SAXTransformerFactory.newInstance()
|
||||
: (SAXTransformerFactory) TransformerFactory.newInstance(DEFAULT_TRANSFORMER_IMPL, StreamValidatorHelper.class.getClassLoader());
|
||||
SAXTransformerFactory tf = fComponentManager.getFeature(
|
||||
Constants.ORACLE_FEATURE_SERVICE_MECHANISM) ?
|
||||
(SAXTransformerFactory) SAXTransformerFactory.newInstance() :
|
||||
(SAXTransformerFactory) TransformerFactory.newInstance(
|
||||
DEFAULT_TRANSFORMER_IMPL,
|
||||
StreamValidatorHelper.class.getClassLoader());
|
||||
identityTransformerHandler = tf.newTransformerHandler();
|
||||
} catch (TransformerConfigurationException e) {
|
||||
throw new TransformerFactoryConfigurationError(e);
|
||||
@ -133,13 +157,14 @@ final class StreamValidatorHelper implements ValidatorHelper {
|
||||
identityTransformerHandler.setResult(result);
|
||||
}
|
||||
|
||||
XMLInputSource input = new XMLInputSource(streamSource.getPublicId(), streamSource.getSystemId(), null, false);
|
||||
XMLInputSource input = new XMLInputSource(streamSource.getPublicId(),
|
||||
streamSource.getSystemId(), null, false);
|
||||
input.setByteStream(streamSource.getInputStream());
|
||||
input.setCharacterStream(streamSource.getReader());
|
||||
|
||||
// Gets the parser configuration. We'll create and initialize a new one, if we
|
||||
// haven't created one before or if the previous one was garbage collected.
|
||||
XMLParserConfiguration config = (XMLParserConfiguration) fConfiguration.get();
|
||||
XMLParserConfiguration config = fConfiguration.get();
|
||||
if (config == null) {
|
||||
config = initialize();
|
||||
}
|
||||
@ -155,18 +180,17 @@ final class StreamValidatorHelper implements ValidatorHelper {
|
||||
|
||||
try {
|
||||
config.parse(input);
|
||||
}
|
||||
catch (XMLParseException e) {
|
||||
} catch (XMLParseException e) {
|
||||
throw Util.toSAXParseException(e);
|
||||
}
|
||||
catch (XNIException e) {
|
||||
} catch (XNIException e) {
|
||||
throw Util.toSAXException(e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
throw new IllegalArgumentException(JAXPValidationMessageFormatter.formatMessage(fComponentManager.getLocale(),
|
||||
throw new IllegalArgumentException(JAXPValidationMessageFormatter.formatMessage(
|
||||
fComponentManager.getLocale(),
|
||||
"SourceResultMismatch",
|
||||
new Object [] {source.getClass().getName(), result.getClass().getName()}));
|
||||
new Object[]{source.getClass().getName(), result.getClass().getName()}));
|
||||
}
|
||||
|
||||
private XMLParserConfiguration initialize() {
|
||||
@ -197,7 +221,10 @@ final class StreamValidatorHelper implements ValidatorHelper {
|
||||
// Passing on the CatalogFeatures settings
|
||||
JdkXmlUtils.catalogFeaturesConfig2Config(fComponentManager, config);
|
||||
|
||||
fConfiguration = new SoftReference(config);
|
||||
config.setProperty(JdkXmlUtils.CDATA_CHUNK_SIZE,
|
||||
fComponentManager.getProperty(JdkXmlUtils.CDATA_CHUNK_SIZE));
|
||||
|
||||
fConfiguration = new SoftReference<>(config);
|
||||
return config;
|
||||
}
|
||||
|
||||
|
@ -165,6 +165,8 @@ public final class XMLSchemaFactory extends SchemaFactory {
|
||||
for (Feature f : Feature.values()) {
|
||||
fXMLSchemaLoader.setProperty(f.getPropertyName(), null);
|
||||
}
|
||||
|
||||
fXMLSchemaLoader.setProperty(JdkXmlUtils.CDATA_CHUNK_SIZE, JdkXmlUtils.CDATA_CHUNK_SIZE_DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -48,6 +48,7 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLComponent;
|
||||
import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
|
||||
import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
|
||||
import javax.xml.catalog.CatalogFeatures;
|
||||
import jdk.xml.internal.JdkXmlUtils;
|
||||
import org.w3c.dom.ls.LSResourceResolver;
|
||||
import org.xml.sax.ErrorHandler;
|
||||
|
||||
@ -311,6 +312,9 @@ final class XMLSchemaValidatorComponentManager extends ParserConfigurationSettin
|
||||
for( CatalogFeatures.Feature f : CatalogFeatures.Feature.values()) {
|
||||
setProperty(f.getPropertyName(), grammarContainer.getProperty(f.getPropertyName()));
|
||||
}
|
||||
|
||||
setProperty(JdkXmlUtils.CDATA_CHUNK_SIZE,
|
||||
grammarContainer.getProperty(JdkXmlUtils.CDATA_CHUNK_SIZE));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -345,7 +345,8 @@ public class DTDConfiguration
|
||||
JdkXmlUtils.CATALOG_DEFER,
|
||||
JdkXmlUtils.CATALOG_FILES,
|
||||
JdkXmlUtils.CATALOG_PREFER,
|
||||
JdkXmlUtils.CATALOG_RESOLVE
|
||||
JdkXmlUtils.CATALOG_RESOLVE,
|
||||
JdkXmlUtils.CDATA_CHUNK_SIZE
|
||||
};
|
||||
addRecognizedProperties(recognizedProperties);
|
||||
|
||||
@ -429,6 +430,8 @@ public class DTDConfiguration
|
||||
for( CatalogFeatures.Feature f : CatalogFeatures.Feature.values()) {
|
||||
setProperty(f.getPropertyName(), null);
|
||||
}
|
||||
|
||||
setProperty(JdkXmlUtils.CDATA_CHUNK_SIZE, JdkXmlUtils.CDATA_CHUNK_SIZE_DEFAULT);
|
||||
} // <init>(SymbolTable,XMLGrammarPool)
|
||||
|
||||
//
|
||||
|
@ -328,7 +328,8 @@ public class NonValidatingConfiguration
|
||||
JdkXmlUtils.CATALOG_DEFER,
|
||||
JdkXmlUtils.CATALOG_FILES,
|
||||
JdkXmlUtils.CATALOG_PREFER,
|
||||
JdkXmlUtils.CATALOG_RESOLVE
|
||||
JdkXmlUtils.CATALOG_RESOLVE,
|
||||
JdkXmlUtils.CDATA_CHUNK_SIZE
|
||||
};
|
||||
addRecognizedProperties(recognizedProperties);
|
||||
|
||||
@ -391,6 +392,8 @@ public class NonValidatingConfiguration
|
||||
for( CatalogFeatures.Feature f : CatalogFeatures.Feature.values()) {
|
||||
setProperty(f.getPropertyName(), null);
|
||||
}
|
||||
|
||||
setProperty(JdkXmlUtils.CDATA_CHUNK_SIZE, JdkXmlUtils.CDATA_CHUNK_SIZE_DEFAULT);
|
||||
} // <init>(SymbolTable,XMLGrammarPool)
|
||||
|
||||
//
|
||||
|
5
jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java
5
jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/parsers/XML11Configuration.java
@ -561,7 +561,8 @@ public class XML11Configuration extends ParserConfigurationSettings
|
||||
JdkXmlUtils.CATALOG_DEFER,
|
||||
JdkXmlUtils.CATALOG_FILES,
|
||||
JdkXmlUtils.CATALOG_PREFER,
|
||||
JdkXmlUtils.CATALOG_RESOLVE
|
||||
JdkXmlUtils.CATALOG_RESOLVE,
|
||||
JdkXmlUtils.CDATA_CHUNK_SIZE
|
||||
};
|
||||
addRecognizedProperties(recognizedProperties);
|
||||
|
||||
@ -629,6 +630,8 @@ public class XML11Configuration extends ParserConfigurationSettings
|
||||
fProperties.put(f.getPropertyName(), null);
|
||||
}
|
||||
|
||||
setProperty(JdkXmlUtils.CDATA_CHUNK_SIZE, JdkXmlUtils.CDATA_CHUNK_SIZE_DEFAULT);
|
||||
|
||||
fConfigUpdated = false;
|
||||
} // <init>(SymbolTable,XMLGrammarPool)
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
@ -17,9 +17,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* $Id: EmptySerializer.java,v 1.2.4.1 2005/09/15 08:15:16 suresh_emailid Exp $
|
||||
*/
|
||||
|
||||
package com.sun.org.apache.xml.internal.serializer;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -48,235 +46,224 @@ import org.xml.sax.SAXParseException;
|
||||
public class EmptySerializer implements SerializationHandler
|
||||
{
|
||||
protected static final String ERR = "EmptySerializer method not over-ridden";
|
||||
/**
|
||||
* @see SerializationHandler#asContentHandler()
|
||||
*/
|
||||
|
||||
protected void couldThrowIOException() throws IOException
|
||||
protected void couldThrowIOException() throws IOException {
|
||||
return; // don't do anything.
|
||||
}
|
||||
|
||||
protected void couldThrowSAXException() throws SAXException {
|
||||
return; // don't do anything.
|
||||
}
|
||||
|
||||
protected void couldThrowSAXException(char[] chars, int off, int len)
|
||||
throws SAXException
|
||||
{
|
||||
return; // don't do anything.
|
||||
}
|
||||
|
||||
protected void couldThrowSAXException() throws SAXException
|
||||
protected void couldThrowSAXException(String elemQName)
|
||||
throws SAXException
|
||||
{
|
||||
return; // don't do anything.
|
||||
}
|
||||
|
||||
protected void couldThrowSAXException(char[] chars, int off, int len) throws SAXException
|
||||
{
|
||||
return; // don't do anything.
|
||||
}
|
||||
|
||||
protected void couldThrowSAXException(String elemQName) throws SAXException
|
||||
{
|
||||
return; // don't do anything.
|
||||
}
|
||||
|
||||
void aMethodIsCalled()
|
||||
{
|
||||
|
||||
void aMethodIsCalled() {
|
||||
// throw new RuntimeException(err);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see SerializationHandler#asContentHandler()
|
||||
*/
|
||||
public ContentHandler asContentHandler() throws IOException
|
||||
{
|
||||
public ContentHandler asContentHandler() throws IOException {
|
||||
couldThrowIOException();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SerializationHandler#setContentHandler(org.xml.sax.ContentHandler)
|
||||
*/
|
||||
public void setContentHandler(ContentHandler ch)
|
||||
{
|
||||
public void setContentHandler(ContentHandler ch) {
|
||||
aMethodIsCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SerializationHandler#close()
|
||||
*/
|
||||
public void close()
|
||||
{
|
||||
public void close() {
|
||||
aMethodIsCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SerializationHandler#getOutputFormat()
|
||||
*/
|
||||
public Properties getOutputFormat()
|
||||
{
|
||||
public Properties getOutputFormat() {
|
||||
aMethodIsCalled();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SerializationHandler#getOutputStream()
|
||||
*/
|
||||
public OutputStream getOutputStream()
|
||||
{
|
||||
public OutputStream getOutputStream() {
|
||||
aMethodIsCalled();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SerializationHandler#getWriter()
|
||||
*/
|
||||
public Writer getWriter()
|
||||
{
|
||||
public Writer getWriter() {
|
||||
aMethodIsCalled();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SerializationHandler#reset()
|
||||
*/
|
||||
public boolean reset()
|
||||
{
|
||||
public boolean reset() {
|
||||
aMethodIsCalled();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SerializationHandler#serialize(org.w3c.dom.Node)
|
||||
*/
|
||||
public void serialize(Node node) throws IOException
|
||||
{
|
||||
public void serialize(Node node) throws IOException {
|
||||
couldThrowIOException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SerializationHandler#setCdataSectionElements(java.util.ArrayList<String>)
|
||||
*/
|
||||
public void setCdataSectionElements(ArrayList<String> URI_and_localNames)
|
||||
{
|
||||
public void setCdataSectionElements(ArrayList<String> URI_and_localNames) {
|
||||
aMethodIsCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SerializationHandler#setEscaping(boolean)
|
||||
*/
|
||||
public boolean setEscaping(boolean escape) throws SAXException
|
||||
{
|
||||
public boolean setEscaping(boolean escape) throws SAXException {
|
||||
couldThrowSAXException();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SerializationHandler#setIndent(boolean)
|
||||
*/
|
||||
public void setIndent(boolean indent)
|
||||
{
|
||||
public void setIndent(boolean indent) {
|
||||
aMethodIsCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SerializationHandler#setIndentAmount(int)
|
||||
*/
|
||||
public void setIndentAmount(int spaces)
|
||||
{
|
||||
public void setIndentAmount(int spaces) {
|
||||
aMethodIsCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SerializationHandler#setIsStandalone(boolean)
|
||||
*/
|
||||
public void setIsStandalone(boolean isStandalone)
|
||||
{
|
||||
public void setIsStandalone(boolean isStandalone) {
|
||||
aMethodIsCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SerializationHandler#setOutputFormat(java.util.Properties)
|
||||
*/
|
||||
public void setOutputFormat(Properties format)
|
||||
{
|
||||
public void setOutputFormat(Properties format) {
|
||||
aMethodIsCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SerializationHandler#setOutputStream(java.io.OutputStream)
|
||||
*/
|
||||
public void setOutputStream(OutputStream output)
|
||||
{
|
||||
public void setOutputStream(OutputStream output) {
|
||||
aMethodIsCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SerializationHandler#setVersion(java.lang.String)
|
||||
*/
|
||||
public void setVersion(String version)
|
||||
{
|
||||
public void setVersion(String version) {
|
||||
aMethodIsCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SerializationHandler#setWriter(java.io.Writer)
|
||||
*/
|
||||
public void setWriter(Writer writer)
|
||||
{
|
||||
public void setWriter(Writer writer) {
|
||||
aMethodIsCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SerializationHandler#setTransformer(javax.xml.transform.Transformer)
|
||||
*/
|
||||
public void setTransformer(Transformer transformer)
|
||||
{
|
||||
public void setTransformer(Transformer transformer) {
|
||||
aMethodIsCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SerializationHandler#getTransformer()
|
||||
*/
|
||||
public Transformer getTransformer()
|
||||
{
|
||||
public Transformer getTransformer() {
|
||||
aMethodIsCalled();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SerializationHandler#flushPending()
|
||||
*/
|
||||
public void flushPending() throws SAXException
|
||||
{
|
||||
public void flushPending() throws SAXException {
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ExtendedContentHandler#addAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void addAttribute(
|
||||
String uri,
|
||||
String localName,
|
||||
String rawName,
|
||||
String type,
|
||||
String value,
|
||||
boolean XSLAttribute)
|
||||
public void addAttribute(String uri, String localName, String rawName,
|
||||
String type, String value, boolean XSLAttribute)
|
||||
throws SAXException
|
||||
{
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ExtendedContentHandler#addAttributes(org.xml.sax.Attributes)
|
||||
*/
|
||||
public void addAttributes(Attributes atts) throws SAXException
|
||||
{
|
||||
public void addAttributes(Attributes atts) throws SAXException {
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ExtendedContentHandler#addAttribute(java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void addAttribute(String name, String value)
|
||||
{
|
||||
public void addAttribute(String name, String value) {
|
||||
aMethodIsCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ExtendedContentHandler#characters(java.lang.String)
|
||||
*/
|
||||
public void characters(String chars) throws SAXException
|
||||
{
|
||||
public void characters(String chars) throws SAXException {
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ExtendedContentHandler#endElement(java.lang.String)
|
||||
*/
|
||||
public void endElement(String elemName) throws SAXException
|
||||
{
|
||||
public void endElement(String elemName) throws SAXException {
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ExtendedContentHandler#startDocument()
|
||||
*/
|
||||
public void startDocument() throws SAXException
|
||||
{
|
||||
public void startDocument() throws SAXException {
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ExtendedContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
@ -285,13 +272,14 @@ public class EmptySerializer implements SerializationHandler
|
||||
{
|
||||
couldThrowSAXException(qName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ExtendedContentHandler#startElement(java.lang.String)
|
||||
*/
|
||||
public void startElement(String qName) throws SAXException
|
||||
{
|
||||
public void startElement(String qName) throws SAXException {
|
||||
couldThrowSAXException(qName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ExtendedContentHandler#namespaceAfterStartElement(java.lang.String, java.lang.String)
|
||||
*/
|
||||
@ -303,68 +291,67 @@ public class EmptySerializer implements SerializationHandler
|
||||
/**
|
||||
* @see ExtendedContentHandler#startPrefixMapping(java.lang.String, java.lang.String, boolean)
|
||||
*/
|
||||
public boolean startPrefixMapping(
|
||||
String prefix,
|
||||
String uri,
|
||||
boolean shouldFlush)
|
||||
public boolean startPrefixMapping(String prefix, String uri,
|
||||
boolean shouldFlush)
|
||||
throws SAXException
|
||||
{
|
||||
couldThrowSAXException();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ExtendedContentHandler#entityReference(java.lang.String)
|
||||
*/
|
||||
public void entityReference(String entityName) throws SAXException
|
||||
{
|
||||
public void entityReference(String entityName) throws SAXException {
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ExtendedContentHandler#getNamespaceMappings()
|
||||
*/
|
||||
public NamespaceMappings getNamespaceMappings()
|
||||
{
|
||||
public NamespaceMappings getNamespaceMappings() {
|
||||
aMethodIsCalled();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ExtendedContentHandler#getPrefix(java.lang.String)
|
||||
*/
|
||||
public String getPrefix(String uri)
|
||||
{
|
||||
public String getPrefix(String uri) {
|
||||
aMethodIsCalled();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ExtendedContentHandler#getNamespaceURI(java.lang.String, boolean)
|
||||
*/
|
||||
public String getNamespaceURI(String name, boolean isElement)
|
||||
{
|
||||
public String getNamespaceURI(String name, boolean isElement) {
|
||||
aMethodIsCalled();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ExtendedContentHandler#getNamespaceURIFromPrefix(java.lang.String)
|
||||
*/
|
||||
public String getNamespaceURIFromPrefix(String prefix)
|
||||
{
|
||||
public String getNamespaceURIFromPrefix(String prefix) {
|
||||
aMethodIsCalled();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ContentHandler#setDocumentLocator(org.xml.sax.Locator)
|
||||
*/
|
||||
public void setDocumentLocator(Locator arg0)
|
||||
{
|
||||
public void setDocumentLocator(Locator arg0) {
|
||||
aMethodIsCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ContentHandler#endDocument()
|
||||
*/
|
||||
public void endDocument() throws SAXException
|
||||
{
|
||||
public void endDocument() throws SAXException {
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String, java.lang.String)
|
||||
*/
|
||||
@ -373,25 +360,24 @@ public class EmptySerializer implements SerializationHandler
|
||||
{
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ContentHandler#endPrefixMapping(java.lang.String)
|
||||
*/
|
||||
public void endPrefixMapping(String arg0) throws SAXException
|
||||
{
|
||||
public void endPrefixMapping(String arg0) throws SAXException {
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
|
||||
*/
|
||||
public void startElement(
|
||||
String arg0,
|
||||
String arg1,
|
||||
String arg2,
|
||||
Attributes arg3)
|
||||
public void startElement(String arg0, String arg1, String arg2,
|
||||
Attributes arg3)
|
||||
throws SAXException
|
||||
{
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
@ -400,13 +386,14 @@ public class EmptySerializer implements SerializationHandler
|
||||
{
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ContentHandler#characters(char[], int, int)
|
||||
*/
|
||||
public void characters(char[] arg0, int arg1, int arg2) throws SAXException
|
||||
{
|
||||
public void characters(char[] arg0, int arg1, int arg2) throws SAXException {
|
||||
couldThrowSAXException(arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
|
||||
*/
|
||||
@ -415,6 +402,7 @@ public class EmptySerializer implements SerializationHandler
|
||||
{
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ContentHandler#processingInstruction(java.lang.String, java.lang.String)
|
||||
*/
|
||||
@ -423,20 +411,21 @@ public class EmptySerializer implements SerializationHandler
|
||||
{
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ContentHandler#skippedEntity(java.lang.String)
|
||||
*/
|
||||
public void skippedEntity(String arg0) throws SAXException
|
||||
{
|
||||
public void skippedEntity(String arg0) throws SAXException {
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ExtendedLexicalHandler#comment(java.lang.String)
|
||||
*/
|
||||
public void comment(String comment) throws SAXException
|
||||
{
|
||||
public void comment(String comment) throws SAXException {
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ext.LexicalHandler#startDTD(java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
@ -445,189 +434,187 @@ public class EmptySerializer implements SerializationHandler
|
||||
{
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ext.LexicalHandler#endDTD()
|
||||
*/
|
||||
public void endDTD() throws SAXException
|
||||
{
|
||||
public void endDTD() throws SAXException {
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ext.LexicalHandler#startEntity(java.lang.String)
|
||||
*/
|
||||
public void startEntity(String arg0) throws SAXException
|
||||
{
|
||||
public void startEntity(String arg0) throws SAXException {
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ext.LexicalHandler#endEntity(java.lang.String)
|
||||
*/
|
||||
public void endEntity(String arg0) throws SAXException
|
||||
{
|
||||
public void endEntity(String arg0) throws SAXException {
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ext.LexicalHandler#startCDATA()
|
||||
*/
|
||||
public void startCDATA() throws SAXException
|
||||
{
|
||||
public void startCDATA() throws SAXException {
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ext.LexicalHandler#endCDATA()
|
||||
*/
|
||||
public void endCDATA() throws SAXException
|
||||
{
|
||||
public void endCDATA() throws SAXException {
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ext.LexicalHandler#comment(char[], int, int)
|
||||
*/
|
||||
public void comment(char[] arg0, int arg1, int arg2) throws SAXException
|
||||
{
|
||||
public void comment(char[] arg0, int arg1, int arg2) throws SAXException {
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see XSLOutputAttributes#getDoctypePublic()
|
||||
*/
|
||||
public String getDoctypePublic()
|
||||
{
|
||||
public String getDoctypePublic() {
|
||||
aMethodIsCalled();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see XSLOutputAttributes#getDoctypeSystem()
|
||||
*/
|
||||
public String getDoctypeSystem()
|
||||
{
|
||||
public String getDoctypeSystem() {
|
||||
aMethodIsCalled();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see XSLOutputAttributes#getEncoding()
|
||||
*/
|
||||
public String getEncoding()
|
||||
{
|
||||
public String getEncoding() {
|
||||
aMethodIsCalled();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see XSLOutputAttributes#getIndent()
|
||||
*/
|
||||
public boolean getIndent()
|
||||
{
|
||||
public boolean getIndent() {
|
||||
aMethodIsCalled();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see XSLOutputAttributes#getIndentAmount()
|
||||
*/
|
||||
public int getIndentAmount()
|
||||
{
|
||||
public int getIndentAmount() {
|
||||
aMethodIsCalled();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see XSLOutputAttributes#getMediaType()
|
||||
*/
|
||||
public String getMediaType()
|
||||
{
|
||||
public String getMediaType() {
|
||||
aMethodIsCalled();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see XSLOutputAttributes#getOmitXMLDeclaration()
|
||||
*/
|
||||
public boolean getOmitXMLDeclaration()
|
||||
{
|
||||
public boolean getOmitXMLDeclaration() {
|
||||
aMethodIsCalled();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see XSLOutputAttributes#getStandalone()
|
||||
*/
|
||||
public String getStandalone()
|
||||
{
|
||||
public String getStandalone() {
|
||||
aMethodIsCalled();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see XSLOutputAttributes#getVersion()
|
||||
*/
|
||||
public String getVersion()
|
||||
{
|
||||
public String getVersion() {
|
||||
aMethodIsCalled();
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see XSLOutputAttributes#setDoctype(java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void setDoctype(String system, String pub)
|
||||
{
|
||||
public void setDoctype(String system, String pub) {
|
||||
aMethodIsCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see XSLOutputAttributes#setDoctypePublic(java.lang.String)
|
||||
*/
|
||||
public void setDoctypePublic(String doctype)
|
||||
{
|
||||
public void setDoctypePublic(String doctype) {
|
||||
aMethodIsCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see XSLOutputAttributes#setDoctypeSystem(java.lang.String)
|
||||
*/
|
||||
public void setDoctypeSystem(String doctype)
|
||||
{
|
||||
public void setDoctypeSystem(String doctype) {
|
||||
aMethodIsCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see XSLOutputAttributes#setEncoding(java.lang.String)
|
||||
*/
|
||||
public void setEncoding(String encoding)
|
||||
{
|
||||
public void setEncoding(String encoding) {
|
||||
aMethodIsCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see XSLOutputAttributes#setMediaType(java.lang.String)
|
||||
*/
|
||||
public void setMediaType(String mediatype)
|
||||
{
|
||||
public void setMediaType(String mediatype) {
|
||||
aMethodIsCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see XSLOutputAttributes#setOmitXMLDeclaration(boolean)
|
||||
*/
|
||||
public void setOmitXMLDeclaration(boolean b)
|
||||
{
|
||||
public void setOmitXMLDeclaration(boolean b) {
|
||||
aMethodIsCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see XSLOutputAttributes#setStandalone(java.lang.String)
|
||||
*/
|
||||
public void setStandalone(String standalone)
|
||||
{
|
||||
public void setStandalone(String standalone) {
|
||||
aMethodIsCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ext.DeclHandler#elementDecl(java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void elementDecl(String arg0, String arg1) throws SAXException
|
||||
{
|
||||
public void elementDecl(String arg0, String arg1) throws SAXException {
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ext.DeclHandler#attributeDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void attributeDecl(
|
||||
String arg0,
|
||||
String arg1,
|
||||
String arg2,
|
||||
String arg3,
|
||||
String arg4)
|
||||
public void attributeDecl(String arg0, String arg1, String arg2,
|
||||
String arg3, String arg4)
|
||||
throws SAXException
|
||||
{
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ext.DeclHandler#internalEntityDecl(java.lang.String, java.lang.String)
|
||||
*/
|
||||
@ -636,6 +623,7 @@ public class EmptySerializer implements SerializationHandler
|
||||
{
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ext.DeclHandler#externalEntityDecl(java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
@ -644,32 +632,32 @@ public class EmptySerializer implements SerializationHandler
|
||||
{
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
|
||||
*/
|
||||
public void warning(SAXParseException arg0) throws SAXException
|
||||
{
|
||||
public void warning(SAXParseException arg0) throws SAXException {
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
|
||||
*/
|
||||
public void error(SAXParseException arg0) throws SAXException
|
||||
{
|
||||
public void error(SAXParseException arg0) throws SAXException {
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
|
||||
*/
|
||||
public void fatalError(SAXParseException arg0) throws SAXException
|
||||
{
|
||||
public void fatalError(SAXParseException arg0) throws SAXException {
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Serializer#asDOMSerializer()
|
||||
*/
|
||||
public DOMSerializer asDOMSerializer() throws IOException
|
||||
{
|
||||
public DOMSerializer asDOMSerializer() throws IOException {
|
||||
couldThrowIOException();
|
||||
return null;
|
||||
}
|
||||
@ -684,8 +672,7 @@ public class EmptySerializer implements SerializationHandler
|
||||
/**
|
||||
* @see ExtendedContentHandler#setSourceLocator(javax.xml.transform.SourceLocator)
|
||||
*/
|
||||
public void setSourceLocator(SourceLocator locator)
|
||||
{
|
||||
public void setSourceLocator(SourceLocator locator) {
|
||||
aMethodIsCalled();
|
||||
}
|
||||
|
||||
@ -701,30 +688,30 @@ public class EmptySerializer implements SerializationHandler
|
||||
/**
|
||||
* @see ExtendedContentHandler#characters(org.w3c.dom.Node)
|
||||
*/
|
||||
public void characters(Node node) throws SAXException
|
||||
{
|
||||
public void characters(Node node) throws SAXException {
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ExtendedContentHandler#addXSLAttribute(java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void addXSLAttribute(String qName, String value, String uri)
|
||||
{
|
||||
public void addXSLAttribute(String qName, String value, String uri) {
|
||||
aMethodIsCalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ExtendedContentHandler#addAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void addAttribute(String uri, String localName, String rawName, String type, String value) throws SAXException
|
||||
{
|
||||
public void addAttribute(String uri, String localName, String rawName,
|
||||
String type, String value) throws SAXException {
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.DTDHandler#notationDecl(java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void notationDecl(String arg0, String arg1, String arg2) throws SAXException
|
||||
public void notationDecl(String arg0, String arg1, String arg2)
|
||||
throws SAXException
|
||||
{
|
||||
couldThrowSAXException();
|
||||
}
|
||||
@ -732,12 +719,8 @@ public class EmptySerializer implements SerializationHandler
|
||||
/**
|
||||
* @see org.xml.sax.DTDHandler#unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void unparsedEntityDecl(
|
||||
String arg0,
|
||||
String arg1,
|
||||
String arg2,
|
||||
String arg3)
|
||||
throws SAXException {
|
||||
public void unparsedEntityDecl(String arg0, String arg1, String arg2,
|
||||
String arg3) throws SAXException {
|
||||
couldThrowSAXException();
|
||||
}
|
||||
|
||||
@ -746,10 +729,8 @@ public class EmptySerializer implements SerializationHandler
|
||||
*/
|
||||
public void setDTDEntityExpansion(boolean expand) {
|
||||
aMethodIsCalled();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public String getOutputProperty(String name) {
|
||||
aMethodIsCalled();
|
||||
return null;
|
||||
@ -762,19 +743,16 @@ public class EmptySerializer implements SerializationHandler
|
||||
|
||||
public void setOutputProperty(String name, String val) {
|
||||
aMethodIsCalled();
|
||||
|
||||
}
|
||||
|
||||
public void setOutputPropertyDefault(String name, String val) {
|
||||
aMethodIsCalled();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.apache.xml.serializer.Serializer#asDOM3Serializer()
|
||||
*/
|
||||
public Object asDOM3Serializer() throws IOException
|
||||
{
|
||||
public Object asDOM3Serializer() throws IOException {
|
||||
couldThrowIOException();
|
||||
return null;
|
||||
}
|
||||
|
@ -1,15 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
@ -19,22 +17,18 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* $Id: SerializerBase.java,v 1.5 2006/04/14 12:09:19 sunithareddy Exp $
|
||||
*/
|
||||
|
||||
package com.sun.org.apache.xml.internal.serializer;
|
||||
|
||||
import com.sun.org.apache.xml.internal.serializer.utils.MsgKey;
|
||||
import com.sun.org.apache.xml.internal.serializer.utils.Utils;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.SourceLocator;
|
||||
import javax.xml.transform.Transformer;
|
||||
|
||||
import com.sun.org.apache.xml.internal.serializer.utils.MsgKey;
|
||||
import com.sun.org.apache.xml.internal.serializer.utils.Utils;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.Locator;
|
||||
@ -42,7 +36,6 @@ import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
import org.xml.sax.ext.Locator2;
|
||||
|
||||
|
||||
/**
|
||||
* This class acts as a base class for the XML "serializers"
|
||||
* and the stream serializers.
|
||||
@ -54,7 +47,6 @@ public abstract class SerializerBase
|
||||
implements SerializationHandler, SerializerConstants
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* To fire off the end element trace event
|
||||
* @param name Name of element
|
||||
@ -62,8 +54,7 @@ public abstract class SerializerBase
|
||||
protected void fireEndElem(String name)
|
||||
throws org.xml.sax.SAXException
|
||||
{
|
||||
if (m_tracer != null)
|
||||
{
|
||||
if (m_tracer != null) {
|
||||
flushMyWriter();
|
||||
m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_ENDELEMENT,name, (Attributes)null);
|
||||
}
|
||||
@ -78,8 +69,7 @@ public abstract class SerializerBase
|
||||
protected void fireCharEvent(char[] chars, int start, int length)
|
||||
throws org.xml.sax.SAXException
|
||||
{
|
||||
if (m_tracer != null)
|
||||
{
|
||||
if (m_tracer != null) {
|
||||
flushMyWriter();
|
||||
m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_CHARACTERS, chars, start,length);
|
||||
}
|
||||
@ -87,7 +77,7 @@ public abstract class SerializerBase
|
||||
|
||||
/**
|
||||
* true if we still need to call startDocumentInternal()
|
||||
*/
|
||||
*/
|
||||
protected boolean m_needToCallStartDocument = true;
|
||||
|
||||
/** True if a trailing "]]>" still needs to be written to be
|
||||
@ -150,6 +140,7 @@ public abstract class SerializerBase
|
||||
* Flag to tell if indenting (pretty-printing) is on.
|
||||
*/
|
||||
protected boolean m_doIndent = false;
|
||||
|
||||
/**
|
||||
* Amount to indent.
|
||||
*/
|
||||
@ -186,7 +177,6 @@ public abstract class SerializerBase
|
||||
|
||||
protected SourceLocator m_sourceLocator;
|
||||
|
||||
|
||||
/**
|
||||
* The writer to send output to. This field is only used in the ToStream
|
||||
* serializers, but exists here just so that the fireStartDoc() and
|
||||
@ -227,11 +217,9 @@ public abstract class SerializerBase
|
||||
*
|
||||
* @see ExtendedLexicalHandler#comment(String)
|
||||
*/
|
||||
public void comment(String data) throws SAXException
|
||||
{
|
||||
public void comment(String data) throws SAXException {
|
||||
final int length = data.length();
|
||||
if (length > m_charsBuff.length)
|
||||
{
|
||||
if (length > m_charsBuff.length) {
|
||||
m_charsBuff = new char[length * 2 + 1];
|
||||
}
|
||||
data.getChars(0, length, m_charsBuff, 0);
|
||||
@ -248,10 +236,7 @@ public abstract class SerializerBase
|
||||
* XML file, it sometimes generates a NS prefix of the form "ns?" for
|
||||
* an attribute.
|
||||
*/
|
||||
protected String patchName(String qname)
|
||||
{
|
||||
|
||||
|
||||
protected String patchName(String qname) {
|
||||
final int lastColon = qname.lastIndexOf(':');
|
||||
|
||||
if (lastColon > 0) {
|
||||
@ -259,12 +244,11 @@ public abstract class SerializerBase
|
||||
final String prefix = qname.substring(0, firstColon);
|
||||
final String localName = qname.substring(lastColon + 1);
|
||||
|
||||
// If uri is "" then ignore prefix
|
||||
// If uri is "" then ignore prefix
|
||||
final String uri = m_prefixMap.lookupNamespace(prefix);
|
||||
if (uri != null && uri.length() == 0) {
|
||||
return localName;
|
||||
}
|
||||
else if (firstColon != lastColon) {
|
||||
} else if (firstColon != lastColon) {
|
||||
return prefix + ':' + localName;
|
||||
}
|
||||
}
|
||||
@ -277,8 +261,7 @@ public abstract class SerializerBase
|
||||
* @param qname the qualified name
|
||||
* @return the name, but excluding any prefix and colon.
|
||||
*/
|
||||
protected static String getLocalName(String qname)
|
||||
{
|
||||
protected static String getLocalName(String qname) {
|
||||
final int col = qname.lastIndexOf(':');
|
||||
return (col > 0) ? qname.substring(col + 1) : qname;
|
||||
}
|
||||
@ -309,8 +292,7 @@ public abstract class SerializerBase
|
||||
* during the invocation of the events in this interface. The
|
||||
* application should not attempt to use it at any other time.</p>
|
||||
*/
|
||||
public void setDocumentLocator(Locator locator)
|
||||
{
|
||||
public void setDocumentLocator(Locator locator) {
|
||||
m_locator = locator;
|
||||
}
|
||||
|
||||
@ -332,20 +314,13 @@ public abstract class SerializerBase
|
||||
* @param XSLAttribute true if this attribute is coming from an xsl:attriute element
|
||||
* @see ExtendedContentHandler#addAttribute(String, String, String, String, String)
|
||||
*/
|
||||
public void addAttribute(
|
||||
String uri,
|
||||
String localName,
|
||||
String rawName,
|
||||
String type,
|
||||
String value,
|
||||
boolean XSLAttribute)
|
||||
public void addAttribute(String uri, String localName, String rawName,
|
||||
String type, String value, boolean XSLAttribute)
|
||||
throws SAXException
|
||||
{
|
||||
if (m_elemContext.m_startTagOpen)
|
||||
{
|
||||
if (m_elemContext.m_startTagOpen) {
|
||||
addAttributeAlways(uri, localName, rawName, type, value, XSLAttribute);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -362,51 +337,32 @@ public abstract class SerializerBase
|
||||
* @return true if the attribute was added,
|
||||
* false if an existing value was replaced.
|
||||
*/
|
||||
public boolean addAttributeAlways(
|
||||
String uri,
|
||||
String localName,
|
||||
String rawName,
|
||||
String type,
|
||||
String value,
|
||||
boolean XSLAttribute)
|
||||
public boolean addAttributeAlways(String uri, String localName, String rawName,
|
||||
String type, String value, boolean XSLAttribute)
|
||||
{
|
||||
boolean was_added;
|
||||
// final int index =
|
||||
// (localName == null || uri == null) ?
|
||||
// m_attributes.getIndex(rawName):m_attributes.getIndex(uri, localName);
|
||||
int index;
|
||||
// if (localName == null || uri == null){
|
||||
// index = m_attributes.getIndex(rawName);
|
||||
// }
|
||||
// else {
|
||||
// index = m_attributes.getIndex(uri, localName);
|
||||
// }
|
||||
|
||||
if (localName == null || uri == null || uri.length() == 0)
|
||||
index = m_attributes.getIndex(rawName);
|
||||
else {
|
||||
index = m_attributes.getIndex(uri,localName);
|
||||
}
|
||||
if (index >= 0)
|
||||
{
|
||||
/* We've seen the attribute before.
|
||||
* We may have a null uri or localName, but all
|
||||
* we really want to re-set is the value anyway.
|
||||
*/
|
||||
m_attributes.setValue(index,value);
|
||||
was_added = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// the attribute doesn't exist yet, create it
|
||||
m_attributes.addAttribute(uri, localName, rawName, type, value);
|
||||
was_added = true;
|
||||
}
|
||||
return was_added;
|
||||
int index;
|
||||
|
||||
if (localName == null || uri == null || uri.length() == 0)
|
||||
index = m_attributes.getIndex(rawName);
|
||||
else {
|
||||
index = m_attributes.getIndex(uri,localName);
|
||||
}
|
||||
if (index >= 0) {
|
||||
/* We've seen the attribute before.
|
||||
* We may have a null uri or localName, but all
|
||||
* we really want to re-set is the value anyway.
|
||||
*/
|
||||
m_attributes.setValue(index,value);
|
||||
was_added = false;
|
||||
} else {
|
||||
// the attribute doesn't exist yet, create it
|
||||
m_attributes.addAttribute(uri, localName, rawName, type, value);
|
||||
was_added = true;
|
||||
}
|
||||
return was_added;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds the given attribute to the set of collected attributes,
|
||||
* but only if there is a currently open element.
|
||||
@ -414,16 +370,14 @@ public abstract class SerializerBase
|
||||
* @param name the attribute's qualified name
|
||||
* @param value the value of the attribute
|
||||
*/
|
||||
public void addAttribute(String name, final String value)
|
||||
{
|
||||
if (m_elemContext.m_startTagOpen)
|
||||
{
|
||||
public void addAttribute(String name, final String value) {
|
||||
if (m_elemContext.m_startTagOpen) {
|
||||
final String patchedName = patchName(name);
|
||||
final String localName = getLocalName(patchedName);
|
||||
final String uri = getNamespaceURI(patchedName, false);
|
||||
|
||||
addAttributeAlways(uri,localName, patchedName, "CDATA", value, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -434,15 +388,13 @@ public abstract class SerializerBase
|
||||
* @param value the value of the attribute
|
||||
* @param uri the URI that the prefix of the name points to
|
||||
*/
|
||||
public void addXSLAttribute(String name, final String value, final String uri)
|
||||
{
|
||||
if (m_elemContext.m_startTagOpen)
|
||||
{
|
||||
public void addXSLAttribute(String name, final String value, final String uri) {
|
||||
if (m_elemContext.m_startTagOpen) {
|
||||
final String patchedName = patchName(name);
|
||||
final String localName = getLocalName(patchedName);
|
||||
|
||||
addAttributeAlways(uri,localName, patchedName, "CDATA", value, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -451,12 +403,9 @@ public abstract class SerializerBase
|
||||
* is currently open.
|
||||
* @param atts List of attributes to add to this list
|
||||
*/
|
||||
public void addAttributes(Attributes atts) throws SAXException
|
||||
{
|
||||
|
||||
public void addAttributes(Attributes atts) throws SAXException {
|
||||
int nAtts = atts.getLength();
|
||||
for (int i = 0; i < nAtts; i++)
|
||||
{
|
||||
for (int i = 0; i < nAtts; i++) {
|
||||
String uri = atts.getURI(i);
|
||||
|
||||
if (null == uri)
|
||||
@ -469,7 +418,6 @@ public abstract class SerializerBase
|
||||
atts.getType(i),
|
||||
atts.getValue(i),
|
||||
false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -482,8 +430,7 @@ public abstract class SerializerBase
|
||||
* or null if the serializer is not SAX 2 capable
|
||||
* @throws IOException An I/O exception occured
|
||||
*/
|
||||
public ContentHandler asContentHandler() throws IOException
|
||||
{
|
||||
public ContentHandler asContentHandler() throws IOException {
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -494,8 +441,7 @@ public abstract class SerializerBase
|
||||
* @throws org.xml.sax.SAXException The application may raise an exception.
|
||||
* @see #startEntity
|
||||
*/
|
||||
public void endEntity(String name) throws org.xml.sax.SAXException
|
||||
{
|
||||
public void endEntity(String name) throws org.xml.sax.SAXException {
|
||||
if (name.equals("[dtd]"))
|
||||
m_inExternalDTD = false;
|
||||
m_inEntityRef = false;
|
||||
@ -509,27 +455,24 @@ public abstract class SerializerBase
|
||||
* ToStream serializers, not ToSAXHandler serializers.
|
||||
* @see ToStream
|
||||
*/
|
||||
public void close()
|
||||
{
|
||||
public void close() {
|
||||
// do nothing (base behavior)
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize global variables
|
||||
*/
|
||||
protected void initCDATA()
|
||||
{
|
||||
protected void initCDATA() {
|
||||
// CDATA stack
|
||||
// _cdataStack = new Stack();
|
||||
// _cdataStack.push(new Integer(-1)); // push dummy value
|
||||
// _cdataStack = new Stack();
|
||||
// _cdataStack.push(new Integer(-1)); // push dummy value
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the character encoding to be used in the output document.
|
||||
* @return the character encoding to be used in the output document.
|
||||
*/
|
||||
public String getEncoding()
|
||||
{
|
||||
public String getEncoding() {
|
||||
return getOutputProperty(OutputKeys.ENCODING);
|
||||
}
|
||||
|
||||
@ -537,8 +480,7 @@ public abstract class SerializerBase
|
||||
* Sets the character encoding coming from the xsl:output encoding stylesheet attribute.
|
||||
* @param m_encoding the character encoding
|
||||
*/
|
||||
public void setEncoding(String encoding)
|
||||
{
|
||||
public void setEncoding(String encoding) {
|
||||
setOutputProperty(OutputKeys.ENCODING,encoding);
|
||||
}
|
||||
|
||||
@ -547,19 +489,16 @@ public abstract class SerializerBase
|
||||
* @param b true if the XML declaration is to be omitted from the output
|
||||
* document.
|
||||
*/
|
||||
public void setOmitXMLDeclaration(boolean b)
|
||||
{
|
||||
public void setOmitXMLDeclaration(boolean b) {
|
||||
String val = b ? "yes":"no";
|
||||
setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,val);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return true if the XML declaration is to be omitted from the output
|
||||
* document.
|
||||
*/
|
||||
public boolean getOmitXMLDeclaration()
|
||||
{
|
||||
public boolean getOmitXMLDeclaration() {
|
||||
return m_shouldNotWriteXMLHeader;
|
||||
}
|
||||
|
||||
@ -625,8 +564,7 @@ public abstract class SerializerBase
|
||||
* document. This method remembers if the value was explicitly set using
|
||||
* this method, verses if the value is the default value.
|
||||
*/
|
||||
public void setStandalone(String standalone)
|
||||
{
|
||||
public void setStandalone(String standalone) {
|
||||
setOutputProperty(OutputKeys.STANDALONE, standalone);
|
||||
}
|
||||
|
||||
@ -635,8 +573,7 @@ public abstract class SerializerBase
|
||||
* default or explicite setting.
|
||||
* @param standalone "yes" | "no"
|
||||
*/
|
||||
protected void setStandaloneInternal(String standalone)
|
||||
{
|
||||
protected void setStandaloneInternal(String standalone) {
|
||||
if ("yes".equals(standalone))
|
||||
m_standalone = "yes";
|
||||
else
|
||||
@ -650,8 +587,7 @@ public abstract class SerializerBase
|
||||
* be included in the output document.
|
||||
* @see XSLOutputAttributes#getStandalone()
|
||||
*/
|
||||
public String getStandalone()
|
||||
{
|
||||
public String getStandalone() {
|
||||
return m_standalone;
|
||||
}
|
||||
|
||||
@ -659,8 +595,7 @@ public abstract class SerializerBase
|
||||
* @return true if the output document should be indented to visually
|
||||
* indicate its structure.
|
||||
*/
|
||||
public boolean getIndent()
|
||||
{
|
||||
public boolean getIndent() {
|
||||
return m_doIndent;
|
||||
}
|
||||
/**
|
||||
@ -669,8 +604,7 @@ public abstract class SerializerBase
|
||||
* @return the mediatype the media-type or MIME type associated with the
|
||||
* output document.
|
||||
*/
|
||||
public String getMediaType()
|
||||
{
|
||||
public String getMediaType() {
|
||||
return m_mediatype;
|
||||
}
|
||||
|
||||
@ -678,8 +612,7 @@ public abstract class SerializerBase
|
||||
* Gets the version of the output format.
|
||||
* @return the version of the output format.
|
||||
*/
|
||||
public String getVersion()
|
||||
{
|
||||
public String getVersion() {
|
||||
return m_version;
|
||||
}
|
||||
|
||||
@ -688,8 +621,7 @@ public abstract class SerializerBase
|
||||
* @param version the version of the output format.
|
||||
* @see SerializationHandler#setVersion(String)
|
||||
*/
|
||||
public void setVersion(String version)
|
||||
{
|
||||
public void setVersion(String version) {
|
||||
setOutputProperty(OutputKeys.VERSION, version);
|
||||
}
|
||||
|
||||
@ -700,16 +632,14 @@ public abstract class SerializerBase
|
||||
* @see javax.xml.transform.OutputKeys#MEDIA_TYPE
|
||||
* @see SerializationHandler#setMediaType(String)
|
||||
*/
|
||||
public void setMediaType(String mediaType)
|
||||
{
|
||||
public void setMediaType(String mediaType) {
|
||||
setOutputProperty(OutputKeys.MEDIA_TYPE,mediaType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of spaces to indent for each indentation level.
|
||||
*/
|
||||
public int getIndentAmount()
|
||||
{
|
||||
public int getIndentAmount() {
|
||||
return m_indentAmount;
|
||||
}
|
||||
|
||||
@ -717,8 +647,7 @@ public abstract class SerializerBase
|
||||
* Sets the indentation amount.
|
||||
* @param m_indentAmount The m_indentAmount to set
|
||||
*/
|
||||
public void setIndentAmount(int m_indentAmount)
|
||||
{
|
||||
public void setIndentAmount(int m_indentAmount) {
|
||||
this.m_indentAmount = m_indentAmount;
|
||||
}
|
||||
|
||||
@ -729,8 +658,7 @@ public abstract class SerializerBase
|
||||
* visually indicate its structure.
|
||||
* @see XSLOutputAttributes#setIndent(boolean)
|
||||
*/
|
||||
public void setIndent(boolean doIndent)
|
||||
{
|
||||
public void setIndent(boolean doIndent) {
|
||||
String val = doIndent ? "yes":"no";
|
||||
setOutputProperty(OutputKeys.INDENT,val);
|
||||
}
|
||||
@ -740,8 +668,7 @@ public abstract class SerializerBase
|
||||
* @param isStandalone true if the ORACLE_IS_STANDALONE is set to yes
|
||||
* @see OutputPropertiesFactory ORACLE_IS_STANDALONE
|
||||
*/
|
||||
public void setIsStandalone(boolean isStandalone)
|
||||
{
|
||||
public void setIsStandalone(boolean isStandalone) {
|
||||
m_isStandalone = isStandalone;
|
||||
}
|
||||
|
||||
@ -772,8 +699,7 @@ public abstract class SerializerBase
|
||||
* @throws IOException An I/O exception occured
|
||||
* @see Serializer#asDOMSerializer()
|
||||
*/
|
||||
public DOMSerializer asDOMSerializer() throws IOException
|
||||
{
|
||||
public DOMSerializer asDOMSerializer() throws IOException {
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -785,8 +711,7 @@ public abstract class SerializerBase
|
||||
*
|
||||
* @return true if strings are equal.
|
||||
*/
|
||||
private static final boolean subPartMatch(String p, String t)
|
||||
{
|
||||
private static final boolean subPartMatch(String p, String t) {
|
||||
return (p == t) || ((null != p) && (p.equals(t)));
|
||||
}
|
||||
|
||||
@ -799,8 +724,7 @@ public abstract class SerializerBase
|
||||
* @return returns the prefix of the qualified name,
|
||||
* or null if there is no prefix.
|
||||
*/
|
||||
protected static final String getPrefixPart(String qname)
|
||||
{
|
||||
protected static final String getPrefixPart(String qname) {
|
||||
final int col = qname.indexOf(':');
|
||||
return (col > 0) ? qname.substring(0, col) : null;
|
||||
//return (col > 0) ? qname.substring(0,col) : "";
|
||||
@ -811,8 +735,7 @@ public abstract class SerializerBase
|
||||
* @return the current namespace mappings (prefix/uri)
|
||||
* @see ExtendedContentHandler#getNamespaceMappings()
|
||||
*/
|
||||
public NamespaceMappings getNamespaceMappings()
|
||||
{
|
||||
public NamespaceMappings getNamespaceMappings() {
|
||||
return m_prefixMap;
|
||||
}
|
||||
|
||||
@ -822,8 +745,7 @@ public abstract class SerializerBase
|
||||
* @return a prefix pointing to the given URI (if any).
|
||||
* @see ExtendedContentHandler#getPrefix(String)
|
||||
*/
|
||||
public String getPrefix(String namespaceURI)
|
||||
{
|
||||
public String getPrefix(String namespaceURI) {
|
||||
String prefix = m_prefixMap.lookupPrefix(namespaceURI);
|
||||
return prefix;
|
||||
}
|
||||
@ -836,19 +758,15 @@ public abstract class SerializerBase
|
||||
* an element.
|
||||
* @return returns the namespace URI associated with the qualified name.
|
||||
*/
|
||||
public String getNamespaceURI(String qname, boolean isElement)
|
||||
{
|
||||
public String getNamespaceURI(String qname, boolean isElement) {
|
||||
String uri = EMPTYSTRING;
|
||||
int col = qname.lastIndexOf(':');
|
||||
final String prefix = (col > 0) ? qname.substring(0, col) : EMPTYSTRING;
|
||||
|
||||
if (!EMPTYSTRING.equals(prefix) || isElement)
|
||||
{
|
||||
if (m_prefixMap != null)
|
||||
{
|
||||
if (!EMPTYSTRING.equals(prefix) || isElement) {
|
||||
if (m_prefixMap != null) {
|
||||
uri = m_prefixMap.lookupNamespace(prefix);
|
||||
if (uri == null && !prefix.equals(XMLNS_PREFIX))
|
||||
{
|
||||
if (uri == null && !prefix.equals(XMLNS_PREFIX)) {
|
||||
throw new RuntimeException(
|
||||
Utils.messages.createMessage(
|
||||
MsgKey.ER_NAMESPACE_PREFIX,
|
||||
@ -866,8 +784,7 @@ public abstract class SerializerBase
|
||||
* @return the namespace URI currently associated with the
|
||||
* prefix, null if the prefix is undefined.
|
||||
*/
|
||||
public String getNamespaceURIFromPrefix(String prefix)
|
||||
{
|
||||
public String getNamespaceURIFromPrefix(String prefix) {
|
||||
String uri = null;
|
||||
if (m_prefixMap != null)
|
||||
uri = m_prefixMap.lookupNamespace(prefix);
|
||||
@ -881,16 +798,14 @@ public abstract class SerializerBase
|
||||
*
|
||||
* @throws org.xml.sax.SAXException
|
||||
*/
|
||||
public void entityReference(String name) throws org.xml.sax.SAXException
|
||||
{
|
||||
|
||||
public void entityReference(String name) throws org.xml.sax.SAXException {
|
||||
flushPending();
|
||||
|
||||
startEntity(name);
|
||||
endEntity(name);
|
||||
|
||||
if (m_tracer != null)
|
||||
fireEntityReference(name);
|
||||
fireEntityReference(name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -898,8 +813,7 @@ public abstract class SerializerBase
|
||||
* @param t the transformer associated with this serializer.
|
||||
* @see SerializationHandler#setTransformer(Transformer)
|
||||
*/
|
||||
public void setTransformer(Transformer t)
|
||||
{
|
||||
public void setTransformer(Transformer t) {
|
||||
m_transformer = t;
|
||||
|
||||
// If this transformer object implements the SerializerTrace interface
|
||||
@ -912,13 +826,13 @@ public abstract class SerializerBase
|
||||
m_tracer = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the transformer associated with this serializer
|
||||
* @return returns the transformer associated with this serializer.
|
||||
* @see SerializationHandler#getTransformer()
|
||||
*/
|
||||
public Transformer getTransformer()
|
||||
{
|
||||
public Transformer getTransformer() {
|
||||
return m_transformer;
|
||||
}
|
||||
|
||||
@ -933,11 +847,9 @@ public abstract class SerializerBase
|
||||
{
|
||||
flushPending();
|
||||
String data = node.getNodeValue();
|
||||
if (data != null)
|
||||
{
|
||||
if (data != null) {
|
||||
final int length = data.length();
|
||||
if (length > m_charsBuff.length)
|
||||
{
|
||||
if (length > m_charsBuff.length) {
|
||||
m_charsBuff = new char[length * 2 + 1];
|
||||
}
|
||||
data.getChars(0, length, m_charsBuff, 0);
|
||||
@ -956,16 +868,13 @@ public abstract class SerializerBase
|
||||
* @see org.xml.sax.ErrorHandler#fatalError(SAXParseException)
|
||||
*/
|
||||
public void fatalError(SAXParseException exc) throws SAXException {
|
||||
|
||||
m_elemContext.m_startTagOpen = false;
|
||||
|
||||
m_elemContext.m_startTagOpen = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ErrorHandler#warning(SAXParseException)
|
||||
*/
|
||||
public void warning(SAXParseException exc) throws SAXException
|
||||
{
|
||||
public void warning(SAXParseException exc) throws SAXException {
|
||||
}
|
||||
|
||||
/**
|
||||
@ -982,20 +891,6 @@ public abstract class SerializerBase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Report the characters event
|
||||
* @param chars content of characters
|
||||
* @param start starting index of characters to output
|
||||
* @param length number of characters to output
|
||||
*/
|
||||
// protected void fireCharEvent(char[] chars, int start, int length)
|
||||
// throws org.xml.sax.SAXException
|
||||
// {
|
||||
// if (m_tracer != null)
|
||||
// m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_CHARACTERS, chars, start,length);
|
||||
// }
|
||||
//
|
||||
|
||||
/**
|
||||
* This method is only used internally when flushing the writer from the
|
||||
* various fire...() trace events. Due to the writer being wrapped with
|
||||
@ -1005,20 +900,15 @@ public abstract class SerializerBase
|
||||
* which trace the output written to the output stream.
|
||||
*
|
||||
*/
|
||||
private void flushMyWriter()
|
||||
{
|
||||
if (m_writer != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
private void flushMyWriter() {
|
||||
if (m_writer != null) {
|
||||
try {
|
||||
m_writer.flush();
|
||||
}
|
||||
catch(IOException ioe)
|
||||
{
|
||||
|
||||
} catch(IOException ioe) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Report the CDATA trace event
|
||||
* @param chars content of CDATA
|
||||
@ -1028,10 +918,9 @@ public abstract class SerializerBase
|
||||
protected void fireCDATAEvent(char[] chars, int start, int length)
|
||||
throws org.xml.sax.SAXException
|
||||
{
|
||||
if (m_tracer != null)
|
||||
{
|
||||
if (m_tracer != null) {
|
||||
flushMyWriter();
|
||||
m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_CDATA, chars, start,length);
|
||||
m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_CDATA, chars, start,length);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1044,10 +933,9 @@ public abstract class SerializerBase
|
||||
protected void fireCommentEvent(char[] chars, int start, int length)
|
||||
throws org.xml.sax.SAXException
|
||||
{
|
||||
if (m_tracer != null)
|
||||
{
|
||||
if (m_tracer != null) {
|
||||
flushMyWriter();
|
||||
m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_COMMENT, new String(chars, start, length));
|
||||
m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_COMMENT, new String(chars, start, length));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1221,12 +1109,10 @@ public abstract class SerializerBase
|
||||
*
|
||||
* @see ExtendedContentHandler#setSourceLocator(javax.xml.transform.SourceLocator)
|
||||
*/
|
||||
public void setSourceLocator(SourceLocator locator)
|
||||
{
|
||||
public void setSourceLocator(SourceLocator locator) {
|
||||
m_sourceLocator = locator;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used only by TransformerSnapshotImpl to restore the serialization
|
||||
* to a previous state.
|
||||
@ -1237,8 +1123,7 @@ public abstract class SerializerBase
|
||||
m_prefixMap = mappings;
|
||||
}
|
||||
|
||||
public boolean reset()
|
||||
{
|
||||
public boolean reset() {
|
||||
resetSerializerBase();
|
||||
return true;
|
||||
}
|
||||
@ -1247,8 +1132,7 @@ public abstract class SerializerBase
|
||||
* Reset all of the fields owned by SerializerBase
|
||||
*
|
||||
*/
|
||||
private void resetSerializerBase()
|
||||
{
|
||||
private void resetSerializerBase() {
|
||||
this.m_attributes.clear();
|
||||
this.m_StringOfCDATASections = null;
|
||||
this.m_elemContext = new ElemContext();
|
||||
@ -1280,13 +1164,12 @@ public abstract class SerializerBase
|
||||
*
|
||||
* This concept is made clear in the XSLT 2.0 draft.
|
||||
*/
|
||||
final boolean inTemporaryOutputState()
|
||||
{
|
||||
final boolean inTemporaryOutputState() {
|
||||
/* This is a hack. We should really be letting the serializer know
|
||||
* that it is in temporary output state with an explicit call, but
|
||||
* from a pragmatic point of view (for now anyways) having no output
|
||||
* encoding at all, not even the default UTF-8 indicates that the serializer
|
||||
* is being used for temporary RTF.
|
||||
* encoding at all, not even the default UTF-8 indicates that the
|
||||
* serializer is being used for temporary RTF.
|
||||
*/
|
||||
return (getEncoding() == null);
|
||||
|
||||
@ -1295,36 +1178,38 @@ public abstract class SerializerBase
|
||||
/**
|
||||
* This method adds an attribute the the current element,
|
||||
* but should not be used for an xsl:attribute child.
|
||||
* @see ExtendedContentHandler#addAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||
* @see ExtendedContentHandler#addAttribute(java.lang.String, java.lang.String,
|
||||
* java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void addAttribute(String uri, String localName, String rawName, String type, String value) throws SAXException
|
||||
public void addAttribute(String uri, String localName, String rawName,
|
||||
String type, String value) throws SAXException
|
||||
{
|
||||
if (m_elemContext.m_startTagOpen)
|
||||
{
|
||||
if (m_elemContext.m_startTagOpen) {
|
||||
addAttributeAlways(uri, localName, rawName, type, value, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.DTDHandler#notationDecl(java.lang.String, java.lang.String, java.lang.String)
|
||||
* @see org.xml.sax.DTDHandler#notationDecl(java.lang.String,
|
||||
* java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void notationDecl(String arg0, String arg1, String arg2)
|
||||
throws SAXException {
|
||||
throws SAXException
|
||||
{
|
||||
// This method just provides a definition to satisfy the interface
|
||||
// A particular sub-class of SerializerBase provides the implementation (if desired)
|
||||
// A particular sub-class of SerializerBase provides the implementation
|
||||
// (if desired)
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.DTDHandler#unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
||||
* @see org.xml.sax.DTDHandler#unparsedEntityDecl(java.lang.String,
|
||||
* java.lang.String, java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void unparsedEntityDecl(
|
||||
String arg0,
|
||||
String arg1,
|
||||
String arg2,
|
||||
String arg3)
|
||||
throws SAXException {
|
||||
public void unparsedEntityDecl(String arg0, String arg1, String arg2,
|
||||
String arg3) throws SAXException {
|
||||
// This method just provides a definition to satisfy the interface
|
||||
// A particular sub-class of SerializerBase provides the implementation (if desired)
|
||||
// A particular sub-class of SerializerBase provides the implementation
|
||||
// (if desired)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1606,6 +1491,7 @@ public abstract class SerializerBase
|
||||
* map will have what that attribute maps to.
|
||||
*/
|
||||
private HashMap<String, String> m_OutputProps;
|
||||
|
||||
/**
|
||||
* A mapping of keys to default values, for example if
|
||||
* the default value of the encoding is "UTF-8" then this
|
||||
@ -1616,6 +1502,7 @@ public abstract class SerializerBase
|
||||
Set<String> getOutputPropDefaultKeys() {
|
||||
return m_OutputPropsDefault.keySet();
|
||||
}
|
||||
|
||||
Set<String> getOutputPropKeys() {
|
||||
return m_OutputProps.keySet();
|
||||
}
|
||||
@ -1634,6 +1521,7 @@ public abstract class SerializerBase
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name The name of the property, e.g. "{http://myprop}indent-tabs" or "indent".
|
||||
|
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
@ -17,13 +17,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* $Id: ToSAXHandler.java,v 1.2.4.1 2005/09/22 11:03:15 pvedula Exp $
|
||||
*/
|
||||
|
||||
package com.sun.org.apache.xml.internal.serializer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.ErrorHandler;
|
||||
@ -39,23 +36,16 @@ import org.xml.sax.ext.LexicalHandler;
|
||||
*
|
||||
* @xsl.usage internal
|
||||
*/
|
||||
public abstract class ToSAXHandler extends SerializerBase
|
||||
{
|
||||
public ToSAXHandler()
|
||||
{
|
||||
}
|
||||
public abstract class ToSAXHandler extends SerializerBase {
|
||||
public ToSAXHandler() { }
|
||||
|
||||
public ToSAXHandler(
|
||||
ContentHandler hdlr,
|
||||
LexicalHandler lex,
|
||||
String encoding)
|
||||
{
|
||||
public ToSAXHandler(ContentHandler hdlr, LexicalHandler lex, String encoding) {
|
||||
setContentHandler(hdlr);
|
||||
setLexHandler(lex);
|
||||
setEncoding(encoding);
|
||||
}
|
||||
public ToSAXHandler(ContentHandler handler, String encoding)
|
||||
{
|
||||
|
||||
public ToSAXHandler(ContentHandler handler, String encoding) {
|
||||
setContentHandler(handler);
|
||||
setEncoding(encoding);
|
||||
}
|
||||
@ -90,16 +80,14 @@ public abstract class ToSAXHandler extends SerializerBase
|
||||
/**
|
||||
* Pass callback to the SAX Handler
|
||||
*/
|
||||
protected void startDocumentInternal() throws SAXException
|
||||
{
|
||||
if (m_needToCallStartDocument)
|
||||
{
|
||||
protected void startDocumentInternal() throws SAXException {
|
||||
if (m_needToCallStartDocument) {
|
||||
super.startDocumentInternal();
|
||||
|
||||
m_saxHandler.startDocument();
|
||||
m_needToCallStartDocument = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do nothing.
|
||||
* @see org.xml.sax.ext.LexicalHandler#startDTD(String, String, String)
|
||||
@ -113,20 +101,20 @@ public abstract class ToSAXHandler extends SerializerBase
|
||||
/**
|
||||
* Receive notification of character data.
|
||||
*
|
||||
* @param characters The string of characters to process.
|
||||
* @param chars The string of characters to process.
|
||||
*
|
||||
* @throws org.xml.sax.SAXException
|
||||
*
|
||||
* @see ExtendedContentHandler#characters(String)
|
||||
*/
|
||||
public void characters(String characters) throws SAXException
|
||||
{
|
||||
final int len = characters.length();
|
||||
if (len > m_charsBuff.length)
|
||||
{
|
||||
m_charsBuff = new char[len*2 + 1];
|
||||
public void characters(String chars) throws SAXException {
|
||||
final int len = (chars == null) ? 0 : chars.length();
|
||||
if (len > m_charsBuff.length) {
|
||||
m_charsBuff = new char[len * 2 + 1];
|
||||
}
|
||||
if (len > 0) {
|
||||
chars.getChars(0, len, m_charsBuff, 0);
|
||||
}
|
||||
characters.getChars(0,len, m_charsBuff, 0);
|
||||
characters(m_charsBuff, 0, len);
|
||||
}
|
||||
|
||||
@ -135,16 +123,13 @@ public abstract class ToSAXHandler extends SerializerBase
|
||||
*
|
||||
* @see ExtendedLexicalHandler#comment(String)
|
||||
*/
|
||||
public void comment(String comment) throws SAXException
|
||||
{
|
||||
public void comment(String comment) throws SAXException {
|
||||
flushPending();
|
||||
|
||||
// Ignore if a lexical handler has not been set
|
||||
if (m_lexHandler != null)
|
||||
{
|
||||
if (m_lexHandler != null) {
|
||||
final int len = comment.length();
|
||||
if (len > m_charsBuff.length)
|
||||
{
|
||||
if (len > m_charsBuff.length) {
|
||||
m_charsBuff = new char[len*2 + 1];
|
||||
}
|
||||
comment.getChars(0,len, m_charsBuff, 0);
|
||||
@ -153,7 +138,6 @@ public abstract class ToSAXHandler extends SerializerBase
|
||||
if (m_tracer != null)
|
||||
super.fireCommentEvent(m_charsBuff, 0, len);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -167,12 +151,10 @@ public abstract class ToSAXHandler extends SerializerBase
|
||||
// Redefined in SAXXMLOutput
|
||||
}
|
||||
|
||||
protected void closeStartTag() throws SAXException
|
||||
{
|
||||
protected void closeStartTag() throws SAXException {
|
||||
}
|
||||
|
||||
protected void closeCDATA() throws SAXException
|
||||
{
|
||||
protected void closeCDATA() throws SAXException {
|
||||
// Redefined in SAXXMLOutput
|
||||
}
|
||||
|
||||
@ -191,12 +173,8 @@ public abstract class ToSAXHandler extends SerializerBase
|
||||
*
|
||||
* @see org.xml.sax.ContentHandler#startElement(String,String,String,Attributes)
|
||||
*/
|
||||
public void startElement(
|
||||
String arg0,
|
||||
String arg1,
|
||||
String arg2,
|
||||
Attributes arg3)
|
||||
throws SAXException
|
||||
public void startElement(String arg0, String arg1, String arg2,
|
||||
Attributes arg3) throws SAXException
|
||||
{
|
||||
if (m_state != null) {
|
||||
m_state.resetState(getTransformer());
|
||||
@ -211,8 +189,7 @@ public abstract class ToSAXHandler extends SerializerBase
|
||||
* Sets the LexicalHandler.
|
||||
* @param _lexHandler The LexicalHandler to set
|
||||
*/
|
||||
public void setLexHandler(LexicalHandler _lexHandler)
|
||||
{
|
||||
public void setLexHandler(LexicalHandler _lexHandler) {
|
||||
this.m_lexHandler = _lexHandler;
|
||||
}
|
||||
|
||||
@ -220,11 +197,9 @@ public abstract class ToSAXHandler extends SerializerBase
|
||||
* Sets the SAX ContentHandler.
|
||||
* @param _saxHandler The ContentHandler to set
|
||||
*/
|
||||
public void setContentHandler(ContentHandler _saxHandler)
|
||||
{
|
||||
public void setContentHandler(ContentHandler _saxHandler) {
|
||||
this.m_saxHandler = _saxHandler;
|
||||
if (m_lexHandler == null && _saxHandler instanceof LexicalHandler)
|
||||
{
|
||||
if (m_lexHandler == null && _saxHandler instanceof LexicalHandler) {
|
||||
// we are not overwriting an existing LexicalHandler, and _saxHandler
|
||||
// is also implements LexicalHandler, so lets use it
|
||||
m_lexHandler = (LexicalHandler) _saxHandler;
|
||||
@ -236,8 +211,7 @@ public abstract class ToSAXHandler extends SerializerBase
|
||||
* stream serializers.
|
||||
* @see SerializationHandler#setCdataSectionElements(java.util.ArrayList<String>)
|
||||
*/
|
||||
public void setCdataSectionElements(ArrayList<String> URI_and_localNames)
|
||||
{
|
||||
public void setCdataSectionElements(ArrayList<String> URI_and_localNames) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@ -247,8 +221,7 @@ public abstract class ToSAXHandler extends SerializerBase
|
||||
* @param doOutputNSAttr whether or not namespace declarations
|
||||
* should appear as attributes
|
||||
*/
|
||||
public void setShouldOutputNSAttr(boolean doOutputNSAttr)
|
||||
{
|
||||
public void setShouldOutputNSAttr(boolean doOutputNSAttr) {
|
||||
m_shouldGenerateNSAttribute = doOutputNSAttr;
|
||||
}
|
||||
|
||||
@ -258,8 +231,7 @@ public abstract class ToSAXHandler extends SerializerBase
|
||||
* also be mirrored with self generated additional attributes of elements
|
||||
* that declare the namespace, for example the attribute xmlns:prefix1="uri1"
|
||||
*/
|
||||
boolean getShouldOutputNSAttr()
|
||||
{
|
||||
boolean getShouldOutputNSAttr() {
|
||||
return m_shouldGenerateNSAttribute;
|
||||
}
|
||||
|
||||
@ -267,27 +239,21 @@ public abstract class ToSAXHandler extends SerializerBase
|
||||
* This method flushes any pending events, which can be startDocument()
|
||||
* closing the opening tag of an element, or closing an open CDATA section.
|
||||
*/
|
||||
public void flushPending() throws SAXException
|
||||
{
|
||||
|
||||
if (m_needToCallStartDocument)
|
||||
{
|
||||
public void flushPending() throws SAXException {
|
||||
if (m_needToCallStartDocument) {
|
||||
startDocumentInternal();
|
||||
m_needToCallStartDocument = false;
|
||||
}
|
||||
|
||||
if (m_elemContext.m_startTagOpen)
|
||||
{
|
||||
if (m_elemContext.m_startTagOpen) {
|
||||
closeStartTag();
|
||||
m_elemContext.m_startTagOpen = false;
|
||||
}
|
||||
|
||||
if (m_cdataTagOpen)
|
||||
{
|
||||
if (m_cdataTagOpen) {
|
||||
closeCDATA();
|
||||
m_cdataTagOpen = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -350,8 +316,7 @@ public abstract class ToSAXHandler extends SerializerBase
|
||||
throws org.xml.sax.SAXException
|
||||
{
|
||||
// remember the current node
|
||||
if (m_state != null)
|
||||
{
|
||||
if (m_state != null) {
|
||||
m_state.setCurrentNode(node);
|
||||
}
|
||||
|
||||
@ -392,12 +357,10 @@ public abstract class ToSAXHandler extends SerializerBase
|
||||
*/
|
||||
public void warning(SAXParseException exc) throws SAXException {
|
||||
super.warning(exc);
|
||||
|
||||
if (m_saxHandler instanceof ErrorHandler)
|
||||
((ErrorHandler)m_saxHandler).warning(exc);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Try's to reset the super class and reset this class for
|
||||
* re-use, so that you don't need to create a new serializer
|
||||
@ -406,11 +369,9 @@ public abstract class ToSAXHandler extends SerializerBase
|
||||
* @return true if the class was successfuly reset.
|
||||
* @see Serializer#reset()
|
||||
*/
|
||||
public boolean reset()
|
||||
{
|
||||
public boolean reset() {
|
||||
boolean wasReset = false;
|
||||
if (super.reset())
|
||||
{
|
||||
if (super.reset()) {
|
||||
resetToSAXHandler();
|
||||
wasReset = true;
|
||||
}
|
||||
@ -421,8 +382,7 @@ public abstract class ToSAXHandler extends SerializerBase
|
||||
* Reset all of the fields owned by ToSAXHandler class
|
||||
*
|
||||
*/
|
||||
private void resetToSAXHandler()
|
||||
{
|
||||
private void resetToSAXHandler() {
|
||||
this.m_lexHandler = null;
|
||||
this.m_saxHandler = null;
|
||||
this.m_state = null;
|
||||
|
@ -1,15 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
@ -19,12 +17,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* $Id: ToStream.java,v 1.4 2005/11/10 06:43:26 suresh_emailid Exp $
|
||||
*/
|
||||
|
||||
package com.sun.org.apache.xml.internal.serializer;
|
||||
|
||||
import com.sun.org.apache.xalan.internal.utils.SecuritySupport;
|
||||
import com.sun.org.apache.xml.internal.serializer.utils.MsgKey;
|
||||
import com.sun.org.apache.xml.internal.serializer.utils.Utils;
|
||||
import com.sun.org.apache.xml.internal.serializer.utils.WrappedRuntimeException;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
@ -36,30 +35,22 @@ import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.xml.transform.ErrorListener;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerException;
|
||||
|
||||
import com.sun.org.apache.xml.internal.serializer.utils.MsgKey;
|
||||
import com.sun.org.apache.xml.internal.serializer.utils.Utils;
|
||||
import com.sun.org.apache.xml.internal.serializer.utils.WrappedRuntimeException;
|
||||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
//import com.sun.media.sound.IESecurity;
|
||||
|
||||
/**
|
||||
* This abstract class is a base class for other stream
|
||||
* serializers (xml, html, text ...) that write output to a stream.
|
||||
*
|
||||
* @xsl.usage internal
|
||||
*/
|
||||
abstract public class ToStream extends SerializerBase
|
||||
{
|
||||
abstract public class ToStream extends SerializerBase {
|
||||
|
||||
private static final String COMMENT_BEGIN = "<!--";
|
||||
private static final String COMMENT_END = "-->";
|
||||
@ -67,7 +58,6 @@ abstract public class ToStream extends SerializerBase
|
||||
/** Stack to keep track of disabling output escaping. */
|
||||
protected BoolStack m_disableOutputEscapingStates = new BoolStack();
|
||||
|
||||
|
||||
/**
|
||||
* The encoding information associated with this serializer.
|
||||
* Although initially there is no encoding,
|
||||
@ -87,21 +77,17 @@ abstract public class ToStream extends SerializerBase
|
||||
*/
|
||||
java.lang.reflect.Method m_canConvertMeth;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Boolean that tells if we already tried to get the converter.
|
||||
*/
|
||||
boolean m_triedToGetConverter = false;
|
||||
|
||||
|
||||
/**
|
||||
* Opaque reference to the sun.io.CharToByteConverter for this
|
||||
* encoding.
|
||||
*/
|
||||
Object m_charToByteConverter = null;
|
||||
|
||||
|
||||
/**
|
||||
* Stack to keep track of whether or not we need to
|
||||
* preserve whitespace.
|
||||
@ -139,7 +125,6 @@ abstract public class ToStream extends SerializerBase
|
||||
*/
|
||||
protected int m_maxCharacter = Encodings.getLastPrintable();
|
||||
|
||||
|
||||
/**
|
||||
* The system line separator for writing out line breaks.
|
||||
* The default value is from the system property,
|
||||
@ -188,8 +173,8 @@ abstract public class ToStream extends SerializerBase
|
||||
protected boolean m_inDoctype = false;
|
||||
|
||||
/**
|
||||
* Flag to quickly tell if the encoding is UTF8.
|
||||
*/
|
||||
* Flag to quickly tell if the encoding is UTF8.
|
||||
*/
|
||||
boolean m_isUTF8 = false;
|
||||
|
||||
/**
|
||||
@ -203,29 +188,23 @@ abstract public class ToStream extends SerializerBase
|
||||
*/
|
||||
private boolean m_expandDTDEntities = true;
|
||||
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
public ToStream()
|
||||
{
|
||||
}
|
||||
public ToStream() { }
|
||||
|
||||
/**
|
||||
* This helper method to writes out "]]>" when closing a CDATA section.
|
||||
*
|
||||
* @throws org.xml.sax.SAXException
|
||||
*/
|
||||
protected void closeCDATA() throws org.xml.sax.SAXException
|
||||
{
|
||||
try
|
||||
{
|
||||
protected void closeCDATA() throws org.xml.sax.SAXException {
|
||||
try {
|
||||
m_writer.write(CDATA_DELIMITER_CLOSE);
|
||||
// write out a CDATA section closing "]]>"
|
||||
m_cdataTagOpen = false; // Remember that we have done so.
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
catch (IOException e) {
|
||||
throw new SAXException(e);
|
||||
}
|
||||
}
|
||||
@ -237,18 +216,11 @@ abstract public class ToStream extends SerializerBase
|
||||
* @param node Node to serialize.
|
||||
* @throws IOException An I/O exception occured while serializing
|
||||
*/
|
||||
public void serialize(Node node) throws IOException
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
TreeWalker walker =
|
||||
new TreeWalker(this);
|
||||
|
||||
public void serialize(Node node) throws IOException {
|
||||
try {
|
||||
TreeWalker walker = new TreeWalker(this);
|
||||
walker.traverse(node);
|
||||
}
|
||||
catch (org.xml.sax.SAXException se)
|
||||
{
|
||||
} catch (org.xml.sax.SAXException se) {
|
||||
throw new WrappedRuntimeException(se);
|
||||
}
|
||||
}
|
||||
@ -260,8 +232,7 @@ abstract public class ToStream extends SerializerBase
|
||||
*
|
||||
* NEEDSDOC ($objectName$) @return
|
||||
*/
|
||||
static final boolean isUTF16Surrogate(char c)
|
||||
{
|
||||
static final boolean isUTF16Surrogate(char c) {
|
||||
return (c & 0xFC00) == 0xD800;
|
||||
}
|
||||
|
||||
@ -275,49 +246,40 @@ abstract public class ToStream extends SerializerBase
|
||||
*
|
||||
* @throws org.xml.sax.SAXException
|
||||
*/
|
||||
protected final void flushWriter() throws org.xml.sax.SAXException
|
||||
{
|
||||
final java.io.Writer writer = m_writer;
|
||||
if (null != writer)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (writer instanceof WriterToUTF8Buffered)
|
||||
{
|
||||
protected final void flushWriter() throws org.xml.sax.SAXException {
|
||||
final Writer writer = m_writer;
|
||||
if (null != writer) {
|
||||
try {
|
||||
if (writer instanceof WriterToUTF8Buffered) {
|
||||
if (m_shouldFlush)
|
||||
((WriterToUTF8Buffered) writer).flush();
|
||||
((WriterToUTF8Buffered)writer).flush();
|
||||
else
|
||||
((WriterToUTF8Buffered) writer).flushBuffer();
|
||||
((WriterToUTF8Buffered)writer).flushBuffer();
|
||||
}
|
||||
if (writer instanceof WriterToASCI)
|
||||
{
|
||||
if (writer instanceof WriterToASCI) {
|
||||
if (m_shouldFlush)
|
||||
writer.flush();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Flush always.
|
||||
// Not a great thing if the writer was created
|
||||
// by this class, but don't have a choice.
|
||||
writer.flush();
|
||||
}
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
} catch (IOException ioe) {
|
||||
throw new org.xml.sax.SAXException(ioe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OutputStream m_outputStream;
|
||||
|
||||
/**
|
||||
* Get the output stream where the events will be serialized to.
|
||||
*
|
||||
* @return reference to the result stream, or null of only a writer was
|
||||
* set.
|
||||
*/
|
||||
public OutputStream getOutputStream()
|
||||
{
|
||||
public OutputStream getOutputStream() {
|
||||
return m_outputStream;
|
||||
}
|
||||
|
||||
@ -341,9 +303,8 @@ abstract public class ToStream extends SerializerBase
|
||||
// Do not inline external DTD
|
||||
if (m_inExternalDTD)
|
||||
return;
|
||||
try
|
||||
{
|
||||
final java.io.Writer writer = m_writer;
|
||||
try {
|
||||
final Writer writer = m_writer;
|
||||
DTDprolog();
|
||||
|
||||
writer.write("<!ELEMENT ");
|
||||
@ -379,13 +340,10 @@ abstract public class ToStream extends SerializerBase
|
||||
// Do not inline external DTD
|
||||
if (m_inExternalDTD)
|
||||
return;
|
||||
try
|
||||
{
|
||||
try {
|
||||
DTDprolog();
|
||||
outputEntityDecl(name, value);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
} catch (IOException e) {
|
||||
throw new SAXException(e);
|
||||
}
|
||||
|
||||
@ -401,7 +359,7 @@ abstract public class ToStream extends SerializerBase
|
||||
*/
|
||||
void outputEntityDecl(String name, String value) throws IOException
|
||||
{
|
||||
final java.io.Writer writer = m_writer;
|
||||
final Writer writer = m_writer;
|
||||
writer.write("<!ENTITY ");
|
||||
writer.write(name);
|
||||
writer.write(" \"");
|
||||
@ -415,8 +373,7 @@ abstract public class ToStream extends SerializerBase
|
||||
*
|
||||
* @throws org.xml.sax.SAXException
|
||||
*/
|
||||
protected final void outputLineSep() throws IOException
|
||||
{
|
||||
protected final void outputLineSep() throws IOException {
|
||||
m_writer.write(m_lineSep, 0, m_lineSepLen);
|
||||
}
|
||||
|
||||
@ -594,20 +551,17 @@ abstract public class ToStream extends SerializerBase
|
||||
*
|
||||
* @param format The output format to use
|
||||
*/
|
||||
public void setOutputFormat(Properties format)
|
||||
{
|
||||
public void setOutputFormat(Properties format) {
|
||||
boolean shouldFlush = m_shouldFlush;
|
||||
|
||||
if (format != null)
|
||||
{
|
||||
if (format != null) {
|
||||
// Set the default values first,
|
||||
// and the non-default values after that,
|
||||
// just in case there is some unexpected
|
||||
// residual values left over from over-ridden default values
|
||||
Enumeration propNames;
|
||||
propNames = format.propertyNames();
|
||||
while (propNames.hasMoreElements())
|
||||
{
|
||||
while (propNames.hasMoreElements()) {
|
||||
String key = (String) propNames.nextElement();
|
||||
// Get the value, possibly a default value
|
||||
String value = format.getProperty(key);
|
||||
@ -629,18 +583,11 @@ abstract public class ToStream extends SerializerBase
|
||||
String entitiesFileName =
|
||||
(String) format.get(OutputPropertiesFactory.S_KEY_ENTITIES);
|
||||
|
||||
if (null != entitiesFileName)
|
||||
{
|
||||
|
||||
String method =
|
||||
(String) format.get(OutputKeys.METHOD);
|
||||
|
||||
if (null != entitiesFileName) {
|
||||
String method = (String) format.get(OutputKeys.METHOD);
|
||||
m_charInfo = CharInfo.getCharInfo(entitiesFileName, method);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
m_shouldFlush = shouldFlush;
|
||||
}
|
||||
|
||||
@ -678,8 +625,7 @@ abstract public class ToStream extends SerializerBase
|
||||
*
|
||||
* @param writer The output writer stream
|
||||
*/
|
||||
public void setWriter(Writer writer)
|
||||
{
|
||||
public void setWriter(Writer writer) {
|
||||
setWriterInternal(writer, true);
|
||||
}
|
||||
|
||||
@ -716,8 +662,7 @@ abstract public class ToStream extends SerializerBase
|
||||
* operating systems end-of-line separator.
|
||||
* @return The previously set value of the serializer.
|
||||
*/
|
||||
public boolean setLineSepUse(boolean use_sytem_line_break)
|
||||
{
|
||||
public boolean setLineSepUse(boolean use_sytem_line_break) {
|
||||
boolean oldValue = m_lineSepUse;
|
||||
m_lineSepUse = use_sytem_line_break;
|
||||
return oldValue;
|
||||
@ -734,8 +679,7 @@ abstract public class ToStream extends SerializerBase
|
||||
*
|
||||
* @param output The output stream
|
||||
*/
|
||||
public void setOutputStream(OutputStream output)
|
||||
{
|
||||
public void setOutputStream(OutputStream output) {
|
||||
setOutputStreamInternal(output, true);
|
||||
}
|
||||
|
||||
@ -848,7 +792,7 @@ abstract public class ToStream extends SerializerBase
|
||||
*/
|
||||
private void printSpace(int n) throws IOException
|
||||
{
|
||||
final java.io.Writer writer = m_writer;
|
||||
final Writer writer = m_writer;
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
writer.write(' ');
|
||||
@ -888,7 +832,7 @@ abstract public class ToStream extends SerializerBase
|
||||
return;
|
||||
try
|
||||
{
|
||||
final java.io.Writer writer = m_writer;
|
||||
final Writer writer = m_writer;
|
||||
DTDprolog();
|
||||
|
||||
writer.write("<!ATTLIST ");
|
||||
@ -1038,7 +982,7 @@ abstract public class ToStream extends SerializerBase
|
||||
+ Integer.toHexString(low)}));
|
||||
}
|
||||
|
||||
final java.io.Writer writer = m_writer;
|
||||
final Writer writer = m_writer;
|
||||
|
||||
// If we make it to here we have a valid high, low surrogate pair
|
||||
if (m_encodingInfo.isInEncoding(c,low)) {
|
||||
@ -1089,7 +1033,7 @@ abstract public class ToStream extends SerializerBase
|
||||
* @throws java.io.IOException
|
||||
*/
|
||||
protected int accumDefaultEntity(
|
||||
java.io.Writer writer,
|
||||
Writer writer,
|
||||
char ch,
|
||||
int i,
|
||||
char[] chars,
|
||||
@ -1146,7 +1090,7 @@ abstract public class ToStream extends SerializerBase
|
||||
boolean useSystemLineSeparator)
|
||||
throws IOException, org.xml.sax.SAXException
|
||||
{
|
||||
final java.io.Writer writer = m_writer;
|
||||
final Writer writer = m_writer;
|
||||
int end = start + length;
|
||||
|
||||
for (int i = start; i < end; i++)
|
||||
@ -1855,7 +1799,7 @@ abstract public class ToStream extends SerializerBase
|
||||
|
||||
m_startNewLine = true;
|
||||
|
||||
final java.io.Writer writer = m_writer;
|
||||
final Writer writer = m_writer;
|
||||
writer.write('<');
|
||||
writer.write(name);
|
||||
}
|
||||
@ -1926,7 +1870,7 @@ abstract public class ToStream extends SerializerBase
|
||||
closeCDATA();
|
||||
try
|
||||
{
|
||||
final java.io.Writer writer = m_writer;
|
||||
final Writer writer = m_writer;
|
||||
writer.write("<!DOCTYPE ");
|
||||
writer.write(name);
|
||||
|
||||
@ -1987,7 +1931,7 @@ abstract public class ToStream extends SerializerBase
|
||||
* @throws java.io.IOException
|
||||
* @throws org.xml.sax.SAXException
|
||||
*/
|
||||
public void processAttributes(java.io.Writer writer, int nAttrs) throws IOException, SAXException
|
||||
public void processAttributes(Writer writer, int nAttrs) throws IOException, SAXException
|
||||
{
|
||||
/* real SAX attributes are not passed in, so process the
|
||||
* attributes that were collected after the startElement call.
|
||||
@ -2084,7 +2028,7 @@ abstract public class ToStream extends SerializerBase
|
||||
|
||||
try
|
||||
{
|
||||
final java.io.Writer writer = m_writer;
|
||||
final Writer writer = m_writer;
|
||||
if (m_elemContext.m_startTagOpen)
|
||||
{
|
||||
if (m_tracer != null)
|
||||
@ -2290,7 +2234,7 @@ abstract public class ToStream extends SerializerBase
|
||||
if (shouldIndent() && !m_isStandalone)
|
||||
indent();
|
||||
|
||||
final java.io.Writer writer = m_writer;
|
||||
final Writer writer = m_writer;
|
||||
writer.write(COMMENT_BEGIN);
|
||||
// Detect occurrences of two consecutive dashes, handle as necessary.
|
||||
for (int i = start; i < limit; i++)
|
||||
@ -2370,7 +2314,7 @@ abstract public class ToStream extends SerializerBase
|
||||
outputDocTypeDecl(m_elemContext.m_elementName, false);
|
||||
m_needToOutputDocTypeDecl = false;
|
||||
}
|
||||
final java.io.Writer writer = m_writer;
|
||||
final Writer writer = m_writer;
|
||||
if (!m_inDoctype)
|
||||
writer.write("]>");
|
||||
else
|
||||
@ -2598,15 +2542,12 @@ abstract public class ToStream extends SerializerBase
|
||||
* OutputProperties. Eventually this method should go away and a call
|
||||
* to setCdataSectionElements(ArrayList<String> v) should be made directly.
|
||||
*/
|
||||
private void setCdataSectionElements(String key, Properties props)
|
||||
{
|
||||
|
||||
private void setCdataSectionElements(String key, Properties props) {
|
||||
String s = props.getProperty(key);
|
||||
|
||||
if (null != s)
|
||||
{
|
||||
if (null != s) {
|
||||
// ArrayList<String> of URI/LocalName pairs
|
||||
ArrayList<String> v = new ArrayList<>();
|
||||
ArrayList<String> al = new ArrayList<>();
|
||||
int l = s.length();
|
||||
boolean inCurly = false;
|
||||
StringBuilder buf = new StringBuilder();
|
||||
@ -2624,7 +2565,7 @@ abstract public class ToStream extends SerializerBase
|
||||
{
|
||||
if (buf.length() > 0)
|
||||
{
|
||||
addCdataSectionElement(buf.toString(), v);
|
||||
addCdataSectionElement(buf.toString(), al);
|
||||
buf.setLength(0);
|
||||
}
|
||||
continue;
|
||||
@ -2640,11 +2581,11 @@ abstract public class ToStream extends SerializerBase
|
||||
|
||||
if (buf.length() > 0)
|
||||
{
|
||||
addCdataSectionElement(buf.toString(), v);
|
||||
addCdataSectionElement(buf.toString(), al);
|
||||
buf.setLength(0);
|
||||
}
|
||||
// call the official, public method to set the collected names
|
||||
setCdataSectionElements(v);
|
||||
setCdataSectionElements(al);
|
||||
}
|
||||
|
||||
}
|
||||
@ -2656,25 +2597,19 @@ abstract public class ToStream extends SerializerBase
|
||||
*
|
||||
* @return a QName object
|
||||
*/
|
||||
private void addCdataSectionElement(String URI_and_localName, ArrayList<String> v)
|
||||
{
|
||||
|
||||
StringTokenizer tokenizer =
|
||||
new StringTokenizer(URI_and_localName, "{}", false);
|
||||
private void addCdataSectionElement(String URI_and_localName, ArrayList<String> al) {
|
||||
StringTokenizer tokenizer = new StringTokenizer(URI_and_localName, "{}", false);
|
||||
String s1 = tokenizer.nextToken();
|
||||
String s2 = tokenizer.hasMoreTokens() ? tokenizer.nextToken() : null;
|
||||
|
||||
if (null == s2)
|
||||
{
|
||||
if (null == s2) {
|
||||
// add null URI and the local name
|
||||
v.add(null);
|
||||
v.add(s1);
|
||||
}
|
||||
else
|
||||
{
|
||||
al.add(null);
|
||||
al.add(s1);
|
||||
} else {
|
||||
// add URI, then local name
|
||||
v.add(s1);
|
||||
v.add(s2);
|
||||
al.add(s1);
|
||||
al.add(s2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2685,25 +2620,20 @@ abstract public class ToStream extends SerializerBase
|
||||
*
|
||||
* @param URI_and_localNames an ArrayList of pairs of Strings (URI/local)
|
||||
*/
|
||||
public void setCdataSectionElements(ArrayList<String> URI_and_localNames)
|
||||
{
|
||||
public void setCdataSectionElements(ArrayList<String> URI_and_localNames) {
|
||||
// convert to the new way.
|
||||
if (URI_and_localNames != null)
|
||||
{
|
||||
if (URI_and_localNames != null) {
|
||||
final int len = URI_and_localNames.size() - 1;
|
||||
if (len > 0)
|
||||
{
|
||||
if (len > 0) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < len; i += 2)
|
||||
{
|
||||
for (int i = 0; i < len; i += 2) {
|
||||
// whitspace separated "{uri1}local1 {uri2}local2 ..."
|
||||
if (i != 0)
|
||||
sb.append(' ');
|
||||
final String uri = (String) URI_and_localNames.get(i);
|
||||
final String localName =
|
||||
(String) URI_and_localNames.get(i + 1);
|
||||
if (uri != null)
|
||||
{
|
||||
if (uri != null) {
|
||||
// If there is no URI don't put this in, just the localName then.
|
||||
sb.append('{');
|
||||
sb.append(uri);
|
||||
@ -3007,25 +2937,19 @@ abstract public class ToStream extends SerializerBase
|
||||
* exist. This method should be called everytime an attribute is added,
|
||||
* or when an attribute value is changed, or an element is created.
|
||||
*/
|
||||
|
||||
protected void firePseudoAttributes()
|
||||
{
|
||||
if (m_tracer != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
protected void firePseudoAttributes() {
|
||||
if (m_tracer != null) {
|
||||
try {
|
||||
// flush out the "<elemName" if not already flushed
|
||||
m_writer.flush();
|
||||
|
||||
// make a StringBuffer to write the name="value" pairs to.
|
||||
StringBuffer sb = new StringBuffer();
|
||||
int nAttrs = m_attributes.getLength();
|
||||
if (nAttrs > 0)
|
||||
{
|
||||
if (nAttrs > 0) {
|
||||
// make a writer that internally appends to the same
|
||||
// StringBuffer
|
||||
java.io.Writer writer =
|
||||
new ToStream.WritertoStringBuffer(sb);
|
||||
Writer writer = new ToStream.WritertoStringBuffer(sb);
|
||||
|
||||
processAttributes(writer, nAttrs);
|
||||
// Don't clear the attributes!
|
||||
@ -3042,13 +2966,9 @@ abstract public class ToStream extends SerializerBase
|
||||
ch,
|
||||
0,
|
||||
ch.length);
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
} catch (IOException ioe) {
|
||||
// ignore ?
|
||||
}
|
||||
catch (SAXException se)
|
||||
{
|
||||
} catch (SAXException se) {
|
||||
// ignore ?
|
||||
}
|
||||
}
|
||||
@ -3060,41 +2980,35 @@ abstract public class ToStream extends SerializerBase
|
||||
* In this manner trace events, and the real writing of attributes will use
|
||||
* the same code.
|
||||
*/
|
||||
private class WritertoStringBuffer extends java.io.Writer
|
||||
{
|
||||
private class WritertoStringBuffer extends Writer {
|
||||
final private StringBuffer m_stringbuf;
|
||||
|
||||
/**
|
||||
* @see java.io.Writer#write(char[], int, int)
|
||||
*/
|
||||
WritertoStringBuffer(StringBuffer sb)
|
||||
{
|
||||
WritertoStringBuffer(StringBuffer sb) {
|
||||
m_stringbuf = sb;
|
||||
}
|
||||
|
||||
public void write(char[] arg0, int arg1, int arg2) throws IOException
|
||||
{
|
||||
public void write(char[] arg0, int arg1, int arg2) throws IOException {
|
||||
m_stringbuf.append(arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.io.Writer#flush()
|
||||
*/
|
||||
public void flush() throws IOException
|
||||
{
|
||||
}
|
||||
public void flush() throws IOException {}
|
||||
|
||||
/**
|
||||
* @see java.io.Writer#close()
|
||||
*/
|
||||
public void close() throws IOException
|
||||
{
|
||||
}
|
||||
public void close() throws IOException {}
|
||||
|
||||
public void write(int i)
|
||||
{
|
||||
public void write(int i) {
|
||||
m_stringbuf.append((char) i);
|
||||
}
|
||||
|
||||
public void write(String s)
|
||||
{
|
||||
public void write(String s) {
|
||||
m_stringbuf.append(s);
|
||||
}
|
||||
}
|
||||
@ -3104,12 +3018,11 @@ abstract public class ToStream extends SerializerBase
|
||||
*/
|
||||
public void setTransformer(Transformer transformer) {
|
||||
super.setTransformer(transformer);
|
||||
if (m_tracer != null
|
||||
&& !(m_writer instanceof SerializerTraceWriter) )
|
||||
if (m_tracer != null && !(m_writer instanceof SerializerTraceWriter)) {
|
||||
m_writer = new SerializerTraceWriter(m_writer, m_tracer);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Try's to reset the super class and reset this class for
|
||||
* re-use, so that you don't need to create a new serializer
|
||||
@ -3117,11 +3030,9 @@ abstract public class ToStream extends SerializerBase
|
||||
*
|
||||
* @return true if the class was successfuly reset.
|
||||
*/
|
||||
public boolean reset()
|
||||
{
|
||||
public boolean reset() {
|
||||
boolean wasReset = false;
|
||||
if (super.reset())
|
||||
{
|
||||
if (super.reset()) {
|
||||
resetToStream();
|
||||
wasReset = true;
|
||||
}
|
||||
@ -3132,14 +3043,12 @@ abstract public class ToStream extends SerializerBase
|
||||
* Reset all of the fields owned by ToStream class
|
||||
*
|
||||
*/
|
||||
private void resetToStream()
|
||||
{
|
||||
private void resetToStream() {
|
||||
this.m_cdataStartCalled = false;
|
||||
/* The stream is being reset. It is one of
|
||||
* ToXMLStream, ToHTMLStream ... and this type can't be changed
|
||||
* so neither should m_charInfo which is associated with the
|
||||
* type of Stream. Just leave m_charInfo as-is for the next re-use.
|
||||
*
|
||||
*/
|
||||
// this.m_charInfo = null; // don't set to null
|
||||
|
||||
@ -3183,173 +3092,150 @@ abstract public class ToStream extends SerializerBase
|
||||
*
|
||||
* @xsl.usage internal
|
||||
*/
|
||||
static final class BoolStack
|
||||
{
|
||||
static final class BoolStack {
|
||||
/** Array of boolean values */
|
||||
private boolean m_values[];
|
||||
|
||||
/** Array of boolean values */
|
||||
private boolean m_values[];
|
||||
/** Array size allocated */
|
||||
private int m_allocatedSize;
|
||||
|
||||
/** Array size allocated */
|
||||
private int m_allocatedSize;
|
||||
/** Index into the array of booleans */
|
||||
private int m_index;
|
||||
|
||||
/** Index into the array of booleans */
|
||||
private int m_index;
|
||||
/**
|
||||
* Default constructor. Note that the default
|
||||
* block size is very small, for small lists.
|
||||
*/
|
||||
public BoolStack() {
|
||||
this(32);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default constructor. Note that the default
|
||||
* block size is very small, for small lists.
|
||||
*/
|
||||
public BoolStack()
|
||||
{
|
||||
this(32);
|
||||
}
|
||||
/**
|
||||
* Construct a IntVector, using the given block size.
|
||||
*
|
||||
* @param size array size to allocate
|
||||
*/
|
||||
public BoolStack(int size) {
|
||||
m_allocatedSize = size;
|
||||
m_values = new boolean[size];
|
||||
m_index = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a IntVector, using the given block size.
|
||||
*
|
||||
* @param size array size to allocate
|
||||
*/
|
||||
public BoolStack(int size)
|
||||
{
|
||||
/**
|
||||
* Get the length of the list.
|
||||
*
|
||||
* @return Current length of the list
|
||||
*/
|
||||
public final int size() {
|
||||
return m_index + 1;
|
||||
}
|
||||
|
||||
m_allocatedSize = size;
|
||||
m_values = new boolean[size];
|
||||
m_index = -1;
|
||||
}
|
||||
/**
|
||||
* Clears the stack.
|
||||
*
|
||||
*/
|
||||
public final void clear() {
|
||||
m_index = -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the length of the list.
|
||||
*
|
||||
* @return Current length of the list
|
||||
*/
|
||||
public final int size()
|
||||
{
|
||||
return m_index + 1;
|
||||
}
|
||||
/**
|
||||
* Pushes an item onto the top of this stack.
|
||||
*
|
||||
*
|
||||
* @param val the boolean to be pushed onto this stack.
|
||||
* @return the <code>item</code> argument.
|
||||
*/
|
||||
public final boolean push(boolean val) {
|
||||
if (m_index == m_allocatedSize - 1)
|
||||
grow();
|
||||
|
||||
/**
|
||||
* Clears the stack.
|
||||
*
|
||||
*/
|
||||
public final void clear()
|
||||
{
|
||||
m_index = -1;
|
||||
}
|
||||
return (m_values[++m_index] = val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pushes an item onto the top of this stack.
|
||||
*
|
||||
*
|
||||
* @param val the boolean to be pushed onto this stack.
|
||||
* @return the <code>item</code> argument.
|
||||
*/
|
||||
public final boolean push(boolean val)
|
||||
{
|
||||
/**
|
||||
* Removes the object at the top of this stack and returns that
|
||||
* object as the value of this function.
|
||||
*
|
||||
* @return The object at the top of this stack.
|
||||
* @throws EmptyStackException if this stack is empty.
|
||||
*/
|
||||
public final boolean pop() {
|
||||
return m_values[m_index--];
|
||||
}
|
||||
|
||||
if (m_index == m_allocatedSize - 1)
|
||||
grow();
|
||||
/**
|
||||
* Removes the object at the top of this stack and returns the
|
||||
* next object at the top as the value of this function.
|
||||
*
|
||||
*
|
||||
* @return Next object to the top or false if none there
|
||||
*/
|
||||
public final boolean popAndTop() {
|
||||
m_index--;
|
||||
return (m_index >= 0) ? m_values[m_index] : false;
|
||||
}
|
||||
|
||||
return (m_values[++m_index] = val);
|
||||
}
|
||||
/**
|
||||
* Set the item at the top of this stack
|
||||
*
|
||||
*
|
||||
* @param b Object to set at the top of this stack
|
||||
*/
|
||||
public final void setTop(boolean b) {
|
||||
m_values[m_index] = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the object at the top of this stack and returns that
|
||||
* object as the value of this function.
|
||||
*
|
||||
* @return The object at the top of this stack.
|
||||
* @throws EmptyStackException if this stack is empty.
|
||||
*/
|
||||
public final boolean pop()
|
||||
{
|
||||
return m_values[m_index--];
|
||||
}
|
||||
/**
|
||||
* Looks at the object at the top of this stack without removing it
|
||||
* from the stack.
|
||||
*
|
||||
* @return the object at the top of this stack.
|
||||
* @throws EmptyStackException if this stack is empty.
|
||||
*/
|
||||
public final boolean peek() {
|
||||
return m_values[m_index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the object at the top of this stack and returns the
|
||||
* next object at the top as the value of this function.
|
||||
*
|
||||
*
|
||||
* @return Next object to the top or false if none there
|
||||
*/
|
||||
public final boolean popAndTop()
|
||||
{
|
||||
/**
|
||||
* Looks at the object at the top of this stack without removing it
|
||||
* from the stack. If the stack is empty, it returns false.
|
||||
*
|
||||
* @return the object at the top of this stack.
|
||||
*/
|
||||
public final boolean peekOrFalse() {
|
||||
return (m_index > -1) ? m_values[m_index] : false;
|
||||
}
|
||||
|
||||
m_index--;
|
||||
/**
|
||||
* Looks at the object at the top of this stack without removing it
|
||||
* from the stack. If the stack is empty, it returns true.
|
||||
*
|
||||
* @return the object at the top of this stack.
|
||||
*/
|
||||
public final boolean peekOrTrue() {
|
||||
return (m_index > -1) ? m_values[m_index] : true;
|
||||
}
|
||||
|
||||
return (m_index >= 0) ? m_values[m_index] : false;
|
||||
}
|
||||
/**
|
||||
* Tests if this stack is empty.
|
||||
*
|
||||
* @return <code>true</code> if this stack is empty;
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return (m_index == -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the item at the top of this stack
|
||||
*
|
||||
*
|
||||
* @param b Object to set at the top of this stack
|
||||
*/
|
||||
public final void setTop(boolean b)
|
||||
{
|
||||
m_values[m_index] = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks at the object at the top of this stack without removing it
|
||||
* from the stack.
|
||||
*
|
||||
* @return the object at the top of this stack.
|
||||
* @throws EmptyStackException if this stack is empty.
|
||||
*/
|
||||
public final boolean peek()
|
||||
{
|
||||
return m_values[m_index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks at the object at the top of this stack without removing it
|
||||
* from the stack. If the stack is empty, it returns false.
|
||||
*
|
||||
* @return the object at the top of this stack.
|
||||
*/
|
||||
public final boolean peekOrFalse()
|
||||
{
|
||||
return (m_index > -1) ? m_values[m_index] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks at the object at the top of this stack without removing it
|
||||
* from the stack. If the stack is empty, it returns true.
|
||||
*
|
||||
* @return the object at the top of this stack.
|
||||
*/
|
||||
public final boolean peekOrTrue()
|
||||
{
|
||||
return (m_index > -1) ? m_values[m_index] : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if this stack is empty.
|
||||
*
|
||||
* @return <code>true</code> if this stack is empty;
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return (m_index == -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Grows the size of the stack
|
||||
*
|
||||
*/
|
||||
private void grow()
|
||||
{
|
||||
|
||||
m_allocatedSize *= 2;
|
||||
|
||||
boolean newVector[] = new boolean[m_allocatedSize];
|
||||
|
||||
System.arraycopy(m_values, 0, newVector, 0, m_index + 1);
|
||||
|
||||
m_values = newVector;
|
||||
}
|
||||
/**
|
||||
* Grows the size of the stack
|
||||
*
|
||||
*/
|
||||
private void grow() {
|
||||
m_allocatedSize *= 2;
|
||||
boolean newVector[] = new boolean[m_allocatedSize];
|
||||
System.arraycopy(m_values, 0, newVector, 0, m_index + 1);
|
||||
m_values = newVector;
|
||||
}
|
||||
}
|
||||
|
||||
// Implement DTDHandler
|
||||
@ -3421,14 +3307,12 @@ abstract public class ToStream extends SerializerBase
|
||||
* @throws IOException
|
||||
*/
|
||||
private void DTDprolog() throws SAXException, IOException {
|
||||
final java.io.Writer writer = m_writer;
|
||||
if (m_needToOutputDocTypeDecl)
|
||||
{
|
||||
final Writer writer = m_writer;
|
||||
if (m_needToOutputDocTypeDecl) {
|
||||
outputDocTypeDecl(m_elemContext.m_elementName, false);
|
||||
m_needToOutputDocTypeDecl = false;
|
||||
}
|
||||
if (m_inDoctype)
|
||||
{
|
||||
if (m_inDoctype) {
|
||||
writer.write(" [");
|
||||
writer.write(m_lineSep, 0, m_lineSepLen);
|
||||
m_inDoctype = false;
|
||||
|
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
@ -17,9 +17,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* $Id: ToUnknownStream.java,v 1.3 2005/09/28 13:49:08 pvedula Exp $
|
||||
*/
|
||||
|
||||
package com.sun.org.apache.xml.internal.serializer;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -27,17 +25,14 @@ import java.io.OutputStream;
|
||||
import java.io.Writer;
|
||||
import java.util.Properties;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.xml.transform.SourceLocator;
|
||||
import javax.xml.transform.Transformer;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.Locator;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
|
||||
/**
|
||||
*This class wraps another SerializationHandler. The wrapped object will either
|
||||
* handler XML or HTML, which is not known until a little later when the first XML
|
||||
@ -55,7 +50,6 @@ import org.xml.sax.SAXException;
|
||||
*/
|
||||
public final class ToUnknownStream extends SerializerBase
|
||||
{
|
||||
|
||||
/**
|
||||
* The wrapped handler, initially XML but possibly switched to HTML
|
||||
*/
|
||||
@ -71,11 +65,11 @@ public final class ToUnknownStream extends SerializerBase
|
||||
*/
|
||||
private boolean m_wrapped_handler_not_initialized = false;
|
||||
|
||||
|
||||
/**
|
||||
* the prefix of the very first tag in the document
|
||||
*/
|
||||
private String m_firstElementPrefix;
|
||||
|
||||
/**
|
||||
* the element name (including any prefix) of the very first tag in the document
|
||||
*/
|
||||
@ -101,6 +95,7 @@ public final class ToUnknownStream extends SerializerBase
|
||||
* _namespacePrefix has the matching prefix for these URI's
|
||||
*/
|
||||
private ArrayList<String> m_namespaceURI = null;
|
||||
|
||||
/**
|
||||
* A collection of namespace Prefix (only for first element)
|
||||
* _namespaceURI has the matching URIs for these prefix'
|
||||
@ -112,34 +107,13 @@ public final class ToUnknownStream extends SerializerBase
|
||||
* was initialized
|
||||
*/
|
||||
private boolean m_needToCallStartDocument = false;
|
||||
/**
|
||||
* true if setVersion() was called before the underlying handler
|
||||
* was initialized
|
||||
*/
|
||||
private boolean m_setVersion_called = false;
|
||||
/**
|
||||
* true if setDoctypeSystem() was called before the underlying handler
|
||||
* was initialized
|
||||
*/
|
||||
private boolean m_setDoctypeSystem_called = false;
|
||||
/**
|
||||
* true if setDoctypePublic() was called before the underlying handler
|
||||
* was initialized
|
||||
*/
|
||||
private boolean m_setDoctypePublic_called = false;
|
||||
/**
|
||||
* true if setMediaType() was called before the underlying handler
|
||||
* was initialized
|
||||
*/
|
||||
private boolean m_setMediaType_called = false;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
* Initially this object wraps an XML Stream object, so _handler is never null.
|
||||
* That may change later to an HTML Stream object.
|
||||
*/
|
||||
public ToUnknownStream()
|
||||
{
|
||||
public ToUnknownStream() {
|
||||
m_handler = new ToXMLStream();
|
||||
}
|
||||
|
||||
@ -147,8 +121,7 @@ public final class ToUnknownStream extends SerializerBase
|
||||
* @see Serializer#asContentHandler()
|
||||
* @return the wrapped XML or HTML handler
|
||||
*/
|
||||
public ContentHandler asContentHandler() throws IOException
|
||||
{
|
||||
public ContentHandler asContentHandler() throws IOException {
|
||||
/* don't return the real handler ( m_handler ) because
|
||||
* that would expose the real handler to the outside.
|
||||
* Keep m_handler private so it can be internally swapped
|
||||
@ -160,8 +133,7 @@ public final class ToUnknownStream extends SerializerBase
|
||||
/**
|
||||
* @see SerializationHandler#close()
|
||||
*/
|
||||
public void close()
|
||||
{
|
||||
public void close() {
|
||||
m_handler.close();
|
||||
}
|
||||
|
||||
@ -169,8 +141,7 @@ public final class ToUnknownStream extends SerializerBase
|
||||
* @see Serializer#getOutputFormat()
|
||||
* @return the properties of the underlying handler
|
||||
*/
|
||||
public Properties getOutputFormat()
|
||||
{
|
||||
public Properties getOutputFormat() {
|
||||
return m_handler.getOutputFormat();
|
||||
}
|
||||
|
||||
@ -178,8 +149,7 @@ public final class ToUnknownStream extends SerializerBase
|
||||
* @see Serializer#getOutputStream()
|
||||
* @return the OutputStream of the underlying XML or HTML handler
|
||||
*/
|
||||
public OutputStream getOutputStream()
|
||||
{
|
||||
public OutputStream getOutputStream() {
|
||||
return m_handler.getOutputStream();
|
||||
}
|
||||
|
||||
@ -187,8 +157,7 @@ public final class ToUnknownStream extends SerializerBase
|
||||
* @see Serializer#getWriter()
|
||||
* @return the Writer of the underlying XML or HTML handler
|
||||
*/
|
||||
public Writer getWriter()
|
||||
{
|
||||
public Writer getWriter() {
|
||||
return m_handler.getWriter();
|
||||
}
|
||||
|
||||
@ -197,8 +166,7 @@ public final class ToUnknownStream extends SerializerBase
|
||||
* @see Serializer#reset()
|
||||
* @return ???
|
||||
*/
|
||||
public boolean reset()
|
||||
{
|
||||
public boolean reset() {
|
||||
return m_handler.reset();
|
||||
}
|
||||
|
||||
@ -208,10 +176,8 @@ public final class ToUnknownStream extends SerializerBase
|
||||
* @see DOMSerializer#serialize(Node)
|
||||
*
|
||||
*/
|
||||
public void serialize(Node node) throws IOException
|
||||
{
|
||||
if (m_firstTagNotEmitted)
|
||||
{
|
||||
public void serialize(Node node) throws IOException {
|
||||
if (m_firstTagNotEmitted) {
|
||||
flush();
|
||||
}
|
||||
m_handler.serialize(node);
|
||||
@ -220,8 +186,7 @@ public final class ToUnknownStream extends SerializerBase
|
||||
/**
|
||||
* @see SerializationHandler#setEscaping(boolean)
|
||||
*/
|
||||
public boolean setEscaping(boolean escape) throws SAXException
|
||||
{
|
||||
public boolean setEscaping(boolean escape) throws SAXException {
|
||||
return m_handler.setEscaping(escape);
|
||||
}
|
||||
|
||||
@ -230,8 +195,7 @@ public final class ToUnknownStream extends SerializerBase
|
||||
* @param format the output properties to set
|
||||
* @see Serializer#setOutputFormat(Properties)
|
||||
*/
|
||||
public void setOutputFormat(Properties format)
|
||||
{
|
||||
public void setOutputFormat(Properties format) {
|
||||
m_handler.setOutputFormat(format);
|
||||
}
|
||||
|
||||
@ -240,8 +204,7 @@ public final class ToUnknownStream extends SerializerBase
|
||||
* @param output the OutputStream to write to
|
||||
* @see Serializer#setOutputStream(OutputStream)
|
||||
*/
|
||||
public void setOutputStream(OutputStream output)
|
||||
{
|
||||
public void setOutputStream(OutputStream output) {
|
||||
m_handler.setOutputStream(output);
|
||||
}
|
||||
|
||||
@ -250,8 +213,7 @@ public final class ToUnknownStream extends SerializerBase
|
||||
* @param writer the writer to write to
|
||||
* @see Serializer#setWriter(Writer)
|
||||
*/
|
||||
public void setWriter(Writer writer)
|
||||
{
|
||||
public void setWriter(Writer writer) {
|
||||
m_handler.setWriter(writer);
|
||||
}
|
||||
|
||||
@ -265,12 +227,8 @@ public final class ToUnknownStream extends SerializerBase
|
||||
* @param XSLAttribute true if this attribute is coming from an xsl:attribute element
|
||||
* @see ExtendedContentHandler#addAttribute(String, String, String, String, String)
|
||||
*/
|
||||
public void addAttribute(
|
||||
String uri,
|
||||
String localName,
|
||||
String rawName,
|
||||
String type,
|
||||
String value)
|
||||
public void addAttribute(String uri, String localName, String rawName,
|
||||
String type, String value)
|
||||
throws SAXException
|
||||
{
|
||||
addAttribute(uri, localName, rawName, type, value, false);
|
||||
@ -286,35 +244,27 @@ public final class ToUnknownStream extends SerializerBase
|
||||
* @param XSLAttribute true if this attribute is coming from an xsl:attribute element
|
||||
* @see ExtendedContentHandler#addAttribute(String, String, String, String, String)
|
||||
*/
|
||||
public void addAttribute(
|
||||
String uri,
|
||||
String localName,
|
||||
String rawName,
|
||||
String type,
|
||||
String value,
|
||||
boolean XSLAttribute)
|
||||
public void addAttribute(String uri, String localName, String rawName,
|
||||
String type, String value, boolean XSLAttribute)
|
||||
throws SAXException
|
||||
{
|
||||
if (m_firstTagNotEmitted)
|
||||
{
|
||||
if (m_firstTagNotEmitted) {
|
||||
flush();
|
||||
}
|
||||
m_handler.addAttribute(uri, localName, rawName, type, value, XSLAttribute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an attribute to the currenly open tag
|
||||
* @param rawName the attribute name, with prefix (if any)
|
||||
* @param value the value of the parameter
|
||||
* @see ExtendedContentHandler#addAttribute(String, String)
|
||||
*/
|
||||
public void addAttribute(String rawName, String value)
|
||||
{
|
||||
if (m_firstTagNotEmitted)
|
||||
{
|
||||
public void addAttribute(String rawName, String value) {
|
||||
if (m_firstTagNotEmitted) {
|
||||
flush();
|
||||
}
|
||||
m_handler.addAttribute(rawName, value);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -323,52 +273,50 @@ public final class ToUnknownStream extends SerializerBase
|
||||
public void addUniqueAttribute(String rawName, String value, int flags)
|
||||
throws SAXException
|
||||
{
|
||||
if (m_firstTagNotEmitted)
|
||||
{
|
||||
if (m_firstTagNotEmitted) {
|
||||
flush();
|
||||
}
|
||||
m_handler.addUniqueAttribute(rawName, value, flags);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the String to a character array and calls the SAX method
|
||||
* characters(char[],int,int);
|
||||
*
|
||||
* @param chars The string of characters to process.
|
||||
*
|
||||
* @throws org.xml.sax.SAXException
|
||||
*
|
||||
* @see ExtendedContentHandler#characters(String)
|
||||
*/
|
||||
public void characters(String chars) throws SAXException
|
||||
{
|
||||
final int length = chars.length();
|
||||
if (length > m_charsBuff.length)
|
||||
{
|
||||
m_charsBuff = new char[length*2 + 1];
|
||||
public void characters(String chars) throws SAXException {
|
||||
final int len = (chars == null) ? 0 : chars.length();
|
||||
if (len > m_charsBuff.length) {
|
||||
m_charsBuff = new char[len * 2 + 1];
|
||||
}
|
||||
chars.getChars(0, length, m_charsBuff, 0);
|
||||
this.characters(m_charsBuff, 0, length);
|
||||
if (len > 0) {
|
||||
chars.getChars(0, len, m_charsBuff, 0);
|
||||
}
|
||||
this.characters(m_charsBuff, 0, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass the call on to the underlying handler
|
||||
* @see ExtendedContentHandler#endElement(String)
|
||||
*/
|
||||
public void endElement(String elementName) throws SAXException
|
||||
{
|
||||
if (m_firstTagNotEmitted)
|
||||
{
|
||||
public void endElement(String elementName) throws SAXException {
|
||||
if (m_firstTagNotEmitted) {
|
||||
flush();
|
||||
}
|
||||
m_handler.endElement(elementName);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ContentHandler#startPrefixMapping(String, String)
|
||||
* @param prefix The prefix that maps to the URI
|
||||
* @param uri The URI for the namespace
|
||||
*/
|
||||
public void startPrefixMapping(String prefix, String uri) throws SAXException
|
||||
{
|
||||
public void startPrefixMapping(String prefix, String uri) throws SAXException {
|
||||
this.startPrefixMapping(prefix,uri, true);
|
||||
}
|
||||
|
||||
@ -387,11 +335,12 @@ public final class ToUnknownStream extends SerializerBase
|
||||
throws SAXException
|
||||
{
|
||||
// hack for XSLTC with finding URI for default namespace
|
||||
if (m_firstTagNotEmitted && m_firstElementURI == null && m_firstElementName != null)
|
||||
if (m_firstTagNotEmitted &&
|
||||
m_firstElementURI == null &&
|
||||
m_firstElementName != null)
|
||||
{
|
||||
String prefix1 = getPrefixPart(m_firstElementName);
|
||||
if (prefix1 == null && EMPTYSTRING.equals(prefix))
|
||||
{
|
||||
if (prefix1 == null && EMPTYSTRING.equals(prefix)) {
|
||||
// the elements URI is not known yet, and it
|
||||
// doesn't have a prefix, and we are currently
|
||||
// setting the uri for prefix "", so we have
|
||||
@ -399,45 +348,36 @@ public final class ToUnknownStream extends SerializerBase
|
||||
m_firstElementURI = uri;
|
||||
}
|
||||
}
|
||||
startPrefixMapping(prefix,uri, false);
|
||||
startPrefixMapping(prefix, uri, false);
|
||||
}
|
||||
|
||||
public boolean startPrefixMapping(String prefix, String uri, boolean shouldFlush)
|
||||
throws SAXException
|
||||
{
|
||||
boolean pushed = false;
|
||||
if (m_firstTagNotEmitted)
|
||||
{
|
||||
if (m_firstElementName != null && shouldFlush)
|
||||
{
|
||||
if (m_firstTagNotEmitted) {
|
||||
if (m_firstElementName != null && shouldFlush) {
|
||||
/* we've already seen a startElement, and this is a prefix mapping
|
||||
* for the up coming element, so flush the old element
|
||||
* then send this event on its way.
|
||||
*/
|
||||
flush();
|
||||
pushed = m_handler.startPrefixMapping(prefix, uri, shouldFlush);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_namespacePrefix == null)
|
||||
{
|
||||
} else {
|
||||
if (m_namespacePrefix == null) {
|
||||
m_namespacePrefix = new ArrayList<>();
|
||||
m_namespaceURI = new ArrayList<>();
|
||||
}
|
||||
m_namespacePrefix.add(prefix);
|
||||
m_namespaceURI.add(uri);
|
||||
|
||||
if (m_firstElementURI == null)
|
||||
{
|
||||
if (m_firstElementURI == null) {
|
||||
if (prefix.equals(m_firstElementPrefix))
|
||||
m_firstElementURI = uri;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
pushed = m_handler.startPrefixMapping(prefix, uri, shouldFlush);
|
||||
} else {
|
||||
pushed = m_handler.startPrefixMapping(prefix, uri, shouldFlush);
|
||||
}
|
||||
return pushed;
|
||||
}
|
||||
@ -446,54 +386,39 @@ public final class ToUnknownStream extends SerializerBase
|
||||
* This method cannot be cached because default is different in
|
||||
* HTML and XML (we need more than a boolean).
|
||||
*/
|
||||
|
||||
public void setVersion(String version)
|
||||
{
|
||||
public void setVersion(String version) {
|
||||
m_handler.setVersion(version);
|
||||
|
||||
// Cache call to setVersion()
|
||||
// super.setVersion(version);
|
||||
m_setVersion_called = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.xml.sax.ContentHandler#startDocument()
|
||||
*/
|
||||
public void startDocument() throws SAXException
|
||||
{
|
||||
public void startDocument() throws SAXException {
|
||||
m_needToCallStartDocument = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void startElement(String qName) throws SAXException
|
||||
{
|
||||
public void startElement(String qName) throws SAXException {
|
||||
this.startElement(null, null, qName, null);
|
||||
}
|
||||
|
||||
public void startElement(String namespaceURI, String localName, String qName) throws SAXException
|
||||
{
|
||||
public void startElement(String namespaceURI, String localName,
|
||||
String qName) throws SAXException {
|
||||
this.startElement(namespaceURI, localName, qName, null);
|
||||
}
|
||||
|
||||
public void startElement(
|
||||
String namespaceURI,
|
||||
String localName,
|
||||
String elementName,
|
||||
Attributes atts) throws SAXException
|
||||
public void startElement(String namespaceURI, String localName,
|
||||
String elementName, Attributes atts)
|
||||
throws SAXException
|
||||
{
|
||||
|
||||
if (m_needToCallSetDocumentInfo){
|
||||
if (m_needToCallSetDocumentInfo) {
|
||||
super.setDocumentInfo();
|
||||
m_needToCallSetDocumentInfo = false;
|
||||
}
|
||||
|
||||
/* we are notified of the start of an element */
|
||||
if (m_firstTagNotEmitted)
|
||||
{
|
||||
if (m_firstTagNotEmitted) {
|
||||
/* we have not yet sent the first element on its way */
|
||||
if (m_firstElementName != null)
|
||||
{
|
||||
if (m_firstElementName != null) {
|
||||
/* this is not the first element, but a later one.
|
||||
* But we have the old element pending, so flush it out,
|
||||
* then send this one on its way.
|
||||
@ -645,16 +570,14 @@ public final class ToUnknownStream extends SerializerBase
|
||||
* Pass the call on to the underlying handler
|
||||
* @see XSLOutputAttributes#getVersion()
|
||||
*/
|
||||
public String getVersion()
|
||||
{
|
||||
public String getVersion() {
|
||||
return m_handler.getVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see XSLOutputAttributes#setDoctype(String, String)
|
||||
*/
|
||||
public void setDoctype(String system, String pub)
|
||||
{
|
||||
public void setDoctype(String system, String pub) {
|
||||
m_handler.setDoctypePublic(pub);
|
||||
m_handler.setDoctypeSystem(system);
|
||||
}
|
||||
@ -665,10 +588,8 @@ public final class ToUnknownStream extends SerializerBase
|
||||
* @param doctype the public doctype to set
|
||||
* @see XSLOutputAttributes#setDoctypePublic(String)
|
||||
*/
|
||||
public void setDoctypePublic(String doctype)
|
||||
{
|
||||
public void setDoctypePublic(String doctype) {
|
||||
m_handler.setDoctypePublic(doctype);
|
||||
m_setDoctypePublic_called = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -677,18 +598,15 @@ public final class ToUnknownStream extends SerializerBase
|
||||
* @param doctype the system doctype to set
|
||||
* @see XSLOutputAttributes#setDoctypeSystem(String)
|
||||
*/
|
||||
public void setDoctypeSystem(String doctype)
|
||||
{
|
||||
public void setDoctypeSystem(String doctype) {
|
||||
m_handler.setDoctypeSystem(doctype);
|
||||
m_setDoctypeSystem_called = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass the call on to the underlying handler
|
||||
* @see XSLOutputAttributes#setEncoding(String)
|
||||
*/
|
||||
public void setEncoding(String encoding)
|
||||
{
|
||||
public void setEncoding(String encoding) {
|
||||
m_handler.setEncoding(encoding);
|
||||
}
|
||||
|
||||
@ -696,34 +614,29 @@ public final class ToUnknownStream extends SerializerBase
|
||||
* Pass the call on to the underlying handler
|
||||
* @see XSLOutputAttributes#setIndent(boolean)
|
||||
*/
|
||||
public void setIndent(boolean indent)
|
||||
{
|
||||
public void setIndent(boolean indent) {
|
||||
m_handler.setIndent(indent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass the call on to the underlying handler
|
||||
*/
|
||||
public void setIndentAmount(int value)
|
||||
{
|
||||
public void setIndentAmount(int value) {
|
||||
m_handler.setIndentAmount(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see XSLOutputAttributes#setMediaType(String)
|
||||
*/
|
||||
public void setMediaType(String mediaType)
|
||||
{
|
||||
public void setMediaType(String mediaType) {
|
||||
m_handler.setMediaType(mediaType);
|
||||
m_setMediaType_called = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass the call on to the underlying handler
|
||||
* @see XSLOutputAttributes#setOmitXMLDeclaration(boolean)
|
||||
*/
|
||||
public void setOmitXMLDeclaration(boolean b)
|
||||
{
|
||||
public void setOmitXMLDeclaration(boolean b) {
|
||||
m_handler.setOmitXMLDeclaration(b);
|
||||
}
|
||||
|
||||
@ -731,27 +644,16 @@ public final class ToUnknownStream extends SerializerBase
|
||||
* Pass the call on to the underlying handler
|
||||
* @see XSLOutputAttributes#setStandalone(String)
|
||||
*/
|
||||
public void setStandalone(String standalone)
|
||||
{
|
||||
public void setStandalone(String standalone) {
|
||||
m_handler.setStandalone(standalone);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see XSLOutputAttributes#setVersion(String)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pass the call on to the underlying handler
|
||||
* @see org.xml.sax.ext.DeclHandler#attributeDecl(String, String, String, String, String)
|
||||
*/
|
||||
public void attributeDecl(
|
||||
String arg0,
|
||||
String arg1,
|
||||
String arg2,
|
||||
String arg3,
|
||||
String arg4)
|
||||
throws SAXException
|
||||
{
|
||||
public void attributeDecl(String arg0, String arg1, String arg2,
|
||||
String arg3, String arg4) throws SAXException {
|
||||
m_handler.attributeDecl(arg0, arg1, arg2, arg3, arg4);
|
||||
}
|
||||
|
||||
@ -761,8 +663,7 @@ public final class ToUnknownStream extends SerializerBase
|
||||
*/
|
||||
public void elementDecl(String arg0, String arg1) throws SAXException
|
||||
{
|
||||
if (m_firstTagNotEmitted)
|
||||
{
|
||||
if (m_firstTagNotEmitted) {
|
||||
emitFirstTag();
|
||||
}
|
||||
m_handler.elementDecl(arg0, arg1);
|
||||
@ -778,8 +679,7 @@ public final class ToUnknownStream extends SerializerBase
|
||||
String systemId)
|
||||
throws SAXException
|
||||
{
|
||||
if (m_firstTagNotEmitted)
|
||||
{
|
||||
if (m_firstTagNotEmitted) {
|
||||
flush();
|
||||
}
|
||||
m_handler.externalEntityDecl(name, publicId, systemId);
|
||||
@ -792,8 +692,7 @@ public final class ToUnknownStream extends SerializerBase
|
||||
public void internalEntityDecl(String arg0, String arg1)
|
||||
throws SAXException
|
||||
{
|
||||
if (m_firstTagNotEmitted)
|
||||
{
|
||||
if (m_firstTagNotEmitted) {
|
||||
flush();
|
||||
}
|
||||
m_handler.internalEntityDecl(arg0, arg1);
|
||||
@ -806,29 +705,21 @@ public final class ToUnknownStream extends SerializerBase
|
||||
public void characters(char[] characters, int offset, int length)
|
||||
throws SAXException
|
||||
{
|
||||
if (m_firstTagNotEmitted)
|
||||
{
|
||||
if (m_firstTagNotEmitted) {
|
||||
flush();
|
||||
}
|
||||
|
||||
m_handler.characters(characters, offset, length);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Pass the call on to the underlying handler
|
||||
* @see org.xml.sax.ContentHandler#endDocument()
|
||||
*/
|
||||
public void endDocument() throws SAXException
|
||||
{
|
||||
if (m_firstTagNotEmitted)
|
||||
{
|
||||
public void endDocument() throws SAXException {
|
||||
if (m_firstTagNotEmitted) {
|
||||
flush();
|
||||
}
|
||||
|
||||
m_handler.endDocument();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -838,17 +729,14 @@ public final class ToUnknownStream extends SerializerBase
|
||||
public void endElement(String namespaceURI, String localName, String qName)
|
||||
throws SAXException
|
||||
{
|
||||
if (m_firstTagNotEmitted)
|
||||
{
|
||||
if (m_firstTagNotEmitted) {
|
||||
flush();
|
||||
if (namespaceURI == null && m_firstElementURI != null)
|
||||
namespaceURI = m_firstElementURI;
|
||||
|
||||
|
||||
if (localName == null && m_firstElementLocalName != null)
|
||||
localName = m_firstElementLocalName;
|
||||
}
|
||||
|
||||
m_handler.endElement(namespaceURI, localName, qName);
|
||||
}
|
||||
|
||||
@ -856,8 +744,7 @@ public final class ToUnknownStream extends SerializerBase
|
||||
* Pass the call on to the underlying handler
|
||||
* @see org.xml.sax.ContentHandler#endPrefixMapping(String)
|
||||
*/
|
||||
public void endPrefixMapping(String prefix) throws SAXException
|
||||
{
|
||||
public void endPrefixMapping(String prefix) throws SAXException {
|
||||
m_handler.endPrefixMapping(prefix);
|
||||
}
|
||||
|
||||
@ -1071,12 +958,9 @@ public final class ToUnknownStream extends SerializerBase
|
||||
m_wrapped_handler_not_initialized = false;
|
||||
}
|
||||
|
||||
private void emitFirstTag() throws SAXException
|
||||
{
|
||||
if (m_firstElementName != null)
|
||||
{
|
||||
if (m_wrapped_handler_not_initialized)
|
||||
{
|
||||
private void emitFirstTag() throws SAXException {
|
||||
if (m_firstElementName != null) {
|
||||
if (m_wrapped_handler_not_initialized) {
|
||||
initStreamOutput();
|
||||
m_wrapped_handler_not_initialized = false;
|
||||
}
|
||||
@ -1086,14 +970,11 @@ public final class ToUnknownStream extends SerializerBase
|
||||
m_attributes = null;
|
||||
|
||||
// Output namespaces of first tag
|
||||
if (m_namespacePrefix != null)
|
||||
{
|
||||
if (m_namespacePrefix != null) {
|
||||
final int n = m_namespacePrefix.size();
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
final String prefix =
|
||||
(String) m_namespacePrefix.get(i);
|
||||
final String uri = (String) m_namespaceURI.get(i);
|
||||
for (int i = 0; i < n; i++) {
|
||||
final String prefix = m_namespacePrefix.get(i);
|
||||
final String uri = m_namespaceURI.get(i);
|
||||
m_handler.startPrefixMapping(prefix, uri, false);
|
||||
}
|
||||
m_namespacePrefix = null;
|
||||
@ -1109,8 +990,7 @@ public final class ToUnknownStream extends SerializerBase
|
||||
* Don't want to override static function on SerializerBase
|
||||
* So added Unknown suffix to method name.
|
||||
*/
|
||||
private String getLocalNameUnknown(String value)
|
||||
{
|
||||
private String getLocalNameUnknown(String value) {
|
||||
int idx = value.lastIndexOf(':');
|
||||
if (idx >= 0)
|
||||
value = value.substring(idx + 1);
|
||||
@ -1121,13 +1001,12 @@ public final class ToUnknownStream extends SerializerBase
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function to return prefix
|
||||
*
|
||||
* Don't want to override static function on SerializerBase
|
||||
* So added Unknown suffix to method name.
|
||||
*/
|
||||
private String getPrefixPartUnknown(String qname)
|
||||
{
|
||||
* Utility function to return prefix
|
||||
*
|
||||
* Don't want to override static function on SerializerBase
|
||||
* So added Unknown suffix to method name.
|
||||
*/
|
||||
private String getPrefixPartUnknown(String qname) {
|
||||
final int index = qname.indexOf(':');
|
||||
return (index > 0) ? qname.substring(0, index) : EMPTYSTRING;
|
||||
}
|
||||
@ -1139,8 +1018,7 @@ public final class ToUnknownStream extends SerializerBase
|
||||
*
|
||||
* @return true if the first element is an opening <html> tag
|
||||
*/
|
||||
private boolean isFirstElemHTML()
|
||||
{
|
||||
private boolean isFirstElemHTML() {
|
||||
boolean isHTML;
|
||||
|
||||
// is the first tag html, not considering the prefix ?
|
||||
@ -1148,29 +1026,27 @@ public final class ToUnknownStream extends SerializerBase
|
||||
getLocalNameUnknown(m_firstElementName).equalsIgnoreCase("html");
|
||||
|
||||
// Try to rule out if this is not to be an HTML document based on URI
|
||||
if (isHTML
|
||||
&& m_firstElementURI != null
|
||||
&& !EMPTYSTRING.equals(m_firstElementURI))
|
||||
if (isHTML &&
|
||||
m_firstElementURI != null &&
|
||||
!EMPTYSTRING.equals(m_firstElementURI))
|
||||
{
|
||||
// the <html> element has a non-trivial namespace
|
||||
isHTML = false;
|
||||
}
|
||||
// Try to rule out if this is an not to be an HTML document based on prefix
|
||||
if (isHTML && m_namespacePrefix != null)
|
||||
{
|
||||
if (isHTML && m_namespacePrefix != null) {
|
||||
/* the first element has a name of "html", but lets check the prefix.
|
||||
* If the prefix points to a namespace with a URL that is not ""
|
||||
* then the doecument doesn't start with an <html> tag, and isn't html
|
||||
*/
|
||||
final int max = m_namespacePrefix.size();
|
||||
for (int i = 0; i < max; i++)
|
||||
{
|
||||
for (int i = 0; i < max; i++) {
|
||||
final String prefix = m_namespacePrefix.get(i);
|
||||
final String uri = m_namespaceURI.get(i);
|
||||
|
||||
if (m_firstElementPrefix != null
|
||||
&& m_firstElementPrefix.equals(prefix)
|
||||
&& !EMPTYSTRING.equals(uri))
|
||||
if (m_firstElementPrefix != null &&
|
||||
m_firstElementPrefix.equals(prefix) &&
|
||||
!EMPTYSTRING.equals(uri))
|
||||
{
|
||||
// The first element has a prefix, so it can't be <html>
|
||||
isHTML = false;
|
||||
@ -1181,11 +1057,11 @@ public final class ToUnknownStream extends SerializerBase
|
||||
}
|
||||
return isHTML;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Serializer#asDOMSerializer()
|
||||
*/
|
||||
public DOMSerializer asDOMSerializer() throws IOException
|
||||
{
|
||||
public DOMSerializer asDOMSerializer() throws IOException {
|
||||
return m_handler.asDOMSerializer();
|
||||
}
|
||||
|
||||
@ -1194,15 +1070,14 @@ public final class ToUnknownStream extends SerializerBase
|
||||
* specified in the cdata-section-elements attribute.
|
||||
* @see SerializationHandler#setCdataSectionElements(java.util.Vector)
|
||||
*/
|
||||
public void setCdataSectionElements(ArrayList<String> URI_and_localNames)
|
||||
{
|
||||
public void setCdataSectionElements(ArrayList<String> URI_and_localNames) {
|
||||
m_handler.setCdataSectionElements(URI_and_localNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ExtendedContentHandler#addAttributes(org.xml.sax.Attributes)
|
||||
*/
|
||||
public void addAttributes(Attributes atts) throws SAXException
|
||||
{
|
||||
public void addAttributes(Attributes atts) throws SAXException {
|
||||
m_handler.addAttributes(atts);
|
||||
}
|
||||
|
||||
@ -1211,98 +1086,83 @@ public final class ToUnknownStream extends SerializerBase
|
||||
* Simply returns the mappings of the wrapped handler.
|
||||
* @see ExtendedContentHandler#getNamespaceMappings()
|
||||
*/
|
||||
public NamespaceMappings getNamespaceMappings()
|
||||
{
|
||||
public NamespaceMappings getNamespaceMappings() {
|
||||
NamespaceMappings mappings = null;
|
||||
if (m_handler != null)
|
||||
{
|
||||
if (m_handler != null) {
|
||||
mappings = m_handler.getNamespaceMappings();
|
||||
}
|
||||
return mappings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SerializationHandler#flushPending()
|
||||
*/
|
||||
public void flushPending() throws SAXException
|
||||
{
|
||||
|
||||
public void flushPending() throws SAXException {
|
||||
flush();
|
||||
|
||||
m_handler.flushPending();
|
||||
}
|
||||
|
||||
private void flush()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (m_firstTagNotEmitted)
|
||||
{
|
||||
emitFirstTag();
|
||||
}
|
||||
if (m_needToCallStartDocument)
|
||||
{
|
||||
m_handler.startDocument();
|
||||
m_needToCallStartDocument = false;
|
||||
}
|
||||
}
|
||||
catch(SAXException e)
|
||||
{
|
||||
private void flush() {
|
||||
try {
|
||||
if (m_firstTagNotEmitted) {
|
||||
emitFirstTag();
|
||||
}
|
||||
if (m_needToCallStartDocument) {
|
||||
m_handler.startDocument();
|
||||
m_needToCallStartDocument = false;
|
||||
}
|
||||
} catch(SAXException e) {
|
||||
throw new RuntimeException(e.toString());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ExtendedContentHandler#getPrefix
|
||||
*/
|
||||
public String getPrefix(String namespaceURI)
|
||||
{
|
||||
public String getPrefix(String namespaceURI) {
|
||||
return m_handler.getPrefix(namespaceURI);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ExtendedContentHandler#entityReference(java.lang.String)
|
||||
*/
|
||||
public void entityReference(String entityName) throws SAXException
|
||||
{
|
||||
public void entityReference(String entityName) throws SAXException {
|
||||
m_handler.entityReference(entityName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ExtendedContentHandler#getNamespaceURI(java.lang.String, boolean)
|
||||
*/
|
||||
public String getNamespaceURI(String qname, boolean isElement)
|
||||
{
|
||||
public String getNamespaceURI(String qname, boolean isElement) {
|
||||
return m_handler.getNamespaceURI(qname, isElement);
|
||||
}
|
||||
|
||||
public String getNamespaceURIFromPrefix(String prefix)
|
||||
{
|
||||
public String getNamespaceURIFromPrefix(String prefix) {
|
||||
return m_handler.getNamespaceURIFromPrefix(prefix);
|
||||
}
|
||||
|
||||
public void setTransformer(Transformer t)
|
||||
{
|
||||
public void setTransformer(Transformer t) {
|
||||
m_handler.setTransformer(t);
|
||||
if ((t instanceof SerializerTrace) &&
|
||||
(((SerializerTrace) t).hasTraceListeners())) {
|
||||
m_tracer = (SerializerTrace) t;
|
||||
(((SerializerTrace) t).hasTraceListeners()))
|
||||
{
|
||||
m_tracer = (SerializerTrace) t;
|
||||
} else {
|
||||
m_tracer = null;
|
||||
m_tracer = null;
|
||||
}
|
||||
}
|
||||
public Transformer getTransformer()
|
||||
{
|
||||
|
||||
public Transformer getTransformer() {
|
||||
return m_handler.getTransformer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see SerializationHandler#setContentHandler(org.xml.sax.ContentHandler)
|
||||
*/
|
||||
public void setContentHandler(ContentHandler ch)
|
||||
{
|
||||
public void setContentHandler(ContentHandler ch) {
|
||||
m_handler.setContentHandler(ch);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to set the source locator, which might be used to
|
||||
* generated an error message.
|
||||
@ -1310,14 +1170,11 @@ public final class ToUnknownStream extends SerializerBase
|
||||
*
|
||||
* @see ExtendedContentHandler#setSourceLocator(javax.xml.transform.SourceLocator)
|
||||
*/
|
||||
public void setSourceLocator(SourceLocator locator)
|
||||
{
|
||||
public void setSourceLocator(SourceLocator locator) {
|
||||
m_handler.setSourceLocator(locator);
|
||||
}
|
||||
|
||||
protected void firePseudoElement(String elementName)
|
||||
{
|
||||
|
||||
protected void firePseudoElement(String elementName) {
|
||||
if (m_tracer != null) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
|
62
jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/XSLOutputAttributes.java
62
jaxp/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/XSLOutputAttributes.java
@ -3,13 +3,12 @@
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
*/
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
@ -19,9 +18,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* $Id: XSLOutputAttributes.java,v 1.2.4.1 2005/09/15 08:15:32 suresh_emailid Exp $
|
||||
*/
|
||||
|
||||
package com.sun.org.apache.xml.internal.serializer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -55,8 +52,7 @@ import java.util.ArrayList;
|
||||
*
|
||||
* @xsl.usage internal
|
||||
*/
|
||||
interface XSLOutputAttributes
|
||||
{
|
||||
interface XSLOutputAttributes {
|
||||
/**
|
||||
* Returns the previously set value of the value to be used as the public
|
||||
* identifier in the document type declaration (DTD).
|
||||
@ -65,6 +61,7 @@ interface XSLOutputAttributes
|
||||
* output document.
|
||||
*/
|
||||
public String getDoctypePublic();
|
||||
|
||||
/**
|
||||
* Returns the previously set value of the value to be used
|
||||
* as the system identifier in the document type declaration (DTD).
|
||||
@ -73,13 +70,15 @@ interface XSLOutputAttributes
|
||||
*
|
||||
*/
|
||||
public String getDoctypeSystem();
|
||||
|
||||
/**
|
||||
* @return the character encoding to be used in the output document.
|
||||
*/
|
||||
public String getEncoding();
|
||||
|
||||
/**
|
||||
* @return true if the output document should be indented to visually
|
||||
* indicate its structure.
|
||||
* @return true if the output document should be indented to visually
|
||||
* indicate its structure.
|
||||
*/
|
||||
public boolean getIndent();
|
||||
|
||||
@ -87,21 +86,25 @@ interface XSLOutputAttributes
|
||||
* @return the number of spaces to indent for each indentation level.
|
||||
*/
|
||||
public int getIndentAmount();
|
||||
|
||||
/**
|
||||
* @return the mediatype the media-type or MIME type associated with the
|
||||
* output document.
|
||||
*/
|
||||
public String getMediaType();
|
||||
|
||||
/**
|
||||
* @return true if the XML declaration is to be omitted from the output
|
||||
* document.
|
||||
*/
|
||||
public boolean getOmitXMLDeclaration();
|
||||
|
||||
/**
|
||||
* @return a value of "yes" if the <code>standalone</code> delaration is to
|
||||
* be included in the output document.
|
||||
*/
|
||||
* @return a value of "yes" if the <code>standalone</code> delaration is to
|
||||
* be included in the output document.
|
||||
*/
|
||||
public String getStandalone();
|
||||
|
||||
/**
|
||||
* @return the version of the output format.
|
||||
*/
|
||||
@ -132,20 +135,23 @@ interface XSLOutputAttributes
|
||||
public void setDoctype(String system, String pub);
|
||||
|
||||
/** Set the value coming from the xsl:output doctype-public stylesheet attribute.
|
||||
* @param doctype the public identifier to be used in the DOCTYPE
|
||||
* declaration in the output document.
|
||||
*/
|
||||
* @param doctype the public identifier to be used in the DOCTYPE
|
||||
* declaration in the output document.
|
||||
*/
|
||||
public void setDoctypePublic(String doctype);
|
||||
|
||||
/** Set the value coming from the xsl:output doctype-system stylesheet attribute.
|
||||
* @param doctype the system identifier to be used in the DOCTYPE
|
||||
* declaration in the output document.
|
||||
*/
|
||||
* @param doctype the system identifier to be used in the DOCTYPE
|
||||
* declaration in the output document.
|
||||
*/
|
||||
public void setDoctypeSystem(String doctype);
|
||||
|
||||
/**
|
||||
* Sets the character encoding coming from the xsl:output encoding stylesheet attribute.
|
||||
* @param encoding the character encoding
|
||||
*/
|
||||
public void setEncoding(String encoding);
|
||||
|
||||
/**
|
||||
* Sets the value coming from the xsl:output indent stylesheet
|
||||
* attribute.
|
||||
@ -153,18 +159,21 @@ interface XSLOutputAttributes
|
||||
* indicate its structure.
|
||||
*/
|
||||
public void setIndent(boolean indent);
|
||||
|
||||
/**
|
||||
* Sets the value coming from the xsl:output media-type stylesheet attribute.
|
||||
* @param mediatype the media-type or MIME type associated with the output
|
||||
* document.
|
||||
*/
|
||||
public void setMediaType(String mediatype);
|
||||
|
||||
/**
|
||||
* Sets the value coming from the xsl:output omit-xml-declaration stylesheet attribute
|
||||
* @param b true if the XML declaration is to be omitted from the output
|
||||
* document.
|
||||
*/
|
||||
public void setOmitXMLDeclaration(boolean b);
|
||||
|
||||
/**
|
||||
* Sets the value coming from the xsl:output standalone stylesheet attribute.
|
||||
* @param standalone a value of "yes" indicates that the
|
||||
@ -172,6 +181,7 @@ interface XSLOutputAttributes
|
||||
* document.
|
||||
*/
|
||||
public void setStandalone(String standalone);
|
||||
|
||||
/**
|
||||
* Sets the value coming from the xsl:output version attribute.
|
||||
* @param version the version of the output format.
|
||||
@ -194,6 +204,7 @@ interface XSLOutputAttributes
|
||||
* @return The value of the parameter
|
||||
*/
|
||||
public String getOutputProperty(String name);
|
||||
|
||||
/**
|
||||
* Get the default value for a property that affects seraialization,
|
||||
* or null if there is none. It is possible that a non-default value
|
||||
@ -203,6 +214,7 @@ interface XSLOutputAttributes
|
||||
* @return The default value of the parameter, or null if there is no default value.
|
||||
*/
|
||||
public String getOutputPropertyDefault(String name);
|
||||
|
||||
/**
|
||||
* Set the non-default value for a property that affects seraialization.
|
||||
* @param name The name of the property, which is just the local name
|
||||
@ -216,7 +228,7 @@ interface XSLOutputAttributes
|
||||
* </ul>
|
||||
* @val The non-default value of the parameter
|
||||
*/
|
||||
public void setOutputProperty(String name, String val);
|
||||
public void setOutputProperty(String name, String val);
|
||||
|
||||
/**
|
||||
* Set the default value for a property that affects seraialization.
|
||||
@ -231,5 +243,5 @@ interface XSLOutputAttributes
|
||||
* </ul>
|
||||
* @val The default value of the parameter
|
||||
*/
|
||||
public void setOutputPropertyDefault(String name, String val);
|
||||
public void setOutputPropertyDefault(String name, String val);
|
||||
}
|
||||
|
@ -81,6 +81,8 @@ public class XMLReaderManager {
|
||||
private boolean _useCatalog;
|
||||
private CatalogFeatures _catalogFeatures;
|
||||
|
||||
private int _cdataChunkSize;
|
||||
|
||||
/**
|
||||
* Hidden constructor
|
||||
*/
|
||||
@ -173,13 +175,12 @@ public class XMLReaderManager {
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
//reader is cached, but this property might have been reset
|
||||
reader.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, _accessExternalDTD);
|
||||
} catch (SAXException se) {
|
||||
XMLSecurityManager.printWarning(reader.getClass().getName(),
|
||||
XMLConstants.ACCESS_EXTERNAL_DTD, se);
|
||||
}
|
||||
//reader is cached, but this property might have been reset
|
||||
JdkXmlUtils.setXMLReaderPropertyIfSupport(reader, XMLConstants.ACCESS_EXTERNAL_DTD,
|
||||
_accessExternalDTD, true);
|
||||
|
||||
JdkXmlUtils.setXMLReaderPropertyIfSupport(reader, JdkXmlUtils.CDATA_CHUNK_SIZE,
|
||||
_cdataChunkSize, false);
|
||||
|
||||
String lastProperty = "";
|
||||
try {
|
||||
@ -278,7 +279,8 @@ public class XMLReaderManager {
|
||||
_xmlSecurityManager = (XMLSecurityManager)value;
|
||||
} else if (JdkXmlFeatures.CATALOG_FEATURES.equals(name)) {
|
||||
_catalogFeatures = (CatalogFeatures)value;
|
||||
} else if (JdkXmlUtils.CDATA_CHUNK_SIZE.equals(name)) {
|
||||
_cdataChunkSize = JdkXmlUtils.getValue(value, _cdataChunkSize);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
package jdk.xml.internal;
|
||||
|
||||
import com.sun.org.apache.xalan.internal.utils.XMLSecurityManager;
|
||||
import com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings;
|
||||
import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
|
||||
import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
|
||||
@ -39,6 +40,7 @@ import org.xml.sax.XMLReader;
|
||||
* Constants for use across JAXP processors.
|
||||
*/
|
||||
public class JdkXmlUtils {
|
||||
|
||||
/**
|
||||
* Catalog features
|
||||
*/
|
||||
@ -58,11 +60,63 @@ public class JdkXmlUtils {
|
||||
/**
|
||||
* Default value of USE_CATALOG. This will read the System property
|
||||
*/
|
||||
public static final boolean USE_CATALOG_DEFAULT =
|
||||
SecuritySupport.getJAXPSystemProperty(SP_USE_CATALOG, true);
|
||||
public static final boolean USE_CATALOG_DEFAULT
|
||||
= SecuritySupport.getJAXPSystemProperty(Boolean.class, SP_USE_CATALOG, "true");
|
||||
|
||||
/**
|
||||
* JDK features (will be consolidated in the next major feature revamp
|
||||
*/
|
||||
public final static String CDATA_CHUNK_SIZE = "jdk.xml.cdataChunkSize";
|
||||
public static final int CDATA_CHUNK_SIZE_DEFAULT
|
||||
= SecuritySupport.getJAXPSystemProperty(Integer.class, CDATA_CHUNK_SIZE, "0");
|
||||
|
||||
/**
|
||||
* Returns the value.
|
||||
*
|
||||
* @param value the specified value
|
||||
* @param defValue the default value
|
||||
* @return the value, or the default value if the value is null
|
||||
*/
|
||||
public static int getValue(Object value, int defValue) {
|
||||
if (value == null) {
|
||||
return defValue;
|
||||
}
|
||||
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).intValue();
|
||||
} else if (value instanceof String) {
|
||||
return Integer.parseInt(String.valueOf(value));
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unexpected class: "
|
||||
+ value.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the XMLReader instance with the specified property if the the
|
||||
* property is supported, ignores error if not, issues a warning if so
|
||||
* requested.
|
||||
*
|
||||
* @param reader an XMLReader instance
|
||||
* @param property the name of the property
|
||||
* @param value the value of the property
|
||||
* @param warn a flag indicating whether a warning should be issued
|
||||
*/
|
||||
public static void setXMLReaderPropertyIfSupport(XMLReader reader, String property,
|
||||
Object value, boolean warn) {
|
||||
try {
|
||||
reader.setProperty(property, value);
|
||||
} catch (SAXNotRecognizedException | SAXNotSupportedException e) {
|
||||
if (warn) {
|
||||
XMLSecurityManager.printWarning(reader.getClass().getName(),
|
||||
property, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of a Catalog feature by the property name.
|
||||
*
|
||||
* @param features a CatalogFeatures instance
|
||||
* @param name the name of a Catalog feature
|
||||
* @return the value of a Catalog feature, null if the name does not match
|
||||
@ -106,10 +160,9 @@ public class JdkXmlUtils {
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Passing on the CatalogFeatures settings from one Xerces configuration object
|
||||
* to another.
|
||||
* Passing on the CatalogFeatures settings from one Xerces configuration
|
||||
* object to another.
|
||||
*
|
||||
* @param config1 a Xerces configuration object
|
||||
* @param config2 a Xerces configuration object
|
||||
@ -120,14 +173,13 @@ public class JdkXmlUtils {
|
||||
boolean useCatalog = config1.getFeature(XMLConstants.USE_CATALOG);
|
||||
try {
|
||||
config2.setFeature(JdkXmlUtils.USE_CATALOG, useCatalog);
|
||||
}
|
||||
catch (XMLConfigurationException e) {
|
||||
} catch (XMLConfigurationException e) {
|
||||
supportCatalog = false;
|
||||
}
|
||||
|
||||
if (supportCatalog && useCatalog) {
|
||||
try {
|
||||
for( CatalogFeatures.Feature f : CatalogFeatures.Feature.values()) {
|
||||
for (CatalogFeatures.Feature f : CatalogFeatures.Feature.values()) {
|
||||
config2.setProperty(f.getPropertyName(), config1.getProperty(f.getPropertyName()));
|
||||
}
|
||||
} catch (XMLConfigurationException e) {
|
||||
@ -137,8 +189,8 @@ public class JdkXmlUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Passing on the CatalogFeatures settings from a Xerces configuration object
|
||||
* to an XMLReader.
|
||||
* Passing on the CatalogFeatures settings from a Xerces configuration
|
||||
* object to an XMLReader.
|
||||
*
|
||||
* @param config a Xerces configuration object
|
||||
* @param reader an XMLReader
|
||||
@ -148,14 +200,13 @@ public class JdkXmlUtils {
|
||||
boolean useCatalog = config.getFeature(XMLConstants.USE_CATALOG);
|
||||
try {
|
||||
reader.setFeature(JdkXmlUtils.USE_CATALOG, useCatalog);
|
||||
}
|
||||
catch (SAXNotRecognizedException | SAXNotSupportedException e) {
|
||||
} catch (SAXNotRecognizedException | SAXNotSupportedException e) {
|
||||
supportCatalog = false;
|
||||
}
|
||||
|
||||
if (supportCatalog && useCatalog) {
|
||||
try {
|
||||
for( CatalogFeatures.Feature f : CatalogFeatures.Feature.values()) {
|
||||
for (CatalogFeatures.Feature f : CatalogFeatures.Feature.values()) {
|
||||
reader.setProperty(f.getPropertyName(), config.getProperty(f.getPropertyName()));
|
||||
}
|
||||
} catch (SAXNotRecognizedException | SAXNotSupportedException e) {
|
||||
|
@ -83,19 +83,26 @@ public class SecuritySupport {
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads boolean type system property.
|
||||
* Reads a system property.
|
||||
*
|
||||
* @param <T> the type of the property value
|
||||
* @param type the type of the property value
|
||||
* @param propName the name of the property
|
||||
* @param defValue the default value
|
||||
* @return the value of the property, or the default value of no system
|
||||
* property is found
|
||||
*/
|
||||
public static boolean getJAXPSystemProperty(String propName, boolean defValue) {
|
||||
public static <T> T getJAXPSystemProperty(Class<T> type, String propName, String defValue) {
|
||||
String value = getJAXPSystemProperty(propName);
|
||||
if (value == null) {
|
||||
return defValue;
|
||||
value = defValue;
|
||||
}
|
||||
return Boolean.parseBoolean(value);
|
||||
if (Integer.class.isAssignableFrom(type)) {
|
||||
return type.cast(Integer.parseInt(value));
|
||||
} else if (Boolean.class.isAssignableFrom(type)) {
|
||||
return type.cast(Boolean.parseBoolean(value));
|
||||
}
|
||||
return type.cast(value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,7 +55,7 @@ TEE = tee
|
||||
UNAME = uname
|
||||
UNIQ = uniq
|
||||
WC = wc
|
||||
ZIP = zip
|
||||
ZIPEXE = zip
|
||||
|
||||
# Get OS name from uname (Cygwin inexplicably adds _NT-5.1)
|
||||
UNAME_S := $(shell $(UNAME) -s | $(CUT) -f1 -d_)
|
||||
@ -130,7 +130,7 @@ endif
|
||||
ZIP_UP_RESULTS = ( $(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)` \
|
||||
&& $(CD) $(ABS_TEST_OUTPUT_DIR) \
|
||||
&& $(CHMOD) -R a+r . \
|
||||
&& $(ZIP) -q -r $(ARCHIVE_BUNDLE) . )
|
||||
&& $(ZIPEXE) -q -r $(ARCHIVE_BUNDLE) . )
|
||||
|
||||
# important results files
|
||||
SUMMARY_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport/text/summary.txt")
|
||||
|
@ -23,4 +23,4 @@
|
||||
#
|
||||
###########################################################################
|
||||
|
||||
javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.sh 8147431 generic-all
|
||||
javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.sh 8169827 generic-all
|
||||
|
@ -23,6 +23,7 @@
|
||||
package jaxp.library;
|
||||
|
||||
|
||||
import java.net.URL;
|
||||
import java.security.CodeSource;
|
||||
import java.security.Permission;
|
||||
import java.security.PermissionCollection;
|
||||
@ -34,6 +35,7 @@ import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.PropertyPermission;
|
||||
import java.util.Set;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
|
||||
@ -107,12 +109,7 @@ public class JAXPPolicyManager {
|
||||
addPermission(new SecurityPermission("getPolicy"));
|
||||
addPermission(new SecurityPermission("setPolicy"));
|
||||
addPermission(new RuntimePermission("setSecurityManager"));
|
||||
//Properties that jtreg and TestNG require
|
||||
addPermission(new PropertyPermission("testng.show.stack.frames", "read"));
|
||||
addPermission(new PropertyPermission("test.src", "read"));
|
||||
addPermission(new PropertyPermission("test.classes", "read"));
|
||||
addPermission(new PropertyPermission("dataproviderthreadcount", "read"));
|
||||
addPermission(new PropertyPermission("experimental", "read"));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -163,6 +160,8 @@ public class JAXPPolicyManager {
|
||||
* JAXP concrete classes.
|
||||
*/
|
||||
class TestPolicy extends Policy {
|
||||
private final static Set<String> TEST_JARS =
|
||||
Set.of("jtreg.jar", "javatest.jar", "testng.jar", "jcommander.jar");
|
||||
private final PermissionCollection permissions = new Permissions();
|
||||
|
||||
private ThreadLocal<Map<Integer, Permission>> transientPermissions = new ThreadLocal<>();
|
||||
@ -211,6 +210,16 @@ class TestPolicy extends Policy {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
private boolean isTestMachineryDomain(ProtectionDomain domain) {
|
||||
CodeSource cs = (domain == null) ? null : domain.getCodeSource();
|
||||
URL loc = (cs == null) ? null : cs.getLocation();
|
||||
String path = (loc == null) ? null : loc.getPath();
|
||||
return path != null && TEST_JARS.stream()
|
||||
.filter(path::endsWith)
|
||||
.findAny()
|
||||
.isPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean implies(ProtectionDomain domain, Permission perm) {
|
||||
if (allowAll())
|
||||
@ -221,8 +230,11 @@ class TestPolicy extends Policy {
|
||||
|
||||
if (permissions.implies(perm))
|
||||
return true;
|
||||
else
|
||||
return tmpImplies(perm);
|
||||
|
||||
if (isTestMachineryDomain(domain))
|
||||
return true;
|
||||
|
||||
return tmpImplies(perm);
|
||||
}
|
||||
|
||||
/*
|
||||
|
284
jaxp/test/javax/xml/jaxp/unittest/common/CDataChunkSizeTest.java
Normal file
284
jaxp/test/javax/xml/jaxp/unittest/common/CDataChunkSizeTest.java
Normal file
File diff suppressed because one or more lines are too long
@ -27,17 +27,20 @@ import static jaxp.library.JAXPTestUtilities.getSystemProperty;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMResult;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.sax.SAXSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
@ -47,6 +50,7 @@ import org.testng.AssertJUnit;
|
||||
import org.testng.annotations.Listeners;
|
||||
import org.testng.annotations.Test;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.ContentHandler;
|
||||
@ -69,33 +73,10 @@ import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
|
||||
* @run testng/othervm -DrunSecMngr=true transform.TransformerTest
|
||||
* @run testng/othervm transform.TransformerTest
|
||||
* @summary Transformer Tests
|
||||
* @bug 6272879 6305029 6505031 8150704 8162598
|
||||
* @bug 6272879 6305029 6505031 8150704 8162598 8169772
|
||||
*/
|
||||
@Listeners({jaxp.library.FilePolicy.class})
|
||||
public class TransformerTest {
|
||||
private Transformer createTransformer() throws TransformerException {
|
||||
return TransformerFactory.newInstance().newTransformer();
|
||||
}
|
||||
|
||||
private Transformer createTransformerFromInputstream(InputStream xslStream) throws TransformerException {
|
||||
return TransformerFactory.newInstance().newTransformer(new StreamSource(xslStream));
|
||||
}
|
||||
|
||||
private Transformer createTransformerFromResource(String xslResource) throws TransformerException {
|
||||
return TransformerFactory.newInstance().newTransformer(new StreamSource(getClass().getResource(xslResource).toString()));
|
||||
}
|
||||
|
||||
private Document transformInputStreamToDocument(Transformer transformer, InputStream sourceStream) throws TransformerException {
|
||||
DOMResult response = new DOMResult();
|
||||
transformer.transform(new StreamSource(sourceStream), response);
|
||||
return (Document)response.getNode();
|
||||
}
|
||||
|
||||
private StringWriter transformResourceToStringWriter(Transformer transformer, String xmlResource) throws TransformerException {
|
||||
StringWriter sw = new StringWriter();
|
||||
transformer.transform(new StreamSource(getClass().getResource(xmlResource).toString()), new StreamResult(sw));
|
||||
return sw;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the contents of the given file into a string.
|
||||
@ -302,10 +283,15 @@ public class TransformerTest {
|
||||
System.out.println(sourceXml);
|
||||
System.out.println();
|
||||
|
||||
// transform to DOM result
|
||||
TransformerFactory tf = TransformerFactory.newInstance();
|
||||
Transformer t = tf.newTransformer(new StreamSource(new ByteArrayInputStream(xsl.getBytes())));
|
||||
DOMResult result = new DOMResult();
|
||||
t.transform(new StreamSource(new ByteArrayInputStream(sourceXml.getBytes())), result);
|
||||
Document document = (Document)result.getNode();
|
||||
|
||||
System.out.println("Result after transformation:");
|
||||
System.out.println("============================");
|
||||
Document document = transformInputStreamToDocument(createTransformerFromInputstream(new ByteArrayInputStream(xsl.getBytes())),
|
||||
new ByteArrayInputStream(sourceXml.getBytes()));
|
||||
OutputFormat format = new OutputFormat();
|
||||
format.setIndenting(true);
|
||||
new XMLSerializer(System.out, format).serialize(document);
|
||||
@ -335,13 +321,14 @@ public class TransformerTest {
|
||||
// test SAXSource
|
||||
SAXSource saxSource = new SAXSource(new XMLReaderFor6305029(), new InputSource());
|
||||
StringWriter resultWriter = new StringWriter();
|
||||
createTransformer().transform(saxSource, new StreamResult(resultWriter));
|
||||
TransformerFactory tf = TransformerFactory.newInstance();
|
||||
tf.newTransformer().transform(saxSource, new StreamResult(resultWriter));
|
||||
AssertJUnit.assertEquals("Identity transform of SAXSource", XML_DOCUMENT, resultWriter.toString());
|
||||
|
||||
// test StreamSource
|
||||
StreamSource streamSource = new StreamSource(new StringReader(XML_DOCUMENT));
|
||||
resultWriter = new StringWriter();
|
||||
createTransformer().transform(streamSource, new StreamResult(resultWriter));
|
||||
tf.newTransformer().transform(streamSource, new StreamResult(resultWriter));
|
||||
AssertJUnit.assertEquals("Identity transform of StreamSource", XML_DOCUMENT, resultWriter.toString());
|
||||
}
|
||||
|
||||
@ -351,10 +338,13 @@ public class TransformerTest {
|
||||
*/
|
||||
@Test
|
||||
public final void testBug6505031() throws TransformerException {
|
||||
Transformer transformer = createTransformerFromResource("transform.xsl");
|
||||
transformer.setParameter("config", getClass().getResource("config.xml").toString());
|
||||
transformer.setParameter("mapsFile", getClass().getResource("maps.xml").toString());
|
||||
String s = transformResourceToStringWriter(transformer, "template.xml").toString();
|
||||
TransformerFactory tf = TransformerFactory.newInstance();
|
||||
Transformer t = tf.newTransformer(new StreamSource(getClass().getResource("transform.xsl").toString()));
|
||||
t.setParameter("config", getClass().getResource("config.xml").toString());
|
||||
t.setParameter("mapsFile", getClass().getResource("maps.xml").toString());
|
||||
StringWriter sw = new StringWriter();
|
||||
t.transform(new StreamSource(getClass().getResource("template.xml").toString()), new StreamResult(sw));
|
||||
String s = sw.toString();
|
||||
Assert.assertTrue(s.contains("map1key1value") && s.contains("map2key1value"));
|
||||
}
|
||||
|
||||
@ -365,17 +355,20 @@ public class TransformerTest {
|
||||
@Test
|
||||
public final void testBug8150704() throws TransformerException, IOException {
|
||||
System.out.println("Testing transformation of Bug8150704-1.xml...");
|
||||
Transformer transformer = createTransformerFromResource("Bug8150704-1.xsl");
|
||||
StringWriter result = transformResourceToStringWriter(transformer, "Bug8150704-1.xml");
|
||||
String resultstring = result.toString().replaceAll("\\r\\n", "\n").replaceAll("\\r", "\n");
|
||||
TransformerFactory tf = TransformerFactory.newInstance();
|
||||
Transformer t = tf.newTransformer(new StreamSource(getClass().getResource("Bug8150704-1.xsl").toString()));
|
||||
StringWriter sw = new StringWriter();
|
||||
t.transform(new StreamSource(getClass().getResource("Bug8150704-1.xml").toString()), new StreamResult(sw));
|
||||
String resultstring = sw.toString().replaceAll("\\r\\n", "\n").replaceAll("\\r", "\n");
|
||||
String reference = getFileContentAsString(new File(getClass().getResource("Bug8150704-1.ref").getPath()));
|
||||
Assert.assertEquals(resultstring, reference, "Output of transformation of Bug8150704-1.xml does not match reference");
|
||||
System.out.println("Passed.");
|
||||
|
||||
System.out.println("Testing transformation of Bug8150704-2.xml...");
|
||||
transformer = createTransformerFromResource("Bug8150704-2.xsl");
|
||||
result = transformResourceToStringWriter(transformer, "Bug8150704-2.xml");
|
||||
resultstring = result.toString().replaceAll("\\r\\n", "\n").replaceAll("\\r", "\n");
|
||||
t = tf.newTransformer(new StreamSource(getClass().getResource("Bug8150704-2.xsl").toString()));
|
||||
sw = new StringWriter();
|
||||
t.transform(new StreamSource(getClass().getResource("Bug8150704-2.xml").toString()), new StreamResult(sw));
|
||||
resultstring = sw.toString().replaceAll("\\r\\n", "\n").replaceAll("\\r", "\n");
|
||||
reference = getFileContentAsString(new File(getClass().getResource("Bug8150704-2.ref").getPath()));
|
||||
Assert.assertEquals(resultstring, reference, "Output of transformation of Bug8150704-2.xml does not match reference");
|
||||
System.out.println("Passed.");
|
||||
@ -422,11 +415,15 @@ public class TransformerTest {
|
||||
System.out.println(sourceXml);
|
||||
System.out.println();
|
||||
|
||||
// transform to DOM result
|
||||
TransformerFactory tf = TransformerFactory.newInstance();
|
||||
Transformer t = tf.newTransformer(new StreamSource(new ByteArrayInputStream(xsl.getBytes())));
|
||||
DOMResult result = new DOMResult();
|
||||
t.transform(new StreamSource(new ByteArrayInputStream(sourceXml.getBytes())), result);
|
||||
Document document = (Document)result.getNode();
|
||||
|
||||
System.out.println("Result after transformation:");
|
||||
System.out.println("============================");
|
||||
Document document = transformInputStreamToDocument(
|
||||
createTransformerFromInputstream(new ByteArrayInputStream(xsl.getBytes())),
|
||||
new ByteArrayInputStream(sourceXml.getBytes()));
|
||||
OutputFormat format = new OutputFormat();
|
||||
format.setIndenting(true);
|
||||
new XMLSerializer(System.out, format).serialize(document);
|
||||
@ -438,4 +435,38 @@ public class TransformerTest {
|
||||
checkNodeNS8162598(document.getElementsByTagName("test5").item(0), "ns1", "ns1", null);
|
||||
Assert.assertNull(document.getElementsByTagName("test6").item(0).getNamespaceURI(), "unexpected namespace for test6");
|
||||
}
|
||||
|
||||
/**
|
||||
* @bug 8169772
|
||||
* @summary Test transformation of DOM with null valued text node
|
||||
*
|
||||
* This test would throw a NullPointerException during transform when the
|
||||
* fix was not present.
|
||||
*/
|
||||
@Test
|
||||
public final void testBug8169772() throws ParserConfigurationException,
|
||||
SAXException, IOException, TransformerException
|
||||
{
|
||||
// create a small DOM
|
||||
Document doc = DocumentBuilderFactory.newInstance().
|
||||
newDocumentBuilder().parse(
|
||||
new ByteArrayInputStream(
|
||||
"<?xml version=\"1.0\"?><DOCROOT/>".getBytes()
|
||||
)
|
||||
);
|
||||
|
||||
// insert a bad element
|
||||
Element e = doc.createElement("ERROR");
|
||||
e.appendChild(doc.createTextNode(null));
|
||||
doc.getDocumentElement().appendChild(e);
|
||||
|
||||
// transform
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
TransformerFactory.newInstance().newTransformer().transform(
|
||||
new DOMSource(doc.getDocumentElement()), new StreamResult(bos)
|
||||
);
|
||||
System.out.println("Transformation result (DOM with null text node):");
|
||||
System.out.println("================================================");
|
||||
System.out.println(bos);
|
||||
}
|
||||
}
|
||||
|
@ -388,3 +388,4 @@ e93b7ea559759f036c9f69fd2ddaf47bb4e98385 jdk-9+140
|
||||
8dbc8594f9d5149bf1c22221272284609408227a jdk-9+143
|
||||
efa71dc820eb8bd5a6c9f2f66f39c383ac3ee99d jdk-9+144
|
||||
99b7853cfbd8227c4441de4b6119c10742556840 jdk-9+145
|
||||
6e4ff59afb5d0adf21a72c4ff534326594a99e5d jdk-9+146
|
||||
|
@ -181,6 +181,7 @@ DEF_POLICY_SRC := $(JDK_TOPDIR)/src/java.base/share/lib/security/default.policy
|
||||
DEF_POLICY_DST := $(LIB_DST_DIR)/security/default.policy
|
||||
|
||||
DEF_POLICY_SRC_LIST := $(DEF_POLICY_SRC)
|
||||
DEF_POLICY_SRC_LIST += $(CUSTOM_POLICY_SRC_LIST)
|
||||
|
||||
ifneq ($(filter $(OPENJDK_TARGET_OS), windows solaris), )
|
||||
DEF_POLICY_SRC_LIST += $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS)/lib/security/default.policy
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2104, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2104, 2016, 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
|
||||
@ -30,8 +30,7 @@ include CopyCommon.gmk
|
||||
ifeq ($(OPENJDK_TARGET_OS), windows)
|
||||
TARGETS += $(INCLUDE_DST_OS_DIR)/bridge/AccessBridgeCallbacks.h \
|
||||
$(INCLUDE_DST_OS_DIR)/bridge/AccessBridgeCalls.h \
|
||||
$(INCLUDE_DST_OS_DIR)/bridge/AccessBridgePackages.h \
|
||||
$(INCLUDE_DST_OS_DIR)/bridge/AccessBridgeCalls.c
|
||||
$(INCLUDE_DST_OS_DIR)/bridge/AccessBridgePackages.h
|
||||
|
||||
$(INCLUDE_DST_OS_DIR)/bridge/%: \
|
||||
$(JDK_TOPDIR)/src/jdk.accessibility/windows/native/include/bridge/%
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2014, 2016, 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
|
||||
@ -71,7 +71,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
|
||||
|
||||
$$(eval $$(call SetupNativeCompilation, BUILD_JACCESSINSPECTOR$1, \
|
||||
SRC := $(TOPDIR)/jaccessinspector $(TOPDIR)/common \
|
||||
$(TOPDIR)/toolscommon $(TOPDIR)/include/bridge, \
|
||||
$(TOPDIR)/toolscommon $(TOPDIR)/bridge, \
|
||||
CFLAGS := $$(CFLAGS_JDKEXE) $(TOOLS_CFLAGS) -DACCESSBRIDGE_ARCH_$2 -EHsc, \
|
||||
LDFLAGS := $$(LDFLAGS_JDKEXE) -stack:655360, \
|
||||
LIBS := advapi32.lib user32.lib, \
|
||||
@ -98,7 +98,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
|
||||
|
||||
$$(eval $$(call SetupNativeCompilation,BUILD_JACCESSWALKER$1, \
|
||||
SRC := $(TOPDIR)/jaccesswalker $(TOPDIR)/common \
|
||||
$(TOPDIR)/toolscommon $(TOPDIR)/include/bridge, \
|
||||
$(TOPDIR)/toolscommon $(TOPDIR)/bridge, \
|
||||
CFLAGS := $$(CFLAGS_JDKEXE) $(TOOLS_CFLAGS) -DACCESSBRIDGE_ARCH_$2 -EHsc, \
|
||||
LDFLAGS := $$(LDFLAGS_JDKEXE) -stack:655360, \
|
||||
LIBS := advapi32.lib comctl32.lib gdi32.lib user32.lib, \
|
||||
|
@ -356,7 +356,7 @@ ifeq ($(findstring $(OPENJDK_TARGET_OS),windows macosx),)
|
||||
$(X_CFLAGS), \
|
||||
WARNINGS_AS_ERRORS_xlc := false, \
|
||||
DISABLED_WARNINGS_gcc := type-limits pointer-to-int-cast \
|
||||
deprecated-declarations unused-result maybe-uninitialized format \
|
||||
unused-result maybe-uninitialized format \
|
||||
format-security int-to-pointer-cast parentheses, \
|
||||
DISABLED_WARNINGS_solstudio := E_DECLARATION_IN_CODE \
|
||||
E_ASSIGNMENT_TYPE_MISMATCH E_NON_CONST_INIT, \
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2014, 2016, 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
|
||||
@ -48,7 +48,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
|
||||
OPTIMIZATION := LOW, \
|
||||
CFLAGS := $(CFLAGS_JDKLIB) $(ACCESSBRIDGE_CFLAGS) \
|
||||
$(addprefix -I,$(JAVA_AB_SRCDIR)) \
|
||||
-I$(JDK_TOPDIR)/src/jdk.accessibility/windows/native/include/bridge \
|
||||
-I$(ROOT_SRCDIR)/include/bridge \
|
||||
-DACCESSBRIDGE_ARCH_$2, \
|
||||
LDFLAGS := $(LDFLAGS_JDKLIB) -subsystem:windows, \
|
||||
LIBS := kernel32.lib user32.lib gdi32.lib \
|
||||
@ -78,7 +78,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
|
||||
OPTIMIZATION := LOW, \
|
||||
CFLAGS := $(filter-out -MD, $(CFLAGS_JDKLIB)) -MT $(ACCESSBRIDGE_CFLAGS) \
|
||||
$(addprefix -I,$(WIN_AB_SRCDIR)) \
|
||||
-I$(JDK_TOPDIR)/src/jdk.accessibility/windows/native/include/bridge \
|
||||
-I$(ROOT_SRCDIR)/include/bridge \
|
||||
-DACCESSBRIDGE_ARCH_$2, \
|
||||
LDFLAGS := $(LDFLAGS_JDKLIB) -subsystem:windows \
|
||||
-def:$(ROOT_SRCDIR)/libwindowsaccessbridge/WinAccessBridge.DEF, \
|
||||
|
@ -194,11 +194,17 @@ public interface ObjectInputFilter {
|
||||
* When setting the filter, it should be stateless and idempotent,
|
||||
* reporting the same result when passed the same arguments.
|
||||
* <p>
|
||||
* The filter is configured using the {@link java.security.Security}
|
||||
* property {@code jdk.serialFilter} and can be overridden by
|
||||
* the System property {@code jdk.serialFilter}.
|
||||
*
|
||||
* The syntax is the same as for the {@link #createFilter(String) createFilter} method.
|
||||
* The filter is configured during the initialization of the {@code ObjectInputFilter.Config}
|
||||
* class. For example, by calling {@link #getSerialFilter() Config.getSerialFilter}.
|
||||
* If the system property {@code jdk.serialFilter} is defined, it is used
|
||||
* to configure the filter.
|
||||
* If the system property is not defined, and the {@link java.security.Security}
|
||||
* property {@code jdk.serialFilter} is defined then it is used to configure the filter.
|
||||
* Otherwise, the filter is not configured during initialization.
|
||||
* The syntax for each property is the same as for the
|
||||
* {@link #createFilter(String) createFilter} method.
|
||||
* If a filter is not configured, it can be set with
|
||||
* {@link #setSerialFilter(ObjectInputFilter) Config.setSerialFilter}.
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
|
@ -121,8 +121,11 @@ public interface CharSequence {
|
||||
* href="{@docRoot}/java/lang/Character.html#unicode">surrogate code
|
||||
* point</a> is passed through uninterpreted.
|
||||
*
|
||||
* <p>If the sequence is mutated while the stream is being read, the
|
||||
* result is undefined.
|
||||
* <p>The stream binds to this sequence when the terminal stream operation
|
||||
* commences (specifically, for mutable sequences the spliterator for the
|
||||
* stream is <a href="../Spliterator.html#binding"><em>late-binding</em></a>).
|
||||
* If the sequence is modified during that operation then the result is
|
||||
* undefined.
|
||||
*
|
||||
* @return an IntStream of char values from this sequence
|
||||
* @since 1.8
|
||||
@ -168,8 +171,11 @@ public interface CharSequence {
|
||||
* unpaired surrogates, and undefined code units, are zero-extended to
|
||||
* {@code int} values which are then passed to the stream.
|
||||
*
|
||||
* <p>If the sequence is mutated while the stream is being read, the result
|
||||
* is undefined.
|
||||
* <p>The stream binds to this sequence when the terminal stream operation
|
||||
* commences (specifically, for mutable sequences the spliterator for the
|
||||
* stream is <a href="../Spliterator.html#binding"><em>late-binding</em></a>).
|
||||
* If the sequence is modified during that operation then the result is
|
||||
* undefined.
|
||||
*
|
||||
* @return an IntStream of Unicode code points from this sequence
|
||||
* @since 1.8
|
||||
|
@ -2704,9 +2704,6 @@ public final class Class<T> implements java.io.Serializable,
|
||||
* Reflection support.
|
||||
*/
|
||||
|
||||
// Caches for certain reflective results
|
||||
private static boolean useCaches = true;
|
||||
|
||||
// reflection data that might get invalidated when JVM TI RedefineClasses() is called
|
||||
private static class ReflectionData<T> {
|
||||
volatile Field[] declaredFields;
|
||||
@ -2739,8 +2736,7 @@ public final class Class<T> implements java.io.Serializable,
|
||||
SoftReference<ReflectionData<T>> reflectionData = this.reflectionData;
|
||||
int classRedefinedCount = this.classRedefinedCount;
|
||||
ReflectionData<T> rd;
|
||||
if (useCaches &&
|
||||
reflectionData != null &&
|
||||
if (reflectionData != null &&
|
||||
(rd = reflectionData.get()) != null &&
|
||||
rd.redefinedCount == classRedefinedCount) {
|
||||
return rd;
|
||||
@ -2752,8 +2748,6 @@ public final class Class<T> implements java.io.Serializable,
|
||||
|
||||
private ReflectionData<T> newReflectionData(SoftReference<ReflectionData<T>> oldReflectionData,
|
||||
int classRedefinedCount) {
|
||||
if (!useCaches) return null;
|
||||
|
||||
while (true) {
|
||||
ReflectionData<T> rd = new ReflectionData<>(classRedefinedCount);
|
||||
// try to CAS it...
|
||||
@ -2819,7 +2813,6 @@ public final class Class<T> implements java.io.Serializable,
|
||||
// be propagated to the outside world, but must instead be copied
|
||||
// via ReflectionFactory.copyField.
|
||||
private Field[] privateGetDeclaredFields(boolean publicOnly) {
|
||||
checkInitted();
|
||||
Field[] res;
|
||||
ReflectionData<T> rd = reflectionData();
|
||||
if (rd != null) {
|
||||
@ -2842,7 +2835,6 @@ public final class Class<T> implements java.io.Serializable,
|
||||
// be propagated to the outside world, but must instead be copied
|
||||
// via ReflectionFactory.copyField.
|
||||
private Field[] privateGetPublicFields(Set<Class<?>> traversedInterfaces) {
|
||||
checkInitted();
|
||||
Field[] res;
|
||||
ReflectionData<T> rd = reflectionData();
|
||||
if (rd != null) {
|
||||
@ -2902,7 +2894,6 @@ public final class Class<T> implements java.io.Serializable,
|
||||
// objects must NOT be propagated to the outside world, but must
|
||||
// instead be copied via ReflectionFactory.copyConstructor.
|
||||
private Constructor<T>[] privateGetDeclaredConstructors(boolean publicOnly) {
|
||||
checkInitted();
|
||||
Constructor<T>[] res;
|
||||
ReflectionData<T> rd = reflectionData();
|
||||
if (rd != null) {
|
||||
@ -2937,7 +2928,6 @@ public final class Class<T> implements java.io.Serializable,
|
||||
// be propagated to the outside world, but must instead be copied
|
||||
// via ReflectionFactory.copyMethod.
|
||||
private Method[] privateGetDeclaredMethods(boolean publicOnly) {
|
||||
checkInitted();
|
||||
Method[] res;
|
||||
ReflectionData<T> rd = reflectionData();
|
||||
if (rd != null) {
|
||||
@ -3134,7 +3124,6 @@ public final class Class<T> implements java.io.Serializable,
|
||||
// be propagated to the outside world, but must instead be copied
|
||||
// via ReflectionFactory.copyMethod.
|
||||
private Method[] privateGetPublicMethods() {
|
||||
checkInitted();
|
||||
Method[] res;
|
||||
ReflectionData<T> rd = reflectionData();
|
||||
if (rd != null) {
|
||||
@ -3445,7 +3434,7 @@ public final class Class<T> implements java.io.Serializable,
|
||||
* @since 1.4
|
||||
*/
|
||||
public boolean desiredAssertionStatus() {
|
||||
ClassLoader loader = getClassLoader();
|
||||
ClassLoader loader = getClassLoader0();
|
||||
// If the loader is null this is a system class, so ask the VM
|
||||
if (loader == null)
|
||||
return desiredAssertionStatus0(this);
|
||||
@ -3490,39 +3479,6 @@ public final class Class<T> implements java.io.Serializable,
|
||||
}
|
||||
private static ReflectionFactory reflectionFactory;
|
||||
|
||||
// To be able to query system properties as soon as they're available
|
||||
private static boolean initted = false;
|
||||
private static void checkInitted() {
|
||||
if (initted) return;
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
public Void run() {
|
||||
// Tests to ensure the system properties table is fully
|
||||
// initialized. This is needed because reflection code is
|
||||
// called very early in the initialization process (before
|
||||
// command-line arguments have been parsed and therefore
|
||||
// these user-settable properties installed.) We assume that
|
||||
// if System.out is non-null then the System class has been
|
||||
// fully initialized and that the bulk of the startup code
|
||||
// has been run.
|
||||
|
||||
if (System.out == null) {
|
||||
// java.lang.System not yet fully initialized
|
||||
return null;
|
||||
}
|
||||
|
||||
// Doesn't use Boolean.getBoolean to avoid class init.
|
||||
String val =
|
||||
System.getProperty("sun.reflect.noCaches");
|
||||
if (val != null && val.equals("true")) {
|
||||
useCaches = false;
|
||||
}
|
||||
|
||||
initted = true;
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the elements of this enum class or null if this
|
||||
* Class object does not represent an enum type.
|
||||
|
@ -104,9 +104,9 @@ import sun.security.util.SecurityConstants;
|
||||
* class or resource itself.
|
||||
*
|
||||
* <p> Class loaders that support concurrent loading of classes are known as
|
||||
* <em>{@linkplain #isParallelCapable() parallel capable}</em> class loaders and
|
||||
* are required to register themselves at their class initialization time by
|
||||
* invoking the {@link
|
||||
* <em>{@linkplain #isRegisteredAsParallelCapable() parallel capable}</em> class
|
||||
* loaders and are required to register themselves at their class initialization
|
||||
* time by invoking the {@link
|
||||
* #registerAsParallelCapable <tt>ClassLoader.registerAsParallelCapable</tt>}
|
||||
* method. Note that the <tt>ClassLoader</tt> class is registered as parallel
|
||||
* capable by default. However, its subclasses still need to register themselves
|
||||
@ -1335,10 +1335,12 @@ public abstract class ClassLoader {
|
||||
* @return A <tt>URL</tt> object for reading the resource, or
|
||||
* <tt>null</tt> if the resource could not be found or the invoker
|
||||
* doesn't have adequate privileges to get the resource.
|
||||
* @throws NullPointerException If {@code name} is {@code null}
|
||||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
public URL getResource(String name) {
|
||||
Objects.requireNonNull(name);
|
||||
URL url;
|
||||
if (parent != null) {
|
||||
url = parent.getResource(name);
|
||||
@ -1382,12 +1384,14 @@ public abstract class ClassLoader {
|
||||
*
|
||||
* @throws IOException
|
||||
* If I/O errors occur
|
||||
* @throws NullPointerException If {@code name} is {@code null}
|
||||
*
|
||||
* @see #findResources(String)
|
||||
*
|
||||
* @since 1.2
|
||||
*/
|
||||
public Enumeration<URL> getResources(String name) throws IOException {
|
||||
Objects.requireNonNull(name);
|
||||
@SuppressWarnings("unchecked")
|
||||
Enumeration<URL>[] tmp = (Enumeration<URL>[]) new Enumeration<?>[2];
|
||||
if (parent != null) {
|
||||
@ -1434,11 +1438,14 @@ public abstract class ClassLoader {
|
||||
* that the class loader doesn't have access to will not be in the
|
||||
* stream.
|
||||
*
|
||||
* @throws NullPointerException If {@code name} is {@code null}
|
||||
*
|
||||
* @see #findResources(String)
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
public Stream<URL> resources(String name) {
|
||||
Objects.requireNonNull(name);
|
||||
int characteristics = Spliterator.NONNULL | Spliterator.IMMUTABLE;
|
||||
Supplier<Spliterator<URL>> si = () -> {
|
||||
try {
|
||||
@ -1495,7 +1502,8 @@ public abstract class ClassLoader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the caller as {@linkplain #isParallelCapable() parallel capable}.
|
||||
* Registers the caller as
|
||||
* {@linkplain #isRegisteredAsParallelCapable() parallel capable}.
|
||||
* The registration succeeds if and only if all of the following
|
||||
* conditions are met:
|
||||
* <ol>
|
||||
@ -1509,7 +1517,7 @@ public abstract class ClassLoader {
|
||||
* @return {@code true} if the caller is successfully registered as
|
||||
* parallel capable and {@code false} if otherwise.
|
||||
*
|
||||
* @see #isParallelCapable()
|
||||
* @see #isRegisteredAsParallelCapable()
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
@ -1521,7 +1529,7 @@ public abstract class ClassLoader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if this class loader is
|
||||
* Returns {@code true} if this class loader is registered as
|
||||
* {@linkplain #registerAsParallelCapable parallel capable}, otherwise
|
||||
* {@code false}.
|
||||
*
|
||||
@ -1532,7 +1540,7 @@ public abstract class ClassLoader {
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
public final boolean isParallelCapable() {
|
||||
public final boolean isRegisteredAsParallelCapable() {
|
||||
return ParallelLoaders.isRegistered(this.getClass());
|
||||
}
|
||||
|
||||
@ -1599,10 +1607,12 @@ public abstract class ClassLoader {
|
||||
*
|
||||
* @return An input stream for reading the resource, or <tt>null</tt>
|
||||
* if the resource could not be found
|
||||
* @throws NullPointerException If {@code name} is {@code null}
|
||||
*
|
||||
* @since 1.1
|
||||
*/
|
||||
public InputStream getResourceAsStream(String name) {
|
||||
Objects.requireNonNull(name);
|
||||
URL url = getResource(name);
|
||||
try {
|
||||
return url != null ? url.openStream() : null;
|
||||
|
@ -200,7 +200,8 @@ public final class Constructor<T> extends Executable {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Returns the {@code Class} object representing the class that
|
||||
* declares the constructor represented by this object.
|
||||
*/
|
||||
@Override
|
||||
public Class<T> getDeclaringClass() {
|
||||
@ -321,6 +322,11 @@ public final class Constructor<T> extends Executable {
|
||||
* public java.util.Hashtable(int,float)
|
||||
* }</pre>
|
||||
*
|
||||
* <p>If the constructor is declared to throw exceptions, the
|
||||
* parameter list is followed by a space, followed by the word
|
||||
* "{@code throws}" followed by a comma-separated list of the
|
||||
* thrown exception types.
|
||||
*
|
||||
* <p>The only possible modifiers for constructors are the access
|
||||
* modifiers {@code public}, {@code protected} or
|
||||
* {@code private}. Only one of these may appear, or none if the
|
||||
@ -357,13 +363,13 @@ public final class Constructor<T> extends Executable {
|
||||
* "<code><i>Type</i>...</code>".
|
||||
*
|
||||
* A space is used to separate access modifiers from one another
|
||||
* and from the type parameters or return type. If there are no
|
||||
* and from the type parameters or class name. If there are no
|
||||
* type parameters, the type parameter list is elided; if the type
|
||||
* parameter list is present, a space separates the list from the
|
||||
* class name. If the constructor is declared to throw
|
||||
* exceptions, the parameter list is followed by a space, followed
|
||||
* by the word "{@code throws}" followed by a
|
||||
* comma-separated list of the thrown exception types.
|
||||
* comma-separated list of the generic thrown exception types.
|
||||
*
|
||||
* <p>The only possible modifiers for constructors are the access
|
||||
* modifiers {@code public}, {@code protected} or
|
||||
|
@ -211,7 +211,8 @@ public final class Method extends Executable {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* Returns the {@code Class} object representing the class or interface
|
||||
* that declares the method represented by this object.
|
||||
*/
|
||||
@Override
|
||||
public Class<?> getDeclaringClass() {
|
||||
@ -372,7 +373,7 @@ public final class Method extends Executable {
|
||||
* the method name, followed by a parenthesized, comma-separated
|
||||
* list of the method's formal parameter types. If the method
|
||||
* throws checked exceptions, the parameter list is followed by a
|
||||
* space, followed by the word throws followed by a
|
||||
* space, followed by the word "{@code throws}" followed by a
|
||||
* comma-separated list of the thrown exception types.
|
||||
* For example:
|
||||
* <pre>
|
||||
@ -428,8 +429,8 @@ public final class Method extends Executable {
|
||||
* parameter list is present, a space separates the list from the
|
||||
* class name. If the method is declared to throw exceptions, the
|
||||
* parameter list is followed by a space, followed by the word
|
||||
* throws followed by a comma-separated list of the generic thrown
|
||||
* exception types.
|
||||
* "{@code throws}" followed by a comma-separated list of the generic
|
||||
* thrown exception types.
|
||||
*
|
||||
* <p>The access modifiers are placed in canonical order as
|
||||
* specified by "The Java Language Specification". This is
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2016, 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
|
||||
@ -130,6 +130,35 @@ class Authenticator {
|
||||
theAuthenticator = a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default authenticator.
|
||||
* First, if there is a security manager, its {@code checkPermission}
|
||||
* method is called with a
|
||||
* {@code NetPermission("requestPasswordAuthentication")} permission.
|
||||
* This may result in a java.lang.SecurityException.
|
||||
* Then the default authenticator, if set, is returned.
|
||||
* Otherwise, {@code null} is returned.
|
||||
*
|
||||
* @return The default authenticator, if set, {@code null} otherwise.
|
||||
*
|
||||
* @throws SecurityException
|
||||
* if a security manager exists and its
|
||||
* {@code checkPermission} method doesn't allow
|
||||
* requesting password authentication.
|
||||
* @since 9
|
||||
* @see SecurityManager#checkPermission
|
||||
* @see java.net.NetPermission
|
||||
*/
|
||||
public static Authenticator getDefault() {
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
NetPermission requestPermission
|
||||
= new NetPermission("requestPasswordAuthentication");
|
||||
sm.checkPermission(requestPermission);
|
||||
}
|
||||
return theAuthenticator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask the authenticator that has been registered with the system
|
||||
* for a password.
|
||||
|
@ -42,6 +42,7 @@ import java.security.SecureClassLoader;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.jar.Attributes;
|
||||
@ -301,9 +302,12 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||
* @return An input stream for reading the resource, or {@code null}
|
||||
* if the resource could not be found
|
||||
*
|
||||
* @throws NullPointerException If {@code name} is {@code null}
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public InputStream getResourceAsStream(String name) {
|
||||
Objects.requireNonNull(name);
|
||||
URL url = getResource(name);
|
||||
try {
|
||||
if (url == null) {
|
||||
|
@ -32,6 +32,7 @@ import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import jdk.internal.misc.JavaSecurityAccess;
|
||||
import jdk.internal.misc.JavaSecurityProtectionDomainAccess;
|
||||
@ -524,7 +525,7 @@ public class ProtectionDomain {
|
||||
// have some side effects so this manual
|
||||
// comparison is sufficient.
|
||||
if (pdpName.equals(pp.getName()) &&
|
||||
pdpActions.equals(pp.getActions())) {
|
||||
Objects.equals(pdpActions, pp.getActions())) {
|
||||
plVector.remove(i);
|
||||
break;
|
||||
}
|
||||
|
@ -120,6 +120,24 @@ import sun.security.util.Debug;
|
||||
* gathered, for example, if the entropy source is /dev/random on various
|
||||
* Unix-like operating systems.
|
||||
*
|
||||
* <h2> Thread safety </h2>
|
||||
* {@code SecureRandom} objects are safe for use by multiple concurrent threads.
|
||||
*
|
||||
* @implSpec
|
||||
* A {@code SecureRandom} service provider can advertise that it is thread-safe
|
||||
* by setting the <a href=
|
||||
* "{@docRoot}/../technotes/guides/security/StandardNames.html#Service">service
|
||||
* provider attribute</a> "ThreadSafe" to "true" when registering the provider.
|
||||
* Otherwise, this class will instead synchronize access to the following
|
||||
* methods of the {@code SecureRandomSpi} implementation:
|
||||
* <ul>
|
||||
* <li>{@link SecureRandomSpi#engineSetSeed(byte[])}
|
||||
* <li>{@link SecureRandomSpi#engineNextBytes(byte[])}
|
||||
* <li>{@link SecureRandomSpi#engineNextBytes(byte[], SecureRandomParameters)}
|
||||
* <li>{@link SecureRandomSpi#engineGenerateSeed(int)}
|
||||
* <li>{@link SecureRandomSpi#engineReseed(SecureRandomParameters)}
|
||||
* </ul>
|
||||
*
|
||||
* @see java.security.SecureRandomSpi
|
||||
* @see java.util.Random
|
||||
*
|
||||
@ -150,6 +168,14 @@ public class SecureRandom extends java.util.Random {
|
||||
*/
|
||||
private SecureRandomSpi secureRandomSpi = null;
|
||||
|
||||
/**
|
||||
* Thread safety.
|
||||
*
|
||||
* @serial
|
||||
* @since 9
|
||||
*/
|
||||
private final boolean threadSafe;
|
||||
|
||||
/*
|
||||
* The algorithm name of null if unknown.
|
||||
*
|
||||
@ -189,6 +215,16 @@ public class SecureRandom extends java.util.Random {
|
||||
*/
|
||||
super(0);
|
||||
getDefaultPRNG(false, null);
|
||||
this.threadSafe = getThreadSafe();
|
||||
}
|
||||
|
||||
private boolean getThreadSafe() {
|
||||
if (provider == null || algorithm == null) {
|
||||
return false;
|
||||
} else {
|
||||
return Boolean.parseBoolean(provider.getProperty(
|
||||
"SecureRandom." + algorithm + " ThreadSafe", "false"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -217,6 +253,7 @@ public class SecureRandom extends java.util.Random {
|
||||
public SecureRandom(byte[] seed) {
|
||||
super(0);
|
||||
getDefaultPRNG(true, seed);
|
||||
this.threadSafe = getThreadSafe();
|
||||
}
|
||||
|
||||
private void getDefaultPRNG(boolean setSeed, byte[] seed) {
|
||||
@ -269,6 +306,7 @@ public class SecureRandom extends java.util.Random {
|
||||
this.secureRandomSpi = secureRandomSpi;
|
||||
this.provider = provider;
|
||||
this.algorithm = algorithm;
|
||||
this.threadSafe = getThreadSafe();
|
||||
|
||||
if (!skipDebug && pdebug != null) {
|
||||
pdebug.println("SecureRandom." + algorithm +
|
||||
@ -653,8 +691,14 @@ public class SecureRandom extends java.util.Random {
|
||||
*
|
||||
* @see #getSeed
|
||||
*/
|
||||
public synchronized void setSeed(byte[] seed) {
|
||||
secureRandomSpi.engineSetSeed(seed);
|
||||
public void setSeed(byte[] seed) {
|
||||
if (threadSafe) {
|
||||
secureRandomSpi.engineSetSeed(seed);
|
||||
} else {
|
||||
synchronized (this) {
|
||||
secureRandomSpi.engineSetSeed(seed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -679,7 +723,7 @@ public class SecureRandom extends java.util.Random {
|
||||
* yet been initialized at that point.
|
||||
*/
|
||||
if (seed != 0) {
|
||||
this.secureRandomSpi.engineSetSeed(longToByteArray(seed));
|
||||
setSeed(longToByteArray(seed));
|
||||
}
|
||||
}
|
||||
|
||||
@ -690,7 +734,13 @@ public class SecureRandom extends java.util.Random {
|
||||
*/
|
||||
@Override
|
||||
public void nextBytes(byte[] bytes) {
|
||||
secureRandomSpi.engineNextBytes(bytes);
|
||||
if (threadSafe) {
|
||||
secureRandomSpi.engineNextBytes(bytes);
|
||||
} else {
|
||||
synchronized (this) {
|
||||
secureRandomSpi.engineNextBytes(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -707,12 +757,19 @@ public class SecureRandom extends java.util.Random {
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
public synchronized void nextBytes(
|
||||
byte[] bytes, SecureRandomParameters params) {
|
||||
public void nextBytes(byte[] bytes, SecureRandomParameters params) {
|
||||
if (params == null) {
|
||||
throw new IllegalArgumentException("params cannot be null");
|
||||
}
|
||||
secureRandomSpi.engineNextBytes(Objects.requireNonNull(bytes), params);
|
||||
if (threadSafe) {
|
||||
secureRandomSpi.engineNextBytes(
|
||||
Objects.requireNonNull(bytes), params);
|
||||
} else {
|
||||
synchronized (this) {
|
||||
secureRandomSpi.engineNextBytes(
|
||||
Objects.requireNonNull(bytes), params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -756,6 +813,7 @@ public class SecureRandom extends java.util.Random {
|
||||
*
|
||||
* @param numBytes the number of seed bytes to generate.
|
||||
*
|
||||
* @throws IllegalArgumentException if {@code numBytes} is negative
|
||||
* @return the seed bytes.
|
||||
*
|
||||
* @see #setSeed
|
||||
@ -782,7 +840,13 @@ public class SecureRandom extends java.util.Random {
|
||||
if (numBytes < 0) {
|
||||
throw new IllegalArgumentException("numBytes cannot be negative");
|
||||
}
|
||||
return secureRandomSpi.engineGenerateSeed(numBytes);
|
||||
if (threadSafe) {
|
||||
return secureRandomSpi.engineGenerateSeed(numBytes);
|
||||
} else {
|
||||
synchronized (this) {
|
||||
return secureRandomSpi.engineGenerateSeed(numBytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -917,8 +981,14 @@ public class SecureRandom extends java.util.Random {
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
public synchronized void reseed() {
|
||||
secureRandomSpi.engineReseed(null);
|
||||
public void reseed() {
|
||||
if (threadSafe) {
|
||||
secureRandomSpi.engineReseed(null);
|
||||
} else {
|
||||
synchronized (this) {
|
||||
secureRandomSpi.engineReseed(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -937,11 +1007,17 @@ public class SecureRandom extends java.util.Random {
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
public synchronized void reseed(SecureRandomParameters params) {
|
||||
public void reseed(SecureRandomParameters params) {
|
||||
if (params == null) {
|
||||
throw new IllegalArgumentException("params cannot be null");
|
||||
}
|
||||
secureRandomSpi.engineReseed(params);
|
||||
if (threadSafe) {
|
||||
secureRandomSpi.engineReseed(params);
|
||||
} else {
|
||||
synchronized (this) {
|
||||
secureRandomSpi.engineReseed(params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Declare serialVersionUID to be compatible with JDK1.1
|
||||
|
@ -58,6 +58,26 @@ package java.security;
|
||||
* a {@code SecureRandomParameters} argument will never
|
||||
* return an instance of this implementation. The
|
||||
* {@link #engineGetParameters()} method must return {@code null}.
|
||||
* <p>
|
||||
* See {@link SecureRandom} for additional details on thread safety. By
|
||||
* default, a {@code SecureRandomSpi} implementation is considered to be
|
||||
* not safe for use by multiple concurrent threads and {@code SecureRandom}
|
||||
* will synchronize access to each of the applicable engine methods
|
||||
* (see {@link SecureRandom} for the list of methods). However, if a
|
||||
* {@code SecureRandomSpi} implementation is thread-safe, the <a href=
|
||||
* "{@docRoot}/../technotes/guides/security/StandardNames.html#Service">
|
||||
* service provider attribute</a> "ThreadSafe" should be set to "true" during
|
||||
* its registration, as follows:
|
||||
* <blockquote><pre>
|
||||
* put("SecureRandom.AlgName ThreadSafe", "true");</pre>
|
||||
* </blockquote>
|
||||
* or
|
||||
* <blockquote><pre>
|
||||
* putService(new Service(this, "SecureRandom", "AlgName", className,
|
||||
* null, Map.of("ThreadSafe", "true")));</pre>
|
||||
* </blockquote>
|
||||
* {@code SecureRandom} will call the applicable engine methods
|
||||
* without any synchronization.
|
||||
*
|
||||
* @since 1.2
|
||||
*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2016, 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
|
||||
@ -76,6 +76,7 @@ import java.time.temporal.UnsupportedTemporalTypeException;
|
||||
import java.time.zone.ZoneRules;
|
||||
import java.time.zone.ZoneRulesException;
|
||||
import java.time.zone.ZoneRulesProvider;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@ -284,7 +285,7 @@ public abstract class ZoneId implements Serializable {
|
||||
* @return a modifiable copy of the set of zone IDs, not null
|
||||
*/
|
||||
public static Set<String> getAvailableZoneIds() {
|
||||
return ZoneRulesProvider.getAvailableZoneIds();
|
||||
return new HashSet<String>(ZoneRulesProvider.getAvailableZoneIds());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2016, 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
|
||||
@ -302,14 +302,10 @@ final class DateTimePrintContext {
|
||||
* @throws DateTimeException if the field is not available and the section is not optional
|
||||
*/
|
||||
Long getValue(TemporalField field) {
|
||||
try {
|
||||
return temporal.getLong(field);
|
||||
} catch (DateTimeException ex) {
|
||||
if (optional > 0) {
|
||||
return null;
|
||||
}
|
||||
throw ex;
|
||||
if (optional > 0 && !temporal.isSupported(field)) {
|
||||
return null;
|
||||
}
|
||||
return temporal.getLong(field);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2016, 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
|
||||
@ -77,6 +77,7 @@ import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Provider of time-zone rules to the system.
|
||||
@ -137,6 +138,11 @@ public abstract class ZoneRulesProvider {
|
||||
*/
|
||||
private static final ConcurrentMap<String, ZoneRulesProvider> ZONES = new ConcurrentHashMap<>(512, 0.75f, 2);
|
||||
|
||||
/**
|
||||
* The zone ID data
|
||||
*/
|
||||
private static volatile Set<String> ZONE_IDS;
|
||||
|
||||
static {
|
||||
// if the property java.time.zone.DefaultZoneRulesProvider is
|
||||
// set then its value is the class name of the default provider
|
||||
@ -194,10 +200,10 @@ public abstract class ZoneRulesProvider {
|
||||
* <p>
|
||||
* These IDs are the string form of a {@link ZoneId}.
|
||||
*
|
||||
* @return a modifiable copy of the set of zone IDs, not null
|
||||
* @return the unmodifiable set of zone IDs, not null
|
||||
*/
|
||||
public static Set<String> getAvailableZoneIds() {
|
||||
return new HashSet<>(ZONES.keySet());
|
||||
return ZONE_IDS;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -303,7 +309,7 @@ public abstract class ZoneRulesProvider {
|
||||
* @param provider the provider to register, not null
|
||||
* @throws ZoneRulesException if unable to complete the registration
|
||||
*/
|
||||
private static void registerProvider0(ZoneRulesProvider provider) {
|
||||
private static synchronized void registerProvider0(ZoneRulesProvider provider) {
|
||||
for (String zoneId : provider.provideZoneIds()) {
|
||||
Objects.requireNonNull(zoneId, "zoneId");
|
||||
ZoneRulesProvider old = ZONES.putIfAbsent(zoneId, provider);
|
||||
@ -313,6 +319,8 @@ public abstract class ZoneRulesProvider {
|
||||
", currently loading from provider: " + provider);
|
||||
}
|
||||
}
|
||||
Set<String> combinedSet = new HashSet<String>(ZONES.keySet());
|
||||
ZONE_IDS = Collections.unmodifiableSet(combinedSet);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2016, 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
|
||||
@ -29,6 +29,7 @@ import java.io.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.LongBuffer;
|
||||
import java.util.function.IntConsumer;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
@ -1209,40 +1210,165 @@ public class BitSet implements Cloneable, java.io.Serializable {
|
||||
* is the number of bits in the set state, equal to the value
|
||||
* returned by the {@link #cardinality()} method.
|
||||
*
|
||||
* <p>The bit set must remain constant during the execution of the
|
||||
* terminal stream operation. Otherwise, the result of the terminal
|
||||
* stream operation is undefined.
|
||||
* <p>The stream binds to this bit set when the terminal stream operation
|
||||
* commences (specifically, the spliterator for the stream is
|
||||
* <a href="../Spliterator.html#binding"><em>late-binding</em></a>). If the
|
||||
* bit set is modified during that operation then the result is undefined.
|
||||
*
|
||||
* @return a stream of integers representing set indices
|
||||
* @since 1.8
|
||||
*/
|
||||
public IntStream stream() {
|
||||
class BitSetIterator implements PrimitiveIterator.OfInt {
|
||||
int next = nextSetBit(0);
|
||||
class BitSetSpliterator implements Spliterator.OfInt {
|
||||
private int index; // current bit index for a set bit
|
||||
private int fence; // -1 until used; then one past last bit index
|
||||
private int est; // size estimate
|
||||
private boolean root; // true if root and not split
|
||||
// root == true then size estimate is accurate
|
||||
// index == -1 or index >= fence if fully traversed
|
||||
// Special case when the max bit set is Integer.MAX_VALUE
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return next != -1;
|
||||
BitSetSpliterator(int origin, int fence, int est, boolean root) {
|
||||
this.index = origin;
|
||||
this.fence = fence;
|
||||
this.est = est;
|
||||
this.root = root;
|
||||
}
|
||||
|
||||
private int getFence() {
|
||||
int hi;
|
||||
if ((hi = fence) < 0) {
|
||||
// Round up fence to maximum cardinality for allocated words
|
||||
// This is sufficient and cheap for sequential access
|
||||
// When splitting this value is lowered
|
||||
hi = fence = (wordsInUse >= wordIndex(Integer.MAX_VALUE))
|
||||
? Integer.MAX_VALUE
|
||||
: wordsInUse << ADDRESS_BITS_PER_WORD;
|
||||
est = cardinality();
|
||||
index = nextSetBit(0);
|
||||
}
|
||||
return hi;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int nextInt() {
|
||||
if (next != -1) {
|
||||
int ret = next;
|
||||
next = (next == Integer.MAX_VALUE) ? -1 : nextSetBit(next+1);
|
||||
return ret;
|
||||
} else {
|
||||
throw new NoSuchElementException();
|
||||
public boolean tryAdvance(IntConsumer action) {
|
||||
Objects.requireNonNull(action);
|
||||
|
||||
int hi = getFence();
|
||||
int i = index;
|
||||
if (i < 0 || i >= hi) {
|
||||
// Check if there is a final bit set for Integer.MAX_VALUE
|
||||
if (i == Integer.MAX_VALUE && hi == Integer.MAX_VALUE) {
|
||||
index = -1;
|
||||
action.accept(Integer.MAX_VALUE);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
index = nextSetBit(i + 1, wordIndex(hi - 1));
|
||||
action.accept(i);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEachRemaining(IntConsumer action) {
|
||||
Objects.requireNonNull(action);
|
||||
|
||||
int hi = getFence();
|
||||
int i = index;
|
||||
int v = wordIndex(hi - 1);
|
||||
index = -1;
|
||||
while (i >= 0 && i < hi) {
|
||||
action.accept(i);
|
||||
i = nextSetBit(i + 1, v);
|
||||
}
|
||||
// Check if there is a final bit set for Integer.MAX_VALUE
|
||||
if (i == Integer.MAX_VALUE && hi == Integer.MAX_VALUE) {
|
||||
action.accept(Integer.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return StreamSupport.intStream(
|
||||
() -> Spliterators.spliterator(
|
||||
new BitSetIterator(), cardinality(),
|
||||
Spliterator.ORDERED | Spliterator.DISTINCT | Spliterator.SORTED),
|
||||
Spliterator.SIZED | Spliterator.SUBSIZED |
|
||||
Spliterator.ORDERED | Spliterator.DISTINCT | Spliterator.SORTED,
|
||||
false);
|
||||
@Override
|
||||
public OfInt trySplit() {
|
||||
int hi = getFence();
|
||||
int lo = index;
|
||||
if (lo < 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Lower the fence to be the upper bound of last bit set
|
||||
// The index is the first bit set, thus this spliterator
|
||||
// covers one bit and cannot be split, or two or more
|
||||
// bits
|
||||
hi = fence = (hi < Integer.MAX_VALUE || !get(Integer.MAX_VALUE))
|
||||
? previousSetBit(hi - 1) + 1
|
||||
: Integer.MAX_VALUE;
|
||||
|
||||
// Find the mid point
|
||||
int mid = (lo + hi) >>> 1;
|
||||
if (lo >= mid) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Raise the index of this spliterator to be the next set bit
|
||||
// from the mid point
|
||||
index = nextSetBit(mid, wordIndex(hi - 1));
|
||||
root = false;
|
||||
|
||||
// Don't lower the fence (mid point) of the returned spliterator,
|
||||
// traversal or further splitting will do that work
|
||||
return new BitSetSpliterator(lo, mid, est >>>= 1, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long estimateSize() {
|
||||
getFence(); // force init
|
||||
return est;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int characteristics() {
|
||||
// Only sized when root and not split
|
||||
return (root ? Spliterator.SIZED : 0) |
|
||||
Spliterator.ORDERED | Spliterator.DISTINCT | Spliterator.SORTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Comparator<? super Integer> getComparator() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return StreamSupport.intStream(new BitSetSpliterator(0, -1, 0, true), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the first bit that is set to {@code true}
|
||||
* that occurs on or after the specified starting index and up to and
|
||||
* including the specified word index
|
||||
* If no such bit exists then {@code -1} is returned.
|
||||
*
|
||||
* @param fromIndex the index to start checking from (inclusive)
|
||||
* @param toWordIndex the last word index to check (inclusive)
|
||||
* @return the index of the next set bit, or {@code -1} if there
|
||||
* is no such bit
|
||||
*/
|
||||
private int nextSetBit(int fromIndex, int toWordIndex) {
|
||||
int u = wordIndex(fromIndex);
|
||||
// Check if out of bounds
|
||||
if (u > toWordIndex)
|
||||
return -1;
|
||||
|
||||
long word = words[u] & (WORD_MASK << fromIndex);
|
||||
|
||||
while (true) {
|
||||
if (word != 0)
|
||||
return (u * BITS_PER_WORD) + Long.numberOfTrailingZeros(word);
|
||||
// Check if out of bounds
|
||||
if (++u > toWordIndex)
|
||||
return -1;
|
||||
word = words[u];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,7 +54,8 @@ import java.util.function.Consumer;
|
||||
* <p>This class and its iterator implement all of the
|
||||
* <em>optional</em> methods of the {@link Collection} and {@link
|
||||
* Iterator} interfaces. The Iterator provided in method {@link
|
||||
* #iterator()} is <em>not</em> guaranteed to traverse the elements of
|
||||
* #iterator()} and the Spliterator provided in method {@link #spliterator()}
|
||||
* are <em>not</em> guaranteed to traverse the elements of
|
||||
* the priority queue in any particular order. If you need ordered
|
||||
* traversal, consider using {@code Arrays.sort(pq.toArray())}.
|
||||
*
|
||||
@ -799,7 +800,8 @@ public class PriorityQueue<E> extends AbstractQueue<E>
|
||||
/**
|
||||
* Creates a <em><a href="Spliterator.html#binding">late-binding</a></em>
|
||||
* and <em>fail-fast</em> {@link Spliterator} over the elements in this
|
||||
* queue.
|
||||
* queue. The spliterator does not traverse elements in any particular order
|
||||
* (the {@link Spliterator#ORDERED ORDERED} characteristic is not reported).
|
||||
*
|
||||
* <p>The {@code Spliterator} reports {@link Spliterator#SIZED},
|
||||
* {@link Spliterator#SUBSIZED}, and {@link Spliterator#NONNULL}.
|
||||
|
@ -65,7 +65,8 @@ import java.util.function.Consumer;
|
||||
* <p>This class and its iterator implement all of the
|
||||
* <em>optional</em> methods of the {@link Collection} and {@link
|
||||
* Iterator} interfaces. The Iterator provided in method {@link
|
||||
* #iterator()} is <em>not</em> guaranteed to traverse the elements of
|
||||
* #iterator()} and the Spliterator provided in method {@link #spliterator()}
|
||||
* are <em>not</em> guaranteed to traverse the elements of
|
||||
* the PriorityBlockingQueue in any particular order. If you need
|
||||
* ordered traversal, consider using
|
||||
* {@code Arrays.sort(pq.toArray())}. Also, method {@code drainTo}
|
||||
@ -994,6 +995,8 @@ public class PriorityBlockingQueue<E> extends AbstractQueue<E>
|
||||
|
||||
/**
|
||||
* Returns a {@link Spliterator} over the elements in this queue.
|
||||
* The spliterator does not traverse elements in any particular order
|
||||
* (the {@link Spliterator#ORDERED ORDERED} characteristic is not reported).
|
||||
*
|
||||
* <p>The returned spliterator is
|
||||
* <a href="package-summary.html#Weakly"><i>weakly consistent</i></a>.
|
||||
|
@ -1327,7 +1327,7 @@ public interface Stream<T> extends BaseStream<T, Stream<T>> {
|
||||
* @param s the {@code Supplier} of generated elements
|
||||
* @return a new infinite sequential unordered {@code Stream}
|
||||
*/
|
||||
public static<T> Stream<T> generate(Supplier<T> s) {
|
||||
public static<T> Stream<T> generate(Supplier<? extends T> s) {
|
||||
Objects.requireNonNull(s);
|
||||
return StreamSupport.stream(
|
||||
new StreamSpliterators.InfiniteSupplyingSpliterator.OfRef<>(Long.MAX_VALUE, s), false);
|
||||
|
@ -1346,9 +1346,9 @@ class StreamSpliterators {
|
||||
}
|
||||
|
||||
static final class OfRef<T> extends InfiniteSupplyingSpliterator<T> {
|
||||
final Supplier<T> s;
|
||||
final Supplier<? extends T> s;
|
||||
|
||||
OfRef(long size, Supplier<T> s) {
|
||||
OfRef(long size, Supplier<? extends T> s) {
|
||||
super(size);
|
||||
this.s = s;
|
||||
}
|
||||
|
@ -72,13 +72,13 @@ public class ClassLoaders {
|
||||
// If neither is specified then default to -cp <working directory>
|
||||
// If -cp is not specified and -m is specified, the value of
|
||||
// java.class.path is an empty string, then no class path.
|
||||
URLClassPath ucp = null;
|
||||
URLClassPath ucp = new URLClassPath(new URL[0]);
|
||||
String mainMid = System.getProperty("jdk.module.main");
|
||||
String cp = System.getProperty("java.class.path");
|
||||
if (cp == null)
|
||||
cp = "";
|
||||
if (mainMid == null || cp.length() > 0)
|
||||
ucp = toURLClassPath(cp);
|
||||
addClassPathToUCP(cp, ucp);
|
||||
|
||||
// create the class loaders
|
||||
BOOT_LOADER = new BootClassLoader(bcp);
|
||||
|
@ -462,6 +462,8 @@ public final class LauncherHelper {
|
||||
* This method:
|
||||
* 1. Loads the main class from the module or class path
|
||||
* 2. Checks the public static void main method.
|
||||
* 3. If the main class extends FX Application then call on FXHelper to
|
||||
* perform the launch.
|
||||
*
|
||||
* @param printToStderr if set, all output will be routed to stderr
|
||||
* @param mode LaunchMode as determined by the arguments passed on the
|
||||
@ -479,11 +481,23 @@ public final class LauncherHelper {
|
||||
Class<?> mainClass = (mode == LM_MODULE) ? loadModuleMainClass(what)
|
||||
: loadMainClass(mode, what);
|
||||
|
||||
validateMainClass(mainClass);
|
||||
// record the real main class for UI purposes
|
||||
// neither method above can return null, they will abort()
|
||||
appClass = mainClass;
|
||||
|
||||
// record main class if not already set
|
||||
if (appClass == null)
|
||||
appClass = mainClass;
|
||||
/*
|
||||
* Check if FXHelper can launch it using the FX launcher. In an FX app,
|
||||
* the main class may or may not have a main method, so do this before
|
||||
* validating the main class.
|
||||
*/
|
||||
if (JAVAFX_FXHELPER_CLASS_NAME_SUFFIX.equals(mainClass.getName()) ||
|
||||
doesExtendFXApplication(mainClass)) {
|
||||
// Will abort() if there are problems with FX runtime
|
||||
FXHelper.setFXLaunchParameters(what, mode);
|
||||
mainClass = FXHelper.class;
|
||||
}
|
||||
|
||||
validateMainClass(mainClass);
|
||||
|
||||
return mainClass;
|
||||
}
|
||||
@ -530,7 +544,6 @@ public final class LauncherHelper {
|
||||
|
||||
String cn = Normalizer.normalize(mainClass, Normalizer.Form.NFC);
|
||||
c = Class.forName(m, cn);
|
||||
|
||||
}
|
||||
if (c == null) {
|
||||
abort(null, "java.launcher.module.error2", mainClass, mainModule);
|
||||
@ -542,8 +555,6 @@ public final class LauncherHelper {
|
||||
|
||||
/**
|
||||
* Loads the main class from the class path (LM_CLASS or LM_JAR).
|
||||
* If the main class extends FX Application then call on FXHelper to
|
||||
* determine the main class to launch.
|
||||
*/
|
||||
private static Class<?> loadMainClass(int mode, String what) {
|
||||
// get the class name
|
||||
@ -570,7 +581,7 @@ public final class LauncherHelper {
|
||||
if (System.getProperty("os.name", "").contains("OS X")
|
||||
&& Normalizer.isNormalized(cn, Normalizer.Form.NFD)) {
|
||||
try {
|
||||
// On Mac OS X since all names with diacretic symbols are
|
||||
// On Mac OS X since all names with diacritical marks are
|
||||
// given as decomposed it is possible that main class name
|
||||
// comes incorrectly from the command line and we have
|
||||
// to re-compose it
|
||||
@ -583,21 +594,6 @@ public final class LauncherHelper {
|
||||
abort(cnfe, "java.launcher.cls.error1", cn);
|
||||
}
|
||||
}
|
||||
|
||||
// record the main class
|
||||
appClass = mainClass;
|
||||
|
||||
/*
|
||||
* Check if FXHelper can launch it using the FX launcher. In an FX app,
|
||||
* the main class may or may not have a main method, so do this before
|
||||
* validating the main class.
|
||||
*/
|
||||
if (JAVAFX_FXHELPER_CLASS_NAME_SUFFIX.equals(mainClass.getName()) ||
|
||||
doesExtendFXApplication(mainClass)) {
|
||||
// Will abort() if there are problems with FX runtime
|
||||
FXHelper.setFXLaunchParameters(what, mode);
|
||||
return FXHelper.class;
|
||||
}
|
||||
return mainClass;
|
||||
}
|
||||
|
||||
@ -773,9 +769,15 @@ public final class LauncherHelper {
|
||||
* java -cp somedir FXClass N/A LM_CLASS "LM_CLASS"
|
||||
* java -jar fxapp.jar Present LM_JAR "LM_JAR"
|
||||
* java -jar fxapp.jar Not Present LM_JAR "LM_JAR"
|
||||
* java -m module/class [1] N/A LM_MODULE "LM_MODULE"
|
||||
* java -m module N/A LM_MODULE "LM_MODULE"
|
||||
*
|
||||
* [1] - JavaFX-Application-Class is ignored when modular args are used, even
|
||||
* if present in a modular jar
|
||||
*/
|
||||
private static final String JAVAFX_LAUNCH_MODE_CLASS = "LM_CLASS";
|
||||
private static final String JAVAFX_LAUNCH_MODE_JAR = "LM_JAR";
|
||||
private static final String JAVAFX_LAUNCH_MODE_MODULE = "LM_MODULE";
|
||||
|
||||
/*
|
||||
* FX application launcher and launch method, so we can launch
|
||||
@ -835,6 +837,9 @@ public final class LauncherHelper {
|
||||
case LM_JAR:
|
||||
fxLaunchMode = JAVAFX_LAUNCH_MODE_JAR;
|
||||
break;
|
||||
case LM_MODULE:
|
||||
fxLaunchMode = JAVAFX_LAUNCH_MODE_MODULE;
|
||||
break;
|
||||
default:
|
||||
// should not have gotten this far...
|
||||
throw new InternalError(mode + ": Unknown launch mode");
|
||||
|
@ -96,25 +96,32 @@ final class SunEntries {
|
||||
if (nativeAvailable && useNativePRNG) {
|
||||
map.put("SecureRandom.NativePRNG",
|
||||
"sun.security.provider.NativePRNG");
|
||||
map.put("SecureRandom.NativePRNG ThreadSafe", "true");
|
||||
}
|
||||
|
||||
map.put("SecureRandom.DRBG", "sun.security.provider.DRBG");
|
||||
map.put("SecureRandom.DRBG ThreadSafe", "true");
|
||||
|
||||
map.put("SecureRandom.SHA1PRNG",
|
||||
"sun.security.provider.SecureRandom");
|
||||
|
||||
map.put("SecureRandom.SHA1PRNG ThreadSafe", "true");
|
||||
if (nativeAvailable && !useNativePRNG) {
|
||||
map.put("SecureRandom.NativePRNG",
|
||||
"sun.security.provider.NativePRNG");
|
||||
map.put("SecureRandom.NativePRNG ThreadSafe", "true");
|
||||
}
|
||||
|
||||
if (NativePRNG.Blocking.isAvailable()) {
|
||||
map.put("SecureRandom.NativePRNGBlocking",
|
||||
"sun.security.provider.NativePRNG$Blocking");
|
||||
map.put("SecureRandom.NativePRNGBlocking ThreadSafe", "true");
|
||||
}
|
||||
|
||||
if (NativePRNG.NonBlocking.isAvailable()) {
|
||||
map.put("SecureRandom.NativePRNGNonBlocking",
|
||||
"sun.security.provider.NativePRNG$NonBlocking");
|
||||
map.put("SecureRandom.NativePRNGNonBlocking ThreadSafe", "true");
|
||||
}
|
||||
|
||||
/*
|
||||
@ -329,6 +336,7 @@ final class SunEntries {
|
||||
map.put("AlgorithmParameters.DSA ImplementedIn", "Software");
|
||||
map.put("KeyFactory.DSA ImplementedIn", "Software");
|
||||
map.put("SecureRandom.SHA1PRNG ImplementedIn", "Software");
|
||||
map.put("SecureRandom.DRBG ImplementedIn", "Software");
|
||||
map.put("CertificateFactory.X.509 ImplementedIn", "Software");
|
||||
map.put("KeyStore.JKS ImplementedIn", "Software");
|
||||
map.put("CertPathValidator.PKIX ImplementedIn", "Software");
|
||||
|
@ -403,6 +403,13 @@ public abstract class SSLContextImpl extends SSLContextSpi {
|
||||
EnumSet.of(CryptoPrimitive.KEY_AGREEMENT),
|
||||
suite.name, null)) {
|
||||
suites.add(suite);
|
||||
} else {
|
||||
if (debug != null && Debug.isOn("sslctx") &&
|
||||
Debug.isOn("verbose")) {
|
||||
System.out.println(
|
||||
"Ignoring disabled cipher suite: " +
|
||||
suite.name);
|
||||
}
|
||||
}
|
||||
} else if (debug != null &&
|
||||
Debug.isOn("sslctx") && Debug.isOn("verbose")) {
|
||||
|
@ -960,17 +960,6 @@ final class SSLSessionImpl extends ExtendedSSLSession {
|
||||
+ "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* When SSL sessions are finalized, all values bound to
|
||||
* them are removed.
|
||||
*/
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
String[] names = getValueNames();
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
removeValue(names[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -155,7 +155,6 @@ grant codeBase "jrt:/jdk.jsobject" {
|
||||
grant codeBase "jrt:/jdk.localedata" {
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.text.*";
|
||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.util.*";
|
||||
permission java.util.PropertyPermission "*", "read";
|
||||
};
|
||||
|
||||
grant codeBase "jrt:/jdk.naming.dns" {
|
||||
|
@ -431,6 +431,7 @@ public class AquaInternalFrameUI extends BasicInternalFrameUI implements SwingCo
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void mouseReleased(final MouseEvent e) {
|
||||
if (didForwardEvent(e)) return;
|
||||
|
||||
|
@ -55,6 +55,7 @@ public class AquaTextFieldFormattedUI extends AquaTextFieldUI implements MouseLi
|
||||
super.uninstallListeners();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void mouseClicked(final MouseEvent e) {
|
||||
if (e.getClickCount() != 1) return;
|
||||
|
||||
|
@ -176,11 +176,12 @@ final class AquaUtils {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
T getInstance() {
|
||||
try {
|
||||
ReflectUtil.checkPackageAccess(clazz);
|
||||
return clazz.newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException ignored) {
|
||||
} catch (ReflectiveOperationException ignored) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -672,7 +672,7 @@ public abstract class OSXSurfaceData extends BufImgSurfaceData {
|
||||
TexturePaint color = (TexturePaint) sg2d.paint;
|
||||
this.fGraphicsStatesInt.put(kColorStateIndex, kColorTexture);
|
||||
texturePaintImage = color.getImage();
|
||||
SurfaceData textureSurfaceData = BufImgSurfaceData.createData(texturePaintImage);
|
||||
SurfaceData textureSurfaceData = OSXOffScreenSurfaceData.createNewSurface(texturePaintImage);
|
||||
this.fGraphicsStatesInt.put(kColorWidthIndex, texturePaintImage.getWidth());
|
||||
this.fGraphicsStatesInt.put(kColorHeightIndex, texturePaintImage.getHeight());
|
||||
Rectangle2D anchor = color.getAnchorRect();
|
||||
|
@ -293,6 +293,7 @@ class CAccessibleText {
|
||||
}, c);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
static int[] getVisibleCharacterRange(final Accessible a) {
|
||||
final Accessible sa = CAccessible.getSwingAccessible(a);
|
||||
if (!(sa instanceof JTextComponent)) return null;
|
||||
|
@ -38,6 +38,7 @@ import java.text.Normalizer.Form;
|
||||
import java.util.*;
|
||||
import java.util.regex.*;
|
||||
import java.awt.datatransfer.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import sun.awt.datatransfer.*;
|
||||
|
||||
public class CDataTransferer extends DataTransferer {
|
||||
@ -132,7 +133,7 @@ public class CDataTransferer extends DataTransferer {
|
||||
String charset = Charset.defaultCharset().name();
|
||||
if (transferable != null && transferable.isDataFlavorSupported(javaTextEncodingFlavor)) {
|
||||
try {
|
||||
charset = new String((byte[]) transferable.getTransferData(javaTextEncodingFlavor), "UTF-8");
|
||||
charset = new String((byte[]) transferable.getTransferData(javaTextEncodingFlavor), StandardCharsets.UTF_8);
|
||||
} catch (UnsupportedFlavorException cannotHappen) {
|
||||
}
|
||||
}
|
||||
|
@ -214,6 +214,7 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
|
||||
this.setDefaultDragImage();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void setDefaultDragImage(JTextComponent component) {
|
||||
DragGestureEvent trigger = getTrigger();
|
||||
int selectionStart = component.getSelectionStart();
|
||||
|
@ -196,7 +196,8 @@ public class CPlatformLWWindow extends CPlatformWindow {
|
||||
getLocalGraphicsEnvironment();
|
||||
|
||||
LWLightweightFramePeer peer = (LWLightweightFramePeer)getPeer();
|
||||
int scale = ((LightweightFrame)peer.getTarget()).getScaleFactor();
|
||||
int scale =(int) Math.round(((LightweightFrame)peer.getTarget())
|
||||
.getScaleFactorX());
|
||||
|
||||
Rectangle bounds = ((LightweightFrame)peer.getTarget()).getHostBounds();
|
||||
for (GraphicsDevice d : ge.getScreenDevices()) {
|
||||
|
@ -25,10 +25,12 @@
|
||||
|
||||
package sun.lwawt.macosx;
|
||||
|
||||
import com.apple.eawt.FullScreenAdapter;
|
||||
import com.apple.eawt.FullScreenUtilities;
|
||||
import com.apple.eawt.event.FullScreenEvent;
|
||||
import java.awt.*;
|
||||
import java.awt.Dialog.ModalityType;
|
||||
import java.awt.event.*;
|
||||
import java.awt.peer.WindowPeer;
|
||||
import java.beans.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
@ -44,6 +46,7 @@ import sun.util.logging.PlatformLogger;
|
||||
import com.apple.laf.*;
|
||||
import com.apple.laf.ClientPropertyApplicator.Property;
|
||||
import com.sun.awt.AWTUtilities;
|
||||
import sun.lwawt.LWWindowPeer.PeerType;
|
||||
|
||||
public class CPlatformWindow extends CFRetainedResource implements PlatformWindow {
|
||||
private native long nativeCreateNSWindow(long nsViewPtr,long ownerPtr, long styleBits, double x, double y, double w, double h);
|
||||
@ -175,10 +178,24 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
c.setStyleBits(CLOSEABLE, Boolean.parseBoolean(value.toString()));
|
||||
}},
|
||||
new Property<CPlatformWindow>(WINDOW_ZOOMABLE) { public void applyProperty(final CPlatformWindow c, final Object value) {
|
||||
c.setStyleBits(ZOOMABLE, Boolean.parseBoolean(value.toString()));
|
||||
boolean zoomable = Boolean.parseBoolean(value.toString());
|
||||
if (c.target instanceof RootPaneContainer
|
||||
&& c.getPeer().getPeerType() == PeerType.FRAME) {
|
||||
if (c.isInFullScreen && !zoomable) {
|
||||
c.toggleFullScreen();
|
||||
}
|
||||
}
|
||||
c.setStyleBits(ZOOMABLE, zoomable);
|
||||
}},
|
||||
new Property<CPlatformWindow>(WINDOW_FULLSCREENABLE) { public void applyProperty(final CPlatformWindow c, final Object value) {
|
||||
c.setStyleBits(FULLSCREENABLE, Boolean.parseBoolean(value.toString()));
|
||||
boolean fullscrenable = Boolean.parseBoolean(value.toString());
|
||||
if (c.target instanceof RootPaneContainer
|
||||
&& c.getPeer().getPeerType() == PeerType.FRAME) {
|
||||
if (c.isInFullScreen && !fullscrenable) {
|
||||
c.toggleFullScreen();
|
||||
}
|
||||
}
|
||||
c.setStyleBits(FULLSCREENABLE, fullscrenable);
|
||||
}},
|
||||
new Property<CPlatformWindow>(WINDOW_SHADOW_REVALIDATE_NOW) { public void applyProperty(final CPlatformWindow c, final Object value) {
|
||||
nativeRevalidateNSWindowShadow(c.getNSWindowPtr());
|
||||
@ -210,6 +227,8 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
private volatile boolean isFullScreenMode;
|
||||
private boolean isFullScreenAnimationOn;
|
||||
|
||||
private volatile boolean isInFullScreen;
|
||||
|
||||
private Window target;
|
||||
private LWWindowPeer peer;
|
||||
protected CPlatformView contentView;
|
||||
@ -308,6 +327,8 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
styleBits = SET(styleBits, RESIZABLE, resizable);
|
||||
if (!resizable) {
|
||||
styleBits = SET(styleBits, ZOOMABLE, false);
|
||||
} else {
|
||||
setCanFullscreen(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -680,9 +701,25 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
updateFocusabilityForAutoRequestFocus(true);
|
||||
}
|
||||
|
||||
private void setCanFullscreen(final boolean canFullScreen) {
|
||||
if (target instanceof RootPaneContainer
|
||||
&& getPeer().getPeerType() == PeerType.FRAME) {
|
||||
|
||||
if (isInFullScreen && !canFullScreen) {
|
||||
toggleFullScreen();
|
||||
}
|
||||
|
||||
final RootPaneContainer rpc = (RootPaneContainer) target;
|
||||
rpc.getRootPane().putClientProperty(
|
||||
CPlatformWindow.WINDOW_FULLSCREENABLE, canFullScreen);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResizable(final boolean resizable) {
|
||||
setCanFullscreen(resizable);
|
||||
setStyleBits(RESIZABLE, resizable);
|
||||
setStyleBits(ZOOMABLE, resizable);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1074,6 +1111,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
}
|
||||
|
||||
private void windowDidEnterFullScreen() {
|
||||
isInFullScreen = true;
|
||||
isFullScreenAnimationOn = false;
|
||||
}
|
||||
|
||||
@ -1082,6 +1120,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
}
|
||||
|
||||
private void windowDidExitFullScreen() {
|
||||
isInFullScreen = false;
|
||||
isFullScreenAnimationOn = false;
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <jni.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <AppKit/NSTrackingArea.h>
|
||||
|
||||
#import "CPopupMenu.h"
|
||||
|
||||
@ -64,12 +65,14 @@ extern "C" {
|
||||
@public
|
||||
AWTTrayIcon *trayIcon;
|
||||
NSImage* image;
|
||||
NSTrackingArea *trackingArea;
|
||||
BOOL isHighlighted;
|
||||
}
|
||||
-(id)initWithTrayIcon:(AWTTrayIcon *)theTrayIcon;
|
||||
-(void)setHighlighted:(BOOL)aFlag;
|
||||
-(void)setImage:(NSImage*)anImage;
|
||||
-(void)setTrayIcon:(AWTTrayIcon*)theTrayIcon;
|
||||
-(void)addTrackingArea;
|
||||
|
||||
@end //AWTTrayIconView
|
||||
|
||||
|
@ -171,12 +171,27 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize, BOOL autosize) {
|
||||
[self setTrayIcon: theTrayIcon];
|
||||
isHighlighted = NO;
|
||||
image = nil;
|
||||
|
||||
trackingArea = nil;
|
||||
|
||||
[self addTrackingArea];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)addTrackingArea {
|
||||
NSTrackingAreaOptions options = NSTrackingMouseMoved |
|
||||
NSTrackingInVisibleRect |
|
||||
NSTrackingActiveAlways;
|
||||
trackingArea = [[NSTrackingArea alloc] initWithRect: CGRectZero
|
||||
options: options
|
||||
owner: self
|
||||
userInfo: nil];
|
||||
[self addTrackingArea:trackingArea];
|
||||
}
|
||||
|
||||
-(void) dealloc {
|
||||
[image release];
|
||||
[trackingArea release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@ -269,6 +284,10 @@ static NSSize ScaledImageSizeForStatusBar(NSSize imageSize, BOOL autosize) {
|
||||
[trayIcon deliverJavaMouseEvent: event];
|
||||
}
|
||||
|
||||
- (void) mouseMoved: (NSEvent *)event {
|
||||
[trayIcon deliverJavaMouseEvent: event];
|
||||
}
|
||||
|
||||
- (void) rightMouseDown:(NSEvent *)event {
|
||||
[trayIcon deliverJavaMouseEvent: event];
|
||||
}
|
||||
|
@ -277,10 +277,12 @@ public final class DocumentHandler extends DefaultHandler {
|
||||
* @param attributes the attributes attached to the element
|
||||
*/
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
|
||||
ElementHandler parent = this.handler;
|
||||
try {
|
||||
this.handler = getElementHandler(qName).newInstance();
|
||||
this.handler =
|
||||
getElementHandler(qName).newInstance();
|
||||
this.handler.setOwner(this);
|
||||
this.handler.setParent(parent);
|
||||
}
|
||||
|
@ -86,6 +86,7 @@ class InstanceFinder<T> {
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
protected T instantiate(Class<?> type, String name) {
|
||||
if (type != null) {
|
||||
try {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2016, 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
|
||||
@ -101,7 +101,8 @@ class TIFFFaxDecompressor extends TIFFDecompressor {
|
||||
0xff // 8
|
||||
};
|
||||
|
||||
// Table to be used when fillOrder = 2, for flipping bytes.
|
||||
// Table to be used for flipping bytes when fillOrder is
|
||||
// BaselineTIFFTagSet.FILL_ORDER_RIGHT_TO_LEFT (2).
|
||||
static byte flipTable[] = {
|
||||
0, -128, 64, -64, 32, -96, 96, -32,
|
||||
16, -112, 80, -48, 48, -80, 112, -16,
|
||||
@ -597,7 +598,8 @@ class TIFFFaxDecompressor extends TIFFDecompressor {
|
||||
TIFFField f;
|
||||
|
||||
f = tmetadata.getTIFFField(BaselineTIFFTagSet.TAG_FILL_ORDER);
|
||||
this.fillOrder = f == null ? 1 : f.getAsInt(0);
|
||||
this.fillOrder = f == null ?
|
||||
BaselineTIFFTagSet.FILL_ORDER_LEFT_TO_RIGHT : f.getAsInt(0);
|
||||
|
||||
f = tmetadata.getTIFFField(BaselineTIFFTagSet.TAG_COMPRESSION);
|
||||
this.compression = f == null ?
|
||||
@ -612,7 +614,7 @@ class TIFFFaxDecompressor extends TIFFDecompressor {
|
||||
f = tmetadata.getTIFFField(BaselineTIFFTagSet.TAG_T6_OPTIONS);
|
||||
this.t6Options = f == null ? 0 : f.getAsInt(0);
|
||||
} else {
|
||||
this.fillOrder = 1; // MSB-to-LSB
|
||||
this.fillOrder = BaselineTIFFTagSet.FILL_ORDER_LEFT_TO_RIGHT;
|
||||
|
||||
this.compression = BaselineTIFFTagSet.COMPRESSION_CCITT_RLE; // RLE
|
||||
|
||||
@ -1458,7 +1460,7 @@ class TIFFFaxDecompressor extends TIFFDecompressor {
|
||||
int l = data.length - 1;
|
||||
int bp = this.bytePointer;
|
||||
|
||||
if (fillOrder == 1) {
|
||||
if (fillOrder == BaselineTIFFTagSet.FILL_ORDER_LEFT_TO_RIGHT) {
|
||||
b = data[bp];
|
||||
|
||||
if (bp == l) {
|
||||
@ -1471,7 +1473,7 @@ class TIFFFaxDecompressor extends TIFFDecompressor {
|
||||
next = data[bp + 1];
|
||||
next2next = data[bp + 2];
|
||||
}
|
||||
} else if (fillOrder == 2) {
|
||||
} else if (fillOrder == BaselineTIFFTagSet.FILL_ORDER_RIGHT_TO_LEFT) {
|
||||
b = flipTable[data[bp] & 0xff];
|
||||
|
||||
if (bp == l) {
|
||||
@ -1527,14 +1529,14 @@ class TIFFFaxDecompressor extends TIFFDecompressor {
|
||||
int l = data.length - 1;
|
||||
int bp = this.bytePointer;
|
||||
|
||||
if (fillOrder == 1) {
|
||||
if (fillOrder == BaselineTIFFTagSet.FILL_ORDER_LEFT_TO_RIGHT) {
|
||||
b = data[bp];
|
||||
if (bp == l) {
|
||||
next = 0x00;
|
||||
} else {
|
||||
next = data[bp + 1];
|
||||
}
|
||||
} else if (fillOrder == 2) {
|
||||
} else if (fillOrder == BaselineTIFFTagSet.FILL_ORDER_RIGHT_TO_LEFT) {
|
||||
b = flipTable[data[bp] & 0xff];
|
||||
if (bp == l) {
|
||||
next = 0x00;
|
||||
|
@ -49,6 +49,52 @@ public class TIFFIFD extends TIFFDirectory {
|
||||
private long stripOrTileOffsetsPosition = -1;
|
||||
private long lastPosition = -1;
|
||||
|
||||
//
|
||||
// A set of tag numbers corresponding to tags essential to decoding
|
||||
// the image and metadata required to interpret its samples.
|
||||
//
|
||||
private static volatile Set<Integer> essentialTags = null;
|
||||
|
||||
private static void initializeEssentialTags() {
|
||||
Set<Integer> tags = essentialTags;
|
||||
if (tags == null) {
|
||||
essentialTags = tags = Set.of(
|
||||
BaselineTIFFTagSet.TAG_BITS_PER_SAMPLE,
|
||||
BaselineTIFFTagSet.TAG_COLOR_MAP,
|
||||
BaselineTIFFTagSet.TAG_COMPRESSION,
|
||||
BaselineTIFFTagSet.TAG_EXTRA_SAMPLES,
|
||||
BaselineTIFFTagSet.TAG_FILL_ORDER,
|
||||
BaselineTIFFTagSet.TAG_ICC_PROFILE,
|
||||
BaselineTIFFTagSet.TAG_IMAGE_LENGTH,
|
||||
BaselineTIFFTagSet.TAG_IMAGE_WIDTH,
|
||||
BaselineTIFFTagSet.TAG_JPEG_AC_TABLES,
|
||||
BaselineTIFFTagSet.TAG_JPEG_DC_TABLES,
|
||||
BaselineTIFFTagSet.TAG_JPEG_INTERCHANGE_FORMAT,
|
||||
BaselineTIFFTagSet.TAG_JPEG_INTERCHANGE_FORMAT_LENGTH,
|
||||
BaselineTIFFTagSet.TAG_JPEG_PROC,
|
||||
BaselineTIFFTagSet.TAG_JPEG_Q_TABLES,
|
||||
BaselineTIFFTagSet.TAG_JPEG_RESTART_INTERVAL,
|
||||
BaselineTIFFTagSet.TAG_JPEG_TABLES,
|
||||
BaselineTIFFTagSet.TAG_PHOTOMETRIC_INTERPRETATION,
|
||||
BaselineTIFFTagSet.TAG_PLANAR_CONFIGURATION,
|
||||
BaselineTIFFTagSet.TAG_PREDICTOR,
|
||||
BaselineTIFFTagSet.TAG_REFERENCE_BLACK_WHITE,
|
||||
BaselineTIFFTagSet.TAG_ROWS_PER_STRIP,
|
||||
BaselineTIFFTagSet.TAG_SAMPLES_PER_PIXEL,
|
||||
BaselineTIFFTagSet.TAG_SAMPLE_FORMAT,
|
||||
BaselineTIFFTagSet.TAG_STRIP_BYTE_COUNTS,
|
||||
BaselineTIFFTagSet.TAG_STRIP_OFFSETS,
|
||||
BaselineTIFFTagSet.TAG_T4_OPTIONS,
|
||||
BaselineTIFFTagSet.TAG_T6_OPTIONS,
|
||||
BaselineTIFFTagSet.TAG_TILE_BYTE_COUNTS,
|
||||
BaselineTIFFTagSet.TAG_TILE_LENGTH,
|
||||
BaselineTIFFTagSet.TAG_TILE_OFFSETS,
|
||||
BaselineTIFFTagSet.TAG_TILE_WIDTH,
|
||||
BaselineTIFFTagSet.TAG_Y_CB_CR_COEFFICIENTS,
|
||||
BaselineTIFFTagSet.TAG_Y_CB_CR_SUBSAMPLING
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a {@code TIFFDirectory} to a {@code TIFFIFD}.
|
||||
@ -507,6 +553,15 @@ public class TIFFIFD extends TIFFDirectory {
|
||||
|
||||
List<TIFFTagSet> tagSetList = getTagSetList();
|
||||
|
||||
boolean ensureEssentialTags = false;
|
||||
TIFFTagSet baselineTagSet = null;
|
||||
if (isPrimaryIFD && ignoreUnknownFields
|
||||
&& !tagSetList.contains(BaselineTIFFTagSet.getInstance())) {
|
||||
ensureEssentialTags = true;
|
||||
initializeEssentialTags();
|
||||
baselineTagSet = BaselineTIFFTagSet.getInstance();
|
||||
}
|
||||
|
||||
List<Object> entries = new ArrayList<>();
|
||||
Object[] entryData = new Object[1]; // allocate once for later reuse.
|
||||
|
||||
@ -530,6 +585,11 @@ public class TIFFIFD extends TIFFDirectory {
|
||||
// Get the associated TIFFTag.
|
||||
TIFFTag tag = getTag(tagNumber, tagSetList);
|
||||
|
||||
if (tag == null && ensureEssentialTags
|
||||
&& essentialTags.contains(tagNumber)) {
|
||||
tag = baselineTagSet.getTag(tagNumber);
|
||||
}
|
||||
|
||||
// Ignore unknown fields, fields with unknown type, and fields
|
||||
// with count out of int range.
|
||||
if((tag == null && ignoreUnknownFields)
|
||||
|
@ -1174,7 +1174,14 @@ public class TIFFImageReader extends ImageReader {
|
||||
int predictor = ((predictorField == null)
|
||||
? BaselineTIFFTagSet.PREDICTOR_NONE
|
||||
: predictorField.getAsInt(0));
|
||||
this.decompressor = new TIFFLZWDecompressor(predictor);
|
||||
|
||||
TIFFField fillOrderField
|
||||
= imageMetadata.getTIFFField(BaselineTIFFTagSet.TAG_FILL_ORDER);
|
||||
int fillOrder = ((fillOrderField == null)
|
||||
? BaselineTIFFTagSet.FILL_ORDER_LEFT_TO_RIGHT
|
||||
: fillOrderField.getAsInt(0));
|
||||
|
||||
this.decompressor = new TIFFLZWDecompressor(predictor, fillOrder);
|
||||
} else if (compression
|
||||
== BaselineTIFFTagSet.COMPRESSION_JPEG) {
|
||||
this.decompressor = new TIFFJPEGDecompressor();
|
||||
|
@ -30,6 +30,10 @@ import javax.imageio.plugins.tiff.BaselineTIFFTagSet;
|
||||
|
||||
class TIFFLZWDecompressor extends TIFFDecompressor {
|
||||
|
||||
private static final int CLEAR_CODE = 256;
|
||||
private static final int EOI_CODE = 257;
|
||||
private static final int FIRST_CODE = 258;
|
||||
|
||||
private static final int andTable[] = {
|
||||
511,
|
||||
1023,
|
||||
@ -39,6 +43,10 @@ class TIFFLZWDecompressor extends TIFFDecompressor {
|
||||
|
||||
private int predictor;
|
||||
|
||||
// whether to reverse the bits in each byte of the input data, i.e.,
|
||||
// convert right-to-left fill order (lsb) to left-to-right (msb).
|
||||
private boolean flipBits;
|
||||
|
||||
private byte[] srcData;
|
||||
private byte[] dstData;
|
||||
|
||||
@ -51,7 +59,8 @@ class TIFFLZWDecompressor extends TIFFDecompressor {
|
||||
private int nextData = 0;
|
||||
private int nextBits = 0;
|
||||
|
||||
public TIFFLZWDecompressor(int predictor) throws IIOException {
|
||||
public TIFFLZWDecompressor(int predictor, int fillOrder)
|
||||
throws IIOException {
|
||||
super();
|
||||
|
||||
if (predictor != BaselineTIFFTagSet.PREDICTOR_NONE &&
|
||||
@ -62,6 +71,8 @@ class TIFFLZWDecompressor extends TIFFDecompressor {
|
||||
}
|
||||
|
||||
this.predictor = predictor;
|
||||
|
||||
flipBits = fillOrder == BaselineTIFFTagSet.FILL_ORDER_RIGHT_TO_LEFT;
|
||||
}
|
||||
|
||||
public void decodeRaw(byte[] b,
|
||||
@ -88,6 +99,12 @@ class TIFFLZWDecompressor extends TIFFDecompressor {
|
||||
byte[] sdata = new byte[byteCount];
|
||||
stream.readFully(sdata);
|
||||
|
||||
if (flipBits) {
|
||||
for (int i = 0; i < byteCount; i++) {
|
||||
sdata[i] = TIFFFaxDecompressor.flipTable[sdata[i] & 0xff];
|
||||
}
|
||||
}
|
||||
|
||||
int bytesPerRow = (srcWidth*bitsPerPixel + 7)/8;
|
||||
byte[] buf;
|
||||
int bufOffset;
|
||||
@ -133,11 +150,11 @@ class TIFFLZWDecompressor extends TIFFDecompressor {
|
||||
int code, oldCode = 0;
|
||||
byte[] string;
|
||||
|
||||
while ((code = getNextCode()) != 257) {
|
||||
if (code == 256) {
|
||||
while ((code = getNextCode()) != EOI_CODE) {
|
||||
if (code == CLEAR_CODE) {
|
||||
initializeStringTable();
|
||||
code = getNextCode();
|
||||
if (code == 257) {
|
||||
if (code == EOI_CODE) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -186,12 +203,12 @@ class TIFFLZWDecompressor extends TIFFDecompressor {
|
||||
public void initializeStringTable() {
|
||||
stringTable = new byte[4096][];
|
||||
|
||||
for (int i = 0; i < 256; i++) {
|
||||
for (int i = 0; i < CLEAR_CODE; i++) {
|
||||
stringTable[i] = new byte[1];
|
||||
stringTable[i][0] = (byte)i;
|
||||
}
|
||||
|
||||
tableIndex = 258;
|
||||
tableIndex = FIRST_CODE;
|
||||
bitsToGet = 9;
|
||||
}
|
||||
|
||||
@ -281,7 +298,7 @@ class TIFFLZWDecompressor extends TIFFDecompressor {
|
||||
return code;
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
// Strip not terminated as expected: return EndOfInformation code.
|
||||
return 257;
|
||||
return EOI_CODE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -88,6 +88,7 @@ public class SwingUtilities3 {
|
||||
* or {@code Applet}
|
||||
* @param isRequested the value to set vsyncRequested state to
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void setVsyncRequested(Container rootContainer,
|
||||
boolean isRequested) {
|
||||
assert (rootContainer instanceof Applet) || (rootContainer instanceof Window);
|
||||
@ -104,6 +105,7 @@ public class SwingUtilities3 {
|
||||
* @param rootContainer topmost container. Should be either Window or Applet
|
||||
* @return {@code true} if vsync painting is requested for {@code rootContainer}
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static boolean isVsyncRequested(Container rootContainer) {
|
||||
assert (rootContainer instanceof Applet) || (rootContainer instanceof Window);
|
||||
return Boolean.TRUE == vsyncedMap.get(rootContainer);
|
||||
|
@ -1125,6 +1125,7 @@ class GTKStyle extends SynthStyle implements GTKConstants {
|
||||
this.methodName = methodName;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public Object createValue(UIDefaults table) {
|
||||
try {
|
||||
Class<?> c = Class.forName(className, true,Thread.currentThread().
|
||||
@ -1136,11 +1137,7 @@ class GTKStyle extends SynthStyle implements GTKConstants {
|
||||
Method m = c.getMethod(methodName, (Class<?>[])null);
|
||||
|
||||
return m.invoke(c, (Object[])null);
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
} catch (IllegalAccessException iae) {
|
||||
} catch (InvocationTargetException ite) {
|
||||
} catch (NoSuchMethodException nsme) {
|
||||
} catch (InstantiationException ie) {
|
||||
} catch (ReflectiveOperationException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user