mirror of
https://github.com/openjdk/jdk.git
synced 2026-07-19 23:48:50 +00:00
Merge
This commit is contained in:
commit
1bdb2e37b2
@ -5,3 +5,5 @@ nbproject/private/
|
||||
^.hgtip
|
||||
^.bridge2
|
||||
.DS_Store
|
||||
.metadata/
|
||||
.recommenders/
|
||||
|
||||
2
.hgtags
2
.hgtags
@ -329,3 +329,5 @@ f61a63b7d1e52e307abc0bfc751203155d362ec4 jdk9-b83
|
||||
51b2db2fa04c16d767b66113dbf08c5349ce382a jdk9-b84
|
||||
8392405ab038b22e69a3728e17dbdd9e3d3a22ed jdk9-b85
|
||||
7db0663a5e968059fa7c772172187ebd60b6492d jdk9-b86
|
||||
1a52a30674cd28c24d4d388150336121f2e9ddf9 jdk9-b87
|
||||
16b4968f9bb8f34371b42c0ba483d76e91ba84d8 jdk9-b88
|
||||
|
||||
@ -329,3 +329,5 @@ ce5c14d97d95084504c32b9320cb33cce4235588 jdk9-b83
|
||||
1c8134475511ffe6726677e1418a89a7a45e92d6 jdk9-b84
|
||||
1f345217c9bab05f192d00cf1665b3286c49ccdb jdk9-b85
|
||||
2aa1daf98d3e2ee37f20f6858c53cc37020f6937 jdk9-b86
|
||||
fd4f4f7561074dc0dbc1772c8489c7b902b6b8a9 jdk9-b87
|
||||
0bb87e05d83e1cf41cfb7ddeb2c8eaec539fd907 jdk9-b88
|
||||
|
||||
3860
README-builds.html
3860
README-builds.html
File diff suppressed because it is too large
Load Diff
1263
README-builds.md
Normal file
1263
README-builds.md
Normal file
File diff suppressed because it is too large
Load Diff
@ -410,6 +410,7 @@ AC_DEFUN_ONCE([BASIC_SETUP_FUNDAMENTAL_TOOLS],
|
||||
BASIC_REQUIRE_PROGS(NAWK, [nawk gawk awk])
|
||||
BASIC_REQUIRE_PROGS(PRINTF, printf)
|
||||
BASIC_REQUIRE_PROGS(RM, rm)
|
||||
BASIC_REQUIRE_PROGS(RMDIR, rmdir)
|
||||
BASIC_REQUIRE_PROGS(SH, sh)
|
||||
BASIC_REQUIRE_PROGS(SORT, sort)
|
||||
BASIC_REQUIRE_PROGS(TAIL, tail)
|
||||
|
||||
@ -305,6 +305,16 @@ AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK],
|
||||
BOOT_JDK_SOURCETARGET="-source 8 -target 8"
|
||||
AC_SUBST(BOOT_JDK_SOURCETARGET)
|
||||
AC_SUBST(JAVAC_FLAGS)
|
||||
|
||||
# Check if the boot jdk is 32 or 64 bit
|
||||
if "$JAVA" -d64 -version > /dev/null 2>&1; then
|
||||
BOOT_JDK_BITS="64"
|
||||
else
|
||||
BOOT_JDK_BITS="32"
|
||||
fi
|
||||
AC_MSG_CHECKING([if Boot JDK is 32 or 64 bits])
|
||||
AC_MSG_RESULT([$BOOT_JDK_BITS])
|
||||
AC_SUBST(BOOT_JDK_BITS)
|
||||
])
|
||||
|
||||
AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK_ARGUMENTS],
|
||||
@ -341,7 +351,7 @@ AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK_ARGUMENTS],
|
||||
# Maximum amount of heap memory.
|
||||
# Maximum stack size.
|
||||
JVM_MAX_HEAP=`expr $MEMORY_SIZE / 2`
|
||||
if test "x$BUILD_NUM_BITS" = x32; then
|
||||
if test "x$BOOT_JDK_BITS" = "x32"; then
|
||||
if test "$JVM_MAX_HEAP" -gt "1100"; then
|
||||
JVM_MAX_HEAP=1100
|
||||
elif test "$JVM_MAX_HEAP" -lt "512"; then
|
||||
@ -349,10 +359,7 @@ AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK_ARGUMENTS],
|
||||
fi
|
||||
STACK_SIZE=768
|
||||
else
|
||||
# Running Javac on a JVM on a 64-bit machine, takes more space since 64-bit
|
||||
# pointers are used. Apparently, we need to increase the heap and stack
|
||||
# space for the jvm. More specifically, when running javac to build huge
|
||||
# jdk batch
|
||||
# Running a 64 bit JVM allows for and requires a bigger heap
|
||||
if test "$JVM_MAX_HEAP" -gt "1600"; then
|
||||
JVM_MAX_HEAP=1600
|
||||
elif test "$JVM_MAX_HEAP" -lt "512"; then
|
||||
|
||||
@ -328,12 +328,23 @@ AC_DEFUN_ONCE([BPERF_SETUP_SMART_JAVAC],
|
||||
|
||||
AC_ARG_ENABLE([sjavac], [AS_HELP_STRING([--enable-sjavac],
|
||||
[use sjavac to do fast incremental compiles @<:@disabled@:>@])],
|
||||
[ENABLE_SJAVAC="${enableval}"], [ENABLE_SJAVAC='no'])
|
||||
[ENABLE_SJAVAC="${enableval}"], [ENABLE_SJAVAC="no"])
|
||||
if test "x$JVM_ARG_OK" = "xfalse"; then
|
||||
AC_MSG_WARN([Could not set -Xms${MS_VALUE}M -Xmx${MX_VALUE}M, disabling sjavac])
|
||||
ENABLE_SJAVAC=no;
|
||||
ENABLE_SJAVAC="no"
|
||||
fi
|
||||
AC_MSG_CHECKING([whether to use sjavac])
|
||||
AC_MSG_RESULT([$ENABLE_SJAVAC])
|
||||
AC_SUBST(ENABLE_SJAVAC)
|
||||
|
||||
AC_ARG_ENABLE([javac-server], [AS_HELP_STRING([--enable-javac-server],
|
||||
[use only the server part of sjavac for faster javac compiles @<:@disabled@:>@])],
|
||||
[ENABLE_JAVAC_SERVER="${enableval}"], [ENABLE_JAVAC_SERVER="no"])
|
||||
if test "x$JVM_ARG_OK" = "xfalse"; then
|
||||
AC_MSG_WARN([Could not set -Xms${MS_VALUE}M -Xmx${MX_VALUE}M, disabling javac server])
|
||||
ENABLE_JAVAC_SERVER="no"
|
||||
fi
|
||||
AC_MSG_CHECKING([whether to use javac server])
|
||||
AC_MSG_RESULT([$ENABLE_JAVAC_SERVER])
|
||||
AC_SUBST(ENABLE_JAVAC_SERVER)
|
||||
])
|
||||
|
||||
@ -66,7 +66,7 @@ export STRIP="@STRIP@ @STRIPFLAGS@"
|
||||
export TEE="@TEE@"
|
||||
export UNIQ="@UNIQ@"
|
||||
export UNPACK200="@FIXPATH@ @BOOT_JDK@/bin/unpack200"
|
||||
export UNZIP="@UNZIP@"
|
||||
export UNARCHIVE="@UNZIP@ -q"
|
||||
|
||||
export SRC_ROOT="@TOPDIR@"
|
||||
export OUTPUT_ROOT="@OUTPUT_ROOT@"
|
||||
|
||||
@ -632,6 +632,7 @@ LIBOBJS
|
||||
CFLAGS_CCACHE
|
||||
CCACHE
|
||||
USE_PRECOMPILED_HEADER
|
||||
ENABLE_JAVAC_SERVER
|
||||
ENABLE_SJAVAC
|
||||
SJAVAC_SERVER_JAVA_FLAGS
|
||||
SJAVAC_SERVER_JAVA
|
||||
@ -815,6 +816,7 @@ JAXWS_TOPDIR
|
||||
JAXP_TOPDIR
|
||||
CORBA_TOPDIR
|
||||
LANGTOOLS_TOPDIR
|
||||
BOOT_JDK_BITS
|
||||
JAVAC_FLAGS
|
||||
BOOT_JDK_SOURCETARGET
|
||||
JARSIGNER
|
||||
@ -968,6 +970,7 @@ TAR
|
||||
TAIL
|
||||
SORT
|
||||
SH
|
||||
RMDIR
|
||||
RM
|
||||
PRINTF
|
||||
NAWK
|
||||
@ -1115,6 +1118,7 @@ with_jobs
|
||||
with_boot_jdk_jvmargs
|
||||
with_sjavac_server_java
|
||||
enable_sjavac
|
||||
enable_javac_server
|
||||
enable_precompiled_headers
|
||||
enable_ccache
|
||||
with_ccache_dir
|
||||
@ -1146,6 +1150,7 @@ MV
|
||||
NAWK
|
||||
PRINTF
|
||||
RM
|
||||
RMDIR
|
||||
SH
|
||||
SORT
|
||||
TAIL
|
||||
@ -1864,6 +1869,8 @@ Optional Features:
|
||||
--with-freetype, disabled otherwise]
|
||||
--enable-sjavac use sjavac to do fast incremental compiles
|
||||
[disabled]
|
||||
--enable-javac-server use only the server part of sjavac for faster javac
|
||||
compiles [disabled]
|
||||
--disable-precompiled-headers
|
||||
disable using precompiled headers when compiling C++
|
||||
[enabled]
|
||||
@ -2025,6 +2032,7 @@ Some influential environment variables:
|
||||
NAWK Override default value for NAWK
|
||||
PRINTF Override default value for PRINTF
|
||||
RM Override default value for RM
|
||||
RMDIR Override default value for RMDIR
|
||||
SH Override default value for SH
|
||||
SORT Override default value for SORT
|
||||
TAIL Override default value for TAIL
|
||||
@ -4587,7 +4595,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=1444224363
|
||||
DATE_WHEN_GENERATED=1445964676
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
@ -9511,6 +9519,209 @@ $as_echo "$tool_specified" >&6; }
|
||||
|
||||
|
||||
|
||||
# Publish this variable in the help.
|
||||
|
||||
|
||||
if [ -z "${RMDIR+x}" ]; then
|
||||
# The variable is not set by user, try to locate tool using the code snippet
|
||||
for ac_prog in rmdir
|
||||
do
|
||||
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
||||
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_RMDIR+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
case $RMDIR in
|
||||
[\\/]* | ?:[\\/]*)
|
||||
ac_cv_path_RMDIR="$RMDIR" # Let the user override the test with a path.
|
||||
;;
|
||||
*)
|
||||
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
||||
for as_dir in $PATH
|
||||
do
|
||||
IFS=$as_save_IFS
|
||||
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_RMDIR="$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
|
||||
done
|
||||
done
|
||||
IFS=$as_save_IFS
|
||||
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
RMDIR=$ac_cv_path_RMDIR
|
||||
if test -n "$RMDIR"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $RMDIR" >&5
|
||||
$as_echo "$RMDIR" >&6; }
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
|
||||
test -n "$RMDIR" && break
|
||||
done
|
||||
|
||||
else
|
||||
# The variable is set, but is it from the command line or the environment?
|
||||
|
||||
# Try to remove the string !RMDIR! from our list.
|
||||
try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!RMDIR!/}
|
||||
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 "xRMDIR" != xBASH; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of RMDIR from the environment. Use command line variables instead." >&5
|
||||
$as_echo "$as_me: WARNING: Ignoring value of RMDIR from the environment. Use command line variables instead." >&2;}
|
||||
fi
|
||||
# Try to locate tool using the code snippet
|
||||
for ac_prog in rmdir
|
||||
do
|
||||
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
||||
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_RMDIR+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
case $RMDIR in
|
||||
[\\/]* | ?:[\\/]*)
|
||||
ac_cv_path_RMDIR="$RMDIR" # Let the user override the test with a path.
|
||||
;;
|
||||
*)
|
||||
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
||||
for as_dir in $PATH
|
||||
do
|
||||
IFS=$as_save_IFS
|
||||
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_RMDIR="$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
|
||||
done
|
||||
done
|
||||
IFS=$as_save_IFS
|
||||
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
RMDIR=$ac_cv_path_RMDIR
|
||||
if test -n "$RMDIR"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $RMDIR" >&5
|
||||
$as_echo "$RMDIR" >&6; }
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
|
||||
test -n "$RMDIR" && break
|
||||
done
|
||||
|
||||
else
|
||||
# If it succeeded, then it was overridden by the user. We will use it
|
||||
# for the tool.
|
||||
|
||||
# First remove it from the list of overridden variables, so we can test
|
||||
# for unknown variables in the end.
|
||||
CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var"
|
||||
|
||||
# Check if we try to supply an empty value
|
||||
if test "x$RMDIR" = x; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: Setting user supplied tool RMDIR= (no value)" >&5
|
||||
$as_echo "$as_me: Setting user supplied tool RMDIR= (no value)" >&6;}
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RMDIR" >&5
|
||||
$as_echo_n "checking for RMDIR... " >&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="$RMDIR"
|
||||
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 RMDIR=$tool_basename" >&5
|
||||
$as_echo "$as_me: Will search for user supplied tool RMDIR=$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_RMDIR+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
case $RMDIR in
|
||||
[\\/]* | ?:[\\/]*)
|
||||
ac_cv_path_RMDIR="$RMDIR" # Let the user override the test with a path.
|
||||
;;
|
||||
*)
|
||||
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
||||
for as_dir in $PATH
|
||||
do
|
||||
IFS=$as_save_IFS
|
||||
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_RMDIR="$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
|
||||
done
|
||||
done
|
||||
IFS=$as_save_IFS
|
||||
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
RMDIR=$ac_cv_path_RMDIR
|
||||
if test -n "$RMDIR"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $RMDIR" >&5
|
||||
$as_echo "$RMDIR" >&6; }
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
fi
|
||||
|
||||
|
||||
if test "x$RMDIR" = 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 RMDIR=$tool_specified" >&5
|
||||
$as_echo "$as_me: Will use user supplied tool RMDIR=$tool_specified" >&6;}
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RMDIR" >&5
|
||||
$as_echo_n "checking for RMDIR... " >&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 RMDIR=$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; }
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if test "x$RMDIR" = x; then
|
||||
as_fn_error $? "Could not find required tool for RMDIR" "$LINENO" 5
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Publish this variable in the help.
|
||||
|
||||
|
||||
@ -26920,6 +27131,18 @@ $as_echo "$tool_specified" >&6; }
|
||||
|
||||
|
||||
|
||||
# Check if the boot jdk is 32 or 64 bit
|
||||
if "$JAVA" -d64 -version > /dev/null 2>&1; then
|
||||
BOOT_JDK_BITS="64"
|
||||
else
|
||||
BOOT_JDK_BITS="32"
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if Boot JDK is 32 or 64 bits" >&5
|
||||
$as_echo_n "checking if Boot JDK is 32 or 64 bits... " >&6; }
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_BITS" >&5
|
||||
$as_echo "$BOOT_JDK_BITS" >&6; }
|
||||
|
||||
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
@ -46678,10 +46901,24 @@ $as_echo "$as_me: WARNING: X11 is not used, so --with-x is ignored" >&2;}
|
||||
X_CFLAGS=
|
||||
X_LIBS=
|
||||
else
|
||||
# Check if the user has specified sysroot, but not --x-includes or --x-libraries.
|
||||
# Make a simple check for the libraries at the sysroot, and setup --x-includes and
|
||||
# --x-libraries for the sysroot, if that seems to be correct.
|
||||
if test "x$OPENJDK_TARGET_OS" = "xlinux"; then
|
||||
|
||||
if test "x${with_x}" = xno; then
|
||||
as_fn_error $? "It is not possible to disable the use of X11. Remove the --without-x option." "$LINENO" 5
|
||||
fi
|
||||
|
||||
if test "x${with_x}" != x && test "x${with_x}" != xyes; then
|
||||
# The user has specified a X11 base directory. Use it for includes and
|
||||
# libraries, unless explicitely overridden.
|
||||
if test "x$x_includes" = xNONE; then
|
||||
x_includes="${with_x}/include"
|
||||
fi
|
||||
if test "x$x_libraries" = xNONE; then
|
||||
x_libraries="${with_x}/lib"
|
||||
fi
|
||||
else
|
||||
# Check if the user has specified sysroot, but not --with-x, --x-includes or --x-libraries.
|
||||
# Make a simple check for the libraries at the sysroot, and setup --x-includes and
|
||||
# --x-libraries for the sysroot, if that seems to be correct.
|
||||
if test "x$SYSROOT" != "x"; then
|
||||
if test "x$x_includes" = xNONE; then
|
||||
if test -f "$SYSROOT/usr/X11R6/include/X11/Xlib.h"; then
|
||||
@ -53085,7 +53322,7 @@ $as_echo_n "checking flags for boot jdk java command for big workloads... " >&6;
|
||||
# Maximum amount of heap memory.
|
||||
# Maximum stack size.
|
||||
JVM_MAX_HEAP=`expr $MEMORY_SIZE / 2`
|
||||
if test "x$BUILD_NUM_BITS" = x32; then
|
||||
if test "x$BOOT_JDK_BITS" = "x32"; then
|
||||
if test "$JVM_MAX_HEAP" -gt "1100"; then
|
||||
JVM_MAX_HEAP=1100
|
||||
elif test "$JVM_MAX_HEAP" -lt "512"; then
|
||||
@ -53093,10 +53330,7 @@ $as_echo_n "checking flags for boot jdk java command for big workloads... " >&6;
|
||||
fi
|
||||
STACK_SIZE=768
|
||||
else
|
||||
# Running Javac on a JVM on a 64-bit machine, takes more space since 64-bit
|
||||
# pointers are used. Apparently, we need to increase the heap and stack
|
||||
# space for the jvm. More specifically, when running javac to build huge
|
||||
# jdk batch
|
||||
# Running a 64 bit JVM allows for and requires a bigger heap
|
||||
if test "$JVM_MAX_HEAP" -gt "1600"; then
|
||||
JVM_MAX_HEAP=1600
|
||||
elif test "$JVM_MAX_HEAP" -lt "512"; then
|
||||
@ -53285,13 +53519,13 @@ fi
|
||||
if test "${enable_sjavac+set}" = set; then :
|
||||
enableval=$enable_sjavac; ENABLE_SJAVAC="${enableval}"
|
||||
else
|
||||
ENABLE_SJAVAC='no'
|
||||
ENABLE_SJAVAC="no"
|
||||
fi
|
||||
|
||||
if test "x$JVM_ARG_OK" = "xfalse"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Could not set -Xms${MS_VALUE}M -Xmx${MX_VALUE}M, disabling sjavac" >&5
|
||||
$as_echo "$as_me: WARNING: Could not set -Xms${MS_VALUE}M -Xmx${MX_VALUE}M, disabling sjavac" >&2;}
|
||||
ENABLE_SJAVAC=no;
|
||||
ENABLE_SJAVAC="no"
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use sjavac" >&5
|
||||
$as_echo_n "checking whether to use sjavac... " >&6; }
|
||||
@ -53299,6 +53533,24 @@ $as_echo_n "checking whether to use sjavac... " >&6; }
|
||||
$as_echo "$ENABLE_SJAVAC" >&6; }
|
||||
|
||||
|
||||
# Check whether --enable-javac-server was given.
|
||||
if test "${enable_javac_server+set}" = set; then :
|
||||
enableval=$enable_javac_server; ENABLE_JAVAC_SERVER="${enableval}"
|
||||
else
|
||||
ENABLE_JAVAC_SERVER="no"
|
||||
fi
|
||||
|
||||
if test "x$JVM_ARG_OK" = "xfalse"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Could not set -Xms${MS_VALUE}M -Xmx${MX_VALUE}M, disabling javac server" >&5
|
||||
$as_echo "$as_me: WARNING: Could not set -Xms${MS_VALUE}M -Xmx${MX_VALUE}M, disabling javac server" >&2;}
|
||||
ENABLE_JAVAC_SERVER="no"
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use javac server" >&5
|
||||
$as_echo_n "checking whether to use javac server... " >&6; }
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ENABLE_JAVAC_SERVER" >&5
|
||||
$as_echo "$ENABLE_JAVAC_SERVER" >&6; }
|
||||
|
||||
|
||||
|
||||
# Can the C/C++ compiler use precompiled headers?
|
||||
|
||||
|
||||
@ -35,10 +35,24 @@ AC_DEFUN_ONCE([LIB_SETUP_X11],
|
||||
X_CFLAGS=
|
||||
X_LIBS=
|
||||
else
|
||||
# Check if the user has specified sysroot, but not --x-includes or --x-libraries.
|
||||
# Make a simple check for the libraries at the sysroot, and setup --x-includes and
|
||||
# --x-libraries for the sysroot, if that seems to be correct.
|
||||
if test "x$OPENJDK_TARGET_OS" = "xlinux"; then
|
||||
|
||||
if test "x${with_x}" = xno; then
|
||||
AC_MSG_ERROR([It is not possible to disable the use of X11. Remove the --without-x option.])
|
||||
fi
|
||||
|
||||
if test "x${with_x}" != x && test "x${with_x}" != xyes; then
|
||||
# The user has specified a X11 base directory. Use it for includes and
|
||||
# libraries, unless explicitely overridden.
|
||||
if test "x$x_includes" = xNONE; then
|
||||
x_includes="${with_x}/include"
|
||||
fi
|
||||
if test "x$x_libraries" = xNONE; then
|
||||
x_libraries="${with_x}/lib"
|
||||
fi
|
||||
else
|
||||
# Check if the user has specified sysroot, but not --with-x, --x-includes or --x-libraries.
|
||||
# Make a simple check for the libraries at the sysroot, and setup --x-includes and
|
||||
# --x-libraries for the sysroot, if that seems to be correct.
|
||||
if test "x$SYSROOT" != "x"; then
|
||||
if test "x$x_includes" = xNONE; then
|
||||
if test -f "$SYSROOT/usr/X11R6/include/X11/Xlib.h"; then
|
||||
|
||||
@ -245,6 +245,7 @@ MEMORY_SIZE:=@MEMORY_SIZE@
|
||||
# Enable sjavac support = use a javac server,
|
||||
# multi core javac compilation and dependency tracking.
|
||||
ENABLE_SJAVAC:=@ENABLE_SJAVAC@
|
||||
ENABLE_JAVAC_SERVER:=@ENABLE_JAVAC_SERVER@
|
||||
# Store sjavac server synchronization files here, and
|
||||
# the sjavac server log files.
|
||||
SJAVAC_SERVER_DIR=$(MAKESUPPORT_OUTPUTDIR)/javacservers
|
||||
@ -504,6 +505,7 @@ PATCH:=@PATCH@
|
||||
PRINTF:=@PRINTF@
|
||||
PWD:=@THEPWDCMD@
|
||||
RM:=@RM@
|
||||
RMDIR:=@RMDIR@
|
||||
SED:=@SED@
|
||||
SH:=@SH@
|
||||
SORT:=@SORT@
|
||||
|
||||
@ -51,8 +51,6 @@ else
|
||||
STAT_PRINT_SIZE="-c %s"
|
||||
fi
|
||||
|
||||
UNARCHIVE="$UNZIP -q"
|
||||
|
||||
COMPARE_EXCEPTIONS_INCLUDE="$SRC_ROOT/common/bin/compare_exceptions.sh.incl"
|
||||
if [ ! -e "$COMPARE_EXCEPTIONS_INCLUDE" ]; then
|
||||
echo "Error: Cannot locate the exceptions file, it should have been here: $COMPARE_EXCEPTIONS_INCLUDE"
|
||||
|
||||
62
common/bin/update-build-readme.sh
Normal file
62
common/bin/update-build-readme.sh
Normal file
@ -0,0 +1,62 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Get an absolute path to this script, since that determines the top-level
|
||||
# directory.
|
||||
this_script_dir=`dirname $0`
|
||||
TOPDIR=`cd $this_script_dir/../.. > /dev/null && pwd`
|
||||
|
||||
GREP=grep
|
||||
MD_FILE=$TOPDIR/README-builds.md
|
||||
HTML_FILE=$TOPDIR/README-builds.html
|
||||
|
||||
# Locate the markdown processor tool and check that it is the correct version.
|
||||
locate_markdown_processor() {
|
||||
if [ -z "$MARKDOWN" ]; then
|
||||
MARKDOWN=`which markdown 2> /dev/null`
|
||||
if [ -z "$MARKDOWN" ]; then
|
||||
echo "Error: Cannot locate markdown processor" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Test version
|
||||
MARKDOWN_VERSION=`$MARKDOWN -version | $GREP version`
|
||||
if [ "x$MARKDOWN_VERSION" != "xThis is Markdown, version 1.0.1." ]; then
|
||||
echo "Error: Expected markdown version 1.0.1." 1>&2
|
||||
echo "Actual version found: $MARKDOWN_VERSION" 1>&2
|
||||
echo "Download markdown here: https://daringfireball.net/projects/markdown/" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
# Verify that the source markdown file looks sound.
|
||||
verify_source_code() {
|
||||
TOO_LONG_LINES=`$GREP -E -e '^.{80}.+$' $MD_FILE`
|
||||
if [ "x$TOO_LONG_LINES" != x ]; then
|
||||
echo "Warning: The following lines are longer than 80 characters:"
|
||||
$GREP -E -e '^.{80}.+$' $MD_FILE
|
||||
fi
|
||||
}
|
||||
|
||||
# Convert the markdown file to html format.
|
||||
process_source() {
|
||||
echo "Generating html file from markdown"
|
||||
cat > $HTML_FILE << END
|
||||
<html>
|
||||
<head>
|
||||
<title>OpenJDK Build README</title>
|
||||
</head>
|
||||
<body>
|
||||
END
|
||||
markdown $MD_FILE >> $HTML_FILE
|
||||
cat >> $HTML_FILE <<END
|
||||
</body>
|
||||
</html>
|
||||
END
|
||||
echo "Done"
|
||||
}
|
||||
|
||||
locate_markdown_processor
|
||||
verify_source_code
|
||||
process_source
|
||||
@ -329,3 +329,5 @@ ca8a1719588424f6e04e943790c7fcb7cb0b8c8f jdk9-b83
|
||||
df70bb200356fec686681f0295c50cc3ed43c3b3 jdk9-b84
|
||||
3ec06af1368924469f7ce60a00324bac55eaeecc jdk9-b85
|
||||
0a3f0d25c201b40575a7c3920fce4d6f4d3ae310 jdk9-b86
|
||||
a5c40ac9b916ff44d512ee764fa919ed2097e149 jdk9-b87
|
||||
00f48ecbc09915f793d9e5ad74ab0b25f2549bf5 jdk9-b88
|
||||
|
||||
@ -567,6 +567,11 @@ public class IIOPInputStream
|
||||
// XXX I18N, logging needed.
|
||||
throw new NotActiveException("defaultReadObjectDelegate");
|
||||
|
||||
if (!currentClassDesc.forClass().isAssignableFrom(
|
||||
currentObject.getClass())) {
|
||||
throw new IOException("Object Type mismatch");
|
||||
}
|
||||
|
||||
// The array will be null unless fields were retrieved
|
||||
// remotely because of a serializable version difference.
|
||||
// Bug fix for 4365188. See the definition of
|
||||
@ -1063,6 +1068,9 @@ public class IIOPInputStream
|
||||
|
||||
int spBase = spClass; // current top of stack
|
||||
|
||||
if (currentClass.getName().equals("java.lang.String")) {
|
||||
return this.readUTF();
|
||||
}
|
||||
/* The object's classes should be processed from supertype to subtype
|
||||
* Push all the clases of the current object onto a stack.
|
||||
* Note that only the serializable classes are represented
|
||||
@ -2257,6 +2265,27 @@ public class IIOPInputStream
|
||||
|
||||
try {
|
||||
Class fieldCl = fields[i].getClazz();
|
||||
if ((objectValue != null)
|
||||
&& (!fieldCl.isAssignableFrom(
|
||||
objectValue.getClass()))) {
|
||||
throw new IllegalArgumentException("Field mismatch");
|
||||
}
|
||||
Field classField = null;
|
||||
try {
|
||||
classField = cl.getDeclaredField(fields[i].getName());
|
||||
} catch (NoSuchFieldException nsfEx) {
|
||||
throw new IllegalArgumentException(nsfEx);
|
||||
} catch (SecurityException secEx) {
|
||||
throw new IllegalArgumentException(secEx.getCause());
|
||||
}
|
||||
Class<?> declaredFieldClass = classField.getType();
|
||||
|
||||
// check input field type is a declared field type
|
||||
// input field is a subclass of the declared field
|
||||
if (!declaredFieldClass.isAssignableFrom(fieldCl)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Field Type mismatch");
|
||||
}
|
||||
if (objectValue != null && !fieldCl.isInstance(objectValue)) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
@ -559,6 +559,10 @@ public class IIOPOutputStream
|
||||
* Push all the clases of the current object onto a stack.
|
||||
* Remember the stack pointer where this set of classes is being pushed.
|
||||
*/
|
||||
if (currentClassDesc.forClass().getName().equals("java.lang.String")) {
|
||||
this.writeUTF((String)obj);
|
||||
return;
|
||||
}
|
||||
int stackMark = classDescStack.size();
|
||||
try {
|
||||
ObjectStreamClass next;
|
||||
|
||||
@ -446,6 +446,9 @@ public class StubGenerator extends sun.rmi.rmic.iiop.Generator {
|
||||
if (emitPermissionCheck) {
|
||||
|
||||
// produce the following generated code for example
|
||||
//
|
||||
// private transient boolean _instantiated = false;
|
||||
//
|
||||
// private static Void checkPermission() {
|
||||
// SecurityManager sm = System.getSecurityManager();
|
||||
// if (sm != null) {
|
||||
@ -460,11 +463,21 @@ public class StubGenerator extends sun.rmi.rmic.iiop.Generator {
|
||||
//
|
||||
// public _XXXXX_Stub() {
|
||||
// this(checkPermission());
|
||||
// _instantiated = true;
|
||||
// }
|
||||
//
|
||||
// private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException {
|
||||
// checkPermission();
|
||||
// s.defaultReadObject();
|
||||
// _instantiated = true;
|
||||
// }
|
||||
//
|
||||
// where XXXXX is the name of the remote interface
|
||||
|
||||
p.pln();
|
||||
p.plnI("private transient boolean _instantiated = false;");
|
||||
p.pln();
|
||||
p.pO();
|
||||
p.plnI("private static Void checkPermission() {");
|
||||
p.plnI("SecurityManager sm = System.getSecurityManager();");
|
||||
p.pln("if (sm != null) {");
|
||||
@ -481,13 +494,23 @@ public class StubGenerator extends sun.rmi.rmic.iiop.Generator {
|
||||
p.pO();
|
||||
|
||||
p.pI();
|
||||
p.pln("private " + currentClass + "(Void ignore) { }");
|
||||
p.plnI("private " + currentClass + "(Void ignore) { }");
|
||||
p.pln();
|
||||
p.pO();
|
||||
|
||||
p.plnI("public " + currentClass + "() { ");
|
||||
p.pln("this(checkPermission());");
|
||||
p.pln("_instantiated = true;");
|
||||
p.pOln("}");
|
||||
p.pln();
|
||||
p.plnI("private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException {");
|
||||
p.plnI("checkPermission();");
|
||||
p.pO();
|
||||
p.pln("s.defaultReadObject();");
|
||||
p.pln("_instantiated = true;");
|
||||
p.pOln("}");
|
||||
p.pln();
|
||||
//p.pO();
|
||||
}
|
||||
|
||||
if (!emitPermissionCheck) {
|
||||
@ -894,6 +917,7 @@ public class StubGenerator extends sun.rmi.rmic.iiop.Generator {
|
||||
String paramNames[] = method.getArgumentNames();
|
||||
Type returnType = method.getReturnType();
|
||||
ValueType[] exceptions = getStubExceptions(method,false);
|
||||
boolean hasIOException = false;
|
||||
|
||||
addNamesInUse(method);
|
||||
addNameInUse("_type_ids");
|
||||
@ -921,6 +945,13 @@ public class StubGenerator extends sun.rmi.rmic.iiop.Generator {
|
||||
p.plnI(" {");
|
||||
|
||||
// Now create the method body...
|
||||
if (emitPermissionCheck) {
|
||||
p.pln("if ((System.getSecurityManager() != null) && (!_instantiated)) {");
|
||||
p.plnI(" throw new java.io.IOError(new java.io.IOException(\"InvalidObject \"));");
|
||||
p.pOln("}");
|
||||
p.pln();
|
||||
}
|
||||
|
||||
|
||||
if (localStubs) {
|
||||
writeLocalStubMethodBody(p,method,theType);
|
||||
|
||||
@ -489,3 +489,5 @@ e9e63d93bbfe2c6c23447e2c1f5cc71c98671cba jdk9-b79
|
||||
184c4328444974edd6b3b490b9d0177ace7e331c jdk9-b84
|
||||
03845376ea9dbf9690b6a9cfb4ed63f8cc0541c0 jdk9-b85
|
||||
1ae4191359d811a51512f17dca80ffe79837a5ff jdk9-b86
|
||||
d7ffd16382fe7071181b967932b47cff6d1312e1 jdk9-b87
|
||||
bc48b669bc6610fac97e16593050c0f559cf6945 jdk9-b88
|
||||
|
||||
@ -77,6 +77,7 @@ $(GENSRC_DIR)/_gensrc_proc_done: $(PROC_SRCS) \
|
||||
$(MKDIR) -p $(@D)
|
||||
$(eval $(call ListPathsSafely,PROC_SRCS,$(@D)/_gensrc_proc_files))
|
||||
$(JAVA_SMALL) $(NEW_JAVAC) \
|
||||
-XDignore.symbol.file \
|
||||
-sourcepath $(SOURCEPATH) \
|
||||
-implicit:none \
|
||||
-proc:only \
|
||||
|
||||
@ -111,7 +111,7 @@ objArrayOop ConstantPool::resolved_references() const {
|
||||
// to map it back for resolving and some unlikely miscellaneous uses.
|
||||
// The objects created by invokedynamic are appended to this list.
|
||||
void ConstantPool::initialize_resolved_references(ClassLoaderData* loader_data,
|
||||
intStack reference_map,
|
||||
const intStack& reference_map,
|
||||
int constant_pool_map_length,
|
||||
TRAPS) {
|
||||
// Initialized the resolved object cache.
|
||||
|
||||
@ -185,7 +185,7 @@ class ConstantPool : public Metadata {
|
||||
|
||||
// Create object cache in the constant pool
|
||||
void initialize_resolved_references(ClassLoaderData* loader_data,
|
||||
intStack reference_map,
|
||||
const intStack& reference_map,
|
||||
int constant_pool_map_length,
|
||||
TRAPS);
|
||||
|
||||
|
||||
@ -329,3 +329,5 @@ f464f9b2fb1178f6a957e5730b4b5252c6149ed9 jdk9-b80
|
||||
91795d86744f3074d1e59b1e75d9c851c098688f jdk9-b84
|
||||
1d9850c1b35c74e8b5c17970ed5d46dc0fc33f06 jdk9-b85
|
||||
88d9b1f6b73e0c46fcb5ccabe1231a30ce758a22 jdk9-b86
|
||||
eb435c878c2cbbfb043d0b205f4d5bd6faffd44a jdk9-b87
|
||||
4700fd67e942714046df1d0514f2ef4ddcac78bb jdk9-b88
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2005, 2015, 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
|
||||
*
|
||||
@ -22,10 +22,10 @@
|
||||
*/
|
||||
package com.sun.org.apache.xalan.internal.lib;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
import com.sun.org.apache.xml.internal.utils.DOMHelper;
|
||||
import com.sun.org.apache.xpath.internal.NodeSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
@ -192,7 +192,7 @@ public class ExsltSets extends ExsltBase
|
||||
NodeSet dist = new NodeSet();
|
||||
dist.setShouldCacheNodes(true);
|
||||
|
||||
Hashtable stringTable = new Hashtable();
|
||||
Map<String, Node> stringTable = new HashMap<>();
|
||||
|
||||
for (int i = 0; i < nl.getLength(); i++)
|
||||
{
|
||||
|
||||
@ -65,27 +65,31 @@ public final class XMLSecurityManager {
|
||||
*/
|
||||
public static enum Limit {
|
||||
|
||||
ENTITY_EXPANSION_LIMIT(XalanConstants.JDK_ENTITY_EXPANSION_LIMIT,
|
||||
ENTITY_EXPANSION_LIMIT("EntityExpansionLimit", XalanConstants.JDK_ENTITY_EXPANSION_LIMIT,
|
||||
XalanConstants.SP_ENTITY_EXPANSION_LIMIT, 0, 64000),
|
||||
MAX_OCCUR_NODE_LIMIT(XalanConstants.JDK_MAX_OCCUR_LIMIT,
|
||||
MAX_OCCUR_NODE_LIMIT("MaxOccurLimit", XalanConstants.JDK_MAX_OCCUR_LIMIT,
|
||||
XalanConstants.SP_MAX_OCCUR_LIMIT, 0, 5000),
|
||||
ELEMENT_ATTRIBUTE_LIMIT(XalanConstants.JDK_ELEMENT_ATTRIBUTE_LIMIT,
|
||||
ELEMENT_ATTRIBUTE_LIMIT("ElementAttributeLimit", XalanConstants.JDK_ELEMENT_ATTRIBUTE_LIMIT,
|
||||
XalanConstants.SP_ELEMENT_ATTRIBUTE_LIMIT, 0, 10000),
|
||||
TOTAL_ENTITY_SIZE_LIMIT(XalanConstants.JDK_TOTAL_ENTITY_SIZE_LIMIT,
|
||||
TOTAL_ENTITY_SIZE_LIMIT("TotalEntitySizeLimit", XalanConstants.JDK_TOTAL_ENTITY_SIZE_LIMIT,
|
||||
XalanConstants.SP_TOTAL_ENTITY_SIZE_LIMIT, 0, 50000000),
|
||||
GENERAL_ENTITY_SIZE_LIMIT(XalanConstants.JDK_GENERAL_ENTITY_SIZE_LIMIT,
|
||||
GENERAL_ENTITY_SIZE_LIMIT("MaxEntitySizeLimit", XalanConstants.JDK_GENERAL_ENTITY_SIZE_LIMIT,
|
||||
XalanConstants.SP_GENERAL_ENTITY_SIZE_LIMIT, 0, 0),
|
||||
PARAMETER_ENTITY_SIZE_LIMIT(XalanConstants.JDK_PARAMETER_ENTITY_SIZE_LIMIT,
|
||||
PARAMETER_ENTITY_SIZE_LIMIT("MaxEntitySizeLimit", XalanConstants.JDK_PARAMETER_ENTITY_SIZE_LIMIT,
|
||||
XalanConstants.SP_PARAMETER_ENTITY_SIZE_LIMIT, 0, 1000000),
|
||||
MAX_ELEMENT_DEPTH_LIMIT(XalanConstants.JDK_MAX_ELEMENT_DEPTH,
|
||||
XalanConstants.SP_MAX_ELEMENT_DEPTH, 0, 0);
|
||||
MAX_ELEMENT_DEPTH_LIMIT("MaxElementDepthLimit", XalanConstants.JDK_MAX_ELEMENT_DEPTH,
|
||||
XalanConstants.SP_MAX_ELEMENT_DEPTH, 0, 0),
|
||||
MAX_NAME_LIMIT("MaxXMLNameLimit", XalanConstants.JDK_XML_NAME_LIMIT,
|
||||
XalanConstants.SP_XML_NAME_LIMIT, 1000, 1000);
|
||||
|
||||
final String key;
|
||||
final String apiProperty;
|
||||
final String systemProperty;
|
||||
final int defaultValue;
|
||||
final int secureValue;
|
||||
|
||||
Limit(String apiProperty, String systemProperty, int value, int secureValue) {
|
||||
Limit(String key, String apiProperty, String systemProperty, int value, int secureValue) {
|
||||
this.key = key;
|
||||
this.apiProperty = apiProperty;
|
||||
this.systemProperty = systemProperty;
|
||||
this.defaultValue = value;
|
||||
@ -100,6 +104,10 @@ public final class XMLSecurityManager {
|
||||
return (propertyName == null) ? false : systemProperty.equals(propertyName);
|
||||
}
|
||||
|
||||
public String key() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String apiProperty() {
|
||||
return apiProperty;
|
||||
}
|
||||
@ -108,7 +116,7 @@ public final class XMLSecurityManager {
|
||||
return systemProperty;
|
||||
}
|
||||
|
||||
int defaultValue() {
|
||||
public int defaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@ -160,7 +168,7 @@ public final class XMLSecurityManager {
|
||||
/**
|
||||
* Index of the special entityCountInfo property
|
||||
*/
|
||||
private int indexEntityCountInfo = 10000;
|
||||
private final int indexEntityCountInfo = 10000;
|
||||
private String printEntityCountInfo = "";
|
||||
|
||||
/**
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, 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
|
||||
*
|
||||
@ -23,14 +23,12 @@
|
||||
|
||||
package com.sun.org.apache.xalan.internal.xsltc;
|
||||
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
|
||||
|
||||
import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
|
||||
import java.util.Map;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
|
||||
|
||||
/**
|
||||
* @author Jacek Ambroziak
|
||||
* @author Santiago Pericas-Geertsen
|
||||
@ -103,5 +101,5 @@ public interface DOM {
|
||||
public int getNSType(int node);
|
||||
public int getDocument();
|
||||
public String getUnparsedEntityURI(String name);
|
||||
public Hashtable getElementsWithIDs();
|
||||
public Map<String, Integer> getElementsWithIDs();
|
||||
}
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, 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
|
||||
*
|
||||
@ -41,6 +41,7 @@ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
|
||||
import com.sun.org.apache.xml.internal.utils.XML11Char;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* @author Jacek Ambroziak
|
||||
@ -122,9 +123,9 @@ final class ApplyTemplates extends Instruction {
|
||||
|
||||
// check if sorting nodes is required
|
||||
final Vector sortObjects = new Vector();
|
||||
final Enumeration children = elements();
|
||||
while (children.hasMoreElements()) {
|
||||
final Object child = children.nextElement();
|
||||
final Iterator<SyntaxTreeNode> children = elements();
|
||||
while (children.hasNext()) {
|
||||
final SyntaxTreeNode child = children.next();
|
||||
if (child instanceof Sort) {
|
||||
sortObjects.addElement(child);
|
||||
}
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, 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
|
||||
*
|
||||
@ -23,9 +23,6 @@
|
||||
|
||||
package com.sun.org.apache.xalan.internal.xsltc.compiler;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Vector;
|
||||
|
||||
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
|
||||
import com.sun.org.apache.bcel.internal.generic.INVOKESPECIAL;
|
||||
import com.sun.org.apache.bcel.internal.generic.InstructionList;
|
||||
@ -37,6 +34,11 @@ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
|
||||
import com.sun.org.apache.xml.internal.utils.XML11Char;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jacek Ambroziak
|
||||
@ -111,10 +113,10 @@ final class AttributeSet extends TopLevelElement {
|
||||
|
||||
// Parse the contents of this node. All child elements must be
|
||||
// <xsl:attribute> elements. Other elements cause an error.
|
||||
final Vector contents = getContents();
|
||||
final List<SyntaxTreeNode> contents = getContents();
|
||||
final int count = contents.size();
|
||||
for (int i=0; i<count; i++) {
|
||||
SyntaxTreeNode child = (SyntaxTreeNode)contents.elementAt(i);
|
||||
SyntaxTreeNode child = (SyntaxTreeNode)contents.get(i);
|
||||
if (child instanceof XslAttribute) {
|
||||
parser.getSymbolTable().setCurrentNode(child);
|
||||
child.parseContents(parser);
|
||||
@ -181,9 +183,9 @@ final class AttributeSet extends TopLevelElement {
|
||||
if (_useSets != null) _useSets.translate(classGen, methodGen);
|
||||
|
||||
// Translate all local attributes
|
||||
final Enumeration attributes = elements();
|
||||
while (attributes.hasMoreElements()) {
|
||||
SyntaxTreeNode element = (SyntaxTreeNode)attributes.nextElement();
|
||||
final Iterator<SyntaxTreeNode> attributes = elements();
|
||||
while (attributes.hasNext()) {
|
||||
SyntaxTreeNode element = (SyntaxTreeNode)attributes.next();
|
||||
if (element instanceof XslAttribute) {
|
||||
final XslAttribute attribute = (XslAttribute)element;
|
||||
attribute.translate(classGen, methodGen);
|
||||
@ -198,10 +200,10 @@ final class AttributeSet extends TopLevelElement {
|
||||
public String toString() {
|
||||
StringBuffer buf = new StringBuffer("attribute-set: ");
|
||||
// Translate all local attributes
|
||||
final Enumeration attributes = elements();
|
||||
while (attributes.hasMoreElements()) {
|
||||
final Iterator<SyntaxTreeNode> attributes = elements();
|
||||
while (attributes.hasNext()) {
|
||||
final XslAttribute attribute =
|
||||
(XslAttribute)attributes.nextElement();
|
||||
(XslAttribute)attributes.next();
|
||||
buf.append(attribute);
|
||||
}
|
||||
return(buf.toString());
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, 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
|
||||
*
|
||||
@ -39,6 +39,8 @@ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Jacek Ambroziak
|
||||
@ -206,12 +208,12 @@ final class AttributeValueTemplate extends AttributeValue {
|
||||
}
|
||||
|
||||
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
|
||||
final Vector contents = getContents();
|
||||
final List<SyntaxTreeNode> contents = getContents();
|
||||
final int n = contents.size();
|
||||
for (int i = 0; i < n; i++) {
|
||||
final Expression exp = (Expression)contents.elementAt(i);
|
||||
final Expression exp = (Expression)contents.get(i);
|
||||
if (!exp.typeCheck(stable).identicalTo(Type.String)) {
|
||||
contents.setElementAt(new CastExpr(exp, Type.String), i);
|
||||
contents.set(i, new CastExpr(exp, Type.String));
|
||||
}
|
||||
}
|
||||
return _type = Type.String;
|
||||
@ -251,9 +253,9 @@ final class AttributeValueTemplate extends AttributeValue {
|
||||
il.append(DUP);
|
||||
il.append(new INVOKESPECIAL(initBuffer));
|
||||
// StringBuffer is on the stack
|
||||
final Enumeration elements = elements();
|
||||
while (elements.hasMoreElements()) {
|
||||
final Expression exp = (Expression)elements.nextElement();
|
||||
final Iterator<SyntaxTreeNode> elements = elements();
|
||||
while (elements.hasNext()) {
|
||||
final Expression exp = (Expression)elements.next();
|
||||
exp.translate(classGen, methodGen);
|
||||
il.append(append);
|
||||
}
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
* 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 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
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@ -51,7 +51,7 @@ final class CastExpr extends Expression {
|
||||
/**
|
||||
* Legal conversions between internal types.
|
||||
*/
|
||||
static private MultiHashtable InternalTypeMap = new MultiHashtable();
|
||||
private static final MultiHashtable<Type, Type> InternalTypeMap = new MultiHashtable<>();
|
||||
|
||||
static {
|
||||
// Possible type conversions between internal types
|
||||
@ -118,6 +118,8 @@ final class CastExpr extends Expression {
|
||||
InternalTypeMap.put(Type.Object, Type.String);
|
||||
|
||||
InternalTypeMap.put(Type.Void, Type.String);
|
||||
|
||||
InternalTypeMap.makeUnmodifiable();
|
||||
}
|
||||
|
||||
private boolean _typeTest = false;
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, 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
|
||||
*
|
||||
@ -37,6 +37,7 @@ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* @author Jacek Ambroziak
|
||||
@ -62,15 +63,15 @@ final class Choose extends Instruction {
|
||||
public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
|
||||
final Vector whenElements = new Vector();
|
||||
Otherwise otherwise = null;
|
||||
Enumeration elements = elements();
|
||||
Iterator<SyntaxTreeNode> elements = elements();
|
||||
|
||||
// These two are for reporting errors only
|
||||
ErrorMsg error = null;
|
||||
final int line = getLineNumber();
|
||||
|
||||
// Traverse all child nodes - must be either When or Otherwise
|
||||
while (elements.hasMoreElements()) {
|
||||
Object element = elements.nextElement();
|
||||
while (elements.hasNext()) {
|
||||
SyntaxTreeNode element = elements.next();
|
||||
// Add a When child element
|
||||
if (element instanceof When) {
|
||||
whenElements.addElement(element);
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, 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
|
||||
*
|
||||
@ -42,6 +42,7 @@ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ResultTreeType;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* @author Jacek Ambroziak
|
||||
@ -97,9 +98,9 @@ final class ForEach extends Instruction {
|
||||
|
||||
// Collect sort objects associated with this instruction
|
||||
final Vector sortObjects = new Vector();
|
||||
Enumeration children = elements();
|
||||
while (children.hasMoreElements()) {
|
||||
final Object child = children.nextElement();
|
||||
Iterator<SyntaxTreeNode> children = elements();
|
||||
while (children.hasNext()) {
|
||||
final Object child = children.next();
|
||||
if (child instanceof Sort) {
|
||||
sortObjects.addElement(child);
|
||||
}
|
||||
@ -187,7 +188,7 @@ final class ForEach extends Instruction {
|
||||
MethodGenerator methodGen) {
|
||||
final int n = elementCount();
|
||||
for (int i = 0; i < n; i++) {
|
||||
final Object child = getContents().elementAt(i);
|
||||
final Object child = getContents().get(i);
|
||||
if (child instanceof Variable) {
|
||||
Variable var = (Variable)child;
|
||||
var.initialize(classGen, methodGen);
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
* 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 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
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@ -23,13 +23,6 @@
|
||||
|
||||
package com.sun.org.apache.xalan.internal.xsltc.compiler;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
|
||||
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
|
||||
import com.sun.org.apache.bcel.internal.generic.IFEQ;
|
||||
import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE;
|
||||
@ -43,6 +36,7 @@ import com.sun.org.apache.bcel.internal.generic.LocalVariableGen;
|
||||
import com.sun.org.apache.bcel.internal.generic.NEW;
|
||||
import com.sun.org.apache.bcel.internal.generic.PUSH;
|
||||
import com.sun.org.apache.xalan.internal.utils.FeatureManager;
|
||||
import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.BooleanType;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
|
||||
@ -54,8 +48,15 @@ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ObjectType;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ReferenceType;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
|
||||
import com.sun.org.apache.xalan.internal.utils.ObjectFactory;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* @author Jacek Ambroziak
|
||||
@ -138,23 +139,23 @@ class FunctionCall extends Expression {
|
||||
private boolean _isStatic = false;
|
||||
|
||||
// Legal conversions between internal and Java types.
|
||||
private static final MultiHashtable _internal2Java = new MultiHashtable();
|
||||
private static final MultiHashtable<Type, JavaType> _internal2Java = new MultiHashtable<>();
|
||||
|
||||
// Legal conversions between Java and internal types.
|
||||
private static final Hashtable _java2Internal = new Hashtable();
|
||||
private static final Map<Class<?>, Type> JAVA2INTERNAL;
|
||||
|
||||
// The mappings between EXSLT extension namespaces and implementation classes
|
||||
private static final Hashtable _extensionNamespaceTable = new Hashtable();
|
||||
private static final Map<String, String> EXTENSIONNAMESPACE;
|
||||
|
||||
// Extension functions that are implemented in BasisLibrary
|
||||
private static final Hashtable _extensionFunctionTable = new Hashtable();
|
||||
private static final Map<String, String> EXTENSIONFUNCTION;
|
||||
/**
|
||||
* inner class to used in internal2Java mappings, contains
|
||||
* the Java type and the distance between the internal type and
|
||||
* the Java type.
|
||||
*/
|
||||
static class JavaType {
|
||||
public Class type;
|
||||
public Class<?> type;
|
||||
public int distance;
|
||||
|
||||
public JavaType(Class type, int distance){
|
||||
@ -168,8 +169,15 @@ class FunctionCall extends Expression {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object query){
|
||||
return query != null && query.equals(type);
|
||||
public boolean equals(Object query) {
|
||||
if (query == null) {
|
||||
return false;
|
||||
}
|
||||
if (query.getClass().isAssignableFrom(JavaType.class)) {
|
||||
return ((JavaType)query).type.equals(type);
|
||||
} else {
|
||||
return query.equals(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,99 +188,112 @@ class FunctionCall extends Expression {
|
||||
* These two tables are used when calling external (Java) functions.
|
||||
*/
|
||||
static {
|
||||
final Class<?> nodeClass, nodeListClass;
|
||||
try {
|
||||
final Class nodeClass = Class.forName("org.w3c.dom.Node");
|
||||
final Class nodeListClass = Class.forName("org.w3c.dom.NodeList");
|
||||
|
||||
// -- Internal to Java --------------------------------------------
|
||||
|
||||
// Type.Boolean -> { boolean(0), Boolean(1), Object(2) }
|
||||
_internal2Java.put(Type.Boolean, new JavaType(Boolean.TYPE, 0));
|
||||
_internal2Java.put(Type.Boolean, new JavaType(Boolean.class, 1));
|
||||
_internal2Java.put(Type.Boolean, new JavaType(Object.class, 2));
|
||||
|
||||
// Type.Real -> { double(0), Double(1), float(2), long(3), int(4),
|
||||
// short(5), byte(6), char(7), Object(8) }
|
||||
_internal2Java.put(Type.Real, new JavaType(Double.TYPE, 0));
|
||||
_internal2Java.put(Type.Real, new JavaType(Double.class, 1));
|
||||
_internal2Java.put(Type.Real, new JavaType(Float.TYPE, 2));
|
||||
_internal2Java.put(Type.Real, new JavaType(Long.TYPE, 3));
|
||||
_internal2Java.put(Type.Real, new JavaType(Integer.TYPE, 4));
|
||||
_internal2Java.put(Type.Real, new JavaType(Short.TYPE, 5));
|
||||
_internal2Java.put(Type.Real, new JavaType(Byte.TYPE, 6));
|
||||
_internal2Java.put(Type.Real, new JavaType(Character.TYPE, 7));
|
||||
_internal2Java.put(Type.Real, new JavaType(Object.class, 8));
|
||||
|
||||
// Type.Int must be the same as Type.Real
|
||||
_internal2Java.put(Type.Int, new JavaType(Double.TYPE, 0));
|
||||
_internal2Java.put(Type.Int, new JavaType(Double.class, 1));
|
||||
_internal2Java.put(Type.Int, new JavaType(Float.TYPE, 2));
|
||||
_internal2Java.put(Type.Int, new JavaType(Long.TYPE, 3));
|
||||
_internal2Java.put(Type.Int, new JavaType(Integer.TYPE, 4));
|
||||
_internal2Java.put(Type.Int, new JavaType(Short.TYPE, 5));
|
||||
_internal2Java.put(Type.Int, new JavaType(Byte.TYPE, 6));
|
||||
_internal2Java.put(Type.Int, new JavaType(Character.TYPE, 7));
|
||||
_internal2Java.put(Type.Int, new JavaType(Object.class, 8));
|
||||
|
||||
// Type.String -> { String(0), Object(1) }
|
||||
_internal2Java.put(Type.String, new JavaType(String.class, 0));
|
||||
_internal2Java.put(Type.String, new JavaType(Object.class, 1));
|
||||
|
||||
// Type.NodeSet -> { NodeList(0), Node(1), Object(2), String(3) }
|
||||
_internal2Java.put(Type.NodeSet, new JavaType(nodeListClass, 0));
|
||||
_internal2Java.put(Type.NodeSet, new JavaType(nodeClass, 1));
|
||||
_internal2Java.put(Type.NodeSet, new JavaType(Object.class, 2));
|
||||
_internal2Java.put(Type.NodeSet, new JavaType(String.class, 3));
|
||||
|
||||
// Type.Node -> { Node(0), NodeList(1), Object(2), String(3) }
|
||||
_internal2Java.put(Type.Node, new JavaType(nodeListClass, 0));
|
||||
_internal2Java.put(Type.Node, new JavaType(nodeClass, 1));
|
||||
_internal2Java.put(Type.Node, new JavaType(Object.class, 2));
|
||||
_internal2Java.put(Type.Node, new JavaType(String.class, 3));
|
||||
|
||||
// Type.ResultTree -> { NodeList(0), Node(1), Object(2), String(3) }
|
||||
_internal2Java.put(Type.ResultTree, new JavaType(nodeListClass, 0));
|
||||
_internal2Java.put(Type.ResultTree, new JavaType(nodeClass, 1));
|
||||
_internal2Java.put(Type.ResultTree, new JavaType(Object.class, 2));
|
||||
_internal2Java.put(Type.ResultTree, new JavaType(String.class, 3));
|
||||
|
||||
_internal2Java.put(Type.Reference, new JavaType(Object.class, 0));
|
||||
|
||||
// Possible conversions between Java and internal types
|
||||
_java2Internal.put(Boolean.TYPE, Type.Boolean);
|
||||
_java2Internal.put(Void.TYPE, Type.Void);
|
||||
_java2Internal.put(Character.TYPE, Type.Real);
|
||||
_java2Internal.put(Byte.TYPE, Type.Real);
|
||||
_java2Internal.put(Short.TYPE, Type.Real);
|
||||
_java2Internal.put(Integer.TYPE, Type.Real);
|
||||
_java2Internal.put(Long.TYPE, Type.Real);
|
||||
_java2Internal.put(Float.TYPE, Type.Real);
|
||||
_java2Internal.put(Double.TYPE, Type.Real);
|
||||
|
||||
_java2Internal.put(String.class, Type.String);
|
||||
|
||||
_java2Internal.put(Object.class, Type.Reference);
|
||||
|
||||
// Conversions from org.w3c.dom.Node/NodeList to internal NodeSet
|
||||
_java2Internal.put(nodeListClass, Type.NodeSet);
|
||||
_java2Internal.put(nodeClass, Type.NodeSet);
|
||||
|
||||
// Initialize the extension namespace table
|
||||
_extensionNamespaceTable.put(EXT_XALAN, "com.sun.org.apache.xalan.internal.lib.Extensions");
|
||||
_extensionNamespaceTable.put(EXSLT_COMMON, "com.sun.org.apache.xalan.internal.lib.ExsltCommon");
|
||||
_extensionNamespaceTable.put(EXSLT_MATH, "com.sun.org.apache.xalan.internal.lib.ExsltMath");
|
||||
_extensionNamespaceTable.put(EXSLT_SETS, "com.sun.org.apache.xalan.internal.lib.ExsltSets");
|
||||
_extensionNamespaceTable.put(EXSLT_DATETIME, "com.sun.org.apache.xalan.internal.lib.ExsltDatetime");
|
||||
_extensionNamespaceTable.put(EXSLT_STRINGS, "com.sun.org.apache.xalan.internal.lib.ExsltStrings");
|
||||
|
||||
// Initialize the extension function table
|
||||
_extensionFunctionTable.put(EXSLT_COMMON + ":nodeSet", "nodeset");
|
||||
_extensionFunctionTable.put(EXSLT_COMMON + ":objectType", "objectType");
|
||||
_extensionFunctionTable.put(EXT_XALAN + ":nodeset", "nodeset");
|
||||
nodeClass = Class.forName("org.w3c.dom.Node");
|
||||
nodeListClass = Class.forName("org.w3c.dom.NodeList");
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
System.err.println(e);
|
||||
ErrorMsg err = new ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR,"org.w3c.dom.Node or NodeList");
|
||||
throw new Error(err.toString());
|
||||
}
|
||||
|
||||
// -- Internal to Java --------------------------------------------
|
||||
|
||||
// Type.Boolean -> { boolean(0), Boolean(1), Object(2) }
|
||||
_internal2Java.put(Type.Boolean, new JavaType(Boolean.TYPE, 0));
|
||||
_internal2Java.put(Type.Boolean, new JavaType(Boolean.class, 1));
|
||||
_internal2Java.put(Type.Boolean, new JavaType(Object.class, 2));
|
||||
|
||||
// Type.Real -> { double(0), Double(1), float(2), long(3), int(4),
|
||||
// short(5), byte(6), char(7), Object(8) }
|
||||
_internal2Java.put(Type.Real, new JavaType(Double.TYPE, 0));
|
||||
_internal2Java.put(Type.Real, new JavaType(Double.class, 1));
|
||||
_internal2Java.put(Type.Real, new JavaType(Float.TYPE, 2));
|
||||
_internal2Java.put(Type.Real, new JavaType(Long.TYPE, 3));
|
||||
_internal2Java.put(Type.Real, new JavaType(Integer.TYPE, 4));
|
||||
_internal2Java.put(Type.Real, new JavaType(Short.TYPE, 5));
|
||||
_internal2Java.put(Type.Real, new JavaType(Byte.TYPE, 6));
|
||||
_internal2Java.put(Type.Real, new JavaType(Character.TYPE, 7));
|
||||
_internal2Java.put(Type.Real, new JavaType(Object.class, 8));
|
||||
|
||||
// Type.Int must be the same as Type.Real
|
||||
_internal2Java.put(Type.Int, new JavaType(Double.TYPE, 0));
|
||||
_internal2Java.put(Type.Int, new JavaType(Double.class, 1));
|
||||
_internal2Java.put(Type.Int, new JavaType(Float.TYPE, 2));
|
||||
_internal2Java.put(Type.Int, new JavaType(Long.TYPE, 3));
|
||||
_internal2Java.put(Type.Int, new JavaType(Integer.TYPE, 4));
|
||||
_internal2Java.put(Type.Int, new JavaType(Short.TYPE, 5));
|
||||
_internal2Java.put(Type.Int, new JavaType(Byte.TYPE, 6));
|
||||
_internal2Java.put(Type.Int, new JavaType(Character.TYPE, 7));
|
||||
_internal2Java.put(Type.Int, new JavaType(Object.class, 8));
|
||||
|
||||
// Type.String -> { String(0), Object(1) }
|
||||
_internal2Java.put(Type.String, new JavaType(String.class, 0));
|
||||
_internal2Java.put(Type.String, new JavaType(Object.class, 1));
|
||||
|
||||
// Type.NodeSet -> { NodeList(0), Node(1), Object(2), String(3) }
|
||||
_internal2Java.put(Type.NodeSet, new JavaType(nodeListClass, 0));
|
||||
_internal2Java.put(Type.NodeSet, new JavaType(nodeClass, 1));
|
||||
_internal2Java.put(Type.NodeSet, new JavaType(Object.class, 2));
|
||||
_internal2Java.put(Type.NodeSet, new JavaType(String.class, 3));
|
||||
|
||||
// Type.Node -> { Node(0), NodeList(1), Object(2), String(3) }
|
||||
_internal2Java.put(Type.Node, new JavaType(nodeListClass, 0));
|
||||
_internal2Java.put(Type.Node, new JavaType(nodeClass, 1));
|
||||
_internal2Java.put(Type.Node, new JavaType(Object.class, 2));
|
||||
_internal2Java.put(Type.Node, new JavaType(String.class, 3));
|
||||
|
||||
// Type.ResultTree -> { NodeList(0), Node(1), Object(2), String(3) }
|
||||
_internal2Java.put(Type.ResultTree, new JavaType(nodeListClass, 0));
|
||||
_internal2Java.put(Type.ResultTree, new JavaType(nodeClass, 1));
|
||||
_internal2Java.put(Type.ResultTree, new JavaType(Object.class, 2));
|
||||
_internal2Java.put(Type.ResultTree, new JavaType(String.class, 3));
|
||||
|
||||
_internal2Java.put(Type.Reference, new JavaType(Object.class, 0));
|
||||
|
||||
_internal2Java.makeUnmodifiable();
|
||||
|
||||
Map<Class<?>, Type> java2Internal = new HashMap<>();
|
||||
Map<String, String> extensionNamespaceTable = new HashMap<>();
|
||||
Map<String, String> extensionFunctionTable = new HashMap<>();
|
||||
|
||||
// Possible conversions between Java and internal types
|
||||
java2Internal.put(Boolean.TYPE, Type.Boolean);
|
||||
java2Internal.put(Void.TYPE, Type.Void);
|
||||
java2Internal.put(Character.TYPE, Type.Real);
|
||||
java2Internal.put(Byte.TYPE, Type.Real);
|
||||
java2Internal.put(Short.TYPE, Type.Real);
|
||||
java2Internal.put(Integer.TYPE, Type.Real);
|
||||
java2Internal.put(Long.TYPE, Type.Real);
|
||||
java2Internal.put(Float.TYPE, Type.Real);
|
||||
java2Internal.put(Double.TYPE, Type.Real);
|
||||
|
||||
java2Internal.put(String.class, Type.String);
|
||||
|
||||
java2Internal.put(Object.class, Type.Reference);
|
||||
|
||||
// Conversions from org.w3c.dom.Node/NodeList to internal NodeSet
|
||||
java2Internal.put(nodeListClass, Type.NodeSet);
|
||||
java2Internal.put(nodeClass, Type.NodeSet);
|
||||
|
||||
// Initialize the extension namespace table
|
||||
extensionNamespaceTable.put(EXT_XALAN, "com.sun.org.apache.xalan.internal.lib.Extensions");
|
||||
extensionNamespaceTable.put(EXSLT_COMMON, "com.sun.org.apache.xalan.internal.lib.ExsltCommon");
|
||||
extensionNamespaceTable.put(EXSLT_MATH, "com.sun.org.apache.xalan.internal.lib.ExsltMath");
|
||||
extensionNamespaceTable.put(EXSLT_SETS, "com.sun.org.apache.xalan.internal.lib.ExsltSets");
|
||||
extensionNamespaceTable.put(EXSLT_DATETIME, "com.sun.org.apache.xalan.internal.lib.ExsltDatetime");
|
||||
extensionNamespaceTable.put(EXSLT_STRINGS, "com.sun.org.apache.xalan.internal.lib.ExsltStrings");
|
||||
|
||||
// Initialize the extension function table
|
||||
extensionFunctionTable.put(EXSLT_COMMON + ":nodeSet", "nodeset");
|
||||
extensionFunctionTable.put(EXSLT_COMMON + ":objectType", "objectType");
|
||||
extensionFunctionTable.put(EXT_XALAN + ":nodeset", "nodeset");
|
||||
|
||||
JAVA2INTERNAL = Collections.unmodifiableMap(java2Internal);
|
||||
EXTENSIONNAMESPACE = Collections.unmodifiableMap(extensionNamespaceTable);
|
||||
EXTENSIONFUNCTION = Collections.unmodifiableMap(extensionFunctionTable);
|
||||
|
||||
}
|
||||
|
||||
public FunctionCall(QName fname, Vector arguments) {
|
||||
@ -304,7 +325,7 @@ class FunctionCall extends Expression {
|
||||
|
||||
public String getClassNameFromUri(String uri)
|
||||
{
|
||||
String className = (String)_extensionNamespaceTable.get(uri);
|
||||
String className = EXTENSIONNAMESPACE.get(uri);
|
||||
|
||||
if (className != null)
|
||||
return className;
|
||||
@ -384,7 +405,7 @@ class FunctionCall extends Expression {
|
||||
local = replaceDash(local);
|
||||
}
|
||||
|
||||
String extFunction = (String)_extensionFunctionTable.get(namespace + ":" + local);
|
||||
String extFunction = EXTENSIONFUNCTION.get(namespace + ":" + local);
|
||||
if (extFunction != null) {
|
||||
_fname = new QName(null, null, extFunction);
|
||||
return typeCheckStandard(stable);
|
||||
@ -464,15 +485,15 @@ class FunctionCall extends Expression {
|
||||
(Constructor)constructors.elementAt(i);
|
||||
final Class[] paramTypes = constructor.getParameterTypes();
|
||||
|
||||
Class extType = null;
|
||||
Class<?> extType;
|
||||
int currConstrDistance = 0;
|
||||
for (j = 0; j < nArgs; j++) {
|
||||
// Convert from internal (translet) type to external (Java) type
|
||||
extType = paramTypes[j];
|
||||
final Type intType = (Type)argsType.elementAt(j);
|
||||
Object match = _internal2Java.maps(intType, extType);
|
||||
JavaType match = _internal2Java.maps(intType, new JavaType(extType, 0));
|
||||
if (match != null) {
|
||||
currConstrDistance += ((JavaType)match).distance;
|
||||
currConstrDistance += match.distance;
|
||||
}
|
||||
else if (intType instanceof ObjectType) {
|
||||
ObjectType objectType = (ObjectType)intType;
|
||||
@ -597,9 +618,9 @@ class FunctionCall extends Expression {
|
||||
// Convert from internal (translet) type to external (Java) type
|
||||
extType = paramTypes[j];
|
||||
final Type intType = (Type)argsType.elementAt(j);
|
||||
Object match = _internal2Java.maps(intType, extType);
|
||||
JavaType match = _internal2Java.maps(intType, new JavaType(extType, 0));
|
||||
if (match != null) {
|
||||
currMethodDistance += ((JavaType)match).distance;
|
||||
currMethodDistance += match.distance;
|
||||
}
|
||||
else {
|
||||
// no mapping available
|
||||
@ -631,7 +652,7 @@ class FunctionCall extends Expression {
|
||||
// Check if the return type can be converted
|
||||
extType = method.getReturnType();
|
||||
|
||||
_type = (Type) _java2Internal.get(extType);
|
||||
_type = JAVA2INTERNAL.get(extType);
|
||||
if (_type == null) {
|
||||
_type = Type.newObjectType(extType);
|
||||
}
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2007, 2015, 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
|
||||
*
|
||||
@ -31,10 +31,7 @@ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
|
||||
import com.sun.org.apache.xml.internal.utils.SystemIDResolver;
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import javax.xml.XMLConstants;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.XMLReader;
|
||||
@ -133,10 +130,10 @@ final class Import extends TopLevelElement {
|
||||
parser.setCurrentStylesheet(_imported);
|
||||
_imported.parseContents(parser);
|
||||
|
||||
final Enumeration elements = _imported.elements();
|
||||
final Iterator<SyntaxTreeNode> elements = _imported.elements();
|
||||
final Stylesheet topStylesheet = parser.getTopLevelStylesheet();
|
||||
while (elements.hasMoreElements()) {
|
||||
final Object element = elements.nextElement();
|
||||
while (elements.hasNext()) {
|
||||
final Object element = elements.next();
|
||||
if (element instanceof TopLevelElement) {
|
||||
if (element instanceof Variable) {
|
||||
topStylesheet.addVariable((Variable) element);
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2007, 2015, 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
|
||||
*
|
||||
@ -31,11 +31,7 @@ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
|
||||
import com.sun.org.apache.xml.internal.utils.SystemIDResolver;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import javax.xml.XMLConstants;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.XMLReader;
|
||||
@ -133,10 +129,10 @@ final class Include extends TopLevelElement {
|
||||
parser.setCurrentStylesheet(_included);
|
||||
_included.parseContents(parser);
|
||||
|
||||
final Enumeration elements = _included.elements();
|
||||
final Iterator<SyntaxTreeNode> elements = _included.elements();
|
||||
final Stylesheet topStylesheet = parser.getTopLevelStylesheet();
|
||||
while (elements.hasMoreElements()) {
|
||||
final Object element = elements.nextElement();
|
||||
while (elements.hasNext()) {
|
||||
final Object element = elements.next();
|
||||
if (element instanceof TopLevelElement) {
|
||||
if (element instanceof Variable) {
|
||||
topStylesheet.addVariable((Variable) element);
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
* 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 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
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@ -226,7 +226,7 @@ final class Key extends TopLevelElement {
|
||||
// AbstractTranslet.buildKeyIndex(name,node_id,value) => void
|
||||
final int key = cpg.addMethodref(TRANSLET_CLASS,
|
||||
"buildKeyIndex",
|
||||
"("+STRING_SIG+"I"+OBJECT_SIG+")V");
|
||||
"("+STRING_SIG+"I"+STRING_SIG+")V");
|
||||
|
||||
// AbstractTranslet.SetKeyIndexDom(name, Dom) => void
|
||||
final int keyDom = cpg.addMethodref(TRANSLET_CLASS,
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
* 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 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
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@ -23,10 +23,6 @@
|
||||
|
||||
package com.sun.org.apache.xalan.internal.xsltc.compiler;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
|
||||
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
|
||||
import com.sun.org.apache.bcel.internal.generic.InstructionList;
|
||||
import com.sun.org.apache.bcel.internal.generic.PUSH;
|
||||
@ -36,9 +32,13 @@ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
|
||||
|
||||
import com.sun.org.apache.xml.internal.serializer.ElemDesc;
|
||||
import com.sun.org.apache.xml.internal.serializer.ToHTMLStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Jacek Ambroziak
|
||||
@ -49,8 +49,8 @@ final class LiteralElement extends Instruction {
|
||||
|
||||
private String _name;
|
||||
private LiteralElement _literalElemParent = null;
|
||||
private Vector _attributeElements = null;
|
||||
private Hashtable _accessedPrefixes = null;
|
||||
private List<SyntaxTreeNode> _attributeElements = null;
|
||||
private Map<String, String> _accessedPrefixes = null;
|
||||
|
||||
// True if all attributes of this LRE are unique, i.e. they all have
|
||||
// different names. This flag is set to false if some attribute
|
||||
@ -85,14 +85,13 @@ final class LiteralElement extends Instruction {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return _accessedPrefixes != null ?
|
||||
(String) _accessedPrefixes.get(prefix) : null;
|
||||
return _accessedPrefixes != null ? _accessedPrefixes.get(prefix) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method used to keep track of what namespaces that are references by
|
||||
* this literal element and its attributes. The output must contain a
|
||||
* definition for each namespace, so we stuff them in a hashtable.
|
||||
* definition for each namespace, so we stuff them in a map.
|
||||
*/
|
||||
public void registerNamespace(String prefix, String uri,
|
||||
SymbolTable stable, boolean declared) {
|
||||
@ -107,12 +106,12 @@ final class LiteralElement extends Instruction {
|
||||
|
||||
// Check if we have any declared namesaces
|
||||
if (_accessedPrefixes == null) {
|
||||
_accessedPrefixes = new Hashtable();
|
||||
_accessedPrefixes = new HashMap<>();
|
||||
}
|
||||
else {
|
||||
if (!declared) {
|
||||
// Check if this node has a declaration for this namespace
|
||||
final String old = (String)_accessedPrefixes.get(prefix);
|
||||
final String old = _accessedPrefixes.get(prefix);
|
||||
if (old != null) {
|
||||
if (old.equals(uri))
|
||||
return;
|
||||
@ -169,7 +168,7 @@ final class LiteralElement extends Instruction {
|
||||
*/
|
||||
public void addAttribute(SyntaxTreeNode attribute) {
|
||||
if (_attributeElements == null) {
|
||||
_attributeElements = new Vector(2);
|
||||
_attributeElements = new ArrayList<>(2);
|
||||
}
|
||||
_attributeElements.add(attribute);
|
||||
}
|
||||
@ -179,9 +178,9 @@ final class LiteralElement extends Instruction {
|
||||
*/
|
||||
public void setFirstAttribute(SyntaxTreeNode attribute) {
|
||||
if (_attributeElements == null) {
|
||||
_attributeElements = new Vector(2);
|
||||
_attributeElements = new ArrayList<>(2);
|
||||
}
|
||||
_attributeElements.insertElementAt(attribute,0);
|
||||
_attributeElements.add(0, attribute);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -191,10 +190,7 @@ final class LiteralElement extends Instruction {
|
||||
public Type typeCheck(SymbolTable stable) throws TypeCheckError {
|
||||
// Type-check all attributes
|
||||
if (_attributeElements != null) {
|
||||
final int count = _attributeElements.size();
|
||||
for (int i = 0; i < count; i++) {
|
||||
SyntaxTreeNode node =
|
||||
(SyntaxTreeNode)_attributeElements.elementAt(i);
|
||||
for (SyntaxTreeNode node : _attributeElements) {
|
||||
node.typeCheck(stable);
|
||||
}
|
||||
}
|
||||
@ -207,23 +203,19 @@ final class LiteralElement extends Instruction {
|
||||
* and assembles a list of all prefixes that (for the given node) maps
|
||||
* to _ANY_ namespace URI. Used by literal result elements to determine
|
||||
*/
|
||||
public Enumeration getNamespaceScope(SyntaxTreeNode node) {
|
||||
Hashtable all = new Hashtable();
|
||||
public Set<Map.Entry<String, String>> getNamespaceScope(SyntaxTreeNode node) {
|
||||
Map<String, String> all = new HashMap<>();
|
||||
|
||||
while (node != null) {
|
||||
Hashtable mapping = node.getPrefixMapping();
|
||||
Map<String, String> mapping = node.getPrefixMapping();
|
||||
if (mapping != null) {
|
||||
Enumeration prefixes = mapping.keys();
|
||||
while (prefixes.hasMoreElements()) {
|
||||
String prefix = (String)prefixes.nextElement();
|
||||
if (!all.containsKey(prefix)) {
|
||||
all.put(prefix, mapping.get(prefix));
|
||||
}
|
||||
}
|
||||
mapping.entrySet().stream().forEach((entry) -> {
|
||||
all.putIfAbsent(entry.getKey(), entry.getValue());
|
||||
});
|
||||
}
|
||||
node = node.getParent();
|
||||
}
|
||||
return(all.keys());
|
||||
return all.entrySet();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -288,9 +280,9 @@ final class LiteralElement extends Instruction {
|
||||
|
||||
// Register all namespaces that are in scope, except for those that
|
||||
// are listed in the xsl:stylesheet element's *-prefixes attributes
|
||||
final Enumeration include = getNamespaceScope(this);
|
||||
while (include.hasMoreElements()) {
|
||||
final String prefix = (String)include.nextElement();
|
||||
Set<Map.Entry<String, String>> include = getNamespaceScope(this);
|
||||
for (Map.Entry<String, String> entry : include) {
|
||||
final String prefix = entry.getKey();
|
||||
if (!prefix.equals("xml")) {
|
||||
final String uri = lookupNamespace(prefix);
|
||||
if (uri != null && !stable.isExcludedNamespace(uri)) {
|
||||
@ -356,11 +348,10 @@ final class LiteralElement extends Instruction {
|
||||
// Compile code to emit namespace attributes
|
||||
if (_accessedPrefixes != null) {
|
||||
boolean declaresDefaultNS = false;
|
||||
Enumeration e = _accessedPrefixes.keys();
|
||||
|
||||
while (e.hasMoreElements()) {
|
||||
final String prefix = (String)e.nextElement();
|
||||
final String uri = (String)_accessedPrefixes.get(prefix);
|
||||
for (Map.Entry<String, String> entry : _accessedPrefixes.entrySet()) {
|
||||
final String prefix = entry.getKey();
|
||||
final String uri = entry.getValue();
|
||||
|
||||
if (uri != Constants.EMPTYSTRING ||
|
||||
prefix != Constants.EMPTYSTRING)
|
||||
@ -391,10 +382,7 @@ final class LiteralElement extends Instruction {
|
||||
|
||||
// Output all attributes
|
||||
if (_attributeElements != null) {
|
||||
final int count = _attributeElements.size();
|
||||
for (int i = 0; i < count; i++) {
|
||||
SyntaxTreeNode node =
|
||||
(SyntaxTreeNode)_attributeElements.elementAt(i);
|
||||
for (SyntaxTreeNode node : _attributeElements) {
|
||||
if (!(node instanceof XslAttribute)) {
|
||||
node.translate(classGen, methodGen);
|
||||
}
|
||||
@ -445,18 +433,18 @@ final class LiteralElement extends Instruction {
|
||||
|
||||
if (_attributeElements != null) {
|
||||
int numAttrs = _attributeElements.size();
|
||||
Hashtable attrsTable = null;
|
||||
Map<String, SyntaxTreeNode> attrsTable = null;
|
||||
for (int i = 0; i < numAttrs; i++) {
|
||||
SyntaxTreeNode node = (SyntaxTreeNode)_attributeElements.elementAt(i);
|
||||
SyntaxTreeNode node = _attributeElements.get(i);
|
||||
|
||||
if (node instanceof UseAttributeSets) {
|
||||
return false;
|
||||
}
|
||||
else if (node instanceof XslAttribute) {
|
||||
if (attrsTable == null) {
|
||||
attrsTable = new Hashtable();
|
||||
attrsTable = new HashMap<>();
|
||||
for (int k = 0; k < i; k++) {
|
||||
SyntaxTreeNode n = (SyntaxTreeNode)_attributeElements.elementAt(k);
|
||||
SyntaxTreeNode n = _attributeElements.get(k);
|
||||
if (n instanceof LiteralAttribute) {
|
||||
LiteralAttribute literalAttr = (LiteralAttribute)n;
|
||||
attrsTable.put(literalAttr.getName(), literalAttr);
|
||||
@ -491,10 +479,8 @@ final class LiteralElement extends Instruction {
|
||||
* <xsl:attribute> children of the current node are not included in the check.
|
||||
*/
|
||||
private boolean canProduceAttributeNodes(SyntaxTreeNode node, boolean ignoreXslAttribute) {
|
||||
Vector contents = node.getContents();
|
||||
int size = contents.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
SyntaxTreeNode child = (SyntaxTreeNode)contents.elementAt(i);
|
||||
List<SyntaxTreeNode> contents = node.getContents();
|
||||
for (SyntaxTreeNode child : contents) {
|
||||
if (child instanceof Text) {
|
||||
Text text = (Text)child;
|
||||
if (text.isIgnore())
|
||||
@ -532,10 +518,8 @@ final class LiteralElement extends Instruction {
|
||||
return true;
|
||||
}
|
||||
else if (child instanceof Choose) {
|
||||
Vector chooseContents = child.getContents();
|
||||
int num = chooseContents.size();
|
||||
for (int k = 0; k < num; k++) {
|
||||
SyntaxTreeNode chooseChild = (SyntaxTreeNode)chooseContents.elementAt(k);
|
||||
List<SyntaxTreeNode> chooseContents = child.getContents();
|
||||
for (SyntaxTreeNode chooseChild : chooseContents) {
|
||||
if (chooseChild instanceof When || chooseChild instanceof Otherwise) {
|
||||
if (canProduceAttributeNodes(chooseChild, false))
|
||||
return true;
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, 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
|
||||
*
|
||||
@ -23,12 +23,6 @@
|
||||
|
||||
package com.sun.org.apache.xalan.internal.xsltc.compiler;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import com.sun.org.apache.bcel.internal.generic.Instruction;
|
||||
import com.sun.org.apache.bcel.internal.generic.BranchHandle;
|
||||
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
|
||||
import com.sun.org.apache.bcel.internal.generic.DUP;
|
||||
@ -38,6 +32,7 @@ import com.sun.org.apache.bcel.internal.generic.ILOAD;
|
||||
import com.sun.org.apache.bcel.internal.generic.INVOKEINTERFACE;
|
||||
import com.sun.org.apache.bcel.internal.generic.INVOKEVIRTUAL;
|
||||
import com.sun.org.apache.bcel.internal.generic.ISTORE;
|
||||
import com.sun.org.apache.bcel.internal.generic.Instruction;
|
||||
import com.sun.org.apache.bcel.internal.generic.InstructionHandle;
|
||||
import com.sun.org.apache.bcel.internal.generic.InstructionList;
|
||||
import com.sun.org.apache.bcel.internal.generic.LocalVariableGen;
|
||||
@ -51,6 +46,12 @@ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.NamedMethodGenerato
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
|
||||
import com.sun.org.apache.xml.internal.dtm.Axis;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTM;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* Mode gathers all the templates belonging to a given mode;
|
||||
@ -128,22 +129,22 @@ final class Mode implements Constants {
|
||||
/**
|
||||
* A mapping between templates and test sequences.
|
||||
*/
|
||||
private Hashtable _neededTemplates = new Hashtable();
|
||||
private Map<Template, Object> _neededTemplates = new HashMap<>();
|
||||
|
||||
/**
|
||||
* A mapping between named templates and Mode objects.
|
||||
*/
|
||||
private Hashtable _namedTemplates = new Hashtable();
|
||||
private Map<Template, Mode> _namedTemplates = new HashMap<>();
|
||||
|
||||
/**
|
||||
* A mapping between templates and instruction handles.
|
||||
*/
|
||||
private Hashtable _templateIHs = new Hashtable();
|
||||
private Map<Template, InstructionHandle> _templateIHs = new HashMap<>();
|
||||
|
||||
/**
|
||||
* A mapping between templates and instruction lists.
|
||||
*/
|
||||
private Hashtable _templateILs = new Hashtable();
|
||||
private Map<Template, InstructionList> _templateILs = new HashMap<>();
|
||||
|
||||
/**
|
||||
* A reference to the pattern matching the root node.
|
||||
@ -152,14 +153,14 @@ final class Mode implements Constants {
|
||||
|
||||
/**
|
||||
* Stores ranges of template precendences for the compilation
|
||||
* of apply-imports (a Hashtable for historical reasons).
|
||||
* of apply-imports.
|
||||
*/
|
||||
private Hashtable _importLevels = null;
|
||||
private Map<Integer, Integer> _importLevels = null;
|
||||
|
||||
/**
|
||||
* A mapping between key names and keys.
|
||||
*/
|
||||
private Hashtable _keys = null;
|
||||
private Map<String, Key> _keys = null;
|
||||
|
||||
/**
|
||||
* Variable index for the current node used in code generation.
|
||||
@ -195,9 +196,9 @@ final class Mode implements Constants {
|
||||
|
||||
public String functionName(int min, int max) {
|
||||
if (_importLevels == null) {
|
||||
_importLevels = new Hashtable();
|
||||
_importLevels = new HashMap<>();
|
||||
}
|
||||
_importLevels.put(new Integer(max), new Integer(min));
|
||||
_importLevels.put(max, min);
|
||||
return _methodName + '_' + max;
|
||||
}
|
||||
|
||||
@ -244,7 +245,7 @@ final class Mode implements Constants {
|
||||
/**
|
||||
* Process all the test patterns in this mode
|
||||
*/
|
||||
public void processPatterns(Hashtable keys) {
|
||||
public void processPatterns(Map<String, Key> keys) {
|
||||
_keys = keys;
|
||||
|
||||
/*
|
||||
@ -300,7 +301,7 @@ for (int i = 0; i < _templates.size(); i++) {
|
||||
*/
|
||||
private void flattenAlternative(Pattern pattern,
|
||||
Template template,
|
||||
Hashtable keys) {
|
||||
Map<String, Key> keys) {
|
||||
// Patterns on type id() and key() are special since they do not have
|
||||
// any kernel node type (it can be anything as long as the node is in
|
||||
// the id's or key's index).
|
||||
@ -560,15 +561,13 @@ for (int i = 0; i < _templates.size(); i++) {
|
||||
MethodGenerator methodGen,
|
||||
InstructionHandle next)
|
||||
{
|
||||
Enumeration templates = _namedTemplates.keys();
|
||||
while (templates.hasMoreElements()) {
|
||||
final Template template = (Template)templates.nextElement();
|
||||
Set<Template> templates = _namedTemplates.keySet();
|
||||
for (Template template : templates) {
|
||||
compileNamedTemplate(template, classGen);
|
||||
}
|
||||
|
||||
templates = _neededTemplates.keys();
|
||||
while (templates.hasMoreElements()) {
|
||||
final Template template = (Template)templates.nextElement();
|
||||
templates = _neededTemplates.keySet();
|
||||
for (Template template : templates) {
|
||||
if (template.hasContents()) {
|
||||
// !!! TODO templates both named and matched
|
||||
InstructionList til = template.compile(classGen, methodGen);
|
||||
@ -584,13 +583,12 @@ for (int i = 0; i < _templates.size(); i++) {
|
||||
}
|
||||
|
||||
private void appendTemplateCode(InstructionList body) {
|
||||
final Enumeration templates = _neededTemplates.keys();
|
||||
while (templates.hasMoreElements()) {
|
||||
final Object iList =
|
||||
_templateILs.get(templates.nextElement());
|
||||
for (Template template : _neededTemplates.keySet()) {
|
||||
final InstructionList iList = _templateILs.get(template);
|
||||
if (iList != null) {
|
||||
body.append((InstructionList)iList);
|
||||
body.append(iList);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1043,11 +1041,8 @@ for (int i = 0; i < _templates.size(); i++) {
|
||||
|
||||
// Compile method(s) for <xsl:apply-imports/> for this mode
|
||||
if (_importLevels != null) {
|
||||
Enumeration levels = _importLevels.keys();
|
||||
while (levels.hasMoreElements()) {
|
||||
Integer max = (Integer)levels.nextElement();
|
||||
Integer min = (Integer)_importLevels.get(max);
|
||||
compileApplyImports(classGen, min.intValue(), max.intValue());
|
||||
for (Map.Entry<Integer, Integer> entry : _importLevels.entrySet()) {
|
||||
compileApplyImports(classGen, entry.getValue(), entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1055,9 +1050,7 @@ for (int i = 0; i < _templates.size(); i++) {
|
||||
private void compileTemplateCalls(ClassGenerator classGen,
|
||||
MethodGenerator methodGen,
|
||||
InstructionHandle next, int min, int max){
|
||||
Enumeration templates = _neededTemplates.keys();
|
||||
while (templates.hasMoreElements()) {
|
||||
final Template template = (Template)templates.nextElement();
|
||||
_neededTemplates.keySet().stream().forEach((template) -> {
|
||||
final int prec = template.getImportPrecedence();
|
||||
if ((prec >= min) && (prec < max)) {
|
||||
if (template.hasContents()) {
|
||||
@ -1071,7 +1064,7 @@ for (int i = 0; i < _templates.size(); i++) {
|
||||
_templateIHs.put(template, next);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -1081,10 +1074,10 @@ for (int i = 0; i < _templates.size(); i++) {
|
||||
final Vector names = xsltc.getNamesIndex();
|
||||
|
||||
// Clear some datastructures
|
||||
_namedTemplates = new Hashtable();
|
||||
_neededTemplates = new Hashtable();
|
||||
_templateIHs = new Hashtable();
|
||||
_templateILs = new Hashtable();
|
||||
_namedTemplates = new HashMap<>();
|
||||
_neededTemplates = new HashMap<>();
|
||||
_templateIHs = new HashMap<>();
|
||||
_templateILs = new HashMap<>();
|
||||
_patternGroups = new Vector[32];
|
||||
_rootPattern = null;
|
||||
|
||||
@ -1503,7 +1496,7 @@ for (int i = 0; i < _templates.size(); i++) {
|
||||
}
|
||||
|
||||
public InstructionHandle getTemplateInstructionHandle(Template template) {
|
||||
return (InstructionHandle)_templateIHs.get(template);
|
||||
return _templateIHs.get(template);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, 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
|
||||
*
|
||||
@ -37,9 +37,10 @@ import com.sun.org.apache.xml.internal.serializer.utils.SystemIDResolver;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.Dictionary;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Stack;
|
||||
import java.util.StringTokenizer;
|
||||
@ -77,14 +78,14 @@ public class Parser implements Constants, ContentHandler {
|
||||
private Vector _errors; // Contains all compilation errors
|
||||
private Vector _warnings; // Contains all compilation errors
|
||||
|
||||
private Hashtable _instructionClasses; // Maps instructions to classes
|
||||
private Hashtable _instructionAttrs;; // reqd and opt attrs
|
||||
private Hashtable _qNames;
|
||||
private Hashtable _namespaces;
|
||||
private Map<String, String> _instructionClasses; // Maps instructions to classes
|
||||
private Map<String, String[]> _instructionAttrs; // reqd and opt attrs
|
||||
private Map<String, QName> _qNames;
|
||||
private Map<String, Map> _namespaces;
|
||||
private QName _useAttributeSets;
|
||||
private QName _excludeResultPrefixes;
|
||||
private QName _extensionElementPrefixes;
|
||||
private Hashtable _variableScope;
|
||||
private Map<String, Object> _variableScope;
|
||||
private Stylesheet _currentStylesheet;
|
||||
private SymbolTable _symbolTable; // Maps QNames to syntax-tree nodes
|
||||
private Output _output;
|
||||
@ -106,11 +107,11 @@ public class Parser implements Constants, ContentHandler {
|
||||
}
|
||||
|
||||
public void init() {
|
||||
_qNames = new Hashtable(512);
|
||||
_namespaces = new Hashtable();
|
||||
_instructionClasses = new Hashtable();
|
||||
_instructionAttrs = new Hashtable();
|
||||
_variableScope = new Hashtable();
|
||||
_qNames = new HashMap<>(512);
|
||||
_namespaces = new HashMap<>();
|
||||
_instructionClasses = new HashMap<>();
|
||||
_instructionAttrs = new HashMap<>();
|
||||
_variableScope = new HashMap<>();
|
||||
_template = null;
|
||||
_errors = new Vector();
|
||||
_warnings = new Vector();
|
||||
@ -169,7 +170,7 @@ public class Parser implements Constants, ContentHandler {
|
||||
}
|
||||
|
||||
private void addVariableOrParam(VariableBase var) {
|
||||
Object existing = _variableScope.get(var.getName());
|
||||
Object existing = _variableScope.get(var.getName().getStringRep());
|
||||
if (existing != null) {
|
||||
if (existing instanceof Stack) {
|
||||
Stack stack = (Stack)existing;
|
||||
@ -179,26 +180,26 @@ public class Parser implements Constants, ContentHandler {
|
||||
Stack stack = new Stack();
|
||||
stack.push(existing);
|
||||
stack.push(var);
|
||||
_variableScope.put(var.getName(), stack);
|
||||
_variableScope.put(var.getName().getStringRep(), stack);
|
||||
}
|
||||
}
|
||||
else {
|
||||
_variableScope.put(var.getName(), var);
|
||||
_variableScope.put(var.getName().getStringRep(), var);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeVariable(QName name) {
|
||||
Object existing = _variableScope.get(name);
|
||||
Object existing = _variableScope.get(name.getStringRep());
|
||||
if (existing instanceof Stack) {
|
||||
Stack stack = (Stack)existing;
|
||||
if (!stack.isEmpty()) stack.pop();
|
||||
if (!stack.isEmpty()) return;
|
||||
}
|
||||
_variableScope.remove(name);
|
||||
_variableScope.remove(name.getStringRep());
|
||||
}
|
||||
|
||||
public VariableBase lookupVariable(QName name) {
|
||||
Object existing = _variableScope.get(name);
|
||||
Object existing = _variableScope.get(name.getStringRep());
|
||||
if (existing instanceof VariableBase) {
|
||||
return((VariableBase)existing);
|
||||
}
|
||||
@ -305,7 +306,7 @@ public class Parser implements Constants, ContentHandler {
|
||||
|
||||
public QName getQName(String namespace, String prefix, String localname) {
|
||||
if (namespace == null || namespace.equals(EMPTYSTRING)) {
|
||||
QName name = (QName)_qNames.get(localname);
|
||||
QName name = _qNames.get(localname);
|
||||
if (name == null) {
|
||||
name = new QName(null, prefix, localname);
|
||||
_qNames.put(localname, name);
|
||||
@ -313,7 +314,7 @@ public class Parser implements Constants, ContentHandler {
|
||||
return name;
|
||||
}
|
||||
else {
|
||||
Dictionary space = (Dictionary)_namespaces.get(namespace);
|
||||
Map<String, QName> space = _namespaces.get(namespace);
|
||||
String lexicalQName =
|
||||
(prefix == null || prefix.length() == 0)
|
||||
? localname
|
||||
@ -321,12 +322,12 @@ public class Parser implements Constants, ContentHandler {
|
||||
|
||||
if (space == null) {
|
||||
final QName name = new QName(namespace, prefix, localname);
|
||||
_namespaces.put(namespace, space = new Hashtable());
|
||||
_namespaces.put(namespace, space = new HashMap<>());
|
||||
space.put(lexicalQName, name);
|
||||
return name;
|
||||
}
|
||||
else {
|
||||
QName name = (QName)space.get(lexicalQName);
|
||||
QName name = space.get(lexicalQName);
|
||||
if (name == null) {
|
||||
name = new QName(namespace, prefix, localname);
|
||||
space.put(lexicalQName, name);
|
||||
@ -397,9 +398,9 @@ public class Parser implements Constants, ContentHandler {
|
||||
if (stylesheet != null) {
|
||||
stylesheet.parseContents(this);
|
||||
final int precedence = stylesheet.getImportPrecedence();
|
||||
final Enumeration elements = stylesheet.elements();
|
||||
while (elements.hasMoreElements()) {
|
||||
Object child = elements.nextElement();
|
||||
final Iterator<SyntaxTreeNode> elements = stylesheet.elements();
|
||||
while (elements.hasNext()) {
|
||||
Object child = elements.next();
|
||||
if (child instanceof Text) {
|
||||
final int l = getLineNumber();
|
||||
ErrorMsg err =
|
||||
@ -609,11 +610,11 @@ public class Parser implements Constants, ContentHandler {
|
||||
String id = root.getAttribute("id");
|
||||
if (id.equals(href)) return root;
|
||||
}
|
||||
Vector children = root.getContents();
|
||||
List<SyntaxTreeNode> children = root.getContents();
|
||||
if (children != null) {
|
||||
final int count = children.size();
|
||||
for (int i = 0; i < count; i++) {
|
||||
SyntaxTreeNode child = (SyntaxTreeNode)children.elementAt(i);
|
||||
SyntaxTreeNode child = children.get(i);
|
||||
SyntaxTreeNode node = findStylesheet(child, href);
|
||||
if (node != null) return node;
|
||||
}
|
||||
@ -640,7 +641,7 @@ public class Parser implements Constants, ContentHandler {
|
||||
}
|
||||
|
||||
private void initAttrTable(String elementName, String[] attrs) {
|
||||
_instructionAttrs.put(getQName(XSLT_URI, XSL, elementName),
|
||||
_instructionAttrs.put(getQName(XSLT_URI, XSL, elementName).getStringRep(),
|
||||
attrs);
|
||||
}
|
||||
|
||||
@ -704,7 +705,7 @@ public class Parser implements Constants, ContentHandler {
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the _instructionClasses Hashtable, which maps XSL element
|
||||
* Initialize the _instructionClasses map, which maps XSL element
|
||||
* names to Java classes in this package.
|
||||
*/
|
||||
private void initStdClasses() {
|
||||
@ -746,12 +747,12 @@ public class Parser implements Constants, ContentHandler {
|
||||
}
|
||||
|
||||
private void initStdClass(String elementName, String className) {
|
||||
_instructionClasses.put(getQName(XSLT_URI, XSL, elementName),
|
||||
_instructionClasses.put(getQName(XSLT_URI, XSL, elementName).getStringRep(),
|
||||
COMPILER_PACKAGE + '.' + className);
|
||||
}
|
||||
|
||||
public boolean elementSupported(String namespace, String localName) {
|
||||
return(_instructionClasses.get(getQName(namespace, XSL, localName)) != null);
|
||||
return(_instructionClasses.get(getQName(namespace, XSL, localName).getStringRep()) != null);
|
||||
}
|
||||
|
||||
public boolean functionSupported(String fname) {
|
||||
@ -764,12 +765,12 @@ public class Parser implements Constants, ContentHandler {
|
||||
}
|
||||
|
||||
private void initExtClass(String elementName, String className) {
|
||||
_instructionClasses.put(getQName(TRANSLET_URI, TRANSLET, elementName),
|
||||
_instructionClasses.put(getQName(TRANSLET_URI, TRANSLET, elementName).getStringRep(),
|
||||
COMPILER_PACKAGE + '.' + className);
|
||||
}
|
||||
|
||||
private void initExtClass(String namespace, String elementName, String className) {
|
||||
_instructionClasses.put(getQName(namespace, TRANSLET, elementName),
|
||||
_instructionClasses.put(getQName(namespace, TRANSLET, elementName).getStringRep(),
|
||||
COMPILER_PACKAGE + '.' + className);
|
||||
}
|
||||
|
||||
@ -969,7 +970,7 @@ public class Parser implements Constants, ContentHandler {
|
||||
{
|
||||
SyntaxTreeNode node = null;
|
||||
QName qname = getQName(uri, prefix, local);
|
||||
String className = (String)_instructionClasses.get(qname);
|
||||
String className = _instructionClasses.get(qname.getStringRep());
|
||||
|
||||
if (className != null) {
|
||||
try {
|
||||
@ -1052,7 +1053,7 @@ public class Parser implements Constants, ContentHandler {
|
||||
{
|
||||
QName qname = node.getQName();
|
||||
boolean isStylesheet = (node instanceof Stylesheet);
|
||||
String[] legal = (String[]) _instructionAttrs.get(qname);
|
||||
String[] legal = _instructionAttrs.get(qname.getStringRep());
|
||||
if (versionIsOne && legal != null) {
|
||||
int j;
|
||||
final int n = attrs.getLength();
|
||||
@ -1250,7 +1251,7 @@ public class Parser implements Constants, ContentHandler {
|
||||
/************************ SAX2 ContentHandler INTERFACE *****************/
|
||||
|
||||
private Stack _parentStack = null;
|
||||
private Hashtable _prefixMapping = null;
|
||||
private Map<String, String> _prefixMapping = null;
|
||||
|
||||
/**
|
||||
* SAX2: Receive notification of the beginning of a document.
|
||||
@ -1274,7 +1275,7 @@ public class Parser implements Constants, ContentHandler {
|
||||
*/
|
||||
public void startPrefixMapping(String prefix, String uri) {
|
||||
if (_prefixMapping == null) {
|
||||
_prefixMapping = new Hashtable();
|
||||
_prefixMapping = new HashMap<>();
|
||||
}
|
||||
_prefixMapping.put(prefix, uri);
|
||||
}
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
* 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 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
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@ -23,14 +23,6 @@
|
||||
|
||||
package com.sun.org.apache.xalan.internal.xsltc.compiler;
|
||||
|
||||
import java.util.Vector;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.sun.org.apache.xml.internal.utils.SystemIDResolver;
|
||||
import com.sun.org.apache.bcel.internal.generic.ANEWARRAY;
|
||||
import com.sun.org.apache.bcel.internal.generic.BasicType;
|
||||
import com.sun.org.apache.bcel.internal.generic.ConstantPoolGen;
|
||||
@ -59,6 +51,14 @@ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTM;
|
||||
import com.sun.org.apache.xml.internal.utils.SystemIDResolver;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* @author Jacek Ambroziak
|
||||
@ -121,7 +121,7 @@ public final class Stylesheet extends SyntaxTreeNode {
|
||||
/**
|
||||
* Mapping between mode names and Mode instances.
|
||||
*/
|
||||
private final Hashtable _modes = new Hashtable();
|
||||
private final Map<String, Mode> _modes = new HashMap<>();
|
||||
|
||||
/**
|
||||
* A reference to the default Mode object.
|
||||
@ -131,7 +131,7 @@ public final class Stylesheet extends SyntaxTreeNode {
|
||||
/**
|
||||
* Mapping between extension URIs and their prefixes.
|
||||
*/
|
||||
private final Hashtable _extensions = new Hashtable();
|
||||
private final Map<String, String> _extensions = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Reference to the stylesheet from which this stylesheet was
|
||||
@ -164,7 +164,7 @@ public final class Stylesheet extends SyntaxTreeNode {
|
||||
/**
|
||||
* Mapping between key names and Key objects (needed by Key/IdPattern).
|
||||
*/
|
||||
private Hashtable _keys = new Hashtable();
|
||||
private Map<String, Key> _keys = new HashMap<>();
|
||||
|
||||
/**
|
||||
* A reference to the SourceLoader set by the user (a URIResolver
|
||||
@ -323,9 +323,9 @@ public final class Stylesheet extends SyntaxTreeNode {
|
||||
_importPrecedence = precedence;
|
||||
|
||||
// Set import precedence for all included stylesheets
|
||||
final Enumeration elements = elements();
|
||||
while (elements.hasMoreElements()) {
|
||||
SyntaxTreeNode child = (SyntaxTreeNode)elements.nextElement();
|
||||
final Iterator<SyntaxTreeNode> elements = elements();
|
||||
while (elements.hasNext()) {
|
||||
SyntaxTreeNode child = elements.next();
|
||||
if (child instanceof Include) {
|
||||
Stylesheet included = ((Include)child).getIncludedStylesheet();
|
||||
if (included != null && included._includedFrom == this) {
|
||||
@ -573,13 +573,13 @@ public final class Stylesheet extends SyntaxTreeNode {
|
||||
stable.excludeNamespaces(excludePrefixes);
|
||||
stable.excludeNamespaces(extensionPrefixes);
|
||||
|
||||
final Vector contents = getContents();
|
||||
final List<SyntaxTreeNode> contents = getContents();
|
||||
final int count = contents.size();
|
||||
|
||||
// We have to scan the stylesheet element's top-level elements for
|
||||
// variables and/or parameters before we parse the other elements
|
||||
for (int i = 0; i < count; i++) {
|
||||
SyntaxTreeNode child = (SyntaxTreeNode)contents.elementAt(i);
|
||||
SyntaxTreeNode child = contents.get(i);
|
||||
if ((child instanceof VariableBase) ||
|
||||
(child instanceof NamespaceAlias)) {
|
||||
parser.getSymbolTable().setCurrentNode(child);
|
||||
@ -589,7 +589,7 @@ public final class Stylesheet extends SyntaxTreeNode {
|
||||
|
||||
// Now go through all the other top-level elements...
|
||||
for (int i = 0; i < count; i++) {
|
||||
SyntaxTreeNode child = (SyntaxTreeNode)contents.elementAt(i);
|
||||
SyntaxTreeNode child = contents.get(i);
|
||||
if (!(child instanceof VariableBase) &&
|
||||
!(child instanceof NamespaceAlias)) {
|
||||
parser.getSymbolTable().setCurrentNode(child);
|
||||
@ -612,20 +612,16 @@ public final class Stylesheet extends SyntaxTreeNode {
|
||||
if (_defaultMode == null)
|
||||
_defaultMode = new Mode(null, this, Constants.EMPTYSTRING);
|
||||
_defaultMode.processPatterns(_keys);
|
||||
final Enumeration modes = _modes.elements();
|
||||
while (modes.hasMoreElements()) {
|
||||
final Mode mode = (Mode)modes.nextElement();
|
||||
_modes.values().stream().forEach((mode) -> {
|
||||
mode.processPatterns(_keys);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void compileModes(ClassGenerator classGen) {
|
||||
_defaultMode.compileApplyTemplates(classGen);
|
||||
final Enumeration modes = _modes.elements();
|
||||
while (modes.hasMoreElements()) {
|
||||
final Mode mode = (Mode)modes.nextElement();
|
||||
_modes.values().stream().forEach((mode) -> {
|
||||
mode.compileApplyTemplates(classGen);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Mode getMode(QName modeName) {
|
||||
@ -636,10 +632,10 @@ public final class Stylesheet extends SyntaxTreeNode {
|
||||
return _defaultMode;
|
||||
}
|
||||
else {
|
||||
Mode mode = (Mode)_modes.get(modeName);
|
||||
Mode mode = _modes.get(modeName.getStringRep());
|
||||
if (mode == null) {
|
||||
final String suffix = Integer.toString(_nextModeSerial++);
|
||||
_modes.put(modeName, mode = new Mode(modeName, this, suffix));
|
||||
_modes.put(modeName.getStringRep(), mode = new Mode(modeName, this, suffix));
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
@ -707,9 +703,9 @@ public final class Stylesheet extends SyntaxTreeNode {
|
||||
compileTransform(classGen);
|
||||
|
||||
// Translate all non-template elements and filter out all templates
|
||||
final Enumeration elements = elements();
|
||||
while (elements.hasMoreElements()) {
|
||||
Object element = elements.nextElement();
|
||||
final Iterator<SyntaxTreeNode> elements = elements();
|
||||
while (elements.hasNext()) {
|
||||
SyntaxTreeNode element = elements.next();
|
||||
// xsl:template
|
||||
if (element instanceof Template) {
|
||||
// Separate templates by modes
|
||||
@ -1054,9 +1050,9 @@ public final class Stylesheet extends SyntaxTreeNode {
|
||||
|
||||
// Create a new list containing variables/params + keys
|
||||
Vector varDepElements = new Vector(_globals);
|
||||
Enumeration elements = elements();
|
||||
while (elements.hasMoreElements()) {
|
||||
final Object element = elements.nextElement();
|
||||
Iterator<SyntaxTreeNode> elements = elements();
|
||||
while (elements.hasNext()) {
|
||||
SyntaxTreeNode element = elements.next();
|
||||
if (element instanceof Key) {
|
||||
varDepElements.add(element);
|
||||
}
|
||||
@ -1079,8 +1075,8 @@ public final class Stylesheet extends SyntaxTreeNode {
|
||||
// Compile code for other top-level elements
|
||||
Vector whitespaceRules = new Vector();
|
||||
elements = elements();
|
||||
while (elements.hasMoreElements()) {
|
||||
final Object element = elements.nextElement();
|
||||
while (elements.hasNext()) {
|
||||
SyntaxTreeNode element = elements.next();
|
||||
// xsl:decimal-format
|
||||
if (element instanceof DecimalFormatting) {
|
||||
((DecimalFormatting)element).translate(classGen,toplevel);
|
||||
@ -1198,10 +1194,10 @@ public final class Stylesheet extends SyntaxTreeNode {
|
||||
|
||||
buildKeys.addException("com.sun.org.apache.xalan.internal.xsltc.TransletException");
|
||||
|
||||
final Enumeration elements = elements();
|
||||
while (elements.hasMoreElements()) {
|
||||
final Iterator<SyntaxTreeNode> elements = elements();
|
||||
while (elements.hasNext()) {
|
||||
// xsl:key
|
||||
final Object element = elements.nextElement();
|
||||
final SyntaxTreeNode element = elements.next();
|
||||
if (element instanceof Key) {
|
||||
final Key key = (Key)element;
|
||||
key.translate(classGen, buildKeys);
|
||||
@ -1325,8 +1321,8 @@ public final class Stylesheet extends SyntaxTreeNode {
|
||||
"buildKeys", keySig);
|
||||
|
||||
// Look for top-level elements that need handling
|
||||
final Enumeration toplevel = elements();
|
||||
if (_globals.size() > 0 || toplevel.hasMoreElements()) {
|
||||
final Iterator<SyntaxTreeNode> toplevel = elements();
|
||||
if (_globals.size() > 0 || toplevel.hasNext()) {
|
||||
// Compile method for handling top-level elements
|
||||
final String topLevelSig = compileTopLevel(classGen);
|
||||
// Get a reference to that method
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, 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
|
||||
*
|
||||
@ -23,13 +23,13 @@
|
||||
|
||||
package com.sun.org.apache.xalan.internal.xsltc.compiler;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.Vector;
|
||||
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType;
|
||||
|
||||
/**
|
||||
* @author Jacek Ambroziak
|
||||
* @author Santiago Pericas-Geertsen
|
||||
@ -37,67 +37,67 @@ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodType;
|
||||
*/
|
||||
final class SymbolTable {
|
||||
|
||||
// These hashtables are used for all stylesheets
|
||||
private final Hashtable _stylesheets = new Hashtable();
|
||||
private final Hashtable _primops = new Hashtable();
|
||||
// These maps are used for all stylesheets
|
||||
private final Map<String, Stylesheet> _stylesheets = new HashMap<>();
|
||||
private final Map<String, Vector> _primops = new HashMap<>();
|
||||
|
||||
// These hashtables are used for some stylesheets
|
||||
private Hashtable _variables = null;
|
||||
private Hashtable _templates = null;
|
||||
private Hashtable _attributeSets = null;
|
||||
private Hashtable _aliases = null;
|
||||
private Hashtable _excludedURI = null;
|
||||
private Stack _excludedURIStack = null;
|
||||
private Hashtable _decimalFormats = null;
|
||||
private Hashtable _keys = null;
|
||||
// These maps are used for some stylesheets
|
||||
private Map<String, VariableBase> _variables = null;
|
||||
private Map<String, Template> _templates = null;
|
||||
private Map<String, AttributeSet> _attributeSets = null;
|
||||
private Map<String, String> _aliases = null;
|
||||
private Map<String, Integer> _excludedURI = null;
|
||||
private Stack<Map<String, Integer>> _excludedURIStack = null;
|
||||
private Map<String, DecimalFormatting> _decimalFormats = null;
|
||||
private Map<String, Key> _keys = null;
|
||||
|
||||
public DecimalFormatting getDecimalFormatting(QName name) {
|
||||
if (_decimalFormats == null) return null;
|
||||
return((DecimalFormatting)_decimalFormats.get(name));
|
||||
return(_decimalFormats.get(name.getStringRep()));
|
||||
}
|
||||
|
||||
public void addDecimalFormatting(QName name, DecimalFormatting symbols) {
|
||||
if (_decimalFormats == null) _decimalFormats = new Hashtable();
|
||||
_decimalFormats.put(name, symbols);
|
||||
if (_decimalFormats == null) _decimalFormats = new HashMap<>();
|
||||
_decimalFormats.put(name.getStringRep(), symbols);
|
||||
}
|
||||
|
||||
public Key getKey(QName name) {
|
||||
if (_keys == null) return null;
|
||||
return (Key) _keys.get(name);
|
||||
return _keys.get(name.getStringRep());
|
||||
}
|
||||
|
||||
public void addKey(QName name, Key key) {
|
||||
if (_keys == null) _keys = new Hashtable();
|
||||
_keys.put(name, key);
|
||||
if (_keys == null) _keys = new HashMap<>();
|
||||
_keys.put(name.getStringRep(), key);
|
||||
}
|
||||
|
||||
public Stylesheet addStylesheet(QName name, Stylesheet node) {
|
||||
return (Stylesheet)_stylesheets.put(name, node);
|
||||
return _stylesheets.put(name.getStringRep(), node);
|
||||
}
|
||||
|
||||
public Stylesheet lookupStylesheet(QName name) {
|
||||
return (Stylesheet)_stylesheets.get(name);
|
||||
return _stylesheets.get(name.getStringRep());
|
||||
}
|
||||
|
||||
public Template addTemplate(Template template) {
|
||||
final QName name = template.getName();
|
||||
if (_templates == null) _templates = new Hashtable();
|
||||
return (Template)_templates.put(name, template);
|
||||
if (_templates == null) _templates = new HashMap<>();
|
||||
return _templates.put(name.getStringRep(), template);
|
||||
}
|
||||
|
||||
public Template lookupTemplate(QName name) {
|
||||
if (_templates == null) return null;
|
||||
return (Template)_templates.get(name);
|
||||
return _templates.get(name.getStringRep());
|
||||
}
|
||||
|
||||
public Variable addVariable(Variable variable) {
|
||||
if (_variables == null) _variables = new Hashtable();
|
||||
if (_variables == null) _variables = new HashMap<>();
|
||||
final String name = variable.getName().getStringRep();
|
||||
return (Variable)_variables.put(name, variable);
|
||||
}
|
||||
|
||||
public Param addParam(Param parameter) {
|
||||
if (_variables == null) _variables = new Hashtable();
|
||||
if (_variables == null) _variables = new HashMap<>();
|
||||
final String name = parameter.getName().getStringRep();
|
||||
return (Param)_variables.put(name, parameter);
|
||||
}
|
||||
@ -105,14 +105,14 @@ final class SymbolTable {
|
||||
public Variable lookupVariable(QName qname) {
|
||||
if (_variables == null) return null;
|
||||
final String name = qname.getStringRep();
|
||||
final Object obj = _variables.get(name);
|
||||
final VariableBase obj = _variables.get(name);
|
||||
return obj instanceof Variable ? (Variable)obj : null;
|
||||
}
|
||||
|
||||
public Param lookupParam(QName qname) {
|
||||
if (_variables == null) return null;
|
||||
final String name = qname.getStringRep();
|
||||
final Object obj = _variables.get(name);
|
||||
final VariableBase obj = _variables.get(name);
|
||||
return obj instanceof Param ? (Param)obj : null;
|
||||
}
|
||||
|
||||
@ -123,13 +123,13 @@ final class SymbolTable {
|
||||
}
|
||||
|
||||
public AttributeSet addAttributeSet(AttributeSet atts) {
|
||||
if (_attributeSets == null) _attributeSets = new Hashtable();
|
||||
return (AttributeSet)_attributeSets.put(atts.getName(), atts);
|
||||
if (_attributeSets == null) _attributeSets = new HashMap<>();
|
||||
return _attributeSets.put(atts.getName().getStringRep(), atts);
|
||||
}
|
||||
|
||||
public AttributeSet lookupAttributeSet(QName name) {
|
||||
if (_attributeSets == null) return null;
|
||||
return (AttributeSet)_attributeSets.get(name);
|
||||
return _attributeSets.get(name.getStringRep());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -138,7 +138,7 @@ final class SymbolTable {
|
||||
* is prepended.
|
||||
*/
|
||||
public void addPrimop(String name, MethodType mtype) {
|
||||
Vector methods = (Vector)_primops.get(name);
|
||||
Vector methods = _primops.get(name);
|
||||
if (methods == null) {
|
||||
_primops.put(name, methods = new Vector());
|
||||
}
|
||||
@ -150,7 +150,7 @@ final class SymbolTable {
|
||||
* prepending the prefix <tt>PrimopPrefix</tt>.
|
||||
*/
|
||||
public Vector lookupPrimop(String name) {
|
||||
return (Vector)_primops.get(name);
|
||||
return _primops.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -181,7 +181,7 @@ final class SymbolTable {
|
||||
* Adds an alias for a namespace prefix
|
||||
*/
|
||||
public void addPrefixAlias(String prefix, String alias) {
|
||||
if (_aliases == null) _aliases = new Hashtable();
|
||||
if (_aliases == null) _aliases = new HashMap<>();
|
||||
_aliases.put(prefix,alias);
|
||||
}
|
||||
|
||||
@ -190,7 +190,7 @@ final class SymbolTable {
|
||||
*/
|
||||
public String lookupPrefixAlias(String prefix) {
|
||||
if (_aliases == null) return null;
|
||||
return (String)_aliases.get(prefix);
|
||||
return _aliases.get(prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -201,15 +201,15 @@ final class SymbolTable {
|
||||
// The null-namespace cannot be excluded
|
||||
if (uri == null) return;
|
||||
|
||||
// Create new hashtable of exlcuded URIs if none exists
|
||||
if (_excludedURI == null) _excludedURI = new Hashtable();
|
||||
// Create a new map of exlcuded URIs if none exists
|
||||
if (_excludedURI == null) _excludedURI = new HashMap<>();
|
||||
|
||||
// Register the namespace URI
|
||||
Integer refcnt = (Integer)_excludedURI.get(uri);
|
||||
Integer refcnt = _excludedURI.get(uri);
|
||||
if (refcnt == null)
|
||||
refcnt = new Integer(1);
|
||||
refcnt = 1;
|
||||
else
|
||||
refcnt = new Integer(refcnt.intValue() + 1);
|
||||
refcnt = refcnt + 1;
|
||||
_excludedURI.put(uri,refcnt);
|
||||
}
|
||||
|
||||
@ -237,8 +237,8 @@ final class SymbolTable {
|
||||
*/
|
||||
public boolean isExcludedNamespace(String uri) {
|
||||
if (uri != null && _excludedURI != null) {
|
||||
final Integer refcnt = (Integer)_excludedURI.get(uri);
|
||||
return (refcnt != null && refcnt.intValue() > 0);
|
||||
final Integer refcnt = _excludedURI.get(uri);
|
||||
return (refcnt != null && refcnt > 0);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -257,9 +257,9 @@ final class SymbolTable {
|
||||
uri = lookupNamespace(Constants.EMPTYSTRING);
|
||||
else
|
||||
uri = lookupNamespace(prefix);
|
||||
Integer refcnt = (Integer)_excludedURI.get(uri);
|
||||
Integer refcnt = _excludedURI.get(uri);
|
||||
if (refcnt != null)
|
||||
_excludedURI.put(uri, new Integer(refcnt.intValue() - 1));
|
||||
_excludedURI.put(uri, refcnt - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -286,7 +286,7 @@ final class SymbolTable {
|
||||
* the current stylesheet.
|
||||
*/
|
||||
public void popExcludedNamespacesContext() {
|
||||
_excludedURI = (Hashtable) _excludedURIStack.pop();
|
||||
_excludedURI = _excludedURIStack.pop();
|
||||
if (_excludedURIStack.isEmpty()) {
|
||||
_excludedURIStack = null;
|
||||
}
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2006, 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
|
||||
*
|
||||
@ -23,10 +23,6 @@
|
||||
|
||||
package com.sun.org.apache.xalan.internal.xsltc.compiler;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
|
||||
import com.sun.org.apache.bcel.internal.generic.ANEWARRAY;
|
||||
import com.sun.org.apache.bcel.internal.generic.BasicType;
|
||||
import com.sun.org.apache.bcel.internal.generic.CHECKCAST;
|
||||
@ -41,14 +37,18 @@ import com.sun.org.apache.bcel.internal.generic.InstructionList;
|
||||
import com.sun.org.apache.bcel.internal.generic.NEW;
|
||||
import com.sun.org.apache.bcel.internal.generic.NEWARRAY;
|
||||
import com.sun.org.apache.bcel.internal.generic.PUSH;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.DOM;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.DOM;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.helpers.AttributesImpl;
|
||||
|
||||
@ -70,13 +70,13 @@ public abstract class SyntaxTreeNode implements Constants {
|
||||
protected SyntaxTreeNode _parent; // Parent node
|
||||
private Stylesheet _stylesheet; // Stylesheet ancestor node
|
||||
private Template _template; // Template ancestor node
|
||||
private final Vector _contents = new Vector(2); // Child nodes
|
||||
private final List<SyntaxTreeNode> _contents = new ArrayList<>(2); // Child nodes
|
||||
|
||||
// Element description data
|
||||
protected QName _qname; // The element QName
|
||||
private int _line; // Source file line number
|
||||
protected AttributesImpl _attributes = null; // Attributes of this element
|
||||
private Hashtable _prefixMapping = null; // Namespace declarations
|
||||
private Map<String, String> _prefixMapping = null; // Namespace declarations
|
||||
|
||||
// Sentinel - used to denote unrecognised syntaxt tree nodes.
|
||||
protected static final SyntaxTreeNode Dummy = new AbsolutePathPattern(null);
|
||||
@ -217,22 +217,22 @@ public abstract class SyntaxTreeNode implements Constants {
|
||||
* Sets the prefix mapping for the namespaces that were declared in this
|
||||
* element. This does not include all prefix mappings in scope, so one
|
||||
* may have to check ancestor elements to get all mappings that are in
|
||||
* in scope. The prefixes must be passed in as a Hashtable that maps
|
||||
* in scope. The prefixes must be passed in as a Map that maps
|
||||
* namespace prefixes (String objects) to namespace URIs (also String).
|
||||
* @param mapping The Hashtable containing the mappings.
|
||||
* @param mapping The Map containing the mappings.
|
||||
*/
|
||||
protected void setPrefixMapping(Hashtable mapping) {
|
||||
protected void setPrefixMapping(Map<String, String> mapping) {
|
||||
_prefixMapping = mapping;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Hashtable containing the prefix mappings that were declared
|
||||
* Returns a Map containing the prefix mappings that were declared
|
||||
* for this element. This does not include all prefix mappings in scope,
|
||||
* so one may have to check ancestor elements to get all mappings that are
|
||||
* in in scope.
|
||||
* @return Prefix mappings (for this element only).
|
||||
*/
|
||||
protected Hashtable getPrefixMapping() {
|
||||
protected Map<String, String> getPrefixMapping() {
|
||||
return _prefixMapping;
|
||||
}
|
||||
|
||||
@ -243,7 +243,7 @@ public abstract class SyntaxTreeNode implements Constants {
|
||||
*/
|
||||
protected void addPrefixMapping(String prefix, String uri) {
|
||||
if (_prefixMapping == null)
|
||||
_prefixMapping = new Hashtable();
|
||||
_prefixMapping = new HashMap<>();
|
||||
_prefixMapping.put(prefix, uri);
|
||||
}
|
||||
|
||||
@ -259,9 +259,9 @@ public abstract class SyntaxTreeNode implements Constants {
|
||||
// Initialise the output (default is 'null' for undefined)
|
||||
String uri = null;
|
||||
|
||||
// First look up the prefix/uri mapping in our own hashtable...
|
||||
// First look up the prefix/uri mapping in our own map...
|
||||
if (_prefixMapping != null)
|
||||
uri = (String)_prefixMapping.get(prefix);
|
||||
uri = _prefixMapping.get(prefix);
|
||||
// ... but if we can't find it there we ask our parent for the mapping
|
||||
if ((uri == null) && (_parent != null)) {
|
||||
uri = _parent.lookupNamespace(prefix);
|
||||
@ -286,13 +286,12 @@ public abstract class SyntaxTreeNode implements Constants {
|
||||
// Initialise the output (default is 'null' for undefined)
|
||||
String prefix = null;
|
||||
|
||||
// First look up the prefix/uri mapping in our own hashtable...
|
||||
// First look up the prefix/uri mapping in our own map...
|
||||
if ((_prefixMapping != null) &&
|
||||
(_prefixMapping.contains(uri))) {
|
||||
Enumeration prefixes = _prefixMapping.keys();
|
||||
while (prefixes.hasMoreElements()) {
|
||||
prefix = (String)prefixes.nextElement();
|
||||
String mapsTo = (String)_prefixMapping.get(prefix);
|
||||
(_prefixMapping.containsValue(uri))) {
|
||||
for (Map.Entry<String, String> entry : _prefixMapping.entrySet()) {
|
||||
prefix = entry.getKey();
|
||||
String mapsTo = entry.getValue();
|
||||
if (mapsTo.equals(uri)) return(prefix);
|
||||
}
|
||||
}
|
||||
@ -427,20 +426,18 @@ public abstract class SyntaxTreeNode implements Constants {
|
||||
*/
|
||||
protected final void parseChildren(Parser parser) {
|
||||
|
||||
Vector locals = null; // only create when needed
|
||||
List<QName> locals = null; // only create when needed
|
||||
|
||||
final int count = _contents.size();
|
||||
for (int i=0; i<count; i++) {
|
||||
SyntaxTreeNode child = (SyntaxTreeNode)_contents.elementAt(i);
|
||||
for (SyntaxTreeNode child : _contents) {
|
||||
parser.getSymbolTable().setCurrentNode(child);
|
||||
child.parseContents(parser);
|
||||
// if variable or parameter, add it to scope
|
||||
final QName varOrParamName = updateScope(parser, child);
|
||||
if (varOrParamName != null) {
|
||||
if (locals == null) {
|
||||
locals = new Vector(2);
|
||||
locals = new ArrayList<>(2);
|
||||
}
|
||||
locals.addElement(varOrParamName);
|
||||
locals.add(varOrParamName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -448,9 +445,8 @@ public abstract class SyntaxTreeNode implements Constants {
|
||||
|
||||
// after the last element, remove any locals from scope
|
||||
if (locals != null) {
|
||||
final int nLocals = locals.size();
|
||||
for (int i = 0; i < nLocals; i++) {
|
||||
parser.removeVariable((QName)locals.elementAt(i));
|
||||
for (QName varOrParamName : locals) {
|
||||
parser.removeVariable(varOrParamName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -487,9 +483,7 @@ public abstract class SyntaxTreeNode implements Constants {
|
||||
* @param stable The compiler/parser's symbol table
|
||||
*/
|
||||
protected Type typeCheckContents(SymbolTable stable) throws TypeCheckError {
|
||||
final int n = elementCount();
|
||||
for (int i = 0; i < n; i++) {
|
||||
SyntaxTreeNode item = (SyntaxTreeNode)_contents.elementAt(i);
|
||||
for (SyntaxTreeNode item : _contents) {
|
||||
item.typeCheck(stable);
|
||||
}
|
||||
return Type.Void;
|
||||
@ -513,9 +507,8 @@ public abstract class SyntaxTreeNode implements Constants {
|
||||
// Call translate() on all child nodes
|
||||
final int n = elementCount();
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (SyntaxTreeNode item : _contents) {
|
||||
methodGen.markChunkStart();
|
||||
final SyntaxTreeNode item = (SyntaxTreeNode)_contents.elementAt(i);
|
||||
item.translate(classGen, methodGen);
|
||||
methodGen.markChunkEnd();
|
||||
}
|
||||
@ -526,8 +519,8 @@ public abstract class SyntaxTreeNode implements Constants {
|
||||
// references falling out-of-scope inside the for-each element.
|
||||
// (the cause of which being 'lazy' register allocation for references)
|
||||
for (int i = 0; i < n; i++) {
|
||||
if( _contents.elementAt(i) instanceof VariableBase) {
|
||||
final VariableBase var = (VariableBase)_contents.elementAt(i);
|
||||
if( _contents.get(i) instanceof VariableBase) {
|
||||
final VariableBase var = (VariableBase)_contents.get(i);
|
||||
var.unmapRegister(methodGen);
|
||||
}
|
||||
}
|
||||
@ -543,10 +536,8 @@ public abstract class SyntaxTreeNode implements Constants {
|
||||
*/
|
||||
private boolean isSimpleRTF(SyntaxTreeNode node) {
|
||||
|
||||
Vector contents = node.getContents();
|
||||
for (int i = 0; i < contents.size(); i++) {
|
||||
SyntaxTreeNode item = (SyntaxTreeNode)contents.elementAt(i);
|
||||
if (!isTextElement(item, false))
|
||||
List<SyntaxTreeNode> contents = node.getContents();
|
||||
if (!contents.stream().noneMatch((item) -> (!isTextElement(item, false)))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -564,9 +555,8 @@ public abstract class SyntaxTreeNode implements Constants {
|
||||
*/
|
||||
private boolean isAdaptiveRTF(SyntaxTreeNode node) {
|
||||
|
||||
Vector contents = node.getContents();
|
||||
for (int i = 0; i < contents.size(); i++) {
|
||||
SyntaxTreeNode item = (SyntaxTreeNode)contents.elementAt(i);
|
||||
List<SyntaxTreeNode> contents = node.getContents();
|
||||
for (SyntaxTreeNode item : contents) {
|
||||
if (!isTextElement(item, true))
|
||||
return false;
|
||||
}
|
||||
@ -600,9 +590,8 @@ public abstract class SyntaxTreeNode implements Constants {
|
||||
return doExtendedCheck ? isAdaptiveRTF(node) : isSimpleRTF(node);
|
||||
}
|
||||
else if (node instanceof Choose) {
|
||||
Vector contents = node.getContents();
|
||||
for (int i = 0; i < contents.size(); i++) {
|
||||
SyntaxTreeNode item = (SyntaxTreeNode)contents.elementAt(i);
|
||||
List<SyntaxTreeNode> contents = node.getContents();
|
||||
for (SyntaxTreeNode item : contents) {
|
||||
if (item instanceof Text ||
|
||||
((item instanceof When || item instanceof Otherwise)
|
||||
&& ((doExtendedCheck && isAdaptiveRTF(item))
|
||||
@ -769,9 +758,7 @@ public abstract class SyntaxTreeNode implements Constants {
|
||||
* @return 'true' if the contents of this node is context dependent.
|
||||
*/
|
||||
protected boolean dependentContents() {
|
||||
final int n = elementCount();
|
||||
for (int i = 0; i < n; i++) {
|
||||
final SyntaxTreeNode item = (SyntaxTreeNode)_contents.elementAt(i);
|
||||
for (SyntaxTreeNode item : _contents) {
|
||||
if (item.contextDependent()) {
|
||||
return true;
|
||||
}
|
||||
@ -784,7 +771,7 @@ public abstract class SyntaxTreeNode implements Constants {
|
||||
* @param element is the new child node.
|
||||
*/
|
||||
protected final void addElement(SyntaxTreeNode element) {
|
||||
_contents.addElement(element);
|
||||
_contents.add(element);
|
||||
element.setParent(this);
|
||||
}
|
||||
|
||||
@ -794,7 +781,7 @@ public abstract class SyntaxTreeNode implements Constants {
|
||||
* @param element is the new child node.
|
||||
*/
|
||||
protected final void setFirstElement(SyntaxTreeNode element) {
|
||||
_contents.insertElementAt(element,0);
|
||||
_contents.add(0, element);
|
||||
element.setParent(this);
|
||||
}
|
||||
|
||||
@ -808,10 +795,10 @@ public abstract class SyntaxTreeNode implements Constants {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Vector containing all the child nodes of this node.
|
||||
* @return A Vector containing all the child nodes of this node.
|
||||
* Returns a List containing all the child nodes of this node.
|
||||
* @return A List containing all the child nodes of this node.
|
||||
*/
|
||||
protected final Vector getContents() {
|
||||
protected final List<SyntaxTreeNode> getContents() {
|
||||
return _contents;
|
||||
}
|
||||
|
||||
@ -832,11 +819,11 @@ public abstract class SyntaxTreeNode implements Constants {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an Enumeration of all child nodes of this node.
|
||||
* @return An Enumeration of all child nodes of this node.
|
||||
* Returns an Iterator of all child nodes of this node.
|
||||
* @return An Iterator of all child nodes of this node.
|
||||
*/
|
||||
protected final Enumeration elements() {
|
||||
return _contents.elements();
|
||||
protected final Iterator<SyntaxTreeNode> elements() {
|
||||
return _contents.iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -845,7 +832,7 @@ public abstract class SyntaxTreeNode implements Constants {
|
||||
* @return The child node.
|
||||
*/
|
||||
protected final Object elementAt(int pos) {
|
||||
return _contents.elementAt(pos);
|
||||
return _contents.get(pos);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -853,8 +840,8 @@ public abstract class SyntaxTreeNode implements Constants {
|
||||
* @return The child node.
|
||||
*/
|
||||
protected final SyntaxTreeNode lastChild() {
|
||||
if (_contents.size() == 0) return null;
|
||||
return (SyntaxTreeNode)_contents.lastElement();
|
||||
if (_contents.isEmpty()) return null;
|
||||
return (SyntaxTreeNode)_contents.get(_contents.size() - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -873,9 +860,7 @@ public abstract class SyntaxTreeNode implements Constants {
|
||||
* @param indent Indentation level for syntax tree levels.
|
||||
*/
|
||||
protected void displayContents(int indent) {
|
||||
final int n = elementCount();
|
||||
for (int i = 0; i < n; i++) {
|
||||
SyntaxTreeNode item = (SyntaxTreeNode)_contents.elementAt(i);
|
||||
for (SyntaxTreeNode item : _contents) {
|
||||
item.display(indent);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, 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
|
||||
*
|
||||
@ -37,6 +37,7 @@ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
|
||||
import com.sun.org.apache.xml.internal.utils.XML11Char;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@ -274,8 +275,8 @@ public final class Template extends TopLevelElement {
|
||||
_priority = Double.NaN;
|
||||
_pattern = parser.parsePattern(this, "/");
|
||||
|
||||
final Vector contents = _stylesheet.getContents();
|
||||
final SyntaxTreeNode root = (SyntaxTreeNode)contents.elementAt(0);
|
||||
final List<SyntaxTreeNode> contents = _stylesheet.getContents();
|
||||
final SyntaxTreeNode root = contents.get(0);
|
||||
|
||||
if (root instanceof LiteralElement) {
|
||||
addElement(root);
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, 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
|
||||
*
|
||||
@ -23,14 +23,14 @@
|
||||
|
||||
package com.sun.org.apache.xalan.internal.xsltc.compiler;
|
||||
|
||||
import java.util.Dictionary;
|
||||
import java.util.Vector;
|
||||
|
||||
import com.sun.org.apache.bcel.internal.generic.GOTO_W;
|
||||
import com.sun.org.apache.bcel.internal.generic.InstructionHandle;
|
||||
import com.sun.org.apache.bcel.internal.generic.InstructionList;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ClassGenerator;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator;
|
||||
import java.util.Dictionary;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* A test sequence is a sequence of patterns that
|
||||
@ -179,7 +179,7 @@ final class TestSeq {
|
||||
* this test sequence. Note that a single template can occur
|
||||
* in several test sequences if its pattern is a union.
|
||||
*/
|
||||
public void findTemplates(Dictionary templates) {
|
||||
public void findTemplates(Map<Template, Object> templates) {
|
||||
if (_default != null) {
|
||||
templates.put(_default, this);
|
||||
}
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, 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
|
||||
*
|
||||
@ -36,6 +36,7 @@ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.MethodGenerator;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Type;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.TypeCheckError;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Morten Jorgensen
|
||||
@ -83,11 +84,11 @@ final class UnsupportedElement extends SyntaxTreeNode {
|
||||
*/
|
||||
private void processFallbacks(Parser parser) {
|
||||
|
||||
Vector children = getContents();
|
||||
List<SyntaxTreeNode> children = getContents();
|
||||
if (children != null) {
|
||||
final int count = children.size();
|
||||
for (int i = 0; i < count; i++) {
|
||||
SyntaxTreeNode child = (SyntaxTreeNode)children.elementAt(i);
|
||||
SyntaxTreeNode child = children.get(i);
|
||||
if (child instanceof Fallback) {
|
||||
Fallback fallback = (Fallback)child;
|
||||
fallback.activate();
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2012, 2015, 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
|
||||
*
|
||||
@ -45,7 +45,6 @@ import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Vector;
|
||||
@ -90,14 +89,14 @@ public final class XSLTC {
|
||||
// Name index tables
|
||||
private int _nextGType; // Next available element type
|
||||
private Vector _namesIndex; // Index of all registered QNames
|
||||
private Hashtable _elements; // Hashtable of all registered elements
|
||||
private Hashtable _attributes; // Hashtable of all registered attributes
|
||||
private Map<String, Integer> _elements; // Map of all registered elements
|
||||
private Map<String, Integer> _attributes; // Map of all registered attributes
|
||||
|
||||
// Namespace index tables
|
||||
private int _nextNSType; // Next available namespace type
|
||||
private Vector _namespaceIndex; // Index of all registered namespaces
|
||||
private Hashtable _namespaces; // Hashtable of all registered namespaces
|
||||
private Hashtable _namespacePrefixes;// Hashtable of all registered namespace prefixes
|
||||
private Map<String, Integer> _namespaces; // Map of all registered namespaces
|
||||
private Map<String, Integer> _namespacePrefixes;// Map of all registered namespace prefixes
|
||||
|
||||
|
||||
// All literal text in the stylesheet
|
||||
@ -319,13 +318,13 @@ public final class XSLTC {
|
||||
*/
|
||||
private void reset() {
|
||||
_nextGType = DTM.NTYPES;
|
||||
_elements = new Hashtable();
|
||||
_attributes = new Hashtable();
|
||||
_namespaces = new Hashtable();
|
||||
_elements = new HashMap<>();
|
||||
_attributes = new HashMap<>();
|
||||
_namespaces = new HashMap<>();
|
||||
_namespaces.put("",new Integer(_nextNSType));
|
||||
_namesIndex = new Vector(128);
|
||||
_namespaceIndex = new Vector(32);
|
||||
_namespacePrefixes = new Hashtable();
|
||||
_namespacePrefixes = new HashMap<>();
|
||||
_stylesheet = null;
|
||||
_parser.init();
|
||||
//_variableSerial = 1;
|
||||
@ -765,9 +764,9 @@ public final class XSLTC {
|
||||
* DOM attribute types at run-time.
|
||||
*/
|
||||
public int registerAttribute(QName name) {
|
||||
Integer code = (Integer)_attributes.get(name.toString());
|
||||
Integer code = _attributes.get(name.toString());
|
||||
if (code == null) {
|
||||
code = new Integer(_nextGType++);
|
||||
code = _nextGType++;
|
||||
_attributes.put(name.toString(), code);
|
||||
final String uri = name.getNamespace();
|
||||
final String local = "@"+name.getLocalPart();
|
||||
@ -788,9 +787,9 @@ public final class XSLTC {
|
||||
*/
|
||||
public int registerElement(QName name) {
|
||||
// Register element (full QName)
|
||||
Integer code = (Integer)_elements.get(name.toString());
|
||||
Integer code = _elements.get(name.toString());
|
||||
if (code == null) {
|
||||
_elements.put(name.toString(), code = new Integer(_nextGType++));
|
||||
_elements.put(name.toString(), code = _nextGType++);
|
||||
_namesIndex.addElement(name.toString());
|
||||
}
|
||||
if (name.getLocalPart().equals("*")) {
|
||||
@ -806,9 +805,9 @@ public final class XSLTC {
|
||||
|
||||
public int registerNamespacePrefix(QName name) {
|
||||
|
||||
Integer code = (Integer)_namespacePrefixes.get(name.toString());
|
||||
Integer code = _namespacePrefixes.get(name.toString());
|
||||
if (code == null) {
|
||||
code = new Integer(_nextGType++);
|
||||
code = _nextGType++;
|
||||
_namespacePrefixes.put(name.toString(), code);
|
||||
final String uri = name.getNamespace();
|
||||
if ((uri != null) && (!uri.equals(""))){
|
||||
@ -826,9 +825,9 @@ public final class XSLTC {
|
||||
* DOM namespace types at run-time.
|
||||
*/
|
||||
public int registerNamespace(String namespaceURI) {
|
||||
Integer code = (Integer)_namespaces.get(namespaceURI);
|
||||
Integer code = _namespaces.get(namespaceURI);
|
||||
if (code == null) {
|
||||
code = new Integer(_nextNSType++);
|
||||
code = _nextNSType++;
|
||||
_namespaces.put(namespaceURI,code);
|
||||
_namespaceIndex.addElement(namespaceURI);
|
||||
}
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, 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
|
||||
*
|
||||
@ -44,6 +44,7 @@ import com.sun.org.apache.xalan.internal.xsltc.compiler.util.Util;
|
||||
import com.sun.org.apache.xml.internal.serializer.ElemDesc;
|
||||
import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
|
||||
import com.sun.org.apache.xml.internal.utils.XML11Char;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Jacek Ambroziak
|
||||
@ -103,9 +104,9 @@ final class XslAttribute extends Instruction {
|
||||
|
||||
// Ignore attribute if preceeded by some other type of element
|
||||
final SyntaxTreeNode parent = getParent();
|
||||
final Vector siblings = parent.getContents();
|
||||
final List<SyntaxTreeNode> siblings = parent.getContents();
|
||||
for (int i = 0; i < parent.elementCount(); i++) {
|
||||
SyntaxTreeNode item = (SyntaxTreeNode)siblings.elementAt(i);
|
||||
SyntaxTreeNode item = siblings.get(i);
|
||||
if (item == this) break;
|
||||
|
||||
// These three objects result in one or more attribute output
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, 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
|
||||
*
|
||||
@ -285,8 +285,7 @@ final class XslElement extends Instruction {
|
||||
MethodGenerator methodGen) {
|
||||
final int n = elementCount();
|
||||
for (int i = 0; i < n; i++) {
|
||||
final SyntaxTreeNode item =
|
||||
(SyntaxTreeNode)getContents().elementAt(i);
|
||||
final SyntaxTreeNode item = getContents().get(i);
|
||||
if (_ignore && item instanceof XslAttribute) continue;
|
||||
item.translate(classGen, methodGen);
|
||||
}
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
* 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 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
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@ -26,7 +26,6 @@ package com.sun.org.apache.xalan.internal.xsltc.compiler.util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
@ -131,7 +130,7 @@ public class MethodGenerator extends MethodGen
|
||||
* times. Note that patterns whose kernels are "*", "node()"
|
||||
* and "@*" can between shared by test sequences.
|
||||
*/
|
||||
private Hashtable _preCompiled = new Hashtable();
|
||||
private Map<Pattern, InstructionList> _preCompiled = new HashMap<>();
|
||||
|
||||
|
||||
public MethodGenerator(int access_flags, Type return_type,
|
||||
@ -715,7 +714,7 @@ public class MethodGenerator extends MethodGen
|
||||
* test sequences to avoid compiling patterns more than once.
|
||||
*/
|
||||
public InstructionList getInstructionList(Pattern pattern) {
|
||||
return (InstructionList) _preCompiled.get(pattern);
|
||||
return _preCompiled.get(pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
* 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 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
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@ -23,35 +23,68 @@
|
||||
|
||||
package com.sun.org.apache.xalan.internal.xsltc.compiler.util;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Jacek Ambroziak
|
||||
* @author Santiago Pericas-Geertsen
|
||||
* @param <K>
|
||||
* @param <V>
|
||||
*/
|
||||
public final class MultiHashtable extends Hashtable {
|
||||
public final class MultiHashtable<K,V> {
|
||||
static final long serialVersionUID = -6151608290510033572L;
|
||||
public Object put(Object key, Object value) {
|
||||
Vector vector = (Vector)get(key);
|
||||
if (vector == null)
|
||||
super.put(key, vector = new Vector());
|
||||
vector.add(value);
|
||||
return vector;
|
||||
|
||||
private final Map<K, Set<V>> map = new HashMap<>();
|
||||
private boolean modifiable = true;
|
||||
|
||||
/**
|
||||
* Associates the specified key with a set of values. If the map previously
|
||||
* contained a mapping for the key, the value is added to the set.
|
||||
* @param key key with which the specified value is to be associated
|
||||
* @param value value to be added to a set that is associated with the specified key
|
||||
* @return the set that is associated with the specified key.
|
||||
* @throw UnsupportedOperationException is the MultiHashtable is not modifiable.
|
||||
*/
|
||||
public Set<V> put(K key, V value) {
|
||||
if (modifiable) {
|
||||
Set<V> set = map.computeIfAbsent(key, k -> new HashSet<>());
|
||||
set.add(value);
|
||||
return set;
|
||||
}
|
||||
throw new UnsupportedOperationException("The MultiHashtable instance is not modifiable.");
|
||||
}
|
||||
|
||||
public Object maps(Object from, Object to) {
|
||||
if (from == null) return null;
|
||||
final Vector vector = (Vector) get(from);
|
||||
if (vector != null) {
|
||||
final int n = vector.size();
|
||||
for (int i = 0; i < n; i++) {
|
||||
final Object item = vector.elementAt(i);
|
||||
if (item.equals(to)) {
|
||||
return item;
|
||||
/**
|
||||
* Maps a key to a value in a set that is associated with the specified key.
|
||||
* The mapping is performed by evaluating whether an item in the set equals
|
||||
* the specified value.
|
||||
*
|
||||
* @param key key with which the specified value is to be associated
|
||||
* @param value value in a set that is associated with the specified key
|
||||
* @return the item in the set if a match is found.
|
||||
*/
|
||||
public V maps(K key, V value) {
|
||||
if (key == null) return null;
|
||||
final Set<V> set = map.get(key);
|
||||
if (set != null) {
|
||||
for (V v : set) {
|
||||
if (v.equals(value)) {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes the MultiHashtable unmodifiable. This method allows modules to set the table
|
||||
* as "read-only" so that only query operation, that is maps, is allowed. Any attempts
|
||||
* to modify the returned map result in an UnsupportedOperationException.
|
||||
*/
|
||||
public void makeUnmodifiable() {
|
||||
modifiable = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, 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
|
||||
*
|
||||
@ -23,18 +23,15 @@
|
||||
package com.sun.org.apache.xalan.internal.xsltc.dom;
|
||||
|
||||
import com.sun.org.apache.xalan.internal.xsltc.DOM;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.TransletException;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.StripFilter;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.TransletException;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary;
|
||||
|
||||
import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTMAxisTraverser;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTMWSFilter;
|
||||
import com.sun.org.apache.xml.internal.utils.XMLString;
|
||||
|
||||
import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
|
||||
|
||||
import com.sun.org.apache.xml.internal.utils.XMLString;
|
||||
import java.util.Map;
|
||||
import javax.xml.transform.SourceLocator;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
@ -556,7 +553,7 @@ public class AdaptiveResultTreeImpl extends SimpleResultTreeImpl
|
||||
}
|
||||
}
|
||||
|
||||
public Hashtable getElementsWithIDs()
|
||||
public Map<String, Integer> getElementsWithIDs()
|
||||
{
|
||||
if (_dom != null) {
|
||||
return _dom.getElementsWithIDs();
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, 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
|
||||
*
|
||||
@ -27,11 +27,10 @@ import com.sun.org.apache.xalan.internal.xsltc.DOM;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.DOMEnhancedForDTM;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.StripFilter;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.TransletException;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTM;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
|
||||
import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
|
||||
|
||||
import java.util.Map;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
@ -462,7 +461,7 @@ public final class DOMAdapter implements DOM {
|
||||
return _dom.getUnparsedEntityURI(entity);
|
||||
}
|
||||
|
||||
public Hashtable getElementsWithIDs() {
|
||||
public Map<String, Integer> getElementsWithIDs() {
|
||||
return _dom.getElementsWithIDs();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2002-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
|
||||
*
|
||||
@ -26,9 +26,10 @@ import com.sun.org.apache.xalan.internal.xsltc.DOM;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.DOMEnhancedForDTM;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.StripFilter;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTM;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTMWSFilter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A wrapper class that adapts the
|
||||
@ -40,8 +41,8 @@ public class DOMWSFilter implements DTMWSFilter {
|
||||
private AbstractTranslet m_translet;
|
||||
private StripFilter m_filter;
|
||||
|
||||
// The Hashtable for DTM to mapping array
|
||||
private Hashtable m_mappings;
|
||||
// The Map for DTM to mapping array
|
||||
private Map<DTM, short[]> m_mappings;
|
||||
|
||||
// Cache the DTM and mapping that are used last time
|
||||
private DTM m_currentDTM;
|
||||
@ -59,7 +60,7 @@ public class DOMWSFilter implements DTMWSFilter {
|
||||
*/
|
||||
public DOMWSFilter(AbstractTranslet translet) {
|
||||
m_translet = translet;
|
||||
m_mappings = new Hashtable();
|
||||
m_mappings = new HashMap<>();
|
||||
|
||||
if (translet instanceof StripFilter) {
|
||||
m_filter = (StripFilter) translet;
|
||||
@ -91,7 +92,7 @@ public class DOMWSFilter implements DTMWSFilter {
|
||||
mapping = m_currentMapping;
|
||||
}
|
||||
else {
|
||||
mapping = (short[])m_mappings.get(dtm);
|
||||
mapping = m_mappings.get(dtm);
|
||||
if (mapping == null) {
|
||||
mapping = mappableDOM.getMapping(
|
||||
m_translet.getNamesArray(),
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, 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
|
||||
*
|
||||
@ -23,20 +23,6 @@
|
||||
|
||||
package com.sun.org.apache.xalan.internal.xsltc.dom;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.Date;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.sax.SAXSource;
|
||||
|
||||
import com.sun.org.apache.xalan.internal.xsltc.DOM;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.DOMCache;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.DOMEnhancedForDTM;
|
||||
@ -45,7 +31,19 @@ import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.Constants;
|
||||
import com.sun.org.apache.xml.internal.utils.SystemIDResolver;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.sax.SAXSource;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.XMLReader;
|
||||
@ -56,7 +54,7 @@ import org.xml.sax.XMLReader;
|
||||
public final class DocumentCache implements DOMCache {
|
||||
|
||||
private int _size;
|
||||
private Hashtable _references;
|
||||
private Map<String, CachedDocument> _references;
|
||||
private String[] _URIs;
|
||||
private int _count;
|
||||
private int _current;
|
||||
@ -170,7 +168,7 @@ public final class DocumentCache implements DOMCache {
|
||||
_count = 0;
|
||||
_current = 0;
|
||||
_size = size;
|
||||
_references = new Hashtable(_size+2);
|
||||
_references = new HashMap<>(_size+2);
|
||||
_URIs = new String[_size];
|
||||
|
||||
try {
|
||||
@ -217,7 +215,7 @@ public final class DocumentCache implements DOMCache {
|
||||
*
|
||||
*/
|
||||
private CachedDocument lookupDocument(String uri) {
|
||||
return((CachedDocument)_references.get(uri));
|
||||
return(_references.get(uri));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -230,7 +228,7 @@ public final class DocumentCache implements DOMCache {
|
||||
_current = 0;
|
||||
}
|
||||
else {
|
||||
// Remove oldest URI from reference Hashtable
|
||||
// Remove oldest URI from reference map
|
||||
_references.remove(_URIs[_current]);
|
||||
// Insert our URI in circular buffer
|
||||
_URIs[_current] = uri;
|
||||
@ -243,7 +241,6 @@ public final class DocumentCache implements DOMCache {
|
||||
*
|
||||
*/
|
||||
private synchronized void replaceDocument(String uri, CachedDocument doc) {
|
||||
CachedDocument old = (CachedDocument)_references.get(uri);
|
||||
if (doc == null)
|
||||
insertDocument(uri, doc);
|
||||
else
|
||||
@ -324,7 +321,7 @@ public final class DocumentCache implements DOMCache {
|
||||
"<td><center><b>Last modified</b></center></td></tr>");
|
||||
|
||||
for (int i=0; i<_count; i++) {
|
||||
CachedDocument doc = (CachedDocument)_references.get(_URIs[i]);
|
||||
CachedDocument doc = _references.get(_URIs[i]);
|
||||
out.print("<tr><td><a href=\""+_URIs[i]+"\">"+
|
||||
"<font size=-1>"+_URIs[i]+"</font></a></td>");
|
||||
out.print("<td><center>"+doc.getLatency()+"ms</center></td>");
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2001-2006 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
|
||||
*
|
||||
@ -23,18 +23,17 @@
|
||||
|
||||
package com.sun.org.apache.xalan.internal.xsltc.dom;
|
||||
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import com.sun.org.apache.xalan.internal.xsltc.DOM;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.DOMEnhancedForDTM;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.util.IntegerArray;
|
||||
|
||||
import com.sun.org.apache.xml.internal.dtm.Axis;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTM;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
|
||||
import com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIteratorBase;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
/**
|
||||
* Stores mappings of key values or IDs to DTM nodes.
|
||||
@ -49,7 +48,7 @@ public class KeyIndex extends DTMAxisIteratorBase {
|
||||
* A mapping between values and nodesets for the current document. Used
|
||||
* only while building keys.
|
||||
*/
|
||||
private Hashtable _index;
|
||||
private Map<String, IntegerArray> _index;
|
||||
|
||||
/**
|
||||
* The document node currently being processed. Used only while building
|
||||
@ -60,7 +59,7 @@ public class KeyIndex extends DTMAxisIteratorBase {
|
||||
/**
|
||||
* A mapping from a document node to the mapping between values and nodesets
|
||||
*/
|
||||
private Hashtable _rootToIndexMap = new Hashtable();
|
||||
private Map<Integer, Map> _rootToIndexMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* The node set associated to the current value passed
|
||||
@ -91,14 +90,14 @@ public class KeyIndex extends DTMAxisIteratorBase {
|
||||
* Adds a node to the node list for a given value. Nodes will
|
||||
* always be added in document order.
|
||||
*/
|
||||
public void add(Object value, int node, int rootNode) {
|
||||
public void add(String value, int node, int rootNode) {
|
||||
if (_currentDocumentNode != rootNode) {
|
||||
_currentDocumentNode = rootNode;
|
||||
_index = new Hashtable();
|
||||
_index = new HashMap<>();
|
||||
_rootToIndexMap.put(new Integer(rootNode), _index);
|
||||
}
|
||||
|
||||
IntegerArray nodes = (IntegerArray) _index.get(value);
|
||||
IntegerArray nodes = _index.get(value);
|
||||
|
||||
if (nodes == null) {
|
||||
nodes = new IntegerArray();
|
||||
@ -145,7 +144,7 @@ public class KeyIndex extends DTMAxisIteratorBase {
|
||||
" \n\t");
|
||||
while (values.hasMoreElements()) {
|
||||
final String token = (String) values.nextElement();
|
||||
IntegerArray nodes = (IntegerArray) _index.get(token);
|
||||
IntegerArray nodes = _index.get(token);
|
||||
|
||||
if (nodes == null && _enhancedDOM != null
|
||||
&& _enhancedDOM.hasDOMSource()) {
|
||||
@ -178,13 +177,13 @@ public class KeyIndex extends DTMAxisIteratorBase {
|
||||
|
||||
if (ident != DTM.NULL) {
|
||||
Integer root = new Integer(_enhancedDOM.getDocument());
|
||||
Hashtable index = (Hashtable) _rootToIndexMap.get(root);
|
||||
Map<String, IntegerArray> index = _rootToIndexMap.get(root);
|
||||
|
||||
if (index == null) {
|
||||
index = new Hashtable();
|
||||
index = new HashMap<>();
|
||||
_rootToIndexMap.put(root, index);
|
||||
} else {
|
||||
nodes = (IntegerArray) index.get(id);
|
||||
nodes = index.get(id);
|
||||
}
|
||||
|
||||
if (nodes == null) {
|
||||
@ -207,7 +206,7 @@ public class KeyIndex extends DTMAxisIteratorBase {
|
||||
* @deprecated
|
||||
*/
|
||||
public void lookupKey(Object value) {
|
||||
IntegerArray nodes = (IntegerArray) _index.get(value);
|
||||
IntegerArray nodes = _index.get(value);
|
||||
_nodes = (nodes != null) ? (IntegerArray) nodes.clone() : null;
|
||||
_position = 0;
|
||||
}
|
||||
@ -243,8 +242,8 @@ public class KeyIndex extends DTMAxisIteratorBase {
|
||||
.setStartNode(node).next();
|
||||
|
||||
// Get the mapping table for the document containing the context node
|
||||
Hashtable index =
|
||||
(Hashtable) _rootToIndexMap.get(new Integer(rootHandle));
|
||||
Map<String, IntegerArray> index =
|
||||
_rootToIndexMap.get(new Integer(rootHandle));
|
||||
|
||||
// Split argument to id function into XML whitespace separated tokens
|
||||
final StringTokenizer values = new StringTokenizer(string, " \n\t");
|
||||
@ -254,7 +253,7 @@ public class KeyIndex extends DTMAxisIteratorBase {
|
||||
IntegerArray nodes = null;
|
||||
|
||||
if (index != null) {
|
||||
nodes = (IntegerArray) index.get(token);
|
||||
nodes = index.get(token);
|
||||
}
|
||||
|
||||
// If input was from W3C DOM, use DOM's getElementById to do
|
||||
@ -294,13 +293,13 @@ public class KeyIndex extends DTMAxisIteratorBase {
|
||||
.setStartNode(node).next();
|
||||
|
||||
// Get the mapping table for the document containing the context node
|
||||
Hashtable index =
|
||||
(Hashtable) _rootToIndexMap.get(new Integer(rootHandle));
|
||||
Map<String,IntegerArray> index =
|
||||
_rootToIndexMap.get(new Integer(rootHandle));
|
||||
|
||||
// Check whether the context node is present in the set of nodes
|
||||
// returned by the key function
|
||||
if (index != null) {
|
||||
final IntegerArray nodes = (IntegerArray) index.get(value);
|
||||
final IntegerArray nodes = index.get(value);
|
||||
return (nodes != null && nodes.indexOf(node) >= 0) ? 1 : 0;
|
||||
}
|
||||
|
||||
@ -689,7 +688,7 @@ public class KeyIndex extends DTMAxisIteratorBase {
|
||||
IntegerArray result = null;
|
||||
|
||||
// Get mapping from key values/IDs to DTM nodes for this document
|
||||
Hashtable index = (Hashtable)_rootToIndexMap.get(new Integer(root));
|
||||
Map<String, IntegerArray> index = _rootToIndexMap.get(new Integer(root));
|
||||
|
||||
if (!_isKeyIterator) {
|
||||
// For id function, tokenize argument as whitespace separated
|
||||
@ -703,7 +702,7 @@ public class KeyIndex extends DTMAxisIteratorBase {
|
||||
|
||||
// Does the ID map to any node in the document?
|
||||
if (index != null) {
|
||||
nodes = (IntegerArray) index.get(token);
|
||||
nodes = index.get(token);
|
||||
}
|
||||
|
||||
// If input was from W3C DOM, use DOM's getElementById to do
|
||||
@ -725,7 +724,7 @@ public class KeyIndex extends DTMAxisIteratorBase {
|
||||
}
|
||||
} else if (index != null) {
|
||||
// For key function, map key value to nodes
|
||||
result = (IntegerArray) index.get(keyValue);
|
||||
result = index.get(keyValue);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@ -3,11 +3,12 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2005 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
|
||||
*
|
||||
@ -22,19 +23,19 @@ package com.sun.org.apache.xalan.internal.xsltc.dom;
|
||||
|
||||
import com.sun.org.apache.xalan.internal.xsltc.DOM;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.StripFilter;
|
||||
import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.TransletException;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTM;
|
||||
import com.sun.org.apache.xml.internal.dtm.Axis;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTM;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTMManager;
|
||||
import com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIteratorBase;
|
||||
import com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBase;
|
||||
import com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIterNodeList;
|
||||
import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
|
||||
import com.sun.org.apache.xml.internal.utils.SuballocatedIntVector;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
@ -54,7 +55,7 @@ public final class MultiDOM implements DOM {
|
||||
private int _free;
|
||||
private int _size;
|
||||
|
||||
private Hashtable _documents = new Hashtable();
|
||||
private Map<String, Integer> _documents = new HashMap<>();
|
||||
|
||||
private final class AxisIterator extends DTMAxisIteratorBase {
|
||||
// constitutive data
|
||||
@ -324,10 +325,10 @@ public final class MultiDOM implements DOM {
|
||||
domNo = domPos;
|
||||
}
|
||||
|
||||
// Store reference to document (URI) in hashtable
|
||||
// Store reference to document (URI) in the Map
|
||||
if (indexByURI) {
|
||||
String uri = adapter.getDocumentURI(0);
|
||||
_documents.put(uri, new Integer(domNo));
|
||||
_documents.put(uri, domNo);
|
||||
}
|
||||
|
||||
// If the dom is an AdaptiveResultTreeImpl, we need to create a
|
||||
@ -350,7 +351,7 @@ public final class MultiDOM implements DOM {
|
||||
}
|
||||
|
||||
public int getDocumentMask(String uri) {
|
||||
Integer domIdx = (Integer)_documents.get(uri);
|
||||
Integer domIdx = _documents.get(uri);
|
||||
if (domIdx == null) {
|
||||
return(-1);
|
||||
} else {
|
||||
@ -359,7 +360,7 @@ public final class MultiDOM implements DOM {
|
||||
}
|
||||
|
||||
public DOM getDOMAdapter(String uri) {
|
||||
Integer domIdx = (Integer)_documents.get(uri);
|
||||
Integer domIdx = _documents.get(uri);
|
||||
if (domIdx == null) {
|
||||
return(null);
|
||||
} else {
|
||||
@ -667,7 +668,7 @@ public final class MultiDOM implements DOM {
|
||||
}
|
||||
|
||||
// %HZ% Does this method make any sense here???
|
||||
public Hashtable getElementsWithIDs() {
|
||||
public Map<String, Integer> getElementsWithIDs() {
|
||||
return _main.getElementsWithIDs();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, 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
|
||||
*
|
||||
@ -23,40 +23,35 @@
|
||||
|
||||
package com.sun.org.apache.xalan.internal.xsltc.dom;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
|
||||
import com.sun.org.apache.xalan.internal.xsltc.DOM;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.DOMEnhancedForDTM;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.StripFilter;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.TransletException;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTM;
|
||||
import com.sun.org.apache.xml.internal.dtm.Axis;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTM;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTMManager;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTMWSFilter;
|
||||
import com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIterNodeList;
|
||||
import com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBase;
|
||||
import com.sun.org.apache.xml.internal.dtm.ref.EmptyIterator;
|
||||
import com.sun.org.apache.xml.internal.dtm.ref.DTMNodeProxy;
|
||||
import com.sun.org.apache.xml.internal.dtm.ref.EmptyIterator;
|
||||
import com.sun.org.apache.xml.internal.dtm.ref.sax2dtm.SAX2DTM2;
|
||||
import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
|
||||
import com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler;
|
||||
import com.sun.org.apache.xml.internal.utils.XMLStringFactory;
|
||||
import com.sun.org.apache.xml.internal.utils.SystemIDResolver;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import com.sun.org.apache.xml.internal.utils.XMLStringFactory;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.DocumentType;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Entity;
|
||||
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
@ -119,7 +114,7 @@ public final class SAXImpl extends SAX2DTM2
|
||||
private int _namesSize = -1;
|
||||
|
||||
// Namespace related stuff
|
||||
private Hashtable _nsIndex = new Hashtable();
|
||||
private Map<Integer, Integer> _nsIndex = new HashMap<>();
|
||||
|
||||
// The initial size of the text buffer
|
||||
private int _size = 0;
|
||||
@ -134,10 +129,10 @@ public final class SAXImpl extends SAX2DTM2
|
||||
// The owner Document when the input source is DOMSource.
|
||||
private Document _document;
|
||||
|
||||
// The hashtable for org.w3c.dom.Node to node id mapping.
|
||||
// The Map for org.w3c.dom.Node to node id mapping.
|
||||
// This is only used when the input is a DOMSource and the
|
||||
// buildIdIndex flag is true.
|
||||
private Hashtable _node2Ids = null;
|
||||
private Map<Node, Integer> _node2Ids = null;
|
||||
|
||||
// True if the input source is a DOMSource.
|
||||
private boolean _hasDOMSource = false;
|
||||
@ -480,7 +475,7 @@ public final class SAXImpl extends SAX2DTM2
|
||||
return 0;
|
||||
}
|
||||
int eType = getIdForNamespace(s);
|
||||
return ((Integer)_nsIndex.get(new Integer(eType))).intValue();
|
||||
return _nsIndex.get(new Integer(eType));
|
||||
}
|
||||
|
||||
|
||||
@ -679,9 +674,9 @@ public final class SAXImpl extends SAX2DTM2
|
||||
|
||||
for (i=0; i<nsLength; i++) {
|
||||
int eType = getIdForNamespace(namespaces[i]);
|
||||
Integer type = (Integer)_nsIndex.get(new Integer(eType));
|
||||
Integer type = _nsIndex.get(new Integer(eType));
|
||||
if (type != null) {
|
||||
result[type.intValue()] = (short)i;
|
||||
result[type] = (short)i;
|
||||
}
|
||||
}
|
||||
|
||||
@ -699,7 +694,7 @@ public final class SAXImpl extends SAX2DTM2
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
int eType = getIdForNamespace(namespaces[i]);
|
||||
Integer type = (Integer)_nsIndex.get(new Integer(eType));
|
||||
Integer type = _nsIndex.get(new Integer(eType));
|
||||
result[i] = (type == null) ? -1 : type.shortValue();
|
||||
}
|
||||
|
||||
@ -752,7 +747,7 @@ public final class SAXImpl extends SAX2DTM2
|
||||
else {
|
||||
_document = node.getOwnerDocument();
|
||||
}
|
||||
_node2Ids = new Hashtable();
|
||||
_node2Ids = new HashMap<>();
|
||||
}
|
||||
}
|
||||
|
||||
@ -780,8 +775,8 @@ public final class SAXImpl extends SAX2DTM2
|
||||
{
|
||||
Node node = _document.getElementById(idString);
|
||||
if (node != null) {
|
||||
Integer id = (Integer)_node2Ids.get(node);
|
||||
return (id != null) ? id.intValue() : DTM.NULL;
|
||||
Integer id = _node2Ids.get(node);
|
||||
return (id != null) ? id : DTM.NULL;
|
||||
}
|
||||
else {
|
||||
return DTM.NULL;
|
||||
@ -880,7 +875,7 @@ public final class SAXImpl extends SAX2DTM2
|
||||
{
|
||||
super.startDocument();
|
||||
|
||||
_nsIndex.put(new Integer(0), new Integer(_uriCount++));
|
||||
_nsIndex.put(0, _uriCount++);
|
||||
definePrefixAndUri(XML_PREFIX, XML_URI);
|
||||
}
|
||||
|
||||
@ -987,8 +982,8 @@ public final class SAXImpl extends SAX2DTM2
|
||||
{
|
||||
// Check if the URI already exists before pushing on stack
|
||||
Integer eType = new Integer(getIdForNamespace(uri));
|
||||
if ((Integer)_nsIndex.get(eType) == null) {
|
||||
_nsIndex.put(eType, new Integer(_uriCount++));
|
||||
if (_nsIndex.get(eType) == null) {
|
||||
_nsIndex.put(eType, _uriCount++);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1840,28 +1835,11 @@ public final class SAXImpl extends SAX2DTM2
|
||||
}
|
||||
|
||||
/**
|
||||
* %HZ% Need Javadoc
|
||||
* Return the attributes map.
|
||||
* @return the attributes map.
|
||||
*/
|
||||
public Hashtable getElementsWithIDs() {
|
||||
if (m_idAttributes == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Convert a java.util.Hashtable to an xsltc.runtime.Hashtable
|
||||
Enumeration idValues = m_idAttributes.keys();
|
||||
if (!idValues.hasMoreElements()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Hashtable idAttrsTable = new Hashtable();
|
||||
|
||||
while (idValues.hasMoreElements()) {
|
||||
Object idValue = idValues.nextElement();
|
||||
|
||||
idAttrsTable.put(idValue, m_idAttributes.get(idValue));
|
||||
}
|
||||
|
||||
return idAttrsTable;
|
||||
public Map<String, Integer> getElementsWithIDs() {
|
||||
return m_idAttributes;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -23,12 +23,11 @@
|
||||
package com.sun.org.apache.xalan.internal.xsltc.dom;
|
||||
|
||||
import com.sun.org.apache.xalan.internal.xsltc.DOM;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.TransletException;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.StripFilter;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.TransletException;
|
||||
|
||||
import com.sun.org.apache.xml.internal.dtm.DTM;
|
||||
import com.sun.org.apache.xml.internal.dtm.Axis;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTM;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTMAxisTraverser;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTMManager;
|
||||
@ -38,14 +37,12 @@ import com.sun.org.apache.xml.internal.serializer.EmptySerializer;
|
||||
import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
|
||||
import com.sun.org.apache.xml.internal.utils.XMLString;
|
||||
import com.sun.org.apache.xml.internal.utils.XMLStringDefault;
|
||||
|
||||
import java.util.Map;
|
||||
import javax.xml.transform.SourceLocator;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import javax.xml.transform.SourceLocator;
|
||||
|
||||
/**
|
||||
* This class represents a light-weight DOM model for simple result tree fragment(RTF).
|
||||
* A simple RTF is an RTF that has only one Text node. The Text node can be produced by a
|
||||
@ -608,7 +605,7 @@ public class SimpleResultTreeImpl extends EmptySerializer implements DOM, DTM
|
||||
return null;
|
||||
}
|
||||
|
||||
public Hashtable getElementsWithIDs()
|
||||
public Map<String, Integer> getElementsWithIDs()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -1,15 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2006, 2015, 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
|
||||
*
|
||||
@ -27,21 +25,6 @@ package com.sun.org.apache.xalan.internal.xsltc.runtime;
|
||||
|
||||
import com.sun.org.apache.xalan.internal.XalanConstants;
|
||||
import com.sun.org.apache.xalan.internal.utils.FactoryImpl;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import javax.xml.transform.Templates;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.DOMImplementation;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import com.sun.org.apache.xml.internal.dtm.DTM;
|
||||
|
||||
import com.sun.org.apache.xalan.internal.xsltc.DOM;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.DOMCache;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.DOMEnhancedForDTM;
|
||||
@ -50,9 +33,24 @@ import com.sun.org.apache.xalan.internal.xsltc.TransletException;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.dom.DOMAdapter;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.dom.KeyIndex;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.output.TransletOutputHandlerFactory;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTM;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator;
|
||||
import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
|
||||
import com.sun.org.apache.xml.internal.serializer.ToStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.Templates;
|
||||
import org.w3c.dom.DOMImplementation;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
/**
|
||||
* @author Jacek Ambroziak
|
||||
@ -273,15 +271,15 @@ public abstract class AbstractTranslet implements Translet {
|
||||
************************************************************************/
|
||||
|
||||
// Contains decimal number formatting symbols used by FormatNumberCall
|
||||
public Hashtable _formatSymbols = null;
|
||||
public Map<String, DecimalFormat> _formatSymbols = null;
|
||||
|
||||
/**
|
||||
* Adds a DecimalFormat object to the _formatSymbols hashtable.
|
||||
* Adds a DecimalFormat object to the _formatSymbols map.
|
||||
* The entry is created with the input DecimalFormatSymbols.
|
||||
*/
|
||||
public void addDecimalFormat(String name, DecimalFormatSymbols symbols) {
|
||||
// Instanciate hashtable for formatting symbols if needed
|
||||
if (_formatSymbols == null) _formatSymbols = new Hashtable();
|
||||
// Instanciate map for formatting symbols if needed
|
||||
if (_formatSymbols == null) _formatSymbols = new HashMap<>();
|
||||
|
||||
// The name cannot be null - use empty string instead
|
||||
if (name == null) name = EMPTYSTRING;
|
||||
@ -295,7 +293,7 @@ public abstract class AbstractTranslet implements Translet {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a named DecimalFormat object from _formatSymbols hashtable.
|
||||
* Retrieves a named DecimalFormat object from the _formatSymbols map.
|
||||
*/
|
||||
public final DecimalFormat getDecimalFormat(String name) {
|
||||
|
||||
@ -303,8 +301,8 @@ public abstract class AbstractTranslet implements Translet {
|
||||
// The name cannot be null - use empty string instead
|
||||
if (name == null) name = EMPTYSTRING;
|
||||
|
||||
DecimalFormat df = (DecimalFormat)_formatSymbols.get(name);
|
||||
if (df == null) df = (DecimalFormat)_formatSymbols.get(EMPTYSTRING);
|
||||
DecimalFormat df = _formatSymbols.get(name);
|
||||
if (df == null) df = _formatSymbols.get(EMPTYSTRING);
|
||||
return df;
|
||||
}
|
||||
return(null);
|
||||
@ -340,26 +338,19 @@ public abstract class AbstractTranslet implements Translet {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
final Hashtable elementsByID = enhancedDOM.getElementsWithIDs();
|
||||
final Map<String, Integer> elementsByID = enhancedDOM.getElementsWithIDs();
|
||||
|
||||
if (elementsByID == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Given a Hashtable of DTM nodes indexed by ID attribute values,
|
||||
// Given a Map of DTM nodes indexed by ID attribute values,
|
||||
// loop through the table copying information to a KeyIndex
|
||||
// for the mapping from ID attribute value to DTM node
|
||||
final Enumeration idValues = elementsByID.keys();
|
||||
boolean hasIDValues = false;
|
||||
|
||||
while (idValues.hasMoreElements()) {
|
||||
final Object idValue = idValues.nextElement();
|
||||
final int element =
|
||||
document.getNodeHandle(
|
||||
((Integer)elementsByID.get(idValue))
|
||||
.intValue());
|
||||
|
||||
buildKeyIndex(ID_INDEX_NAME, element, idValue);
|
||||
for (Map.Entry<String, Integer> entry : elementsByID.entrySet()) {
|
||||
final int element = document.getNodeHandle(entry.getValue());
|
||||
buildKeyIndex(ID_INDEX_NAME, element, entry.getKey());
|
||||
hasIDValues = true;
|
||||
}
|
||||
|
||||
@ -427,7 +418,7 @@ public abstract class AbstractTranslet implements Translet {
|
||||
************************************************************************/
|
||||
|
||||
// Container for all indexes for xsl:key elements
|
||||
private Hashtable _keyIndexes = null;
|
||||
private Map<String, KeyIndex> _keyIndexes = null;
|
||||
private KeyIndex _emptyKeyIndex = null;
|
||||
private int _indexSize = 0;
|
||||
private int _currentRootForKeys = 0;
|
||||
@ -453,13 +444,8 @@ public abstract class AbstractTranslet implements Translet {
|
||||
* @param node is the node handle of the node to insert
|
||||
* @param value is the value that will look up the node in the given index
|
||||
*/
|
||||
public void buildKeyIndex(String name, int node, Object value) {
|
||||
if (_keyIndexes == null) _keyIndexes = new Hashtable();
|
||||
|
||||
KeyIndex index = (KeyIndex)_keyIndexes.get(name);
|
||||
if (index == null) {
|
||||
_keyIndexes.put(name, index = new KeyIndex(_indexSize));
|
||||
}
|
||||
public void buildKeyIndex(String name, int node, String value) {
|
||||
KeyIndex index = buildKeyIndexHelper(name);
|
||||
index.add(value, node, _currentRootForKeys);
|
||||
}
|
||||
|
||||
@ -469,18 +455,33 @@ public abstract class AbstractTranslet implements Translet {
|
||||
* @param dom is the DOM
|
||||
*/
|
||||
public void buildKeyIndex(String name, DOM dom) {
|
||||
if (_keyIndexes == null) _keyIndexes = new Hashtable();
|
||||
KeyIndex index = buildKeyIndexHelper(name);
|
||||
index.setDom(dom, dom.getDocument());
|
||||
}
|
||||
|
||||
KeyIndex index = (KeyIndex)_keyIndexes.get(name);
|
||||
/**
|
||||
* Return KeyIndex for the buildKeyIndex methods. Note the difference from the
|
||||
* public getKeyIndex method, this method creates a new Map if keyIndexes does
|
||||
* not exist.
|
||||
*
|
||||
* @param name the name of the index (the key or ##id)
|
||||
* @return a KeyIndex.
|
||||
*/
|
||||
private KeyIndex buildKeyIndexHelper(String name) {
|
||||
if (_keyIndexes == null) _keyIndexes = new HashMap<>();
|
||||
|
||||
KeyIndex index = _keyIndexes.get(name);
|
||||
if (index == null) {
|
||||
_keyIndexes.put(name, index = new KeyIndex(_indexSize));
|
||||
}
|
||||
index.setDom(dom, dom.getDocument());
|
||||
return index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index for a given key (or id).
|
||||
* The index implements our internal iterator interface
|
||||
* @param name the name of the index (the key or ##id)
|
||||
* @return a KeyIndex.
|
||||
*/
|
||||
public KeyIndex getKeyIndex(String name) {
|
||||
// Return an empty key index iterator if none are defined
|
||||
@ -491,7 +492,7 @@ public abstract class AbstractTranslet implements Translet {
|
||||
}
|
||||
|
||||
// Look up the requested key index
|
||||
final KeyIndex index = (KeyIndex)_keyIndexes.get(name);
|
||||
final KeyIndex index = _keyIndexes.get(name);
|
||||
|
||||
// Return an empty key index iterator if the requested index not found
|
||||
if (index == null) {
|
||||
@ -708,14 +709,14 @@ public abstract class AbstractTranslet implements Translet {
|
||||
}
|
||||
}
|
||||
|
||||
private Hashtable _auxClasses = null;
|
||||
private Map<String, Class<?>> _auxClasses = null;
|
||||
|
||||
public void addAuxiliaryClass(Class auxClass) {
|
||||
if (_auxClasses == null) _auxClasses = new Hashtable();
|
||||
if (_auxClasses == null) _auxClasses = new HashMap<>();
|
||||
_auxClasses.put(auxClass.getName(), auxClass);
|
||||
}
|
||||
|
||||
public void setAuxiliaryClasses(Hashtable auxClasses) {
|
||||
public void setAuxiliaryClasses(Map<String, Class<?>> auxClasses) {
|
||||
_auxClasses = auxClasses;
|
||||
}
|
||||
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2007, 2015, 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
|
||||
*
|
||||
@ -983,7 +983,7 @@ public final class BasisLibrary {
|
||||
|
||||
/**
|
||||
* Utility function: used to format/adjust a double to a string. The
|
||||
* DecimalFormat object comes from the 'formatSymbols' hashtable in
|
||||
* DecimalFormat object comes from the 'formatSymbols' map in
|
||||
* AbstractTranslet.
|
||||
*/
|
||||
private static FieldPosition _fieldPosition = new FieldPosition(0);
|
||||
|
||||
@ -1,345 +0,0 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
*/
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/*
|
||||
* $Id: Hashtable.java,v 1.2.4.1 2005/09/06 11:05:18 pvedula Exp $
|
||||
*/
|
||||
|
||||
package com.sun.org.apache.xalan.internal.xsltc.runtime;
|
||||
|
||||
import java.util.Enumeration;
|
||||
|
||||
/**
|
||||
* IMPORTANT NOTE:
|
||||
* This code was taken from Sun's Java1.1 JDK java.util.HashTable.java
|
||||
* All "synchronized" keywords and some methods we do not need have been
|
||||
* all been removed.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Object that wraps entries in the hash-table
|
||||
* @author Morten Jorgensen
|
||||
*/
|
||||
class HashtableEntry {
|
||||
int hash;
|
||||
Object key;
|
||||
Object value;
|
||||
HashtableEntry next;
|
||||
|
||||
protected Object clone() {
|
||||
HashtableEntry entry = new HashtableEntry();
|
||||
entry.hash = hash;
|
||||
entry.key = key;
|
||||
entry.value = value;
|
||||
entry.next = (next != null) ? (HashtableEntry)next.clone() : null;
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The main hash-table implementation
|
||||
*/
|
||||
public class Hashtable {
|
||||
|
||||
private transient HashtableEntry table[]; // hash-table entries
|
||||
private transient int count; // number of entries
|
||||
private int threshold; // current size of hash-tabke
|
||||
private float loadFactor; // load factor
|
||||
|
||||
/**
|
||||
* Constructs a new, empty hashtable with the specified initial
|
||||
* capacity and the specified load factor.
|
||||
*/
|
||||
public Hashtable(int initialCapacity, float loadFactor) {
|
||||
if (initialCapacity <= 0) initialCapacity = 11;
|
||||
if (loadFactor <= 0.0) loadFactor = 0.75f;
|
||||
this.loadFactor = loadFactor;
|
||||
table = new HashtableEntry[initialCapacity];
|
||||
threshold = (int)(initialCapacity * loadFactor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new, empty hashtable with the specified initial capacity
|
||||
* and default load factor.
|
||||
*/
|
||||
public Hashtable(int initialCapacity) {
|
||||
this(initialCapacity, 0.75f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new, empty hashtable with a default capacity and load
|
||||
* factor.
|
||||
*/
|
||||
public Hashtable() {
|
||||
this(101, 0.75f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of keys in this hashtable.
|
||||
*/
|
||||
public int size() {
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if this hashtable maps no keys to values.
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return count == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an enumeration of the keys in this hashtable.
|
||||
*/
|
||||
public Enumeration keys() {
|
||||
return new HashtableEnumerator(table, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an enumeration of the values in this hashtable.
|
||||
* Use the Enumeration methods on the returned object to fetch the elements
|
||||
* sequentially.
|
||||
*/
|
||||
public Enumeration elements() {
|
||||
return new HashtableEnumerator(table, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if some key maps into the specified value in this hashtable.
|
||||
* This operation is more expensive than the <code>containsKey</code>
|
||||
* method.
|
||||
*/
|
||||
public boolean contains(Object value) {
|
||||
|
||||
if (value == null) throw new NullPointerException();
|
||||
|
||||
int i;
|
||||
HashtableEntry e;
|
||||
HashtableEntry tab[] = table;
|
||||
|
||||
for (i = tab.length ; i-- > 0 ;) {
|
||||
for (e = tab[i] ; e != null ; e = e.next) {
|
||||
if (e.value.equals(value)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the specified object is a key in this hashtable.
|
||||
*/
|
||||
public boolean containsKey(Object key) {
|
||||
HashtableEntry e;
|
||||
HashtableEntry tab[] = table;
|
||||
int hash = key.hashCode();
|
||||
int index = (hash & 0x7FFFFFFF) % tab.length;
|
||||
|
||||
for (e = tab[index] ; e != null ; e = e.next)
|
||||
if ((e.hash == hash) && e.key.equals(key))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value to which the specified key is mapped in this hashtable.
|
||||
*/
|
||||
public Object get(Object key) {
|
||||
HashtableEntry e;
|
||||
HashtableEntry tab[] = table;
|
||||
int hash = key.hashCode();
|
||||
int index = (hash & 0x7FFFFFFF) % tab.length;
|
||||
|
||||
for (e = tab[index] ; e != null ; e = e.next)
|
||||
if ((e.hash == hash) && e.key.equals(key))
|
||||
return e.value;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rehashes the contents of the hashtable into a hashtable with a
|
||||
* larger capacity. This method is called automatically when the
|
||||
* number of keys in the hashtable exceeds this hashtable's capacity
|
||||
* and load factor.
|
||||
*/
|
||||
protected void rehash() {
|
||||
HashtableEntry e, old;
|
||||
int i, index;
|
||||
int oldCapacity = table.length;
|
||||
HashtableEntry oldTable[] = table;
|
||||
|
||||
int newCapacity = oldCapacity * 2 + 1;
|
||||
HashtableEntry newTable[] = new HashtableEntry[newCapacity];
|
||||
|
||||
threshold = (int)(newCapacity * loadFactor);
|
||||
table = newTable;
|
||||
|
||||
for (i = oldCapacity ; i-- > 0 ;) {
|
||||
for (old = oldTable[i] ; old != null ; ) {
|
||||
e = old;
|
||||
old = old.next;
|
||||
index = (e.hash & 0x7FFFFFFF) % newCapacity;
|
||||
e.next = newTable[index];
|
||||
newTable[index] = e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps the specified <code>key</code> to the specified
|
||||
* <code>value</code> in this hashtable. Neither the key nor the
|
||||
* value can be <code>null</code>.
|
||||
* <p>
|
||||
* The value can be retrieved by calling the <code>get</code> method
|
||||
* with a key that is equal to the original key.
|
||||
*/
|
||||
public Object put(Object key, Object value) {
|
||||
// Make sure the value is not null
|
||||
if (value == null) throw new NullPointerException();
|
||||
|
||||
// Makes sure the key is not already in the hashtable.
|
||||
HashtableEntry e;
|
||||
HashtableEntry tab[] = table;
|
||||
int hash = key.hashCode();
|
||||
int index = (hash & 0x7FFFFFFF) % tab.length;
|
||||
|
||||
for (e = tab[index] ; e != null ; e = e.next) {
|
||||
if ((e.hash == hash) && e.key.equals(key)) {
|
||||
Object old = e.value;
|
||||
e.value = value;
|
||||
return old;
|
||||
}
|
||||
}
|
||||
|
||||
// Rehash the table if the threshold is exceeded
|
||||
if (count >= threshold) {
|
||||
rehash();
|
||||
return put(key, value);
|
||||
}
|
||||
|
||||
// Creates the new entry.
|
||||
e = new HashtableEntry();
|
||||
e.hash = hash;
|
||||
e.key = key;
|
||||
e.value = value;
|
||||
e.next = tab[index];
|
||||
tab[index] = e;
|
||||
count++;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the key (and its corresponding value) from this
|
||||
* hashtable. This method does nothing if the key is not in the hashtable.
|
||||
*/
|
||||
public Object remove(Object key) {
|
||||
HashtableEntry e, prev;
|
||||
HashtableEntry tab[] = table;
|
||||
int hash = key.hashCode();
|
||||
int index = (hash & 0x7FFFFFFF) % tab.length;
|
||||
for (e = tab[index], prev = null ; e != null ; prev = e, e = e.next) {
|
||||
if ((e.hash == hash) && e.key.equals(key)) {
|
||||
if (prev != null)
|
||||
prev.next = e.next;
|
||||
else
|
||||
tab[index] = e.next;
|
||||
count--;
|
||||
return e.value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears this hashtable so that it contains no keys.
|
||||
*/
|
||||
public void clear() {
|
||||
HashtableEntry tab[] = table;
|
||||
for (int index = tab.length; --index >= 0; )
|
||||
tab[index] = null;
|
||||
count = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a rather long string representation of this hashtable.
|
||||
* Handy for debugging - leave it here!!!
|
||||
*/
|
||||
public String toString() {
|
||||
int i;
|
||||
int max = size() - 1;
|
||||
StringBuffer buf = new StringBuffer();
|
||||
Enumeration k = keys();
|
||||
Enumeration e = elements();
|
||||
buf.append("{");
|
||||
|
||||
for (i = 0; i <= max; i++) {
|
||||
String s1 = k.nextElement().toString();
|
||||
String s2 = e.nextElement().toString();
|
||||
buf.append(s1).append('=').append(s2);
|
||||
if (i < max) buf.append(", ");
|
||||
}
|
||||
buf.append("}");
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* A hashtable enumerator class. This class should remain opaque
|
||||
* to the client. It will use the Enumeration interface.
|
||||
*/
|
||||
class HashtableEnumerator implements Enumeration {
|
||||
boolean keys;
|
||||
int index;
|
||||
HashtableEntry table[];
|
||||
HashtableEntry entry;
|
||||
|
||||
HashtableEnumerator(HashtableEntry table[], boolean keys) {
|
||||
this.table = table;
|
||||
this.keys = keys;
|
||||
this.index = table.length;
|
||||
}
|
||||
|
||||
public boolean hasMoreElements() {
|
||||
if (entry != null) {
|
||||
return true;
|
||||
}
|
||||
while (index-- > 0) {
|
||||
if ((entry = table[index]) != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Object nextElement() {
|
||||
if (entry == null) {
|
||||
while ((index-- > 0) && ((entry = table[index]) == null));
|
||||
}
|
||||
if (entry != null) {
|
||||
HashtableEntry e = entry;
|
||||
entry = e.next;
|
||||
return keys ? e.key : e.value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, 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
|
||||
*
|
||||
@ -24,14 +24,15 @@
|
||||
|
||||
package com.sun.org.apache.xalan.internal.xsltc.trax;
|
||||
|
||||
import com.sun.org.apache.xalan.internal.xsltc.dom.SAXImpl;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary;
|
||||
import java.io.IOException;
|
||||
import java.util.Hashtable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.DTDHandler;
|
||||
import org.xml.sax.EntityResolver;
|
||||
@ -44,8 +45,6 @@ import org.xml.sax.SAXNotSupportedException;
|
||||
import org.xml.sax.XMLReader;
|
||||
import org.xml.sax.ext.LexicalHandler;
|
||||
import org.xml.sax.helpers.AttributesImpl;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.dom.SAXImpl;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.BasisLibrary;
|
||||
|
||||
/**
|
||||
* @author G. Todd Miller
|
||||
@ -59,7 +58,7 @@ public class DOM2SAX implements XMLReader, Locator {
|
||||
private ContentHandler _sax = null;
|
||||
private LexicalHandler _lex = null;
|
||||
private SAXImpl _saxImpl = null;
|
||||
private Hashtable _nsPrefixes = new Hashtable();
|
||||
private Map<String, Stack> _nsPrefixes = new HashMap<>();
|
||||
|
||||
public DOM2SAX(Node root) {
|
||||
_dom = root;
|
||||
@ -91,7 +90,7 @@ public class DOM2SAX implements XMLReader, Locator {
|
||||
throws SAXException
|
||||
{
|
||||
boolean pushed = true;
|
||||
Stack uriStack = (Stack) _nsPrefixes.get(prefix);
|
||||
Stack uriStack = _nsPrefixes.get(prefix);
|
||||
|
||||
if (uriStack != null) {
|
||||
if (uriStack.isEmpty()) {
|
||||
@ -124,7 +123,7 @@ public class DOM2SAX implements XMLReader, Locator {
|
||||
private void endPrefixMapping(String prefix)
|
||||
throws SAXException
|
||||
{
|
||||
final Stack uriStack = (Stack) _nsPrefixes.get(prefix);
|
||||
final Stack uriStack = _nsPrefixes.get(prefix);
|
||||
|
||||
if (uriStack != null) {
|
||||
_sax.endPrefixMapping(prefix);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2015, 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
|
||||
@ -75,7 +75,6 @@ public class StAXEvent2SAX implements XMLReader, Locator {
|
||||
private ContentHandler _sax = null;
|
||||
private LexicalHandler _lex = null;
|
||||
private SAXImpl _saxImpl = null;
|
||||
//private Hashtable _nsPrefixes = new Hashtable();
|
||||
private String version = null;
|
||||
private String encoding = null;
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2015, 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
|
||||
@ -26,11 +26,6 @@
|
||||
package com.sun.org.apache.xalan.internal.xsltc.trax;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Stack;
|
||||
import java.util.Vector;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.DTDHandler;
|
||||
@ -53,14 +48,6 @@ import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.XMLStreamConstants;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.events.Attribute;
|
||||
import javax.xml.stream.events.Characters;
|
||||
import javax.xml.stream.events.EndElement;
|
||||
import javax.xml.stream.events.Namespace;
|
||||
import javax.xml.stream.events.ProcessingInstruction;
|
||||
import javax.xml.stream.events.StartElement;
|
||||
import javax.xml.stream.events.StartDocument;
|
||||
import javax.xml.stream.events.XMLEvent;
|
||||
|
||||
|
||||
|
||||
@ -80,7 +67,6 @@ public class StAXStream2SAX implements XMLReader, Locator {
|
||||
private ContentHandler _sax = null;
|
||||
private LexicalHandler _lex = null;
|
||||
private SAXImpl _saxImpl = null;
|
||||
//private Hashtable _nsPrefixes = new Hashtable();
|
||||
|
||||
public StAXStream2SAX(XMLStreamReader staxSrc) {
|
||||
staxStreamReader = staxSrc;
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
* 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 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
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@ -30,13 +30,15 @@ import com.sun.org.apache.xalan.internal.xsltc.DOM;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.Translet;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
|
||||
import java.io.IOException;
|
||||
import java.io.NotSerializableException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.ObjectStreamField;
|
||||
import java.io.Serializable;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import javax.xml.XMLConstants;
|
||||
@ -89,7 +91,7 @@ public final class TemplatesImpl implements Templates, Serializable {
|
||||
/**
|
||||
* Contains the list of auxiliary class definitions.
|
||||
*/
|
||||
private Hashtable _auxClasses = null;
|
||||
private transient Map<String, Class<?>> _auxClasses = null;
|
||||
|
||||
/**
|
||||
* Output properties of this translet.
|
||||
@ -122,19 +124,39 @@ public final class TemplatesImpl implements Templates, Serializable {
|
||||
*/
|
||||
private transient TransformerFactoryImpl _tfactory = null;
|
||||
|
||||
private boolean _useServicesMechanism;
|
||||
/**
|
||||
* A flag to determine whether the Service Mechanism is used
|
||||
*/
|
||||
private transient boolean _useServicesMechanism;
|
||||
|
||||
/**
|
||||
* protocols allowed for external references set by the stylesheet processing instruction, Import and Include element.
|
||||
*/
|
||||
private String _accessExternalStylesheet = XalanConstants.EXTERNAL_ACCESS_DEFAULT;
|
||||
private transient String _accessExternalStylesheet = XalanConstants.EXTERNAL_ACCESS_DEFAULT;
|
||||
|
||||
/**
|
||||
* @serialField _name String The Name of the main class
|
||||
* @serialField _bytecodes byte[][] Class definition
|
||||
* @serialField _class Class[] The translet class definition(s).
|
||||
* @serialField _transletIndex int The index of the main translet class
|
||||
* @serialField _outputProperties Properties Output properties of this translet.
|
||||
* @serialField _indentNumber int Number of spaces to add for output indentation.
|
||||
*/
|
||||
private static final ObjectStreamField[] serialPersistentFields =
|
||||
new ObjectStreamField[] {
|
||||
new ObjectStreamField("_name", String.class),
|
||||
new ObjectStreamField("_bytecodes", byte[][].class),
|
||||
new ObjectStreamField("_class", Class[].class),
|
||||
new ObjectStreamField("_transletIndex", int.class),
|
||||
new ObjectStreamField("_outputProperties", Properties.class),
|
||||
new ObjectStreamField("_indentNumber", int.class),
|
||||
};
|
||||
|
||||
static final class TransletClassLoader extends ClassLoader {
|
||||
|
||||
private final Map<String,Class> _loadedExternalExtensionFunctions;
|
||||
|
||||
TransletClassLoader(ClassLoader parent) {
|
||||
super(parent);
|
||||
TransletClassLoader(ClassLoader parent) {
|
||||
super(parent);
|
||||
_loadedExternalExtensionFunctions = null;
|
||||
}
|
||||
|
||||
@ -154,7 +176,7 @@ public final class TemplatesImpl implements Templates, Serializable {
|
||||
ret = super.loadClass(name);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Access to final protected superclass member from outer class.
|
||||
@ -214,6 +236,7 @@ public final class TemplatesImpl implements Templates, Serializable {
|
||||
* if yes then we need to deserialize the URIResolver
|
||||
* Fix for bugzilla bug 22438
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private void readObject(ObjectInputStream is)
|
||||
throws IOException, ClassNotFoundException
|
||||
{
|
||||
@ -226,7 +249,16 @@ public final class TemplatesImpl implements Templates, Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
is.defaultReadObject();
|
||||
// We have to read serialized fields first.
|
||||
ObjectInputStream.GetField gf = is.readFields();
|
||||
_name = (String)gf.get("_name", null);
|
||||
_bytecodes = (byte[][])gf.get("_bytecodes", null);
|
||||
_class = (Class[])gf.get("_class", null);
|
||||
_transletIndex = gf.get("_transletIndex", -1);
|
||||
|
||||
_outputProperties = (Properties)gf.get("_outputProperties", null);
|
||||
_indentNumber = gf.get("_indentNumber", 0);
|
||||
|
||||
if (is.readBoolean()) {
|
||||
_uriResolver = (URIResolver) is.readObject();
|
||||
}
|
||||
@ -242,7 +274,22 @@ public final class TemplatesImpl implements Templates, Serializable {
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream os)
|
||||
throws IOException, ClassNotFoundException {
|
||||
os.defaultWriteObject();
|
||||
if (_auxClasses != null) {
|
||||
//throw with the same message as when Hashtable was used for compatibility.
|
||||
throw new NotSerializableException(
|
||||
"com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable");
|
||||
}
|
||||
|
||||
// Write serialized fields
|
||||
ObjectOutputStream.PutField pf = os.putFields();
|
||||
pf.put("_name", _name);
|
||||
pf.put("_bytecodes", _bytecodes);
|
||||
pf.put("_class", _class);
|
||||
pf.put("_transletIndex", _transletIndex);
|
||||
pf.put("_outputProperties", _outputProperties);
|
||||
pf.put("_indentNumber", _indentNumber);
|
||||
os.writeFields();
|
||||
|
||||
if (_uriResolver instanceof Serializable) {
|
||||
os.writeBoolean(true);
|
||||
os.writeObject((Serializable) _uriResolver);
|
||||
@ -360,7 +407,7 @@ public final class TemplatesImpl implements Templates, Serializable {
|
||||
_class = new Class[classCount];
|
||||
|
||||
if (classCount > 1) {
|
||||
_auxClasses = new Hashtable();
|
||||
_auxClasses = new HashMap<>();
|
||||
}
|
||||
|
||||
for (int i = 0; i < classCount; i++) {
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2007, 2015, 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
|
||||
*
|
||||
@ -49,7 +49,6 @@ import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Vector;
|
||||
@ -146,13 +145,13 @@ public class TransformerFactoryImpl
|
||||
private String _jarFileName = null;
|
||||
|
||||
/**
|
||||
* This Hashtable is used to store parameters for locating
|
||||
* This Map is used to store parameters for locating
|
||||
* <?xml-stylesheet ...?> processing instructions in XML docs.
|
||||
*/
|
||||
private Hashtable _piParams = null;
|
||||
private Map<Source, PIParamWrapper> _piParams = null;
|
||||
|
||||
/**
|
||||
* The above hashtable stores objects of this class.
|
||||
* The above Map stores objects of this class.
|
||||
*/
|
||||
private static class PIParamWrapper {
|
||||
public String _media = null;
|
||||
@ -935,7 +934,7 @@ public class TransformerFactoryImpl
|
||||
// <?xml-stylesheet ...?> PI in an XML input document
|
||||
if ((_piParams != null) && (_piParams.get(source) != null)) {
|
||||
// Get the parameters for this Source object
|
||||
PIParamWrapper p = (PIParamWrapper)_piParams.get(source);
|
||||
PIParamWrapper p = _piParams.get(source);
|
||||
// Pass them on to the compiler (which will pass then to the parser)
|
||||
if (p != null) {
|
||||
xsltc.setPIParameters(p._media, p._title, p._charset);
|
||||
|
||||
@ -1,15 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2007, 2015, 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
|
||||
*
|
||||
@ -28,6 +26,22 @@ package com.sun.org.apache.xalan.internal.xsltc.trax;
|
||||
import com.sun.org.apache.xalan.internal.XalanConstants;
|
||||
import com.sun.org.apache.xalan.internal.utils.FactoryImpl;
|
||||
import com.sun.org.apache.xalan.internal.utils.XMLSecurityManager;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.DOM;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.DOMCache;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.StripFilter;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.Translet;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.TransletException;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.dom.DOMWSFilter;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.dom.SAXImpl;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.output.TransletOutputHandlerFactory;
|
||||
import com.sun.org.apache.xml.internal.dtm.DTMWSFilter;
|
||||
import com.sun.org.apache.xml.internal.serializer.OutputPropertiesFactory;
|
||||
import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
|
||||
import com.sun.org.apache.xml.internal.utils.SystemIDResolver;
|
||||
import com.sun.org.apache.xml.internal.utils.XMLReaderManager;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@ -39,12 +53,13 @@ import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.UnknownServiceException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.ArrayList;
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
@ -65,29 +80,6 @@ import javax.xml.transform.stax.StAXResult;
|
||||
import javax.xml.transform.stax.StAXSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
import javax.xml.XMLConstants;
|
||||
|
||||
import com.sun.org.apache.xml.internal.utils.SystemIDResolver;
|
||||
|
||||
import com.sun.org.apache.xalan.internal.xsltc.DOM;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.DOMCache;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.DOMEnhancedForDTM;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.StripFilter;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.Translet;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.TransletException;
|
||||
import com.sun.org.apache.xml.internal.serializer.OutputPropertiesFactory;
|
||||
import com.sun.org.apache.xml.internal.serializer.SerializationHandler;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.util.ErrorMsg;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.dom.DOMWSFilter;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.dom.SAXImpl;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable;
|
||||
import com.sun.org.apache.xalan.internal.xsltc.runtime.output.TransletOutputHandlerFactory;
|
||||
|
||||
import com.sun.org.apache.xml.internal.dtm.DTMWSFilter;
|
||||
import com.sun.org.apache.xml.internal.utils.XMLReaderManager;
|
||||
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
@ -219,11 +211,11 @@ public final class TransformerImpl extends Transformer
|
||||
|
||||
private XMLSecurityManager _securityManager;
|
||||
/**
|
||||
* A hashtable to store parameters for the identity transform. These
|
||||
* A map to store parameters for the identity transform. These
|
||||
* are not needed during the transformation, but we must keep track of
|
||||
* them to be fully complaint with the JAXP API.
|
||||
*/
|
||||
private Hashtable _parameters = null;
|
||||
private Map<String, Object> _parameters = null;
|
||||
|
||||
/**
|
||||
* This class wraps an ErrorListener into a MessageHandler in order to
|
||||
@ -828,31 +820,6 @@ public final class TransformerImpl extends Transformer
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The translet stores all CDATA sections set in the <xsl:output> element
|
||||
* in a Hashtable. This method will re-construct the whitespace separated
|
||||
* list of elements given in the <xsl:output> element.
|
||||
*/
|
||||
private String makeCDATAString(Hashtable cdata) {
|
||||
// Return a 'null' string if no CDATA section elements were specified
|
||||
if (cdata == null) return null;
|
||||
|
||||
final StringBuilder result = new StringBuilder();
|
||||
|
||||
// Get an enumeration of all the elements in the hashtable
|
||||
Enumeration elements = cdata.keys();
|
||||
if (elements.hasMoreElements()) {
|
||||
result.append((String)elements.nextElement());
|
||||
while (elements.hasMoreElements()) {
|
||||
String element = (String)elements.nextElement();
|
||||
result.append(' ');
|
||||
result.append(element);
|
||||
}
|
||||
}
|
||||
|
||||
return(result.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements JAXP's Transformer.getOutputProperties().
|
||||
* Returns a copy of the output properties for the transformation. This is
|
||||
@ -1226,7 +1193,7 @@ public final class TransformerImpl extends Transformer
|
||||
|
||||
if (_isIdentity) {
|
||||
if (_parameters == null) {
|
||||
_parameters = new Hashtable();
|
||||
_parameters = new HashMap<>();
|
||||
}
|
||||
_parameters.put(name, value);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2002,2004,2005 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
|
||||
*
|
||||
@ -21,7 +21,7 @@
|
||||
package com.sun.org.apache.xerces.internal.dom;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import java.util.HashMap;
|
||||
import org.w3c.dom.DOMImplementation;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
@ -2056,9 +2056,9 @@ public class DeferredDocumentImpl
|
||||
element+')');
|
||||
}
|
||||
|
||||
// create hashtable
|
||||
// create Map
|
||||
if (identifiers == null) {
|
||||
identifiers = new java.util.Hashtable();
|
||||
identifiers = new HashMap<>();
|
||||
}
|
||||
|
||||
// save ID and its associated element
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2001,2002,2004,2005 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
|
||||
*
|
||||
@ -20,13 +20,19 @@
|
||||
|
||||
package com.sun.org.apache.xerces.internal.dom;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
|
||||
import com.sun.org.apache.xerces.internal.dom.events.EventImpl;
|
||||
import com.sun.org.apache.xerces.internal.dom.events.MutationEventImpl;
|
||||
import org.w3c.dom.UserDataHandler;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.ObjectStreamField;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.DOMImplementation;
|
||||
@ -34,6 +40,7 @@ import org.w3c.dom.DocumentType;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.UserDataHandler;
|
||||
import org.w3c.dom.events.DocumentEvent;
|
||||
import org.w3c.dom.events.Event;
|
||||
import org.w3c.dom.events.EventException;
|
||||
@ -95,18 +102,33 @@ public class DocumentImpl
|
||||
|
||||
/** Iterators */
|
||||
// REVISIT: Should this be transient? -Ac
|
||||
protected Vector iterators;
|
||||
protected List<NodeIterator> iterators;
|
||||
|
||||
/** Ranges */
|
||||
// REVISIT: Should this be transient? -Ac
|
||||
protected Vector ranges;
|
||||
protected List<Range> ranges;
|
||||
|
||||
/** Table for event listeners registered to this document nodes. */
|
||||
protected Hashtable eventListeners;
|
||||
protected Map<NodeImpl, List<LEntry>> eventListeners;
|
||||
|
||||
/** Bypass mutation events firing. */
|
||||
protected boolean mutationEvents = false;
|
||||
|
||||
|
||||
/**
|
||||
* @serialField iterators Vector Node iterators
|
||||
* @serialField ranges Vector ranges
|
||||
* @serialField eventListeners Hashtable Event listeners
|
||||
* @serialField mutationEvents boolean Bypass mutation events firing
|
||||
*/
|
||||
private static final ObjectStreamField[] serialPersistentFields =
|
||||
new ObjectStreamField[] {
|
||||
new ObjectStreamField("iterators", Vector.class),
|
||||
new ObjectStreamField("ranges", Vector.class),
|
||||
new ObjectStreamField("eventListeners", Hashtable.class),
|
||||
new ObjectStreamField("mutationEvents", boolean.class),
|
||||
};
|
||||
|
||||
//
|
||||
// Constructors
|
||||
//
|
||||
@ -226,10 +248,10 @@ public class DocumentImpl
|
||||
filter,
|
||||
entityReferenceExpansion);
|
||||
if (iterators == null) {
|
||||
iterators = new Vector();
|
||||
iterators = new ArrayList<>();
|
||||
}
|
||||
|
||||
iterators.addElement(iterator);
|
||||
iterators.add(iterator);
|
||||
|
||||
return iterator;
|
||||
}
|
||||
@ -286,7 +308,7 @@ public class DocumentImpl
|
||||
if (nodeIterator == null) return;
|
||||
if (iterators == null) return;
|
||||
|
||||
iterators.removeElement(nodeIterator);
|
||||
iterators.remove(nodeIterator);
|
||||
}
|
||||
|
||||
//
|
||||
@ -297,12 +319,11 @@ public class DocumentImpl
|
||||
public Range createRange() {
|
||||
|
||||
if (ranges == null) {
|
||||
ranges = new Vector();
|
||||
ranges = new ArrayList<>();
|
||||
}
|
||||
|
||||
Range range = new RangeImpl(this);
|
||||
|
||||
ranges.addElement(range);
|
||||
ranges.add(range);
|
||||
|
||||
return range;
|
||||
|
||||
@ -317,7 +338,7 @@ public class DocumentImpl
|
||||
if (range == null) return;
|
||||
if (ranges == null) return;
|
||||
|
||||
ranges.removeElement(range);
|
||||
ranges.remove(range);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -329,7 +350,7 @@ public class DocumentImpl
|
||||
if (ranges != null) {
|
||||
int size = ranges.size();
|
||||
for (int i = 0; i != size; i++) {
|
||||
((RangeImpl)ranges.elementAt(i)).receiveReplacedText(node);
|
||||
((RangeImpl)ranges.get(i)).receiveReplacedText(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -343,7 +364,7 @@ public class DocumentImpl
|
||||
if (ranges != null) {
|
||||
int size = ranges.size();
|
||||
for (int i = 0; i != size; i++) {
|
||||
((RangeImpl)ranges.elementAt(i)).receiveDeletedText(node,
|
||||
((RangeImpl)ranges.get(i)).receiveDeletedText(node,
|
||||
offset, count);
|
||||
}
|
||||
}
|
||||
@ -358,7 +379,7 @@ public class DocumentImpl
|
||||
if (ranges != null) {
|
||||
int size = ranges.size();
|
||||
for (int i = 0; i != size; i++) {
|
||||
((RangeImpl)ranges.elementAt(i)).receiveInsertedText(node,
|
||||
((RangeImpl)ranges.get(i)).receiveInsertedText(node,
|
||||
offset, count);
|
||||
}
|
||||
}
|
||||
@ -373,7 +394,7 @@ public class DocumentImpl
|
||||
if (ranges != null) {
|
||||
int size = ranges.size();
|
||||
for (int i = 0; i != size; i++) {
|
||||
((RangeImpl)ranges.elementAt(i)).receiveSplitData(node,
|
||||
((RangeImpl)ranges.get(i)).receiveSplitData(node,
|
||||
newNode, offset);
|
||||
}
|
||||
}
|
||||
@ -436,9 +457,9 @@ public class DocumentImpl
|
||||
* node here won't be GC'ed as long as some listener is registered on it,
|
||||
* since the eventsListeners table will have a reference to the node.
|
||||
*/
|
||||
protected void setEventListeners(NodeImpl n, Vector listeners) {
|
||||
protected void setEventListeners(NodeImpl n, List<LEntry> listeners) {
|
||||
if (eventListeners == null) {
|
||||
eventListeners = new Hashtable();
|
||||
eventListeners = new HashMap<>();
|
||||
}
|
||||
if (listeners == null) {
|
||||
eventListeners.remove(n);
|
||||
@ -456,11 +477,11 @@ public class DocumentImpl
|
||||
/**
|
||||
* Retreive event listener registered on a given node
|
||||
*/
|
||||
protected Vector getEventListeners(NodeImpl n) {
|
||||
protected List getEventListeners(NodeImpl n) {
|
||||
if (eventListeners == null) {
|
||||
return null;
|
||||
}
|
||||
return (Vector) eventListeners.get(n);
|
||||
return eventListeners.get(n);
|
||||
}
|
||||
|
||||
//
|
||||
@ -514,6 +535,7 @@ public class DocumentImpl
|
||||
* @param useCapture True iff listener is registered on
|
||||
* capturing phase rather than at-target or bubbling
|
||||
*/
|
||||
@Override
|
||||
protected void addEventListener(NodeImpl node, String type,
|
||||
EventListener listener, boolean useCapture)
|
||||
{
|
||||
@ -526,12 +548,12 @@ public class DocumentImpl
|
||||
// Simplest way to code that is to zap the previous entry, if any.
|
||||
removeEventListener(node, type, listener, useCapture);
|
||||
|
||||
Vector nodeListeners = getEventListeners(node);
|
||||
List<LEntry> nodeListeners = getEventListeners(node);
|
||||
if(nodeListeners == null) {
|
||||
nodeListeners = new Vector();
|
||||
nodeListeners = new ArrayList<>();
|
||||
setEventListeners(node, nodeListeners);
|
||||
}
|
||||
nodeListeners.addElement(new LEntry(type, listener, useCapture));
|
||||
nodeListeners.add(new LEntry(type, listener, useCapture));
|
||||
|
||||
// Record active listener
|
||||
LCount lc = LCount.lookup(type);
|
||||
@ -557,6 +579,7 @@ public class DocumentImpl
|
||||
* @param useCapture True iff listener is registered on
|
||||
* capturing phase rather than at-target or bubbling
|
||||
*/
|
||||
@Override
|
||||
protected void removeEventListener(NodeImpl node, String type,
|
||||
EventListener listener,
|
||||
boolean useCapture)
|
||||
@ -564,7 +587,7 @@ public class DocumentImpl
|
||||
// If this couldn't be a valid listener registration, ignore request
|
||||
if (type == null || type.equals("") || listener == null)
|
||||
return;
|
||||
Vector nodeListeners = getEventListeners(node);
|
||||
List<LEntry> nodeListeners = getEventListeners(node);
|
||||
if (nodeListeners == null)
|
||||
return;
|
||||
|
||||
@ -572,12 +595,12 @@ public class DocumentImpl
|
||||
// each listener may be registered only once per type per phase.
|
||||
// count-down is OK for deletions!
|
||||
for (int i = nodeListeners.size() - 1; i >= 0; --i) {
|
||||
LEntry le = (LEntry) nodeListeners.elementAt(i);
|
||||
LEntry le = nodeListeners.get(i);
|
||||
if (le.useCapture == useCapture && le.listener == listener &&
|
||||
le.type.equals(type)) {
|
||||
nodeListeners.removeElementAt(i);
|
||||
nodeListeners.remove(i);
|
||||
// Storage management: Discard empty listener lists
|
||||
if (nodeListeners.size() == 0)
|
||||
if (nodeListeners.isEmpty())
|
||||
setEventListeners(node, null);
|
||||
|
||||
// Remove active listener
|
||||
@ -596,12 +619,13 @@ public class DocumentImpl
|
||||
}
|
||||
} // removeEventListener(NodeImpl,String,EventListener,boolean) :void
|
||||
|
||||
@Override
|
||||
protected void copyEventListeners(NodeImpl src, NodeImpl tgt) {
|
||||
Vector nodeListeners = getEventListeners(src);
|
||||
List<LEntry> nodeListeners = getEventListeners(src);
|
||||
if (nodeListeners == null) {
|
||||
return;
|
||||
}
|
||||
setEventListeners(tgt, (Vector) nodeListeners.clone());
|
||||
setEventListeners(tgt, new ArrayList<>(nodeListeners));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -654,6 +678,7 @@ public class DocumentImpl
|
||||
* @return true if the event's <code>preventDefault()</code>
|
||||
* method was invoked by an EventListener; otherwise false.
|
||||
*/
|
||||
@Override
|
||||
protected boolean dispatchEvent(NodeImpl node, Event event) {
|
||||
if (event == null) return false;
|
||||
|
||||
@ -690,11 +715,11 @@ public class DocumentImpl
|
||||
// is issued to the Element rather than the Attr
|
||||
// and causes a _second_ DOMSubtreeModified in the Element's
|
||||
// tree.
|
||||
Vector pv = new Vector(10,10);
|
||||
List<Node> pv = new ArrayList<>(10);
|
||||
Node p = node;
|
||||
Node n = p.getParentNode();
|
||||
while (n != null) {
|
||||
pv.addElement(n);
|
||||
pv.add(n);
|
||||
p = n;
|
||||
n = n.getParentNode();
|
||||
}
|
||||
@ -709,15 +734,15 @@ public class DocumentImpl
|
||||
break; // Someone set the flag. Phase ends.
|
||||
|
||||
// Handle all capturing listeners on this node
|
||||
NodeImpl nn = (NodeImpl) pv.elementAt(j);
|
||||
NodeImpl nn = (NodeImpl) pv.get(j);
|
||||
evt.currentTarget = nn;
|
||||
Vector nodeListeners = getEventListeners(nn);
|
||||
List<LEntry> nodeListeners = getEventListeners(nn);
|
||||
if (nodeListeners != null) {
|
||||
Vector nl = (Vector) nodeListeners.clone();
|
||||
List<LEntry> nl = (List)((ArrayList)nodeListeners).clone();
|
||||
// call listeners in the order in which they got registered
|
||||
int nlsize = nl.size();
|
||||
for (int i = 0; i < nlsize; i++) {
|
||||
LEntry le = (LEntry) nl.elementAt(i);
|
||||
LEntry le = nl.get(i);
|
||||
if (le.useCapture && le.type.equals(evt.type) &&
|
||||
nodeListeners.contains(le)) {
|
||||
try {
|
||||
@ -740,13 +765,13 @@ public class DocumentImpl
|
||||
// node are _not_ invoked, even during the capture phase.
|
||||
evt.eventPhase = Event.AT_TARGET;
|
||||
evt.currentTarget = node;
|
||||
Vector nodeListeners = getEventListeners(node);
|
||||
List<LEntry> nodeListeners = getEventListeners(node);
|
||||
if (!evt.stopPropagation && nodeListeners != null) {
|
||||
Vector nl = (Vector) nodeListeners.clone();
|
||||
List<LEntry> nl = (List)((ArrayList)nodeListeners).clone();
|
||||
// call listeners in the order in which they got registered
|
||||
int nlsize = nl.size();
|
||||
for (int i = 0; i < nlsize; i++) {
|
||||
LEntry le = (LEntry) nl.elementAt(i);
|
||||
LEntry le = (LEntry) nl.get(i);
|
||||
if (!le.useCapture && le.type.equals(evt.type) &&
|
||||
nodeListeners.contains(le)) {
|
||||
try {
|
||||
@ -771,16 +796,16 @@ public class DocumentImpl
|
||||
break; // Someone set the flag. Phase ends.
|
||||
|
||||
// Handle all bubbling listeners on this node
|
||||
NodeImpl nn = (NodeImpl) pv.elementAt(j);
|
||||
NodeImpl nn = (NodeImpl) pv.get(j);
|
||||
evt.currentTarget = nn;
|
||||
nodeListeners = getEventListeners(nn);
|
||||
if (nodeListeners != null) {
|
||||
Vector nl = (Vector) nodeListeners.clone();
|
||||
List<LEntry> nl = (List)((ArrayList)nodeListeners).clone();
|
||||
// call listeners in the order in which they got
|
||||
// registered
|
||||
int nlsize = nl.size();
|
||||
for (int i = 0; i < nlsize; i++) {
|
||||
LEntry le = (LEntry) nl.elementAt(i);
|
||||
LEntry le = nl.get(i);
|
||||
if (!le.useCapture && le.type.equals(evt.type) &&
|
||||
nodeListeners.contains(le)) {
|
||||
try {
|
||||
@ -1117,7 +1142,7 @@ public class DocumentImpl
|
||||
if (ranges != null) {
|
||||
int size = ranges.size();
|
||||
for (int i = 0; i != size; i++) {
|
||||
((RangeImpl)ranges.elementAt(i)).insertedNodeFromDOM(newInternal);
|
||||
((RangeImpl)ranges.get(i)).insertedNodeFromDOM(newInternal);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1131,7 +1156,7 @@ public class DocumentImpl
|
||||
if (iterators != null) {
|
||||
int size = iterators.size();
|
||||
for (int i = 0; i != size; i++) {
|
||||
((NodeIteratorImpl)iterators.elementAt(i)).removeNode(oldChild);
|
||||
((NodeIteratorImpl)iterators.get(i)).removeNode(oldChild);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1139,7 +1164,7 @@ public class DocumentImpl
|
||||
if (ranges != null) {
|
||||
int size = ranges.size();
|
||||
for (int i = 0; i != size; i++) {
|
||||
((RangeImpl)ranges.elementAt(i)).removeNode(oldChild);
|
||||
((RangeImpl)ranges.get(i)).removeNode(oldChild);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1301,4 +1326,53 @@ public class DocumentImpl
|
||||
// REVISIT: To be implemented!!!
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @serialData Serialized fields. Convert Maps to Hashtables and Lists
|
||||
* to Vectors for backward compatibility.
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream out) throws IOException {
|
||||
// Convert Maps to Hashtables, Lists to Vectors
|
||||
Vector<NodeIterator> it = (iterators == null)? null : new Vector<>(iterators);
|
||||
Vector<Range> r = (ranges == null)? null : new Vector<>(ranges);
|
||||
|
||||
Hashtable<NodeImpl, Vector<LEntry>> el = null;
|
||||
if (eventListeners != null) {
|
||||
el = new Hashtable<>();
|
||||
for (Map.Entry<NodeImpl, List<LEntry>> e : eventListeners.entrySet()) {
|
||||
el.put(e.getKey(), new Vector<>(e.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
// Write serialized fields
|
||||
ObjectOutputStream.PutField pf = out.putFields();
|
||||
pf.put("iterators", it);
|
||||
pf.put("ranges", r);
|
||||
pf.put("eventListeners", el);
|
||||
pf.put("mutationEvents", mutationEvents);
|
||||
out.writeFields();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void readObject(ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException {
|
||||
// We have to read serialized fields first.
|
||||
ObjectInputStream.GetField gf = in.readFields();
|
||||
Vector<NodeIterator> it = (Vector<NodeIterator>)gf.get("iterators", null);
|
||||
Vector<Range> r = (Vector<Range>)gf.get("ranges", null);
|
||||
Hashtable<NodeImpl, Vector<LEntry>> el =
|
||||
(Hashtable<NodeImpl, Vector<LEntry>>)gf.get("eventListeners", null);
|
||||
|
||||
mutationEvents = gf.get("mutationEvents", false);
|
||||
|
||||
//convert Hashtables back to HashMaps and Vectors to Lists
|
||||
if (it != null) iterators = new ArrayList<>(it);
|
||||
if (r != null) ranges = new ArrayList<>(r);
|
||||
if (el != null) {
|
||||
eventListeners = new HashMap<>();
|
||||
for (Map.Entry<NodeImpl, Vector<LEntry>> e : el.entrySet()) {
|
||||
eventListeners.put(e.getKey(), new ArrayList<>(e.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
} // class DocumentImpl
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2002,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
|
||||
*
|
||||
@ -20,11 +20,17 @@
|
||||
|
||||
package com.sun.org.apache.xerces.internal.dom;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.ObjectStreamField;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.DocumentType;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import java.util.Hashtable;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.UserDataHandler;
|
||||
|
||||
/**
|
||||
@ -95,10 +101,37 @@ public class DocumentTypeImpl
|
||||
// a number, on demand, for ordering purposes for compareDocumentPosition
|
||||
private int doctypeNumber=0;
|
||||
|
||||
private Map<String, UserDataRecord> userData = null;
|
||||
|
||||
|
||||
/**
|
||||
* @serialField name String document type name
|
||||
* @serialField entities NamedNodeMapImpl entities
|
||||
* @serialField notations NamedNodeMapImpl notations
|
||||
* @serialField elements NamedNodeMapImpl elements
|
||||
* @serialField publicID String support public ID
|
||||
* @serialField systemID String support system ID
|
||||
* @serialField internalSubset String support internal subset
|
||||
* @serialField doctypeNumber int Doctype number
|
||||
* @serialField userData Hashtable user data
|
||||
*/
|
||||
private static final ObjectStreamField[] serialPersistentFields =
|
||||
new ObjectStreamField[] {
|
||||
new ObjectStreamField("name", String.class),
|
||||
new ObjectStreamField("entities", NamedNodeMapImpl.class),
|
||||
new ObjectStreamField("notations", NamedNodeMapImpl.class),
|
||||
new ObjectStreamField("elements", NamedNodeMapImpl.class),
|
||||
new ObjectStreamField("publicID", String.class),
|
||||
new ObjectStreamField("systemID", String.class),
|
||||
new ObjectStreamField("internalSubset", String.class),
|
||||
new ObjectStreamField("doctypeNumber", int.class),
|
||||
new ObjectStreamField("userData", Hashtable.class),
|
||||
};
|
||||
|
||||
//
|
||||
// Constructors
|
||||
//
|
||||
private Hashtable userData = null;
|
||||
|
||||
/** Factory method for creating a document type node. */
|
||||
public DocumentTypeImpl(CoreDocumentImpl ownerDocument, String name) {
|
||||
super(ownerDocument);
|
||||
@ -445,22 +478,20 @@ public class DocumentTypeImpl
|
||||
public Object setUserData(String key,
|
||||
Object data, UserDataHandler handler) {
|
||||
if(userData == null)
|
||||
userData = new Hashtable();
|
||||
userData = new HashMap<>();
|
||||
if (data == null) {
|
||||
if (userData != null) {
|
||||
Object o = userData.remove(key);
|
||||
if (o != null) {
|
||||
UserDataRecord r = (UserDataRecord) o;
|
||||
return r.fData;
|
||||
UserDataRecord udr = userData.remove(key);
|
||||
if (udr != null) {
|
||||
return udr.fData;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
Object o = userData.put(key, new UserDataRecord(data, handler));
|
||||
if (o != null) {
|
||||
UserDataRecord r = (UserDataRecord) o;
|
||||
return r.fData;
|
||||
UserDataRecord udr = userData.put(key, new UserDataRecord(data, handler));
|
||||
if (udr != null) {
|
||||
return udr.fData;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -470,16 +501,58 @@ public class DocumentTypeImpl
|
||||
if (userData == null) {
|
||||
return null;
|
||||
}
|
||||
Object o = userData.get(key);
|
||||
if (o != null) {
|
||||
UserDataRecord r = (UserDataRecord) o;
|
||||
return r.fData;
|
||||
UserDataRecord udr = userData.get(key);
|
||||
if (udr != null) {
|
||||
return udr.fData;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Hashtable getUserDataRecord(){
|
||||
@Override
|
||||
protected Map<String, UserDataRecord> getUserDataRecord(){
|
||||
return userData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @serialData Serialized fields. Convert Map to Hashtable for backward
|
||||
* compatibility.
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream out) throws IOException {
|
||||
// Convert the HashMap to Hashtable
|
||||
Hashtable<String, UserDataRecord> ud = (userData == null)? null : new Hashtable<>(userData);
|
||||
|
||||
// Write serialized fields
|
||||
ObjectOutputStream.PutField pf = out.putFields();
|
||||
pf.put("name", name);
|
||||
pf.put("entities", entities);
|
||||
pf.put("notations", notations);
|
||||
pf.put("elements", elements);
|
||||
pf.put("publicID", publicID);
|
||||
pf.put("systemID", systemID);
|
||||
pf.put("internalSubset", internalSubset);
|
||||
pf.put("doctypeNumber", doctypeNumber);
|
||||
pf.put("userData", ud);
|
||||
out.writeFields();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void readObject(ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException {
|
||||
// We have to read serialized fields first.
|
||||
ObjectInputStream.GetField gf = in.readFields();
|
||||
name = (String)gf.get("name", null);
|
||||
entities = (NamedNodeMapImpl)gf.get("entities", null);
|
||||
notations = (NamedNodeMapImpl)gf.get("notations", null);
|
||||
elements = (NamedNodeMapImpl)gf.get("elements", null);
|
||||
publicID = (String)gf.get("publicID", null);
|
||||
systemID = (String)gf.get("systemID", null);
|
||||
internalSubset = (String)gf.get("internalSubset", null);
|
||||
doctypeNumber = gf.get("doctypeNumber", 0);
|
||||
|
||||
Hashtable<String, UserDataRecord> ud =
|
||||
(Hashtable<String, UserDataRecord>)gf.get("userData", null);
|
||||
|
||||
//convert the Hashtable back to HashMap
|
||||
if (ud != null) userData = new HashMap<>(ud);
|
||||
}
|
||||
} // class DocumentTypeImpl
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2002,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
|
||||
*
|
||||
@ -22,20 +22,13 @@ package com.sun.org.apache.xerces.internal.dom;
|
||||
|
||||
/** Internal class LCount is used to track the number of
|
||||
listeners registered for a given event name, as an entry
|
||||
in a global hashtable. This should allow us to avoid generating,
|
||||
or discard, events for which no listeners are registered.
|
||||
in a global Map. This should allow us to avoid generating,
|
||||
or discarding, events for which no listeners are registered.
|
||||
|
||||
***** There should undoubtedly be methods here to manipulate
|
||||
this table. At the moment that code's residing in NodeImpl.
|
||||
Move it when we have a chance to do so. Sorry; we were
|
||||
rushed.
|
||||
|
||||
???? CONCERN: Hashtables are known to be "overserialized" in
|
||||
current versions of Java. That may impact performance.
|
||||
|
||||
???? CONCERN: The hashtable should probably be a per-document object.
|
||||
Finer granularity would be even better, but would cost more cycles to
|
||||
resolve and might not save enough event traffic to be worth the investment.
|
||||
*/
|
||||
/**
|
||||
* @xerces.internal
|
||||
@ -44,14 +37,11 @@ package com.sun.org.apache.xerces.internal.dom;
|
||||
|
||||
class LCount
|
||||
{
|
||||
static java.util.Hashtable lCounts=new java.util.Hashtable();
|
||||
static final java.util.Map<String, LCount> lCounts=new java.util.concurrent.ConcurrentHashMap<>();
|
||||
public int captures=0,bubbles=0,defaults, total=0;
|
||||
|
||||
static LCount lookup(String evtName)
|
||||
{
|
||||
LCount lc=(LCount)lCounts.get(evtName);
|
||||
if(lc==null)
|
||||
lCounts.put(evtName,(lc=new LCount()));
|
||||
return lc;
|
||||
return lCounts.computeIfAbsent(evtName, (key) -> new LCount());
|
||||
}
|
||||
} // class LCount
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2002,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
|
||||
*
|
||||
@ -23,15 +23,14 @@ package com.sun.org.apache.xerces.internal.dom;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import org.w3c.dom.UserDataHandler;
|
||||
import java.util.Map;
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.DocumentType;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.w3c.dom.UserDataHandler;
|
||||
import org.w3c.dom.events.Event;
|
||||
import org.w3c.dom.events.EventListener;
|
||||
import org.w3c.dom.events.EventTarget;
|
||||
@ -1793,7 +1792,7 @@ public abstract class NodeImpl
|
||||
return ownerDocument().getUserData(this, key);
|
||||
}
|
||||
|
||||
protected Hashtable getUserDataRecord(){
|
||||
protected Map<String, ParentNode.UserDataRecord> getUserDataRecord(){
|
||||
return ownerDocument().getUserDataRecord(this);
|
||||
}
|
||||
|
||||
@ -1845,7 +1844,7 @@ public abstract class NodeImpl
|
||||
* NON-DOM: As an alternative to subclassing the DOM, this implementation
|
||||
* has been extended with the ability to attach an object to each node.
|
||||
* (If you need multiple objects, you can attach a collection such as a
|
||||
* vector or hashtable, then attach your application information to that.)
|
||||
* List or Map, then attach your application information to that.)
|
||||
* <p><b>Important Note:</b> You are responsible for removing references
|
||||
* to your data on nodes that are no longer used. Failure to do so will
|
||||
* prevent the nodes, your data is attached to, to be garbage collected
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2002,2004,2005 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
|
||||
*
|
||||
@ -1022,7 +1022,7 @@ public abstract class ParentNode
|
||||
/*
|
||||
* a class to store some user data along with its handler
|
||||
*/
|
||||
class UserDataRecord implements Serializable {
|
||||
protected class UserDataRecord implements Serializable {
|
||||
/** Serialization version. */
|
||||
private static final long serialVersionUID = 3258126977134310455L;
|
||||
|
||||
|
||||
@ -331,7 +331,7 @@ public class XML11DocumentScannerImpl
|
||||
new Object[]{entityName});
|
||||
}
|
||||
}
|
||||
fEntityManager.startEntity(entityName, true);
|
||||
fEntityManager.startEntity(false, entityName, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,62 +1,21 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The Apache Software License, Version 1.1
|
||||
* Copyright 2005 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
|
||||
*
|
||||
* Copyright (c) 1999-2002 The Apache Software Foundation.
|
||||
* All rights reserved.
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The end-user documentation included with the redistribution,
|
||||
* if any, must include the following acknowledgment:
|
||||
* "This product includes software developed by the
|
||||
* Apache Software Foundation (http://www.apache.org/)."
|
||||
* Alternately, this acknowledgment may appear in the software itself,
|
||||
* if and wherever such third-party acknowledgments normally appear.
|
||||
*
|
||||
* 4. The names "Xerces" and "Apache Software Foundation" must
|
||||
* not be used to endorse or promote products derived from this
|
||||
* software without prior written permission. For written
|
||||
* permission, please contact apache@apache.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "Apache",
|
||||
* nor may "Apache" appear in their name, without prior written
|
||||
* permission of the Apache Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation and was
|
||||
* originally based on software copyright (c) 1999, International
|
||||
* Business Machines, Inc., http://www.apache.org. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.sun.org.apache.xerces.internal.impl;
|
||||
@ -65,6 +24,8 @@ import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
|
||||
import com.sun.org.apache.xerces.internal.util.XML11Char;
|
||||
import com.sun.org.apache.xerces.internal.util.XMLChar;
|
||||
import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
|
||||
import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
|
||||
import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager.Limit;
|
||||
import com.sun.org.apache.xerces.internal.xni.QName;
|
||||
import com.sun.org.apache.xerces.internal.xni.XMLString;
|
||||
import java.io.IOException;
|
||||
@ -689,9 +650,13 @@ public class XML11EntityScanner
|
||||
break;
|
||||
}
|
||||
index = fCurrentEntity.position;
|
||||
//check prefix before further read
|
||||
checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, index - offset);
|
||||
}
|
||||
if (++fCurrentEntity.position == fCurrentEntity.count) {
|
||||
int length = fCurrentEntity.position - offset;
|
||||
//check localpart before loading more data
|
||||
checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, length - index - 1);
|
||||
invokeListeners(length);
|
||||
if (length == fCurrentEntity.ch.length) {
|
||||
// bad luck we have to resize our buffer
|
||||
@ -785,6 +750,8 @@ public class XML11EntityScanner
|
||||
offset, length);
|
||||
if (index != -1) {
|
||||
int prefixLength = index - offset;
|
||||
//check the result: prefix
|
||||
checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, prefixLength);
|
||||
prefix = fSymbolTable.addSymbol(fCurrentEntity.ch,
|
||||
offset, prefixLength);
|
||||
int len = length - prefixLength - 1;
|
||||
@ -797,12 +764,16 @@ public class XML11EntityScanner
|
||||
null,
|
||||
XMLErrorReporter.SEVERITY_FATAL_ERROR);
|
||||
}
|
||||
//check the result: localpart
|
||||
checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, index + 1, len);
|
||||
localpart = fSymbolTable.addSymbol(fCurrentEntity.ch,
|
||||
index + 1, len);
|
||||
|
||||
}
|
||||
else {
|
||||
localpart = rawname;
|
||||
//check the result: localpart
|
||||
checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, length);
|
||||
}
|
||||
qname.setValues(prefix, localpart, rawname, null);
|
||||
return true;
|
||||
@ -933,6 +904,9 @@ public class XML11EntityScanner
|
||||
}
|
||||
int length = fCurrentEntity.position - offset;
|
||||
fCurrentEntity.columnNumber += length - newlines;
|
||||
if (fCurrentEntity.reference) {
|
||||
checkLimit(Limit.TOTAL_ENTITY_SIZE_LIMIT, fCurrentEntity, offset, length);
|
||||
}
|
||||
content.setValues(fCurrentEntity.ch, offset, length);
|
||||
|
||||
// return next character
|
||||
|
||||
@ -1,62 +1,21 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The Apache Software License, Version 1.1
|
||||
* Copyright 2005 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
|
||||
*
|
||||
* Copyright (c) 1999-2003 The Apache Software Foundation.
|
||||
* All rights reserved.
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The end-user documentation included with the redistribution,
|
||||
* if any, must include the following acknowledgment:
|
||||
* "This product includes software developed by the
|
||||
* Apache Software Foundation (http://www.apache.org/)."
|
||||
* Alternately, this acknowledgment may appear in the software itself,
|
||||
* if and wherever such third-party acknowledgments normally appear.
|
||||
*
|
||||
* 4. The names "Xerces" and "Apache Software Foundation" must
|
||||
* not be used to endorse or promote products derived from this
|
||||
* software without prior written permission. For written
|
||||
* permission, please contact apache@apache.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "Apache",
|
||||
* nor may "Apache" appear in their name, without prior written
|
||||
* permission of the Apache Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation and was
|
||||
* originally based on software copyright (c) 2002, International
|
||||
* Business Machines, Inc., http://www.apache.org. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.sun.org.apache.xerces.internal.impl;
|
||||
@ -67,6 +26,7 @@ import com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidatorFilter;
|
||||
import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
|
||||
import com.sun.org.apache.xerces.internal.util.XMLAttributesImpl;
|
||||
import com.sun.org.apache.xerces.internal.util.XMLSymbols;
|
||||
import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
|
||||
import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
|
||||
import com.sun.org.apache.xerces.internal.xni.QName;
|
||||
import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
|
||||
@ -339,36 +299,37 @@ public class XML11NSDocumentScannerImpl extends XML11DocumentScannerImpl {
|
||||
}
|
||||
|
||||
// call handler
|
||||
if (empty) {
|
||||
//decrease the markup depth..
|
||||
fMarkupDepth--;
|
||||
|
||||
if (empty) {
|
||||
|
||||
//decrease the markup depth..
|
||||
fMarkupDepth--;
|
||||
|
||||
// check that this element was opened in the same entity
|
||||
if (fMarkupDepth < fEntityStack[fEntityDepth - 1]) {
|
||||
reportFatalError(
|
||||
"ElementEntityMismatch",
|
||||
new Object[] { fCurrentElement.rawname });
|
||||
}
|
||||
// check that this element was opened in the same entity
|
||||
if (fMarkupDepth < fEntityStack[fEntityDepth - 1]) {
|
||||
reportFatalError(
|
||||
"ElementEntityMismatch",
|
||||
new Object[] { fCurrentElement.rawname });
|
||||
}
|
||||
|
||||
if (fDocumentHandler != null) {
|
||||
fDocumentHandler.emptyElement(fElementQName, fAttributes, null);
|
||||
}
|
||||
|
||||
/*if (fBindNamespaces) {
|
||||
fNamespaceContext.popContext();
|
||||
}*/
|
||||
fScanEndElement = true;
|
||||
/*if (fBindNamespaces) {
|
||||
fNamespaceContext.popContext();
|
||||
}*/
|
||||
fScanEndElement = true;
|
||||
|
||||
//pop the element off the stack..
|
||||
fElementStack.popElement();
|
||||
} else {
|
||||
//pop the element off the stack..
|
||||
fElementStack.popElement();
|
||||
} else {
|
||||
if(dtdGrammarUtil != null) {
|
||||
dtdGrammarUtil.startElement(fElementQName, fAttributes);
|
||||
}
|
||||
|
||||
if(dtdGrammarUtil != null)
|
||||
dtdGrammarUtil.startElement(fElementQName, fAttributes);
|
||||
|
||||
if (fDocumentHandler != null)
|
||||
if (fDocumentHandler != null) {
|
||||
fDocumentHandler.startElement(fElementQName, fAttributes, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (DEBUG_START_END_ELEMENT)
|
||||
System.out.println("<<< scanStartElement(): " + empty);
|
||||
@ -678,7 +639,13 @@ public class XML11NSDocumentScannerImpl extends XML11DocumentScannerImpl {
|
||||
if (prefix == XMLSymbols.PREFIX_XMLNS
|
||||
|| prefix == XMLSymbols.EMPTY_STRING
|
||||
&& localpart == XMLSymbols.PREFIX_XMLNS) {
|
||||
|
||||
if (value.length() > fXMLNameLimit) {
|
||||
fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
|
||||
"MaxXMLNameLimit",
|
||||
new Object[]{value, value.length(), fXMLNameLimit,
|
||||
fSecurityManager.getStateLiteral(XMLSecurityManager.Limit.MAX_NAME_LIMIT)},
|
||||
XMLErrorReporter.SEVERITY_FATAL_ERROR);
|
||||
}
|
||||
// get the internalized value of this attribute
|
||||
String uri = fSymbolTable.addSymbol(value);
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -368,6 +368,8 @@ implements XMLDTDScanner, XMLComponent, XMLEntityHandler {
|
||||
}
|
||||
// we're done, set starting state for external subset
|
||||
setScannerState(SCANNER_STATE_TEXT_DECL);
|
||||
// we're done scanning DTD.
|
||||
fLimitAnalyzer.reset(XMLSecurityManager.Limit.TOTAL_ENTITY_SIZE_LIMIT);
|
||||
return false;
|
||||
}
|
||||
} while (complete);
|
||||
@ -377,6 +379,26 @@ implements XMLDTDScanner, XMLComponent, XMLEntityHandler {
|
||||
|
||||
} // scanDTDInternalSubset(boolean,boolean,boolean):boolean
|
||||
|
||||
/**
|
||||
* Skip the DTD if javax.xml.stream.supportDTD is false.
|
||||
*
|
||||
* @param supportDTD The value of the property javax.xml.stream.supportDTD.
|
||||
* @return true if DTD is skipped, false otherwise.
|
||||
* @throws java.io.IOException if i/o error occurs
|
||||
*/
|
||||
@Override
|
||||
public boolean skipDTD(boolean supportDTD) throws IOException {
|
||||
if (!supportDTD) {
|
||||
fStringBuffer.clear();
|
||||
if (!fEntityScanner.scanData("]", fStringBuffer)) {
|
||||
fEntityScanner.fCurrentEntity.position--;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// XMLComponent methods
|
||||
//
|
||||
@ -703,7 +725,7 @@ implements XMLDTDScanner, XMLComponent, XMLEntityHandler {
|
||||
fErrorReporter.reportError( XMLMessageFormatter.XML_DOMAIN,"EntityNotDeclared",
|
||||
new Object[]{name}, XMLErrorReporter.SEVERITY_ERROR);
|
||||
}
|
||||
fEntityManager.startEntity(fSymbolTable.addSymbol(pName),
|
||||
fEntityManager.startEntity(false, fSymbolTable.addSymbol(pName),
|
||||
literal);
|
||||
// if we actually got a new entity and it's external
|
||||
// parse text decl if there is any
|
||||
@ -1631,7 +1653,7 @@ implements XMLDTDScanner, XMLComponent, XMLEntityHandler {
|
||||
XMLString literal2 = fString;
|
||||
int countChar = 0;
|
||||
if (fLimitAnalyzer == null ) {
|
||||
fLimitAnalyzer = new XMLLimitAnalyzer();
|
||||
fLimitAnalyzer = fEntityManager.fLimitAnalyzer;
|
||||
}
|
||||
fLimitAnalyzer.startEntity(entityName);
|
||||
|
||||
@ -1639,9 +1661,7 @@ implements XMLDTDScanner, XMLComponent, XMLEntityHandler {
|
||||
fStringBuffer.clear();
|
||||
fStringBuffer2.clear();
|
||||
do {
|
||||
if (isPEDecl && fLimitAnalyzer != null) {
|
||||
checkLimit("%" + entityName, fString.length + countChar);
|
||||
}
|
||||
checkEntityLimit(isPEDecl, entityName, fString.length + countChar);
|
||||
countChar = 0;
|
||||
fStringBuffer.append(fString);
|
||||
fStringBuffer2.append(fString);
|
||||
@ -1727,9 +1747,7 @@ implements XMLDTDScanner, XMLComponent, XMLEntityHandler {
|
||||
literal = fStringBuffer;
|
||||
literal2 = fStringBuffer2;
|
||||
} else {
|
||||
if (isPEDecl) {
|
||||
checkLimit("%" + entityName, literal);
|
||||
}
|
||||
checkEntityLimit(isPEDecl, entityName, literal);
|
||||
}
|
||||
value.setValues(literal);
|
||||
nonNormalizedValue.setValues(literal2);
|
||||
@ -2151,35 +2169,49 @@ implements XMLDTDScanner, XMLComponent, XMLEntityHandler {
|
||||
setScannerState(SCANNER_STATE_TEXT_DECL);
|
||||
//new SymbolTable());
|
||||
|
||||
fLimitAnalyzer = new XMLLimitAnalyzer();
|
||||
fLimitAnalyzer = fEntityManager.fLimitAnalyzer;
|
||||
fSecurityManager = fEntityManager.fSecurityManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the count of the content buffer and check if the accumulated
|
||||
* value exceeds the limit
|
||||
* @param isPEDecl a flag to indicate whether the entity is parameter
|
||||
* @param entityName entity name
|
||||
* @param buffer content buffer
|
||||
*/
|
||||
private void checkLimit(String entityName, XMLString buffer) {
|
||||
checkLimit(entityName, buffer.length);
|
||||
private void checkEntityLimit(boolean isPEDecl, String entityName, XMLString buffer) {
|
||||
checkEntityLimit(isPEDecl, entityName, buffer.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the count and check limit
|
||||
* @param isPEDecl a flag to indicate whether the entity is parameter
|
||||
* @param entityName entity name
|
||||
* @param len length of the buffer
|
||||
*/
|
||||
private void checkLimit(String entityName, int len) {
|
||||
private void checkEntityLimit(boolean isPEDecl, String entityName, int len) {
|
||||
if (fLimitAnalyzer == null) {
|
||||
fLimitAnalyzer = new XMLLimitAnalyzer();
|
||||
fLimitAnalyzer = fEntityManager.fLimitAnalyzer;
|
||||
}
|
||||
fLimitAnalyzer.addValue(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT, entityName, len);
|
||||
if (fSecurityManager.isOverLimit(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT, fLimitAnalyzer)) {
|
||||
fSecurityManager.debugPrint(fLimitAnalyzer);
|
||||
reportFatalError("MaxEntitySizeLimit", new Object[]{entityName,
|
||||
fLimitAnalyzer.getValue(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT),
|
||||
fSecurityManager.getLimit(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT),
|
||||
fSecurityManager.getStateLiteral(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT)});
|
||||
if (isPEDecl) {
|
||||
fLimitAnalyzer.addValue(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT, "%" + entityName, len);
|
||||
if (fSecurityManager.isOverLimit(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT, fLimitAnalyzer)) {
|
||||
fSecurityManager.debugPrint(fLimitAnalyzer);
|
||||
reportFatalError("MaxEntitySizeLimit", new Object[]{"%" + entityName,
|
||||
fLimitAnalyzer.getValue(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT),
|
||||
fSecurityManager.getLimit(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT),
|
||||
fSecurityManager.getStateLiteral(XMLSecurityManager.Limit.PARAMETER_ENTITY_SIZE_LIMIT)});
|
||||
}
|
||||
} else {
|
||||
fLimitAnalyzer.addValue(XMLSecurityManager.Limit.GENERAL_ENTITY_SIZE_LIMIT, entityName, len);
|
||||
if (fSecurityManager.isOverLimit(XMLSecurityManager.Limit.GENERAL_ENTITY_SIZE_LIMIT, fLimitAnalyzer)) {
|
||||
fSecurityManager.debugPrint(fLimitAnalyzer);
|
||||
reportFatalError("MaxEntitySizeLimit", new Object[]{entityName,
|
||||
fLimitAnalyzer.getValue(XMLSecurityManager.Limit.GENERAL_ENTITY_SIZE_LIMIT),
|
||||
fSecurityManager.getLimit(XMLSecurityManager.Limit.GENERAL_ENTITY_SIZE_LIMIT),
|
||||
fSecurityManager.getStateLiteral(XMLSecurityManager.Limit.GENERAL_ENTITY_SIZE_LIMIT)});
|
||||
}
|
||||
}
|
||||
if (fSecurityManager.isOverLimit(XMLSecurityManager.Limit.TOTAL_ENTITY_SIZE_LIMIT, fLimitAnalyzer)) {
|
||||
fSecurityManager.debugPrint(fLimitAnalyzer);
|
||||
|
||||
@ -88,7 +88,7 @@ public class XMLDocumentFragmentScannerImpl
|
||||
// Constants
|
||||
//
|
||||
|
||||
protected int fElementAttributeLimit;
|
||||
protected int fElementAttributeLimit, fXMLNameLimit;
|
||||
|
||||
/** External subset resolver. **/
|
||||
protected ExternalSubsetResolver fExternalSubsetResolver;
|
||||
@ -426,7 +426,7 @@ public class XMLDocumentFragmentScannerImpl
|
||||
*/
|
||||
public void setInputSource(XMLInputSource inputSource) throws IOException {
|
||||
fEntityManager.setEntityHandler(this);
|
||||
fEntityManager.startEntity("$fragment$", inputSource, false, true);
|
||||
fEntityManager.startEntity(false, "$fragment$", inputSource, false, true);
|
||||
// fDocumentSystemId = fEntityManager.expandSystemId(inputSource.getSystemId());
|
||||
} // setInputSource(XMLInputSource)
|
||||
|
||||
@ -661,11 +661,12 @@ public class XMLDocumentFragmentScannerImpl
|
||||
|
||||
if (fSecurityManager != null) {
|
||||
fElementAttributeLimit = fSecurityManager.getLimit(XMLSecurityManager.Limit.ELEMENT_ATTRIBUTE_LIMIT);
|
||||
fXMLNameLimit = fSecurityManager.getLimit(XMLSecurityManager.Limit.MAX_NAME_LIMIT);
|
||||
} else {
|
||||
fElementAttributeLimit = 0;
|
||||
fXMLNameLimit = XMLSecurityManager.Limit.MAX_NAME_LIMIT.defaultValue();
|
||||
}
|
||||
fLimitAnalyzer = new XMLLimitAnalyzer();
|
||||
fEntityManager.setLimitAnalyzer(fLimitAnalyzer);
|
||||
fLimitAnalyzer = fEntityManager.fLimitAnalyzer;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1906,7 +1907,7 @@ public class XMLDocumentFragmentScannerImpl
|
||||
//if that was the case it its taken care in XMLEntityManager.startEntity()
|
||||
//we immediately call the endEntity. Application gets to know if there was
|
||||
//any entity that was not declared.
|
||||
fEntityManager.startEntity(name, false);
|
||||
fEntityManager.startEntity(true, name, false);
|
||||
//set the scaner state to content.. parser will automatically revive itself at any point of time.
|
||||
//setScannerState(SCANNER_STATE_CONTENT);
|
||||
//return true ;
|
||||
@ -2855,8 +2856,6 @@ public class XMLDocumentFragmentScannerImpl
|
||||
if(DEBUG){
|
||||
System.out.println("NOT USING THE BUFFER, STRING = " + fTempString.toString());
|
||||
}
|
||||
//check limit before returning event
|
||||
checkLimit(fContentBuffer);
|
||||
if(dtdGrammarUtil!= null && dtdGrammarUtil.isIgnorableWhiteSpace(fContentBuffer)){
|
||||
if(DEBUG)System.out.println("Return SPACE EVENT");
|
||||
return XMLEvent.SPACE;
|
||||
@ -2955,8 +2954,6 @@ public class XMLDocumentFragmentScannerImpl
|
||||
fLastSectionWasCharacterData = true ;
|
||||
continue;
|
||||
}else{
|
||||
//check limit before returning event
|
||||
checkLimit(fContentBuffer);
|
||||
if(dtdGrammarUtil!= null && dtdGrammarUtil.isIgnorableWhiteSpace(fContentBuffer)){
|
||||
if(DEBUG)System.out.println("Return SPACE EVENT");
|
||||
return XMLEvent.SPACE;
|
||||
@ -3172,31 +3169,6 @@ public class XMLDocumentFragmentScannerImpl
|
||||
} //while loop
|
||||
}//next
|
||||
|
||||
/**
|
||||
* Add the count of the content buffer and check if the accumulated
|
||||
* value exceeds the limit
|
||||
* @param buffer content buffer
|
||||
*/
|
||||
protected void checkLimit(XMLStringBuffer buffer) {
|
||||
if (fLimitAnalyzer.isTracking(fCurrentEntityName)) {
|
||||
fLimitAnalyzer.addValue(Limit.GENERAL_ENTITY_SIZE_LIMIT, fCurrentEntityName, buffer.length);
|
||||
if (fSecurityManager.isOverLimit(Limit.GENERAL_ENTITY_SIZE_LIMIT, fLimitAnalyzer)) {
|
||||
fSecurityManager.debugPrint(fLimitAnalyzer);
|
||||
reportFatalError("MaxEntitySizeLimit", new Object[]{fCurrentEntityName,
|
||||
fLimitAnalyzer.getValue(Limit.GENERAL_ENTITY_SIZE_LIMIT),
|
||||
fSecurityManager.getLimit(Limit.GENERAL_ENTITY_SIZE_LIMIT),
|
||||
fSecurityManager.getStateLiteral(Limit.GENERAL_ENTITY_SIZE_LIMIT)});
|
||||
}
|
||||
if (fSecurityManager.isOverLimit(Limit.TOTAL_ENTITY_SIZE_LIMIT, fLimitAnalyzer)) {
|
||||
fSecurityManager.debugPrint(fLimitAnalyzer);
|
||||
reportFatalError("TotalEntitySizeLimit",
|
||||
new Object[]{fLimitAnalyzer.getTotalValue(Limit.TOTAL_ENTITY_SIZE_LIMIT),
|
||||
fSecurityManager.getLimit(Limit.TOTAL_ENTITY_SIZE_LIMIT),
|
||||
fSecurityManager.getStateLiteral(Limit.TOTAL_ENTITY_SIZE_LIMIT)});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Protected methods
|
||||
//
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -1095,11 +1095,14 @@ public class XMLDocumentScannerImpl
|
||||
again = false;
|
||||
switch (fScannerState) {
|
||||
case SCANNER_STATE_DTD_INTERNAL_DECLS: {
|
||||
// REVISIT: Should there be a feature for
|
||||
// the "complete" parameter?
|
||||
boolean completeDTD = true;
|
||||
boolean moreToScan = false;
|
||||
if (!fDTDScanner.skipDTD(fSupportDTD)) {
|
||||
// REVISIT: Should there be a feature for
|
||||
// the "complete" parameter?
|
||||
boolean completeDTD = true;
|
||||
|
||||
boolean moreToScan = fDTDScanner.scanDTDInternalSubset(completeDTD, fStandalone, fHasExternalDTD && fLoadExternalDTD);
|
||||
moreToScan = fDTDScanner.scanDTDInternalSubset(completeDTD, fStandalone, fHasExternalDTD && fLoadExternalDTD);
|
||||
}
|
||||
Entity entity = fEntityScanner.getCurrentEntity();
|
||||
if(entity instanceof Entity.ScannedEntity){
|
||||
fEndPos=((Entity.ScannedEntity)entity).position;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
@ -47,7 +47,7 @@ import java.net.HttpURLConnection;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Hashtable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@ -367,7 +367,7 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
// entities
|
||||
|
||||
/** Entities. */
|
||||
protected Hashtable fEntities = new Hashtable();
|
||||
protected Map<String, Entity> fEntities = new HashMap<>();
|
||||
|
||||
/** Entity stack. */
|
||||
protected Stack fEntityStack = new Stack();
|
||||
@ -404,6 +404,8 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
* If this constructor is used to create the object, reset() should be invoked on this object
|
||||
*/
|
||||
public XMLEntityManager() {
|
||||
//for entity managers not created by parsers
|
||||
fSecurityManager = new XMLSecurityManager(true);
|
||||
fEntityStorage = new XMLEntityStorage(this) ;
|
||||
setScannerVersion(Constants.XML_VERSION_1_0);
|
||||
} // <init>()
|
||||
@ -581,6 +583,8 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
/**
|
||||
* This method uses the passed-in XMLInputSource to make
|
||||
* fCurrentEntity usable for reading.
|
||||
*
|
||||
* @param reference flag to indicate whether the entity is an Entity Reference.
|
||||
* @param name name of the entity (XML is it's the document entity)
|
||||
* @param xmlInputSource the input source, with sufficient information
|
||||
* to begin scanning characters.
|
||||
@ -591,7 +595,7 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
* XNIException If any parser-specific goes wrong.
|
||||
* @return the encoding of the new entity or null if a character stream was employed
|
||||
*/
|
||||
public String setupCurrentEntity(String name, XMLInputSource xmlInputSource,
|
||||
public String setupCurrentEntity(boolean reference, String name, XMLInputSource xmlInputSource,
|
||||
boolean literal, boolean isExternal)
|
||||
throws IOException, XNIException {
|
||||
// get information
|
||||
@ -834,7 +838,9 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
* in the prolog of the XML document is not considered. Hence, prolog can
|
||||
* be read in Chunks of data instead of byte by byte.
|
||||
*/
|
||||
fCurrentEntity = new com.sun.xml.internal.stream.Entity.ScannedEntity(name,new XMLResourceIdentifierImpl(publicId, literalSystemId, baseSystemId, expandedSystemId),stream, reader, encoding, literal, encodingExternallySpecified, isExternal);
|
||||
fCurrentEntity = new Entity.ScannedEntity(reference, name,
|
||||
new XMLResourceIdentifierImpl(publicId, literalSystemId, baseSystemId, expandedSystemId),
|
||||
stream, reader, encoding, literal, encodingExternallySpecified, isExternal);
|
||||
fCurrentEntity.setEncodingExternallySpecified(encodingExternallySpecified);
|
||||
fEntityScanner.setCurrentEntity(fCurrentEntity);
|
||||
fResourceIdentifier.setValues(publicId, literalSystemId, baseSystemId, expandedSystemId);
|
||||
@ -854,7 +860,7 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
*/
|
||||
public boolean isExternalEntity(String entityName) {
|
||||
|
||||
Entity entity = (Entity)fEntities.get(entityName);
|
||||
Entity entity = fEntities.get(entityName);
|
||||
if (entity == null) {
|
||||
return false;
|
||||
}
|
||||
@ -871,7 +877,7 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
*/
|
||||
public boolean isEntityDeclInExternalSubset(String entityName) {
|
||||
|
||||
Entity entity = (Entity)fEntities.get(entityName);
|
||||
Entity entity = fEntities.get(entityName);
|
||||
if (entity == null) {
|
||||
return false;
|
||||
}
|
||||
@ -901,13 +907,13 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
|
||||
public boolean isDeclaredEntity(String entityName) {
|
||||
|
||||
Entity entity = (Entity)fEntities.get(entityName);
|
||||
Entity entity = fEntities.get(entityName);
|
||||
return entity != null;
|
||||
}
|
||||
|
||||
public boolean isUnparsedEntity(String entityName) {
|
||||
|
||||
Entity entity = (Entity)fEntities.get(entityName);
|
||||
Entity entity = fEntities.get(entityName);
|
||||
if (entity == null) {
|
||||
return false;
|
||||
}
|
||||
@ -1102,6 +1108,7 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
/**
|
||||
* Starts a named entity.
|
||||
*
|
||||
* @param reference flag to indicate whether the entity is an Entity Reference.
|
||||
* @param entityName The name of the entity to start.
|
||||
* @param literal True if this entity is started within a literal
|
||||
* value.
|
||||
@ -1109,11 +1116,11 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
* @throws IOException Thrown on i/o error.
|
||||
* @throws XNIException Thrown by entity handler to signal an error.
|
||||
*/
|
||||
public void startEntity(String entityName, boolean literal)
|
||||
public void startEntity(boolean reference, String entityName, boolean literal)
|
||||
throws IOException, XNIException {
|
||||
|
||||
// was entity declared?
|
||||
Entity entity = (Entity)fEntityStorage.getEntity(entityName);
|
||||
Entity entity = fEntityStorage.getEntity(entityName);
|
||||
if (entity == null) {
|
||||
if (fEntityHandler != null) {
|
||||
String encoding = null;
|
||||
@ -1233,7 +1240,7 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
}
|
||||
|
||||
// start the entity
|
||||
startEntity(entityName, xmlInputSource, literal, external);
|
||||
startEntity(reference, entityName, xmlInputSource, literal, external);
|
||||
|
||||
} // startEntity(String,boolean)
|
||||
|
||||
@ -1248,7 +1255,7 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
*/
|
||||
public void startDocumentEntity(XMLInputSource xmlInputSource)
|
||||
throws IOException, XNIException {
|
||||
startEntity(XMLEntity, xmlInputSource, false, true);
|
||||
startEntity(false, XMLEntity, xmlInputSource, false, true);
|
||||
} // startDocumentEntity(XMLInputSource)
|
||||
|
||||
//xxx these methods are not required.
|
||||
@ -1263,7 +1270,7 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
*/
|
||||
public void startDTDEntity(XMLInputSource xmlInputSource)
|
||||
throws IOException, XNIException {
|
||||
startEntity(DTDEntity, xmlInputSource, false, true);
|
||||
startEntity(false, DTDEntity, xmlInputSource, false, true);
|
||||
} // startDTDEntity(XMLInputSource)
|
||||
|
||||
// indicate start of external subset so that
|
||||
@ -1282,6 +1289,7 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
* This method can be used to insert an application defined XML
|
||||
* entity stream into the parsing stream.
|
||||
*
|
||||
* @param reference flag to indicate whether the entity is an Entity Reference.
|
||||
* @param name The name of the entity.
|
||||
* @param xmlInputSource The input source of the entity.
|
||||
* @param literal True if this entity is started within a
|
||||
@ -1291,12 +1299,12 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
* @throws IOException Thrown on i/o error.
|
||||
* @throws XNIException Thrown by entity handler to signal an error.
|
||||
*/
|
||||
public void startEntity(String name,
|
||||
public void startEntity(boolean reference, String name,
|
||||
XMLInputSource xmlInputSource,
|
||||
boolean literal, boolean isExternal)
|
||||
throws IOException, XNIException {
|
||||
|
||||
String encoding = setupCurrentEntity(name, xmlInputSource, literal, isExternal);
|
||||
String encoding = setupCurrentEntity(reference, name, xmlInputSource, literal, isExternal);
|
||||
|
||||
//when entity expansion limit is set by the Application, we need to
|
||||
//check for the entity expansion limit set by the parser, if number of entity
|
||||
@ -1308,7 +1316,7 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
}
|
||||
if( fSecurityManager != null && fSecurityManager.isOverLimit(entityExpansionIndex, fLimitAnalyzer)){
|
||||
fSecurityManager.debugPrint(fLimitAnalyzer);
|
||||
fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,"EntityExpansionLimitExceeded",
|
||||
fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,"EntityExpansionLimit",
|
||||
new Object[]{fSecurityManager.getLimitValueByIndex(entityExpansionIndex)},
|
||||
XMLErrorReporter.SEVERITY_FATAL_ERROR );
|
||||
// is there anything better to do than reset the counter?
|
||||
@ -1424,10 +1432,6 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
// XMLComponent methods
|
||||
//
|
||||
public void reset(PropertyManager propertyManager){
|
||||
//reset fEntityStorage
|
||||
fEntityStorage.reset(propertyManager);
|
||||
//reset XMLEntityReaderImpl
|
||||
fEntityScanner.reset(propertyManager);
|
||||
// xerces properties
|
||||
fSymbolTable = (SymbolTable)propertyManager.getProperty(Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY);
|
||||
fErrorReporter = (XMLErrorReporter)propertyManager.getProperty(Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY);
|
||||
@ -1450,6 +1454,12 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
|
||||
fSecurityManager = (XMLSecurityManager)propertyManager.getProperty(SECURITY_MANAGER);
|
||||
|
||||
fLimitAnalyzer = new XMLLimitAnalyzer();
|
||||
//reset fEntityStorage
|
||||
fEntityStorage.reset(propertyManager);
|
||||
//reset XMLEntityReaderImpl
|
||||
fEntityScanner.reset(propertyManager);
|
||||
|
||||
// initialize state
|
||||
//fStandalone = false;
|
||||
fEntities.clear();
|
||||
@ -1536,7 +1546,7 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver {
|
||||
// a class acting as a component manager but not
|
||||
// implementing that interface for whatever reason.
|
||||
public void reset() {
|
||||
|
||||
fLimitAnalyzer = new XMLLimitAnalyzer();
|
||||
// initialize state
|
||||
fStandalone = false;
|
||||
fEntities.clear();
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -30,10 +30,14 @@ import com.sun.org.apache.xerces.internal.util.EncodingMap;
|
||||
import com.sun.org.apache.xerces.internal.util.SymbolTable;
|
||||
import com.sun.org.apache.xerces.internal.util.XMLChar;
|
||||
import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
|
||||
import com.sun.org.apache.xerces.internal.utils.XMLLimitAnalyzer;
|
||||
import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
|
||||
import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager.Limit;
|
||||
import com.sun.org.apache.xerces.internal.xni.*;
|
||||
import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
|
||||
import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
|
||||
import com.sun.xml.internal.stream.Entity;
|
||||
import com.sun.xml.internal.stream.Entity.ScannedEntity;
|
||||
import com.sun.xml.internal.stream.XMLBufferListener;
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
@ -60,6 +64,12 @@ public class XMLEntityScanner implements XMLLocator {
|
||||
|
||||
protected XMLEntityManager fEntityManager ;
|
||||
|
||||
/** Security manager. */
|
||||
protected XMLSecurityManager fSecurityManager = null;
|
||||
|
||||
/** Limit analyzer. */
|
||||
protected XMLLimitAnalyzer fLimitAnalyzer = null;
|
||||
|
||||
/** Debug switching readers for encodings. */
|
||||
private static final boolean DEBUG_ENCODINGS = false;
|
||||
/** Listeners which should know when load is being called */
|
||||
@ -174,10 +184,7 @@ public class XMLEntityScanner implements XMLLocator {
|
||||
public void reset(PropertyManager propertyManager){
|
||||
fSymbolTable = (SymbolTable)propertyManager.getProperty(SYMBOL_TABLE) ;
|
||||
fErrorReporter = (XMLErrorReporter)propertyManager.getProperty(ERROR_REPORTER) ;
|
||||
fCurrentEntity = null;
|
||||
whiteSpaceLen = 0;
|
||||
whiteSpaceInfoNeeded = true;
|
||||
listeners.clear();
|
||||
resetCommon();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -196,18 +203,13 @@ public class XMLEntityScanner implements XMLLocator {
|
||||
*/
|
||||
public void reset(XMLComponentManager componentManager)
|
||||
throws XMLConfigurationException {
|
||||
|
||||
//System.out.println(" this is being called");
|
||||
// xerces features
|
||||
fAllowJavaEncodings = componentManager.getFeature(ALLOW_JAVA_ENCODINGS, false);
|
||||
|
||||
//xerces properties
|
||||
fSymbolTable = (SymbolTable)componentManager.getProperty(SYMBOL_TABLE);
|
||||
fErrorReporter = (XMLErrorReporter)componentManager.getProperty(ERROR_REPORTER);
|
||||
fCurrentEntity = null;
|
||||
whiteSpaceLen = 0;
|
||||
whiteSpaceInfoNeeded = true;
|
||||
listeners.clear();
|
||||
resetCommon();
|
||||
} // reset(XMLComponentManager)
|
||||
|
||||
|
||||
@ -217,6 +219,17 @@ public class XMLEntityScanner implements XMLLocator {
|
||||
fSymbolTable = symbolTable;
|
||||
fEntityManager = entityManager;
|
||||
fErrorReporter = reporter;
|
||||
fLimitAnalyzer = fEntityManager.fLimitAnalyzer;
|
||||
fSecurityManager = fEntityManager.fSecurityManager;
|
||||
}
|
||||
|
||||
private void resetCommon() {
|
||||
fCurrentEntity = null;
|
||||
whiteSpaceLen = 0;
|
||||
whiteSpaceInfoNeeded = true;
|
||||
listeners.clear();
|
||||
fLimitAnalyzer = fEntityManager.fLimitAnalyzer;
|
||||
fSecurityManager = fEntityManager.fSecurityManager;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -813,9 +826,13 @@ public class XMLEntityScanner implements XMLLocator {
|
||||
break;
|
||||
}
|
||||
index = fCurrentEntity.position;
|
||||
//check prefix before further read
|
||||
checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, index - offset);
|
||||
}
|
||||
if (++fCurrentEntity.position == fCurrentEntity.count) {
|
||||
int length = fCurrentEntity.position - offset;
|
||||
//check localpart before loading more data
|
||||
checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, length - index - 1);
|
||||
invokeListeners(length);
|
||||
if (length == fCurrentEntity.fBufferSize) {
|
||||
// bad luck we have to resize our buffer
|
||||
@ -847,14 +864,20 @@ public class XMLEntityScanner implements XMLLocator {
|
||||
|
||||
if (index != -1) {
|
||||
int prefixLength = index - offset;
|
||||
//check the result: prefix
|
||||
checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, prefixLength);
|
||||
prefix = fSymbolTable.addSymbol(fCurrentEntity.ch,
|
||||
offset, prefixLength);
|
||||
int len = length - prefixLength - 1;
|
||||
//check the result: localpart
|
||||
checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, index + 1, len);
|
||||
localpart = fSymbolTable.addSymbol(fCurrentEntity.ch,
|
||||
index + 1, len);
|
||||
|
||||
} else {
|
||||
localpart = rawname;
|
||||
//check the result: localpart
|
||||
checkLimit(Limit.MAX_NAME_LIMIT, fCurrentEntity, offset, length);
|
||||
}
|
||||
qname.setValues(prefix, localpart, rawname, null);
|
||||
if (DEBUG_BUFFER) {
|
||||
@ -876,6 +899,27 @@ public class XMLEntityScanner implements XMLLocator {
|
||||
|
||||
} // scanQName(QName):boolean
|
||||
|
||||
/**
|
||||
* Checks whether the value of the specified Limit exceeds its limit
|
||||
*
|
||||
* @param limit The Limit to be checked.
|
||||
* @param entity The current entity.
|
||||
* @param offset The index of the first byte
|
||||
* @param length The length of the entity scanned.
|
||||
*/
|
||||
protected void checkLimit(Limit limit, ScannedEntity entity, int offset, int length) {
|
||||
fLimitAnalyzer.addValue(limit, null, length);
|
||||
if (fSecurityManager.isOverLimit(limit, fLimitAnalyzer)) {
|
||||
fSecurityManager.debugPrint(fLimitAnalyzer);
|
||||
fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN, limit.key(),
|
||||
new Object[]{new String(entity.ch, offset, length),
|
||||
fLimitAnalyzer.getTotalValue(limit),
|
||||
fSecurityManager.getLimit(limit),
|
||||
fSecurityManager.getStateLiteral(limit)},
|
||||
XMLErrorReporter.SEVERITY_FATAL_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* CHANGED:
|
||||
* Scans a range of parsed character data, This function appends the character data to
|
||||
@ -994,6 +1038,9 @@ public class XMLEntityScanner implements XMLLocator {
|
||||
}
|
||||
int length = fCurrentEntity.position - offset;
|
||||
fCurrentEntity.columnNumber += length - newlines;
|
||||
if (fCurrentEntity.reference) {
|
||||
checkLimit(Limit.TOTAL_ENTITY_SIZE_LIMIT, fCurrentEntity, offset, length);
|
||||
}
|
||||
|
||||
//CHANGED: dont replace the value.. append to the buffer. This gives control to the callee
|
||||
//on buffering the data..
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
@ -20,9 +19,6 @@
|
||||
*/
|
||||
|
||||
package com.sun.org.apache.xerces.internal.impl;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Locale;
|
||||
|
||||
import com.sun.org.apache.xerces.internal.util.DefaultErrorHandler;
|
||||
import com.sun.org.apache.xerces.internal.util.ErrorHandlerProxy;
|
||||
import com.sun.org.apache.xerces.internal.util.MessageFormatter;
|
||||
@ -33,6 +29,9 @@ import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager;
|
||||
import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException;
|
||||
import com.sun.org.apache.xerces.internal.xni.parser.XMLErrorHandler;
|
||||
import com.sun.org.apache.xerces.internal.xni.parser.XMLParseException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import org.xml.sax.ErrorHandler;
|
||||
|
||||
/**
|
||||
@ -148,7 +147,7 @@ public class XMLErrorReporter
|
||||
protected Locale fLocale;
|
||||
|
||||
/** Mapping of Message formatters for domains. */
|
||||
protected Hashtable fMessageFormatters;
|
||||
protected Map<String, MessageFormatter> fMessageFormatters;
|
||||
|
||||
/** Error handler. */
|
||||
protected XMLErrorHandler fErrorHandler;
|
||||
@ -192,7 +191,7 @@ public class XMLErrorReporter
|
||||
// caller to specify the location of the error being
|
||||
// reported. -Ac
|
||||
|
||||
fMessageFormatters = new Hashtable();
|
||||
fMessageFormatters = new HashMap<>();
|
||||
|
||||
} // <init>()
|
||||
|
||||
@ -250,7 +249,7 @@ public class XMLErrorReporter
|
||||
* @param domain The domain of the message formatter.
|
||||
*/
|
||||
public MessageFormatter getMessageFormatter(String domain) {
|
||||
return (MessageFormatter)fMessageFormatters.get(domain);
|
||||
return fMessageFormatters.get(domain);
|
||||
} // getMessageFormatter(String):MessageFormatter
|
||||
|
||||
/**
|
||||
@ -260,7 +259,7 @@ public class XMLErrorReporter
|
||||
* @param domain The domain of the message formatter.
|
||||
*/
|
||||
public MessageFormatter removeMessageFormatter(String domain) {
|
||||
return (MessageFormatter) fMessageFormatters.remove(domain);
|
||||
return fMessageFormatters.remove(domain);
|
||||
} // removeMessageFormatter(String):MessageFormatter
|
||||
|
||||
/**
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -37,6 +37,7 @@ import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
|
||||
import com.sun.org.apache.xerces.internal.xni.XMLAttributes;
|
||||
import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource;
|
||||
import com.sun.org.apache.xerces.internal.util.XMLAttributesImpl;
|
||||
import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager;
|
||||
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLStreamConstants;
|
||||
@ -452,7 +453,15 @@ public class XMLNSDocumentScannerImpl
|
||||
// it's a namespace declaration. but prefix:xmlns="..." isn't.
|
||||
if (prefix == XMLSymbols.PREFIX_XMLNS ||
|
||||
prefix == XMLSymbols.EMPTY_STRING && localpart == XMLSymbols.PREFIX_XMLNS) {
|
||||
|
||||
//check the length of URI
|
||||
if (tmpStr.length > fXMLNameLimit) {
|
||||
fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
|
||||
"MaxXMLNameLimit",
|
||||
new Object[]{new String(tmpStr.ch,tmpStr.offset,tmpStr.length),
|
||||
tmpStr.length, fXMLNameLimit,
|
||||
fSecurityManager.getStateLiteral(XMLSecurityManager.Limit.MAX_NAME_LIMIT)},
|
||||
XMLErrorReporter.SEVERITY_FATAL_ERROR);
|
||||
}
|
||||
// get the internalized value of this attribute
|
||||
String uri = fSymbolTable.addSymbol(tmpStr.ch,tmpStr.offset,tmpStr.length);
|
||||
value = uri;
|
||||
|
||||
@ -946,7 +946,7 @@ public abstract class XMLScanner
|
||||
new Object[]{entityName});
|
||||
}
|
||||
}
|
||||
fEntityManager.startEntity(entityName, true);
|
||||
fEntityManager.startEntity(false, entityName, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2015, 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,20 +48,15 @@ import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLStreamConstants;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter;
|
||||
import com.sun.org.apache.xerces.internal.util.XMLChar;
|
||||
import com.sun.org.apache.xerces.internal.util.XMLStringBuffer;
|
||||
import com.sun.org.apache.xerces.internal.util.NamespaceSupport;
|
||||
import com.sun.org.apache.xerces.internal.util.XMLAttributesImpl;
|
||||
import com.sun.org.apache.xerces.internal.impl.Constants;
|
||||
import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler;
|
||||
import com.sun.xml.internal.stream.dtd.DTDGrammarUtil;
|
||||
|
||||
/** This class implements javax.xml.stream.XMLStreamReader. It makes use of XML*Scanner classes to
|
||||
* derive most of its functionality. If desired, Application can reuse this instance by calling
|
||||
@ -1173,7 +1168,7 @@ public class XMLStreamReaderImpl implements javax.xml.stream.XMLStreamReader {
|
||||
public boolean hasText() {
|
||||
if(DEBUG) pr("XMLReaderImpl#EVENT TYPE = " + fEventType ) ;
|
||||
if( fEventType == XMLEvent.CHARACTERS || fEventType == XMLEvent.COMMENT || fEventType == XMLEvent.CDATA) {
|
||||
return fScanner.getCharacterData().length > 0 ? true : false;
|
||||
return fScanner.getCharacterData().length > 0;
|
||||
} else if(fEventType == XMLEvent.ENTITY_REFERENCE) {
|
||||
String name = fScanner.getEntityName();
|
||||
if(name != null){
|
||||
@ -1185,9 +1180,9 @@ public class XMLStreamReaderImpl implements javax.xml.stream.XMLStreamReader {
|
||||
if(en == null)
|
||||
return false;
|
||||
if(en.isExternal()){
|
||||
return ((Entity.ExternalEntity)en).entityLocation.getExpandedSystemId() != null ? true : false;
|
||||
return ((Entity.ExternalEntity)en).entityLocation.getExpandedSystemId() != null;
|
||||
} else{
|
||||
return ((Entity.InternalEntity)en).text != null ? true : false ;
|
||||
return ((Entity.InternalEntity)en).text != null ;
|
||||
}
|
||||
}else
|
||||
return false;
|
||||
|
||||
@ -186,7 +186,7 @@ public class XMLVersionDetector {
|
||||
* @throws IOException
|
||||
*/
|
||||
public short determineDocVersion(XMLInputSource inputSource) throws IOException {
|
||||
fEncoding = fEntityManager.setupCurrentEntity(fXMLSymbol, inputSource, false, true);
|
||||
fEncoding = fEntityManager.setupCurrentEntity(false, fXMLSymbol, inputSource, false, true);
|
||||
|
||||
// Must use XML 1.0 scanner to handle whitespace correctly
|
||||
// in the XML declaration.
|
||||
|
||||
@ -1,69 +1,25 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* The Apache Software License, Version 1.1
|
||||
* 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
|
||||
*
|
||||
* Copyright (c) 1999-2002 The Apache Software Foundation.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The end-user documentation included with the redistribution,
|
||||
* if any, must include the following acknowledgment:
|
||||
* "This product includes software developed by the
|
||||
* Apache Software Foundation (http://www.apache.org/)."
|
||||
* Alternately, this acknowledgment may appear in the software itself,
|
||||
* if and wherever such third-party acknowledgments normally appear.
|
||||
*
|
||||
* 4. The names "Xerces" and "Apache Software Foundation" must
|
||||
* not be used to endorse or promote products derived from this
|
||||
* software without prior written permission. For written
|
||||
* permission, please contact apache@apache.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "Apache",
|
||||
* nor may "Apache" appear in their name, without prior written
|
||||
* permission of the Apache Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation and was
|
||||
* originally based on software copyright (c) 1999, International
|
||||
* Business Machines, Inc., http://www.apache.org. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.sun.org.apache.xerces.internal.impl.dtd;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import com.sun.org.apache.xerces.internal.impl.dtd.models.CMAny;
|
||||
import com.sun.org.apache.xerces.internal.impl.dtd.models.CMBinOp;
|
||||
import com.sun.org.apache.xerces.internal.impl.dtd.models.CMLeaf;
|
||||
@ -88,10 +44,14 @@ import com.sun.org.apache.xerces.internal.xni.grammars.Grammar;
|
||||
import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
|
||||
import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDContentModelSource;
|
||||
import com.sun.org.apache.xerces.internal.xni.parser.XMLDTDSource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* A DTD grammar. This class implements the XNI handler interfaces
|
||||
* for DTD information so that it can build the approprate validation
|
||||
* for DTD information so that it can build the appropriate validation
|
||||
* structures automatically from the callbacks.
|
||||
*
|
||||
* @xerces.internal
|
||||
@ -250,13 +210,13 @@ public class DTDGrammar
|
||||
// other information
|
||||
|
||||
/** Element index mapping table. */
|
||||
private QNameHashtable fElementIndexMap = new QNameHashtable();
|
||||
private final Map<String, Integer> fElementIndexMap = new HashMap<>();
|
||||
|
||||
/** Entity index mapping table. */
|
||||
private QNameHashtable fEntityIndexMap = new QNameHashtable();
|
||||
private final Map<String, Integer> fEntityIndexMap = new HashMap<>();
|
||||
|
||||
/** Notation index mapping table. */
|
||||
private QNameHashtable fNotationIndexMap = new QNameHashtable();
|
||||
private final Map<String, Integer> fNotationIndexMap = new HashMap<>();
|
||||
|
||||
// temp variables
|
||||
|
||||
@ -290,7 +250,7 @@ public class DTDGrammar
|
||||
private XMLContentSpec fContentSpec = new XMLContentSpec();
|
||||
|
||||
/** table of XMLElementDecl */
|
||||
Hashtable fElementDeclTab = new Hashtable();
|
||||
Map<String, XMLElementDecl> fElementDeclTab = new HashMap<>();
|
||||
|
||||
/** Children content model operation stack. */
|
||||
private short[] fOpStack = null;
|
||||
@ -515,7 +475,7 @@ public class DTDGrammar
|
||||
public void elementDecl(String name, String contentModel, Augmentations augs)
|
||||
throws XNIException {
|
||||
|
||||
XMLElementDecl tmpElementDecl = (XMLElementDecl) fElementDeclTab.get(name) ;
|
||||
XMLElementDecl tmpElementDecl = fElementDeclTab.get(name) ;
|
||||
|
||||
// check if it is already defined
|
||||
if ( tmpElementDecl != null ) {
|
||||
@ -605,7 +565,7 @@ public class DTDGrammar
|
||||
String defaultType, XMLString defaultValue,
|
||||
XMLString nonNormalizedDefaultValue, Augmentations augs) throws XNIException {
|
||||
|
||||
if ( this.fElementDeclTab.containsKey( (String) elementName) ) {
|
||||
if ( this.fElementDeclTab.containsKey(elementName) ) {
|
||||
//if ElementDecl has already being created in the Grammar then remove from table,
|
||||
//this.fElementDeclTab.remove( (String) elementName );
|
||||
}
|
||||
@ -988,7 +948,7 @@ public class DTDGrammar
|
||||
public void startContentModel(String elementName, Augmentations augs)
|
||||
throws XNIException {
|
||||
|
||||
XMLElementDecl elementDecl = (XMLElementDecl) this.fElementDeclTab.get( elementName);
|
||||
XMLElementDecl elementDecl = this.fElementDeclTab.get(elementName);
|
||||
if ( elementDecl != null ) {
|
||||
fElementDecl = elementDecl;
|
||||
}
|
||||
@ -1215,7 +1175,10 @@ public class DTDGrammar
|
||||
* @return index of the elementDeclName in scope
|
||||
*/
|
||||
public int getElementDeclIndex(String elementDeclName) {
|
||||
int mapping = fElementIndexMap.get(elementDeclName);
|
||||
Integer mapping = fElementIndexMap.get(elementDeclName);
|
||||
if (mapping == null) {
|
||||
mapping = -1;
|
||||
}
|
||||
//System.out.println("getElementDeclIndex("+elementDeclName+") -> "+mapping);
|
||||
return mapping;
|
||||
} // getElementDeclIndex(String):int
|
||||
@ -1392,7 +1355,7 @@ public class DTDGrammar
|
||||
* @return the index of the EntityDecl
|
||||
*/
|
||||
public int getEntityDeclIndex(String entityDeclName) {
|
||||
if (entityDeclName == null) {
|
||||
if (entityDeclName == null || fEntityIndexMap.get(entityDeclName) == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1435,7 +1398,7 @@ public class DTDGrammar
|
||||
* @return the index if found a notation with the name, otherwise -1.
|
||||
*/
|
||||
public int getNotationDeclIndex(String notationDeclName) {
|
||||
if (notationDeclName == null) {
|
||||
if (notationDeclName == null || fNotationIndexMap.get(notationDeclName) == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -2668,108 +2631,6 @@ public class DTDGrammar
|
||||
|
||||
} // class ChildrenList
|
||||
|
||||
//
|
||||
// Classes
|
||||
//
|
||||
|
||||
/**
|
||||
* A simple Hashtable implementation that takes a tuple (String, String)
|
||||
* as the key and a int as value.
|
||||
*
|
||||
* @xerces.internal
|
||||
*
|
||||
* @author Eric Ye, IBM
|
||||
* @author Andy Clark, IBM
|
||||
*/
|
||||
protected static final class QNameHashtable {
|
||||
|
||||
//
|
||||
// Constants
|
||||
//
|
||||
|
||||
/** Initial bucket size (4). */
|
||||
private static final int INITIAL_BUCKET_SIZE = 4;
|
||||
|
||||
// NOTE: Changed previous hashtable size from 512 to 101 so
|
||||
// that we get a better distribution for hashing. -Ac
|
||||
/** Hashtable size (101). */
|
||||
private static final int HASHTABLE_SIZE = 101;
|
||||
|
||||
//
|
||||
// Data
|
||||
//
|
||||
private Object[][] fHashTable = new Object[HASHTABLE_SIZE][];
|
||||
|
||||
//
|
||||
// Public methods
|
||||
//
|
||||
/** Associates the given value with the specified key tuple. */
|
||||
public void put(String key, int value) {
|
||||
|
||||
int hash = (key.hashCode() & 0x7FFFFFFF) % HASHTABLE_SIZE;
|
||||
Object[] bucket = fHashTable[hash];
|
||||
|
||||
if (bucket == null) {
|
||||
bucket = new Object[1 + 2*INITIAL_BUCKET_SIZE];
|
||||
bucket[0] = new int[]{1};
|
||||
bucket[1] = key;
|
||||
bucket[2] = new int[]{value};
|
||||
fHashTable[hash] = bucket;
|
||||
} else {
|
||||
int count = ((int[])bucket[0])[0];
|
||||
int offset = 1 + 2*count;
|
||||
if (offset == bucket.length) {
|
||||
int newSize = count + INITIAL_BUCKET_SIZE;
|
||||
Object[] newBucket = new Object[1 + 2*newSize];
|
||||
System.arraycopy(bucket, 0, newBucket, 0, offset);
|
||||
bucket = newBucket;
|
||||
fHashTable[hash] = bucket;
|
||||
}
|
||||
boolean found = false;
|
||||
int j=1;
|
||||
for (int i=0; i<count; i++){
|
||||
if ((String)bucket[j] == key) {
|
||||
((int[])bucket[j+1])[0] = value;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
j += 2;
|
||||
}
|
||||
if (! found) {
|
||||
bucket[offset++] = key;
|
||||
bucket[offset]= new int[]{value};
|
||||
((int[])bucket[0])[0] = ++count;
|
||||
}
|
||||
|
||||
}
|
||||
//System.out.println("put("+key+" -> "+value+')');
|
||||
//System.out.println("get("+key+") -> "+get(key));
|
||||
|
||||
} // put(int,String,String,int)
|
||||
|
||||
/** Returns the value associated with the specified key tuple. */
|
||||
public int get(String key) {
|
||||
int hash = (key.hashCode() & 0x7FFFFFFF) % HASHTABLE_SIZE;
|
||||
Object[] bucket = fHashTable[hash];
|
||||
|
||||
if (bucket == null) {
|
||||
return -1;
|
||||
}
|
||||
int count = ((int[])bucket[0])[0];
|
||||
|
||||
int j=1;
|
||||
for (int i=0; i<count; i++){
|
||||
if ((String)bucket[j] == key) {
|
||||
return ((int[])bucket[j+1])[0];
|
||||
}
|
||||
j += 2;
|
||||
}
|
||||
return -1;
|
||||
|
||||
} // get(int,String,String)
|
||||
|
||||
} // class QNameHashtable
|
||||
|
||||
//
|
||||
// EntityState methods
|
||||
//
|
||||
|
||||
@ -1,68 +1,28 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* The Apache Software License, Version 1.1
|
||||
* 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
|
||||
*
|
||||
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
|
||||
* reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The end-user documentation included with the redistribution,
|
||||
* if any, must include the following acknowledgment:
|
||||
* "This product includes software developed by the
|
||||
* Apache Software Foundation (http://www.apache.org/)."
|
||||
* Alternately, this acknowledgment may appear in the software itself,
|
||||
* if and wherever such third-party acknowledgments normally appear.
|
||||
*
|
||||
* 4. The names "Xerces" and "Apache Software Foundation" must
|
||||
* not be used to endorse or promote products derived from this
|
||||
* software without prior written permission. For written
|
||||
* permission, please contact apache@apache.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "Apache",
|
||||
* nor may "Apache" appear in their name, without prior written
|
||||
* permission of the Apache Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation and was
|
||||
* originally based on software copyright (c) 1999, International
|
||||
* Business Machines, Inc., http://www.apache.org. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.sun.org.apache.xerces.internal.impl.dtd;
|
||||
|
||||
import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarDescription;
|
||||
import java.util.Hashtable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* This very simple class is the skeleton of what the DTDValidator could use
|
||||
@ -87,7 +47,7 @@ public class DTDGrammarBucket {
|
||||
//
|
||||
|
||||
/** Grammars associated with element root name. */
|
||||
protected Hashtable fGrammars;
|
||||
protected Map<XMLDTDDescription, DTDGrammar> fGrammars;
|
||||
|
||||
// the unique grammar from fGrammars (or that we're
|
||||
// building) that is used in validation.
|
||||
@ -102,7 +62,7 @@ public class DTDGrammarBucket {
|
||||
|
||||
/** Default constructor. */
|
||||
public DTDGrammarBucket() {
|
||||
fGrammars = new Hashtable();
|
||||
fGrammars = new HashMap<>();
|
||||
} // <init>()
|
||||
|
||||
//
|
||||
@ -122,7 +82,7 @@ public class DTDGrammarBucket {
|
||||
|
||||
// retrieve a DTDGrammar given an XMLDTDDescription
|
||||
public DTDGrammar getGrammar(XMLGrammarDescription desc) {
|
||||
return (DTDGrammar)(fGrammars.get((XMLDTDDescription)desc));
|
||||
return fGrammars.get((XMLDTDDescription)desc);
|
||||
} // putGrammar(DTDGrammar)
|
||||
|
||||
public void clear() {
|
||||
|
||||
@ -23,7 +23,7 @@ package com.sun.org.apache.xerces.internal.impl.dv;
|
||||
import com.sun.org.apache.xerces.internal.impl.dv.dtd.DTDDVFactoryImpl;
|
||||
import com.sun.org.apache.xerces.internal.impl.dv.dtd.XML11DTDDVFactoryImpl;
|
||||
import com.sun.org.apache.xerces.internal.utils.ObjectFactory;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The factory to create and return DTD types. The implementation should
|
||||
@ -91,10 +91,10 @@ public abstract class DTDDVFactory {
|
||||
public abstract DatatypeValidator getBuiltInDV(String name);
|
||||
|
||||
/**
|
||||
* get all built-in DVs, which are stored in a hashtable keyed by the name
|
||||
* get all built-in DVs, which are stored in a map keyed by the name
|
||||
*
|
||||
* @return a hashtable which contains all datatypes
|
||||
* @return a map which contains all datatypes
|
||||
*/
|
||||
public abstract Hashtable getBuiltInTypes();
|
||||
public abstract Map<String, DatatypeValidator> getBuiltInTypes();
|
||||
|
||||
}
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2001, 2002,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
|
||||
*
|
||||
@ -22,7 +22,9 @@ package com.sun.org.apache.xerces.internal.impl.dv.dtd;
|
||||
|
||||
import com.sun.org.apache.xerces.internal.impl.dv.DTDDVFactory;
|
||||
import com.sun.org.apache.xerces.internal.impl.dv.DatatypeValidator;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* the factory to create/return built-in schema DVs and create user-defined DVs
|
||||
@ -34,9 +36,25 @@ import java.util.Hashtable;
|
||||
*/
|
||||
public class DTDDVFactoryImpl extends DTDDVFactory {
|
||||
|
||||
static Hashtable fBuiltInTypes = new Hashtable();
|
||||
static final Map<String, DatatypeValidator> fBuiltInTypes;
|
||||
static {
|
||||
createBuiltInTypes();
|
||||
Map<String, DatatypeValidator> builtInTypes = new HashMap<>();
|
||||
DatatypeValidator dvTemp;
|
||||
|
||||
builtInTypes.put("string", new StringDatatypeValidator());
|
||||
builtInTypes.put("ID", new IDDatatypeValidator());
|
||||
dvTemp = new IDREFDatatypeValidator();
|
||||
builtInTypes.put("IDREF", dvTemp);
|
||||
builtInTypes.put("IDREFS", new ListDatatypeValidator(dvTemp));
|
||||
dvTemp = new ENTITYDatatypeValidator();
|
||||
builtInTypes.put("ENTITY", new ENTITYDatatypeValidator());
|
||||
builtInTypes.put("ENTITIES", new ListDatatypeValidator(dvTemp));
|
||||
builtInTypes.put("NOTATION", new NOTATIONDatatypeValidator());
|
||||
dvTemp = new NMTOKENDatatypeValidator();
|
||||
builtInTypes.put("NMTOKEN", dvTemp);
|
||||
builtInTypes.put("NMTOKENS", new ListDatatypeValidator(dvTemp));
|
||||
|
||||
fBuiltInTypes = Collections.unmodifiableMap(builtInTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -45,37 +63,19 @@ public class DTDDVFactoryImpl extends DTDDVFactory {
|
||||
* @param name the name of the datatype
|
||||
* @return the datatype validator of the given name
|
||||
*/
|
||||
@Override
|
||||
public DatatypeValidator getBuiltInDV(String name) {
|
||||
return (DatatypeValidator)fBuiltInTypes.get(name);
|
||||
return fBuiltInTypes.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* get all built-in DVs, which are stored in a hashtable keyed by the name
|
||||
* get all built-in DVs, which are stored in a Map keyed by the name
|
||||
*
|
||||
* @return a hashtable which contains all datatypes
|
||||
* @return a Map which contains all datatypes
|
||||
*/
|
||||
public Hashtable getBuiltInTypes() {
|
||||
return (Hashtable)fBuiltInTypes.clone();
|
||||
@Override
|
||||
public Map<String, DatatypeValidator> getBuiltInTypes() {
|
||||
return new HashMap<>(fBuiltInTypes);
|
||||
}
|
||||
|
||||
// create all built-in types
|
||||
static void createBuiltInTypes() {
|
||||
|
||||
DatatypeValidator dvTemp;
|
||||
|
||||
fBuiltInTypes.put("string", new StringDatatypeValidator());
|
||||
fBuiltInTypes.put("ID", new IDDatatypeValidator());
|
||||
dvTemp = new IDREFDatatypeValidator();
|
||||
fBuiltInTypes.put("IDREF", dvTemp);
|
||||
fBuiltInTypes.put("IDREFS", new ListDatatypeValidator(dvTemp));
|
||||
dvTemp = new ENTITYDatatypeValidator();
|
||||
fBuiltInTypes.put("ENTITY", new ENTITYDatatypeValidator());
|
||||
fBuiltInTypes.put("ENTITIES", new ListDatatypeValidator(dvTemp));
|
||||
fBuiltInTypes.put("NOTATION", new NOTATIONDatatypeValidator());
|
||||
dvTemp = new NMTOKENDatatypeValidator();
|
||||
fBuiltInTypes.put("NMTOKEN", dvTemp);
|
||||
fBuiltInTypes.put("NMTOKENS", new ListDatatypeValidator(dvTemp));
|
||||
|
||||
}//createBuiltInTypes()
|
||||
|
||||
}// DTDDVFactoryImpl
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2001, 2002,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
|
||||
*
|
||||
@ -20,10 +20,10 @@
|
||||
|
||||
package com.sun.org.apache.xerces.internal.impl.dv.dtd;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import com.sun.org.apache.xerces.internal.impl.dv.DatatypeValidator;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* the factory to create/return built-in XML 1.1 DVs and create user-defined DVs
|
||||
@ -35,7 +35,18 @@ import com.sun.org.apache.xerces.internal.impl.dv.DatatypeValidator;
|
||||
*/
|
||||
public class XML11DTDDVFactoryImpl extends DTDDVFactoryImpl {
|
||||
|
||||
static Hashtable fXML11BuiltInTypes = new Hashtable();
|
||||
static Map<String, DatatypeValidator> XML11BUILTINTYPES;
|
||||
static {
|
||||
Map<String, DatatypeValidator> xml11BuiltInTypes = new HashMap<>();
|
||||
xml11BuiltInTypes.put("XML11ID", new XML11IDDatatypeValidator());
|
||||
DatatypeValidator dvTemp = new XML11IDREFDatatypeValidator();
|
||||
xml11BuiltInTypes.put("XML11IDREF", dvTemp);
|
||||
xml11BuiltInTypes.put("XML11IDREFS", new ListDatatypeValidator(dvTemp));
|
||||
dvTemp = new XML11NMTOKENDatatypeValidator();
|
||||
xml11BuiltInTypes.put("XML11NMTOKEN", dvTemp);
|
||||
xml11BuiltInTypes.put("XML11NMTOKENS", new ListDatatypeValidator(dvTemp));
|
||||
XML11BUILTINTYPES = Collections.unmodifiableMap(xml11BuiltInTypes);
|
||||
} // <clinit>
|
||||
|
||||
/**
|
||||
* return a dtd type of the given name
|
||||
@ -45,38 +56,24 @@ public class XML11DTDDVFactoryImpl extends DTDDVFactoryImpl {
|
||||
* @param name the name of the datatype
|
||||
* @return the datatype validator of the given name
|
||||
*/
|
||||
@Override
|
||||
public DatatypeValidator getBuiltInDV(String name) {
|
||||
if(fXML11BuiltInTypes.get(name) != null) {
|
||||
return (DatatypeValidator)fXML11BuiltInTypes.get(name);
|
||||
if(XML11BUILTINTYPES.get(name) != null) {
|
||||
return XML11BUILTINTYPES.get(name);
|
||||
}
|
||||
return (DatatypeValidator)fBuiltInTypes.get(name);
|
||||
return fBuiltInTypes.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* get all built-in DVs, which are stored in a hashtable keyed by the name
|
||||
* get all built-in DVs, which are stored in a Map keyed by the name
|
||||
* New XML 1.1 datatypes are inserted.
|
||||
*
|
||||
* @return a hashtable which contains all datatypes
|
||||
* @return a Map which contains all datatypes
|
||||
*/
|
||||
public Hashtable getBuiltInTypes() {
|
||||
Hashtable toReturn = (Hashtable)fBuiltInTypes.clone();
|
||||
Enumeration xml11Keys = fXML11BuiltInTypes.keys();
|
||||
while (xml11Keys.hasMoreElements()) {
|
||||
Object key = xml11Keys.nextElement();
|
||||
toReturn.put(key, fXML11BuiltInTypes.get(key));
|
||||
}
|
||||
@Override
|
||||
public Map<String, DatatypeValidator> getBuiltInTypes() {
|
||||
final HashMap<String, DatatypeValidator> toReturn = new HashMap<>(fBuiltInTypes);
|
||||
toReturn.putAll(XML11BUILTINTYPES);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
static {
|
||||
fXML11BuiltInTypes.put("XML11ID", new XML11IDDatatypeValidator());
|
||||
DatatypeValidator dvTemp = new XML11IDREFDatatypeValidator();
|
||||
fXML11BuiltInTypes.put("XML11IDREF", dvTemp);
|
||||
fXML11BuiltInTypes.put("XML11IDREFS", new ListDatatypeValidator(dvTemp));
|
||||
dvTemp = new XML11NMTOKENDatatypeValidator();
|
||||
fXML11BuiltInTypes.put("XML11NMTOKEN", dvTemp);
|
||||
fXML11BuiltInTypes.put("XML11NMTOKENS", new ListDatatypeValidator(dvTemp));
|
||||
} // <clinit>
|
||||
|
||||
|
||||
}//XML11DTDDVFactoryImpl
|
||||
|
||||
@ -294,10 +294,10 @@
|
||||
|
||||
|
||||
# Implementation limits
|
||||
EntityExpansionLimitExceeded=JAXP00010001: The parser has encountered more than \"{0}\" entity expansions in this document; this is the limit imposed by the JDK.
|
||||
EntityExpansionLimit=JAXP00010001: The parser has encountered more than \"{0}\" entity expansions in this document; this is the limit imposed by the JDK.
|
||||
ElementAttributeLimit=JAXP00010002: Element \"{0}\" has more than \"{1}\" attributes, \"{1}\" is the limit imposed by the JDK.
|
||||
MaxEntitySizeLimit=JAXP00010003: The length of entity \"{0}\" is \"{1}\" that exceeds the \"{2}\" limit set by \"{3}\".
|
||||
TotalEntitySizeLimit=JAXP00010004: The accumulated size \"{0}\" of entities exceeded the \"{1}\" limit set by \"{2}\".
|
||||
MaxXMLNameLimit=JAXP00010005: The name \"{0}\" exceeded the \"{1}\" limit set by \"{2}\".
|
||||
TotalEntitySizeLimit=JAXP00010004: The accumulated size of entities is \"{1}\" that exceeded the \"{2}\" limit set by \"{3}\".
|
||||
MaxXMLNameLimit=JAXP00010005: The length of entity \"{0}\" is \"{1}\" that exceeds the \"{2}\" limit set by \"{3}\".
|
||||
MaxElementDepthLimit=JAXP00010006: The element \"{0}\" has a depth of \"{1}\" that exceeds the limit \"{2}\" set by \"{3}\".
|
||||
|
||||
|
||||
@ -289,7 +289,7 @@
|
||||
FacetValueFromBase = FacetValueFromBase: In the declaration of type ''{0}'', value ''{1}'' of facet ''{2}'' must be from the value space of the base type, ''{3}''.
|
||||
FixedFacetValue = FixedFacetValue: In the definition of {3}, the value ''{1}'' for the facet ''{0}'' is invalid, because the value for ''{0}'' has been set to ''{2}'' in one of the ancestor types, and '{'fixed'}' = true.
|
||||
InvalidRegex = InvalidRegex: Pattern value ''{0}'' is not a valid regular expression. The reported error was: ''{1}'' at column ''{2}''.
|
||||
maxOccurLimit = Current configuration of the parser doesn''t allow a maxOccurs attribute value to be set greater than the value {0}.
|
||||
MaxOccurLimit = Current configuration of the parser doesn''t allow a maxOccurs attribute value to be set greater than the value {0}.
|
||||
PublicSystemOnNotation = PublicSystemOnNotation: At least one of ''public'' and ''system'' must appear in element ''notation''.
|
||||
SchemaLocation = SchemaLocation: schemaLocation value = ''{0}'' must have even number of URI''s.
|
||||
TargetNamespace.1 = TargetNamespace.1: Expecting namespace ''{0}'', but the target namespace of the schema document is ''{1}''.
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2000-2002,2004,2005 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
|
||||
*
|
||||
@ -20,13 +20,14 @@
|
||||
|
||||
package com.sun.org.apache.xerces.internal.impl.xpath;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import com.sun.org.apache.xerces.internal.util.SymbolTable;
|
||||
import com.sun.org.apache.xerces.internal.util.XMLSymbols;
|
||||
import com.sun.org.apache.xerces.internal.util.XMLChar;
|
||||
import com.sun.org.apache.xerces.internal.util.XMLSymbols;
|
||||
import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
|
||||
import com.sun.org.apache.xerces.internal.xni.QName;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
* Bare minimum XPath parser.
|
||||
@ -858,10 +859,10 @@ public class XPath {
|
||||
private SymbolTable fSymbolTable;
|
||||
|
||||
// REVISIT: Code something better here. -Ac
|
||||
private java.util.Hashtable fSymbolMapping = new java.util.Hashtable();
|
||||
private Map<String, Integer> fSymbolMapping = new HashMap<>();
|
||||
|
||||
// REVISIT: Code something better here. -Ac
|
||||
private java.util.Hashtable fTokenNames = new java.util.Hashtable();
|
||||
private Map<Integer, String> fTokenNames = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Current position in the token list.
|
||||
@ -882,57 +883,57 @@ public class XPath {
|
||||
"self",
|
||||
};
|
||||
for (int i = 0; i < symbols.length; i++) {
|
||||
fSymbolMapping.put(fSymbolTable.addSymbol(symbols[i]), new Integer(i));
|
||||
fSymbolMapping.put(fSymbolTable.addSymbol(symbols[i]), i);
|
||||
}
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_OPEN_PAREN), "EXPRTOKEN_OPEN_PAREN");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_CLOSE_PAREN), "EXPRTOKEN_CLOSE_PAREN");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_OPEN_BRACKET), "EXPRTOKEN_OPEN_BRACKET");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_CLOSE_BRACKET), "EXPRTOKEN_CLOSE_BRACKET");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_PERIOD), "EXPRTOKEN_PERIOD");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_DOUBLE_PERIOD), "EXPRTOKEN_DOUBLE_PERIOD");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_ATSIGN), "EXPRTOKEN_ATSIGN");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_COMMA), "EXPRTOKEN_COMMA");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_DOUBLE_COLON), "EXPRTOKEN_DOUBLE_COLON");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_NAMETEST_ANY), "EXPRTOKEN_NAMETEST_ANY");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_NAMETEST_NAMESPACE), "EXPRTOKEN_NAMETEST_NAMESPACE");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_NAMETEST_QNAME), "EXPRTOKEN_NAMETEST_QNAME");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_NODETYPE_COMMENT), "EXPRTOKEN_NODETYPE_COMMENT");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_NODETYPE_TEXT), "EXPRTOKEN_NODETYPE_TEXT");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_NODETYPE_PI), "EXPRTOKEN_NODETYPE_PI");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_NODETYPE_NODE), "EXPRTOKEN_NODETYPE_NODE");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_AND), "EXPRTOKEN_OPERATOR_AND");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_OR), "EXPRTOKEN_OPERATOR_OR");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_MOD), "EXPRTOKEN_OPERATOR_MOD");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_DIV), "EXPRTOKEN_OPERATOR_DIV");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_MULT), "EXPRTOKEN_OPERATOR_MULT");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_SLASH), "EXPRTOKEN_OPERATOR_SLASH");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_DOUBLE_SLASH), "EXPRTOKEN_OPERATOR_DOUBLE_SLASH");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_UNION), "EXPRTOKEN_OPERATOR_UNION");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_PLUS), "EXPRTOKEN_OPERATOR_PLUS");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_MINUS), "EXPRTOKEN_OPERATOR_MINUS");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_EQUAL), "EXPRTOKEN_OPERATOR_EQUAL");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_NOT_EQUAL), "EXPRTOKEN_OPERATOR_NOT_EQUAL");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_LESS), "EXPRTOKEN_OPERATOR_LESS");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_LESS_EQUAL), "EXPRTOKEN_OPERATOR_LESS_EQUAL");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_GREATER), "EXPRTOKEN_OPERATOR_GREATER");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_OPERATOR_GREATER_EQUAL), "EXPRTOKEN_OPERATOR_GREATER_EQUAL");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_FUNCTION_NAME), "EXPRTOKEN_FUNCTION_NAME");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_ANCESTOR), "EXPRTOKEN_AXISNAME_ANCESTOR");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_ANCESTOR_OR_SELF), "EXPRTOKEN_AXISNAME_ANCESTOR_OR_SELF");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_ATTRIBUTE), "EXPRTOKEN_AXISNAME_ATTRIBUTE");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_CHILD), "EXPRTOKEN_AXISNAME_CHILD");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_DESCENDANT), "EXPRTOKEN_AXISNAME_DESCENDANT");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_DESCENDANT_OR_SELF), "EXPRTOKEN_AXISNAME_DESCENDANT_OR_SELF");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_FOLLOWING), "EXPRTOKEN_AXISNAME_FOLLOWING");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_FOLLOWING_SIBLING), "EXPRTOKEN_AXISNAME_FOLLOWING_SIBLING");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_NAMESPACE), "EXPRTOKEN_AXISNAME_NAMESPACE");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_PARENT), "EXPRTOKEN_AXISNAME_PARENT");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_PRECEDING), "EXPRTOKEN_AXISNAME_PRECEDING");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_PRECEDING_SIBLING), "EXPRTOKEN_AXISNAME_PRECEDING_SIBLING");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_AXISNAME_SELF), "EXPRTOKEN_AXISNAME_SELF");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_LITERAL), "EXPRTOKEN_LITERAL");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_NUMBER), "EXPRTOKEN_NUMBER");
|
||||
fTokenNames.put(new Integer(EXPRTOKEN_VARIABLE_REFERENCE), "EXPRTOKEN_VARIABLE_REFERENCE");
|
||||
fTokenNames.put(EXPRTOKEN_OPEN_PAREN, "EXPRTOKEN_OPEN_PAREN");
|
||||
fTokenNames.put(EXPRTOKEN_CLOSE_PAREN, "EXPRTOKEN_CLOSE_PAREN");
|
||||
fTokenNames.put(EXPRTOKEN_OPEN_BRACKET, "EXPRTOKEN_OPEN_BRACKET");
|
||||
fTokenNames.put(EXPRTOKEN_CLOSE_BRACKET, "EXPRTOKEN_CLOSE_BRACKET");
|
||||
fTokenNames.put(EXPRTOKEN_PERIOD, "EXPRTOKEN_PERIOD");
|
||||
fTokenNames.put(EXPRTOKEN_DOUBLE_PERIOD, "EXPRTOKEN_DOUBLE_PERIOD");
|
||||
fTokenNames.put(EXPRTOKEN_ATSIGN, "EXPRTOKEN_ATSIGN");
|
||||
fTokenNames.put(EXPRTOKEN_COMMA, "EXPRTOKEN_COMMA");
|
||||
fTokenNames.put(EXPRTOKEN_DOUBLE_COLON, "EXPRTOKEN_DOUBLE_COLON");
|
||||
fTokenNames.put(EXPRTOKEN_NAMETEST_ANY, "EXPRTOKEN_NAMETEST_ANY");
|
||||
fTokenNames.put(EXPRTOKEN_NAMETEST_NAMESPACE, "EXPRTOKEN_NAMETEST_NAMESPACE");
|
||||
fTokenNames.put(EXPRTOKEN_NAMETEST_QNAME, "EXPRTOKEN_NAMETEST_QNAME");
|
||||
fTokenNames.put(EXPRTOKEN_NODETYPE_COMMENT, "EXPRTOKEN_NODETYPE_COMMENT");
|
||||
fTokenNames.put(EXPRTOKEN_NODETYPE_TEXT, "EXPRTOKEN_NODETYPE_TEXT");
|
||||
fTokenNames.put(EXPRTOKEN_NODETYPE_PI, "EXPRTOKEN_NODETYPE_PI");
|
||||
fTokenNames.put(EXPRTOKEN_NODETYPE_NODE, "EXPRTOKEN_NODETYPE_NODE");
|
||||
fTokenNames.put(EXPRTOKEN_OPERATOR_AND, "EXPRTOKEN_OPERATOR_AND");
|
||||
fTokenNames.put(EXPRTOKEN_OPERATOR_OR, "EXPRTOKEN_OPERATOR_OR");
|
||||
fTokenNames.put(EXPRTOKEN_OPERATOR_MOD, "EXPRTOKEN_OPERATOR_MOD");
|
||||
fTokenNames.put(EXPRTOKEN_OPERATOR_DIV, "EXPRTOKEN_OPERATOR_DIV");
|
||||
fTokenNames.put(EXPRTOKEN_OPERATOR_MULT, "EXPRTOKEN_OPERATOR_MULT");
|
||||
fTokenNames.put(EXPRTOKEN_OPERATOR_SLASH, "EXPRTOKEN_OPERATOR_SLASH");
|
||||
fTokenNames.put(EXPRTOKEN_OPERATOR_DOUBLE_SLASH, "EXPRTOKEN_OPERATOR_DOUBLE_SLASH");
|
||||
fTokenNames.put(EXPRTOKEN_OPERATOR_UNION, "EXPRTOKEN_OPERATOR_UNION");
|
||||
fTokenNames.put(EXPRTOKEN_OPERATOR_PLUS, "EXPRTOKEN_OPERATOR_PLUS");
|
||||
fTokenNames.put(EXPRTOKEN_OPERATOR_MINUS, "EXPRTOKEN_OPERATOR_MINUS");
|
||||
fTokenNames.put(EXPRTOKEN_OPERATOR_EQUAL, "EXPRTOKEN_OPERATOR_EQUAL");
|
||||
fTokenNames.put(EXPRTOKEN_OPERATOR_NOT_EQUAL, "EXPRTOKEN_OPERATOR_NOT_EQUAL");
|
||||
fTokenNames.put(EXPRTOKEN_OPERATOR_LESS, "EXPRTOKEN_OPERATOR_LESS");
|
||||
fTokenNames.put(EXPRTOKEN_OPERATOR_LESS_EQUAL, "EXPRTOKEN_OPERATOR_LESS_EQUAL");
|
||||
fTokenNames.put(EXPRTOKEN_OPERATOR_GREATER, "EXPRTOKEN_OPERATOR_GREATER");
|
||||
fTokenNames.put(EXPRTOKEN_OPERATOR_GREATER_EQUAL, "EXPRTOKEN_OPERATOR_GREATER_EQUAL");
|
||||
fTokenNames.put(EXPRTOKEN_FUNCTION_NAME, "EXPRTOKEN_FUNCTION_NAME");
|
||||
fTokenNames.put(EXPRTOKEN_AXISNAME_ANCESTOR, "EXPRTOKEN_AXISNAME_ANCESTOR");
|
||||
fTokenNames.put(EXPRTOKEN_AXISNAME_ANCESTOR_OR_SELF, "EXPRTOKEN_AXISNAME_ANCESTOR_OR_SELF");
|
||||
fTokenNames.put(EXPRTOKEN_AXISNAME_ATTRIBUTE, "EXPRTOKEN_AXISNAME_ATTRIBUTE");
|
||||
fTokenNames.put(EXPRTOKEN_AXISNAME_CHILD, "EXPRTOKEN_AXISNAME_CHILD");
|
||||
fTokenNames.put(EXPRTOKEN_AXISNAME_DESCENDANT, "EXPRTOKEN_AXISNAME_DESCENDANT");
|
||||
fTokenNames.put(EXPRTOKEN_AXISNAME_DESCENDANT_OR_SELF, "EXPRTOKEN_AXISNAME_DESCENDANT_OR_SELF");
|
||||
fTokenNames.put(EXPRTOKEN_AXISNAME_FOLLOWING, "EXPRTOKEN_AXISNAME_FOLLOWING");
|
||||
fTokenNames.put(EXPRTOKEN_AXISNAME_FOLLOWING_SIBLING, "EXPRTOKEN_AXISNAME_FOLLOWING_SIBLING");
|
||||
fTokenNames.put(EXPRTOKEN_AXISNAME_NAMESPACE, "EXPRTOKEN_AXISNAME_NAMESPACE");
|
||||
fTokenNames.put(EXPRTOKEN_AXISNAME_PARENT, "EXPRTOKEN_AXISNAME_PARENT");
|
||||
fTokenNames.put(EXPRTOKEN_AXISNAME_PRECEDING, "EXPRTOKEN_AXISNAME_PRECEDING");
|
||||
fTokenNames.put(EXPRTOKEN_AXISNAME_PRECEDING_SIBLING, "EXPRTOKEN_AXISNAME_PRECEDING_SIBLING");
|
||||
fTokenNames.put(EXPRTOKEN_AXISNAME_SELF, "EXPRTOKEN_AXISNAME_SELF");
|
||||
fTokenNames.put(EXPRTOKEN_LITERAL, "EXPRTOKEN_LITERAL");
|
||||
fTokenNames.put(EXPRTOKEN_NUMBER, "EXPRTOKEN_NUMBER");
|
||||
fTokenNames.put(EXPRTOKEN_VARIABLE_REFERENCE, "EXPRTOKEN_VARIABLE_REFERENCE");
|
||||
}
|
||||
|
||||
//
|
||||
@ -946,16 +947,21 @@ public class XPath {
|
||||
// }
|
||||
//
|
||||
public String getTokenString(int token) {
|
||||
return (String)fTokenNames.get(new Integer(token));
|
||||
return fTokenNames.get(token);
|
||||
}
|
||||
|
||||
public void addToken(String tokenStr) {
|
||||
Integer tokenInt = (Integer)fTokenNames.get(tokenStr);
|
||||
Integer tokenInt = null;
|
||||
for (Map.Entry<Integer, String> entry : fTokenNames.entrySet()) {
|
||||
if (entry.getValue().equals(tokenStr)) {
|
||||
tokenInt = entry.getKey();
|
||||
}
|
||||
}
|
||||
if (tokenInt == null) {
|
||||
tokenInt = new Integer(fTokenNames.size());
|
||||
tokenInt = fTokenNames.size();
|
||||
fTokenNames.put(tokenInt, tokenStr);
|
||||
}
|
||||
addToken(tokenInt.intValue());
|
||||
addToken(tokenInt);
|
||||
}
|
||||
|
||||
public void addToken(int token) {
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2005 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
|
||||
*
|
||||
@ -20,8 +20,9 @@
|
||||
|
||||
package com.sun.org.apache.xerces.internal.impl.xpath.regex;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A regular expression parser for the XML Schema.
|
||||
@ -368,12 +369,12 @@ class ParserForXMLSchema extends RegexParser {
|
||||
return c;
|
||||
}
|
||||
|
||||
static private Hashtable ranges = null;
|
||||
static private Hashtable ranges2 = null;
|
||||
static private Map<String, Token> ranges = null;
|
||||
static private Map<String, Token> ranges2 = null;
|
||||
static synchronized protected RangeToken getRange(String name, boolean positive) {
|
||||
if (ranges == null) {
|
||||
ranges = new Hashtable();
|
||||
ranges2 = new Hashtable();
|
||||
ranges = new HashMap<>();
|
||||
ranges2 = new HashMap<>();
|
||||
|
||||
Token tok = Token.createRange();
|
||||
setupRange(tok, SPACES);
|
||||
@ -389,7 +390,7 @@ class ParserForXMLSchema extends RegexParser {
|
||||
tok = Token.createRange();
|
||||
setupRange(tok, LETTERS);
|
||||
setupRange(tok, LETTERS_INT);
|
||||
tok.mergeRanges((Token)ranges.get("xml:isDigit"));
|
||||
tok.mergeRanges(ranges.get("xml:isDigit"));
|
||||
ranges.put("xml:isWord", tok);
|
||||
ranges2.put("xml:isWord", Token.complementRanges(tok));
|
||||
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 1999-2002,2004,2005 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
|
||||
*
|
||||
@ -20,8 +20,18 @@
|
||||
|
||||
package com.sun.org.apache.xerces.internal.impl.xpath.regex;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.ObjectStreamField;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
import java.util.Hashtable;
|
||||
|
||||
/**
|
||||
* This class represents a node in parse tree.
|
||||
@ -582,8 +592,8 @@ class Token implements java.io.Serializable {
|
||||
}
|
||||
|
||||
// ------------------------------------------------------
|
||||
private final static Hashtable categories = new Hashtable();
|
||||
private final static Hashtable categories2 = new Hashtable();
|
||||
private final static Map<String, Token> categories = new HashMap<>();
|
||||
private final static Map<String, Token> categories2 = new HashMap<>();
|
||||
private static final String[] categoryNames = {
|
||||
"Cn", "Lu", "Ll", "Lt", "Lm", "Lo", "Mn", "Me", "Mc", "Nd",
|
||||
"Nl", "No", "Zs", "Zl", "Zp", "Cc", "Cf", null, "Co", "Cs",
|
||||
@ -819,7 +829,7 @@ class Token implements java.io.Serializable {
|
||||
//REVISIT: do we really need to support block names as in Unicode 3.1
|
||||
// or we can just create all the names in IsBLOCKNAME format (XML Schema REC)?
|
||||
//
|
||||
StringBuffer buffer = new StringBuffer(50);
|
||||
StringBuilder buffer = new StringBuilder(50);
|
||||
for (int i = 0; i < Token.blockNames.length; i ++) {
|
||||
Token r1 = Token.createRange();
|
||||
int location;
|
||||
@ -971,22 +981,17 @@ class Token implements java.io.Serializable {
|
||||
return range;
|
||||
}
|
||||
|
||||
static Hashtable nonxs = null;
|
||||
static final Set<String> nonxs = Collections.synchronizedSet(new HashSet<>());
|
||||
/**
|
||||
* This method is called by only getRange().
|
||||
* So this method need not MT-safe.
|
||||
*/
|
||||
static protected void registerNonXS(String name) {
|
||||
if (Token.nonxs == null)
|
||||
Token.nonxs = new Hashtable();
|
||||
Token.nonxs.put(name, name);
|
||||
Token.nonxs.add(name);
|
||||
}
|
||||
|
||||
static protected boolean isRegisterNonXS(String name) {
|
||||
if (Token.nonxs == null)
|
||||
return false;
|
||||
//DEBUG
|
||||
//System.err.println("isRegisterNonXS: "+name);
|
||||
return Token.nonxs.containsKey(name);
|
||||
return Token.nonxs.contains(name);
|
||||
}
|
||||
|
||||
private static void setAlias(String newName, String name, boolean positive) {
|
||||
@ -1422,17 +1427,26 @@ class Token implements java.io.Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2568843945989489861L;
|
||||
|
||||
Vector children;
|
||||
List<Token> children;
|
||||
|
||||
/**
|
||||
* @serialField children Vector children
|
||||
*/
|
||||
private static final ObjectStreamField[] serialPersistentFields =
|
||||
new ObjectStreamField[] {
|
||||
new ObjectStreamField("children", Vector.class),
|
||||
};
|
||||
|
||||
UnionToken(int type) {
|
||||
super(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
void addChild(Token tok) {
|
||||
if (tok == null) return;
|
||||
if (this.children == null) this.children = new Vector();
|
||||
if (this.children == null) this.children = new ArrayList<>();
|
||||
if (this.type == UNION) {
|
||||
this.children.addElement(tok);
|
||||
this.children.add(tok);
|
||||
return;
|
||||
}
|
||||
// This is CONCAT, and new child is CONCAT.
|
||||
@ -1443,31 +1457,31 @@ class Token implements java.io.Serializable {
|
||||
}
|
||||
int size = this.children.size();
|
||||
if (size == 0) {
|
||||
this.children.addElement(tok);
|
||||
this.children.add(tok);
|
||||
return;
|
||||
}
|
||||
Token previous = (Token)this.children.elementAt(size-1);
|
||||
Token previous = this.children.get(size - 1);
|
||||
if (!((previous.type == CHAR || previous.type == STRING)
|
||||
&& (tok.type == CHAR || tok.type == STRING))) {
|
||||
this.children.addElement(tok);
|
||||
this.children.add(tok);
|
||||
return;
|
||||
}
|
||||
|
||||
//System.err.println("Merge '"+previous+"' and '"+tok+"'.");
|
||||
|
||||
StringBuffer buffer;
|
||||
StringBuilder buffer;
|
||||
int nextMaxLength = (tok.type == CHAR ? 2 : tok.getString().length());
|
||||
if (previous.type == CHAR) { // Replace previous token by STRING
|
||||
buffer = new StringBuffer(2 + nextMaxLength);
|
||||
buffer = new StringBuilder(2 + nextMaxLength);
|
||||
int ch = previous.getChar();
|
||||
if (ch >= 0x10000)
|
||||
buffer.append(REUtil.decomposeToSurrogates(ch));
|
||||
else
|
||||
buffer.append((char)ch);
|
||||
previous = Token.createString(null);
|
||||
this.children.setElementAt(previous, size-1);
|
||||
this.children.set(size - 1, previous);
|
||||
} else { // STRING
|
||||
buffer = new StringBuffer(previous.getString().length() + nextMaxLength);
|
||||
buffer = new StringBuilder(previous.getString().length() + nextMaxLength);
|
||||
buffer.append(previous.getString());
|
||||
}
|
||||
|
||||
@ -1484,13 +1498,16 @@ class Token implements java.io.Serializable {
|
||||
((StringToken)previous).string = new String(buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
int size() {
|
||||
return this.children == null ? 0 : this.children.size();
|
||||
}
|
||||
@Override
|
||||
Token getChild(int index) {
|
||||
return (Token)this.children.elementAt(index);
|
||||
return this.children.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(int options) {
|
||||
String ret;
|
||||
if (this.type == CONCAT) {
|
||||
@ -1504,10 +1521,10 @@ class Token implements java.io.Serializable {
|
||||
} else
|
||||
ret = ch.toString(options)+ch2.toString(options);
|
||||
} else {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i = 0; i < this.children.size(); i ++) {
|
||||
sb.append(((Token)this.children.elementAt(i)).toString(options));
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
this.children.stream().forEach((children1) -> {
|
||||
sb.append((children1).toString(options));
|
||||
});
|
||||
ret = new String(sb);
|
||||
}
|
||||
return ret;
|
||||
@ -1518,15 +1535,39 @@ class Token implements java.io.Serializable {
|
||||
&& this.getChild(0).type == EMPTY) {
|
||||
ret = this.getChild(1).toString(options)+"??";
|
||||
} else {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(((Token)this.children.elementAt(0)).toString(options));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append((this.children.get(0)).toString(options));
|
||||
for (int i = 1; i < this.children.size(); i ++) {
|
||||
sb.append((char)'|');
|
||||
sb.append(((Token)this.children.elementAt(i)).toString(options));
|
||||
sb.append((this.children.get(i)).toString(options));
|
||||
}
|
||||
ret = new String(sb);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* @serialData Serialized fields. Convert the List to Vector for backward compatibility.
|
||||
*/
|
||||
private void writeObject(ObjectOutputStream out) throws IOException {
|
||||
// Convert List to Vector
|
||||
Vector<Token> vChildren = (children == null)? null : new Vector<>(children);
|
||||
|
||||
// Write serialized fields
|
||||
ObjectOutputStream.PutField pf = out.putFields();
|
||||
pf.put("children", vChildren);
|
||||
out.writeFields();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void readObject(ObjectInputStream in)
|
||||
throws IOException, ClassNotFoundException {
|
||||
// We have to read serialized fields first.
|
||||
ObjectInputStream.GetField gf = in.readFields();
|
||||
Vector<Token> vChildren = (Vector<Token>)gf.get("children", null);
|
||||
|
||||
//convert Vector back to List
|
||||
if (vChildren != null) children = new ArrayList<>(vChildren);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
/*
|
||||
* reserved comment block
|
||||
* DO NOT REMOVE OR ALTER!
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
@ -21,12 +20,14 @@
|
||||
|
||||
package com.sun.org.apache.xerces.internal.impl.xs;
|
||||
|
||||
import com.sun.org.apache.xerces.internal.xni.QName;
|
||||
import com.sun.org.apache.xerces.internal.xs.XSConstants;
|
||||
import com.sun.org.apache.xerces.internal.xs.XSElementDeclaration;
|
||||
import com.sun.org.apache.xerces.internal.xs.XSObjectList;
|
||||
import com.sun.org.apache.xerces.internal.xs.XSSimpleTypeDefinition;
|
||||
import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
|
||||
import com.sun.org.apache.xerces.internal.xni.QName;
|
||||
import java.util.Hashtable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
|
||||
/**
|
||||
@ -175,14 +176,14 @@ public class SubstitutionGroupHandler {
|
||||
}
|
||||
|
||||
// to store substitution group information
|
||||
// the key to the hashtable is an element decl, and the value is
|
||||
// the key to the map is an element decl, and the value is
|
||||
// - a Vector, which contains all elements that has this element as their
|
||||
// substitution group affilication
|
||||
// - an array of OneSubGroup, which contains its substitution group before block.
|
||||
Hashtable fSubGroupsB = new Hashtable();
|
||||
Map<XSElementDecl, Object> fSubGroupsB = new HashMap<>();
|
||||
private static final OneSubGroup[] EMPTY_VECTOR = new OneSubGroup[0];
|
||||
// The real substitution groups (after "block")
|
||||
Hashtable fSubGroups = new Hashtable();
|
||||
Map<XSElementDecl, XSElementDecl[]> fSubGroups = new HashMap<>();
|
||||
|
||||
/**
|
||||
* clear the internal registry of substitutionGroup information
|
||||
@ -224,9 +225,9 @@ public class SubstitutionGroupHandler {
|
||||
*/
|
||||
public XSElementDecl[] getSubstitutionGroup(XSElementDecl element) {
|
||||
// If we already have sub group for this element, just return it.
|
||||
Object subGroup = fSubGroups.get(element);
|
||||
XSElementDecl[] subGroup = fSubGroups.get(element);
|
||||
if (subGroup != null)
|
||||
return (XSElementDecl[])subGroup;
|
||||
return subGroup;
|
||||
|
||||
if ((element.fBlock & XSConstants.DERIVATION_SUBSTITUTION) != 0) {
|
||||
fSubGroups.put(element, EMPTY_GROUP);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
@ -592,9 +592,8 @@ XSLoader, DOMConfiguration {
|
||||
* @throws IOException
|
||||
* @throws XNIException
|
||||
*/
|
||||
SchemaGrammar loadSchema(XSDDescription desc,
|
||||
XMLInputSource source,
|
||||
Map locationPairs) throws IOException, XNIException {
|
||||
SchemaGrammar loadSchema(XSDDescription desc, XMLInputSource source,
|
||||
Map<String, LocationArray> locationPairs) throws IOException, XNIException {
|
||||
|
||||
// this should only be done once per invocation of this object;
|
||||
// unless application alters JAXPSource in the mean time.
|
||||
@ -617,9 +616,9 @@ XSLoader, DOMConfiguration {
|
||||
|
||||
/**
|
||||
* This method tries to resolve location of the given schema.
|
||||
* The loader stores the namespace/location pairs in a hashtable (use "" as the
|
||||
* The loader stores the namespace/location pairs in a map (use "" as the
|
||||
* namespace of absent namespace). When resolving an entity, loader first tries
|
||||
* to find in the hashtable whether there is a value for that namespace,
|
||||
* to find in the map whether there is a value for that namespace,
|
||||
* if so, pass that location value to the user-defined entity resolver.
|
||||
*
|
||||
* @param desc
|
||||
@ -628,7 +627,8 @@ XSLoader, DOMConfiguration {
|
||||
* @return the XMLInputSource
|
||||
* @throws IOException
|
||||
*/
|
||||
public static XMLInputSource resolveDocument(XSDDescription desc, Map locationPairs,
|
||||
public static XMLInputSource resolveDocument(XSDDescription desc,
|
||||
Map<String, LocationArray> locationPairs,
|
||||
XMLEntityResolver entityResolver) throws IOException {
|
||||
String loc = null;
|
||||
// we consider the schema location properties for import
|
||||
@ -638,7 +638,7 @@ XSLoader, DOMConfiguration {
|
||||
String namespace = desc.getTargetNamespace();
|
||||
String ns = namespace == null ? XMLSymbols.EMPTY_STRING : namespace;
|
||||
// get the location hint for that namespace
|
||||
LocationArray tempLA = (LocationArray)locationPairs.get(ns);
|
||||
LocationArray tempLA = locationPairs.get(ns);
|
||||
if(tempLA != null)
|
||||
loc = tempLA.getFirstLocation();
|
||||
}
|
||||
@ -659,7 +659,7 @@ XSLoader, DOMConfiguration {
|
||||
|
||||
// add external schema locations to the location pairs
|
||||
public static void processExternalHints(String sl, String nsl,
|
||||
Map locations,
|
||||
Map<String, XMLSchemaLoader.LocationArray> locations,
|
||||
XMLErrorReporter er) {
|
||||
if (sl != null) {
|
||||
try {
|
||||
@ -712,7 +712,8 @@ XSLoader, DOMConfiguration {
|
||||
// @param schemaStr The schemaLocation string to tokenize
|
||||
// @param locations HashMap mapping namespaces to LocationArray objects holding lists of locaitons
|
||||
// @return true if no problems; false if string could not be tokenized
|
||||
public static boolean tokenizeSchemaLocationStr(String schemaStr, Map locations, String base) {
|
||||
public static boolean tokenizeSchemaLocationStr(String schemaStr,
|
||||
Map<String, XMLSchemaLoader.LocationArray> locations, String base) {
|
||||
if (schemaStr!= null) {
|
||||
StringTokenizer t = new StringTokenizer(schemaStr, " \n\t\r");
|
||||
String namespace, location;
|
||||
@ -722,7 +723,7 @@ XSLoader, DOMConfiguration {
|
||||
return false; // error!
|
||||
}
|
||||
location = t.nextToken();
|
||||
LocationArray la = ((LocationArray)locations.get(namespace));
|
||||
LocationArray la = locations.get(namespace);
|
||||
if(la == null) {
|
||||
la = new LocationArray();
|
||||
locations.put(namespace, la);
|
||||
@ -749,7 +750,8 @@ XSLoader, DOMConfiguration {
|
||||
* Note: all JAXP schema files will be checked for full-schema validity if the feature was set up
|
||||
*
|
||||
*/
|
||||
private void processJAXPSchemaSource(Map locationPairs) throws IOException {
|
||||
private void processJAXPSchemaSource(
|
||||
Map<String, LocationArray> locationPairs) throws IOException {
|
||||
fJAXPProcessed = true;
|
||||
if (fJAXPSource == null) {
|
||||
return;
|
||||
@ -932,7 +934,7 @@ XSLoader, DOMConfiguration {
|
||||
return new XMLInputSource(publicId, systemId, null);
|
||||
}
|
||||
|
||||
static class LocationArray{
|
||||
public static class LocationArray{
|
||||
|
||||
int length ;
|
||||
String [] locations = new String[2];
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
@ -20,15 +20,6 @@
|
||||
|
||||
package com.sun.org.apache.xerces.internal.impl.xs;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
import java.util.Vector;
|
||||
import javax.xml.XMLConstants;
|
||||
import com.sun.org.apache.xerces.internal.impl.Constants;
|
||||
import com.sun.org.apache.xerces.internal.impl.RevalidationHandler;
|
||||
import com.sun.org.apache.xerces.internal.impl.XMLEntityManager;
|
||||
@ -53,13 +44,14 @@ import com.sun.org.apache.xerces.internal.impl.xs.models.CMBuilder;
|
||||
import com.sun.org.apache.xerces.internal.impl.xs.models.CMNodeFactory;
|
||||
import com.sun.org.apache.xerces.internal.impl.xs.models.XSCMValidator;
|
||||
import com.sun.org.apache.xerces.internal.impl.xs.util.XS10TypeHelper;
|
||||
import com.sun.org.apache.xerces.internal.parsers.XMLParser;
|
||||
import com.sun.org.apache.xerces.internal.util.AugmentationsImpl;
|
||||
import com.sun.org.apache.xerces.internal.util.IntStack;
|
||||
import com.sun.org.apache.xerces.internal.util.SymbolTable;
|
||||
import com.sun.org.apache.xerces.internal.util.URI.MalformedURIException;
|
||||
import com.sun.org.apache.xerces.internal.util.XMLAttributesImpl;
|
||||
import com.sun.org.apache.xerces.internal.util.XMLChar;
|
||||
import com.sun.org.apache.xerces.internal.util.XMLSymbols;
|
||||
import com.sun.org.apache.xerces.internal.util.URI.MalformedURIException;
|
||||
import com.sun.org.apache.xerces.internal.xni.Augmentations;
|
||||
import com.sun.org.apache.xerces.internal.xni.NamespaceContext;
|
||||
import com.sun.org.apache.xerces.internal.xni.QName;
|
||||
@ -85,7 +77,15 @@ import com.sun.org.apache.xerces.internal.xs.StringList;
|
||||
import com.sun.org.apache.xerces.internal.xs.XSConstants;
|
||||
import com.sun.org.apache.xerces.internal.xs.XSObjectList;
|
||||
import com.sun.org.apache.xerces.internal.xs.XSTypeDefinition;
|
||||
import com.sun.org.apache.xerces.internal.parsers.XMLParser;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
import java.util.Vector;
|
||||
import javax.xml.XMLConstants;
|
||||
|
||||
/**
|
||||
* The XML Schema validator. The validator implements a document
|
||||
@ -352,9 +352,6 @@ public class XMLSchemaValidator
|
||||
static final XSAttributeDecl XSI_SCHEMALOCATION = SchemaGrammar.SG_XSI.getGlobalAttributeDecl(SchemaSymbols.XSI_SCHEMALOCATION);
|
||||
static final XSAttributeDecl XSI_NONAMESPACESCHEMALOCATION = SchemaGrammar.SG_XSI.getGlobalAttributeDecl(SchemaSymbols.XSI_NONAMESPACESCHEMALOCATION);
|
||||
|
||||
//
|
||||
private static final Hashtable EMPTY_TABLE = new Hashtable();
|
||||
|
||||
//
|
||||
// Data
|
||||
//
|
||||
@ -536,7 +533,7 @@ public class XMLSchemaValidator
|
||||
|
||||
/** Schema Grammar Description passed, to give a chance to application to supply the Grammar */
|
||||
protected final XSDDescription fXSDDescription = new XSDDescription();
|
||||
protected final Hashtable fLocationPairs = new Hashtable();
|
||||
protected final Map<String, XMLSchemaLoader.LocationArray> fLocationPairs = new HashMap<>();
|
||||
|
||||
|
||||
// handlers
|
||||
@ -2583,7 +2580,8 @@ public class XMLSchemaValidator
|
||||
|
||||
void storeLocations(String sLocation, String nsLocation) {
|
||||
if (sLocation != null) {
|
||||
if (!XMLSchemaLoader.tokenizeSchemaLocationStr(sLocation, fLocationPairs, fLocator == null ? null : fLocator.getExpandedSystemId())) {
|
||||
if (!XMLSchemaLoader.tokenizeSchemaLocationStr(sLocation,
|
||||
fLocationPairs, fLocator == null ? null : fLocator.getExpandedSystemId())) {
|
||||
// error!
|
||||
fXSIErrorReporter.reportError(
|
||||
XSMessageFormatter.SCHEMA_DOMAIN,
|
||||
@ -2593,8 +2591,7 @@ public class XMLSchemaValidator
|
||||
}
|
||||
}
|
||||
if (nsLocation != null) {
|
||||
XMLSchemaLoader.LocationArray la =
|
||||
((XMLSchemaLoader.LocationArray) fLocationPairs.get(XMLSymbols.EMPTY_STRING));
|
||||
XMLSchemaLoader.LocationArray la = fLocationPairs.get(XMLSymbols.EMPTY_STRING);
|
||||
if (la == null) {
|
||||
la = new XMLSchemaLoader.LocationArray();
|
||||
fLocationPairs.put(XMLSymbols.EMPTY_STRING, la);
|
||||
@ -2657,11 +2654,11 @@ public class XMLSchemaValidator
|
||||
fXSDDescription.setBaseSystemId(fLocator.getExpandedSystemId());
|
||||
}
|
||||
|
||||
Hashtable locationPairs = fLocationPairs;
|
||||
Object locationArray =
|
||||
Map<String, XMLSchemaLoader.LocationArray> locationPairs = fLocationPairs;
|
||||
XMLSchemaLoader.LocationArray locationArray =
|
||||
locationPairs.get(namespace == null ? XMLSymbols.EMPTY_STRING : namespace);
|
||||
if (locationArray != null) {
|
||||
String[] temp = ((XMLSchemaLoader.LocationArray) locationArray).getLocationArray();
|
||||
String[] temp = locationArray.getLocationArray();
|
||||
if (temp.length != 0) {
|
||||
setLocationHints(fXSDDescription, temp, grammar);
|
||||
}
|
||||
@ -2671,7 +2668,7 @@ public class XMLSchemaValidator
|
||||
boolean toParseSchema = true;
|
||||
if (grammar != null) {
|
||||
// use location hints instead
|
||||
locationPairs = EMPTY_TABLE;
|
||||
locationPairs = Collections.emptyMap();
|
||||
}
|
||||
|
||||
// try to parse the grammar using location hints from that namespace..
|
||||
@ -3981,7 +3978,7 @@ public class XMLSchemaValidator
|
||||
|
||||
protected void checkDuplicateValues() {
|
||||
// no-op
|
||||
} // duplicateValue(Hashtable)
|
||||
} // duplicateValue(Map)
|
||||
|
||||
/** Returns a string of the specified values. */
|
||||
protected String toString(Object[] values) {
|
||||
@ -4154,7 +4151,7 @@ public class XMLSchemaValidator
|
||||
String cName = fIdentityConstraint.getIdentityConstraintName();
|
||||
reportSchemaError(code, new Object[] { value, eName, cName });
|
||||
}
|
||||
} // duplicateValue(Hashtable)
|
||||
} // duplicateValue(Map)
|
||||
|
||||
} // class UniqueValueStore
|
||||
|
||||
@ -4191,7 +4188,7 @@ public class XMLSchemaValidator
|
||||
String cName = fIdentityConstraint.getIdentityConstraintName();
|
||||
reportSchemaError(code, new Object[] { value, eName, cName });
|
||||
}
|
||||
} // duplicateValue(Hashtable)
|
||||
} // duplicateValue(Map)
|
||||
|
||||
} // class KeyValueStore
|
||||
|
||||
@ -4283,14 +4280,15 @@ public class XMLSchemaValidator
|
||||
|
||||
/**
|
||||
* Values stores associated to specific identity constraints.
|
||||
* This hashtable maps IdentityConstraints and
|
||||
* This map maps IdentityConstraints and
|
||||
* the 0-based element on which their selectors first matched to
|
||||
* a corresponding ValueStore. This should take care
|
||||
* of all cases, including where ID constraints with
|
||||
* descendant-or-self axes occur on recursively-defined
|
||||
* elements.
|
||||
*/
|
||||
protected final HashMap fIdentityConstraint2ValueStoreMap = new HashMap();
|
||||
protected final Map<LocalIDKey, ValueStoreBase>
|
||||
fIdentityConstraint2ValueStoreMap = new HashMap<>();
|
||||
|
||||
// sketch of algorithm:
|
||||
// - when a constraint is first encountered, its
|
||||
@ -4303,7 +4301,7 @@ public class XMLSchemaValidator
|
||||
// The fGlobalIDMapStack has the following structure:
|
||||
// - validation always occurs against the fGlobalIDConstraintMap
|
||||
// (which comprises all the "eligible" id constraints);
|
||||
// When an endElement is found, this Hashtable is merged with the one
|
||||
// When an endElement is found, this Map is merged with the one
|
||||
// below in the stack.
|
||||
// When a start tag is encountered, we create a new
|
||||
// fGlobalIDConstraintMap.
|
||||
@ -4311,8 +4309,10 @@ public class XMLSchemaValidator
|
||||
// the preceding siblings' eligible id constraints;
|
||||
// the fGlobalIDConstraintMap contains descendants+self.
|
||||
// keyrefs can only match descendants+self.
|
||||
protected final Stack fGlobalMapStack = new Stack();
|
||||
protected final HashMap fGlobalIDConstraintMap = new HashMap();
|
||||
protected final Stack<Map<IdentityConstraint, ValueStoreBase>>
|
||||
fGlobalMapStack = new Stack<>();
|
||||
protected final Map<IdentityConstraint, ValueStoreBase>
|
||||
fGlobalIDConstraintMap = new HashMap<>();
|
||||
|
||||
//
|
||||
// Constructors
|
||||
@ -4339,7 +4339,8 @@ public class XMLSchemaValidator
|
||||
public void startElement() {
|
||||
// only clone the map when there are elements
|
||||
if (fGlobalIDConstraintMap.size() > 0)
|
||||
fGlobalMapStack.push(fGlobalIDConstraintMap.clone());
|
||||
fGlobalMapStack.push((Map<IdentityConstraint, ValueStoreBase>)
|
||||
((HashMap)fGlobalIDConstraintMap).clone());
|
||||
else
|
||||
fGlobalMapStack.push(null);
|
||||
fGlobalIDConstraintMap.clear();
|
||||
@ -4352,19 +4353,17 @@ public class XMLSchemaValidator
|
||||
if (fGlobalMapStack.isEmpty()) {
|
||||
return; // must be an invalid doc!
|
||||
}
|
||||
HashMap oldMap = (HashMap) fGlobalMapStack.pop();
|
||||
Map<IdentityConstraint, ValueStoreBase> oldMap = fGlobalMapStack.pop();
|
||||
// return if there is no element
|
||||
if (oldMap == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator entries = oldMap.entrySet().iterator();
|
||||
while (entries.hasNext()) {
|
||||
Map.Entry entry = (Map.Entry) entries.next();
|
||||
IdentityConstraint id = (IdentityConstraint) entry.getKey();
|
||||
ValueStoreBase oldVal = (ValueStoreBase) entry.getValue();
|
||||
for (Map.Entry<IdentityConstraint, ValueStoreBase> entry : oldMap.entrySet()) {
|
||||
IdentityConstraint id = entry.getKey();
|
||||
ValueStoreBase oldVal = entry.getValue();
|
||||
if (oldVal != null) {
|
||||
ValueStoreBase currVal = (ValueStoreBase) fGlobalIDConstraintMap.get(id);
|
||||
ValueStoreBase currVal = fGlobalIDConstraintMap.get(id);
|
||||
if (currVal == null) {
|
||||
fGlobalIDConstraintMap.put(id, oldVal);
|
||||
}
|
||||
@ -4438,26 +4437,25 @@ public class XMLSchemaValidator
|
||||
public ValueStoreBase getValueStoreFor(IdentityConstraint id, int initialDepth) {
|
||||
fLocalId.fDepth = initialDepth;
|
||||
fLocalId.fId = id;
|
||||
return (ValueStoreBase) fIdentityConstraint2ValueStoreMap.get(fLocalId);
|
||||
return fIdentityConstraint2ValueStoreMap.get(fLocalId);
|
||||
} // getValueStoreFor(IdentityConstraint, int):ValueStoreBase
|
||||
|
||||
/** Returns the global value store associated to the specified IdentityConstraint. */
|
||||
public ValueStoreBase getGlobalValueStoreFor(IdentityConstraint id) {
|
||||
return (ValueStoreBase) fGlobalIDConstraintMap.get(id);
|
||||
return fGlobalIDConstraintMap.get(id);
|
||||
} // getValueStoreFor(IdentityConstraint):ValueStoreBase
|
||||
|
||||
// This method takes the contents of the (local) ValueStore
|
||||
// associated with id and moves them into the global
|
||||
// hashtable, if id is a <unique> or a <key>.
|
||||
// map, if id is a <unique> or a <key>.
|
||||
// If it's a <keyRef>, then we leave it for later.
|
||||
public void transplant(IdentityConstraint id, int initialDepth) {
|
||||
fLocalId.fDepth = initialDepth;
|
||||
fLocalId.fId = id;
|
||||
ValueStoreBase newVals =
|
||||
(ValueStoreBase) fIdentityConstraint2ValueStoreMap.get(fLocalId);
|
||||
ValueStoreBase newVals = fIdentityConstraint2ValueStoreMap.get(fLocalId);
|
||||
if (id.getCategory() == IdentityConstraint.IC_KEYREF)
|
||||
return;
|
||||
ValueStoreBase currVals = (ValueStoreBase) fGlobalIDConstraintMap.get(id);
|
||||
ValueStoreBase currVals = fGlobalIDConstraintMap.get(id);
|
||||
if (currVals != null) {
|
||||
currVals.append(newVals);
|
||||
fGlobalIDConstraintMap.put(id, currVals);
|
||||
@ -4498,7 +4496,7 @@ public class XMLSchemaValidator
|
||||
} // class ValueStoreCache
|
||||
|
||||
// the purpose of this class is to enable IdentityConstraint,int
|
||||
// pairs to be used easily as keys in Hashtables.
|
||||
// pairs to be used easily as keys in Maps.
|
||||
protected static final class LocalIDKey {
|
||||
|
||||
public IdentityConstraint fId;
|
||||
|
||||
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