From 9556f88777b749e2e436b61073ea9d3c68630f42 Mon Sep 17 00:00:00 2001 From: Anthony Green Date: Wed, 11 Jul 2001 03:59:16 +0000 Subject: [PATCH] Add some org packages. From-SVN: r43922 --- libjava/ChangeLog | 43 + libjava/Makefile.am | 57 +- libjava/Makefile.in | 1098 ++++++++++++++++- libjava/org/w3c/dom/Attr.java | 111 ++ libjava/org/w3c/dom/CDATASection.java | 48 + libjava/org/w3c/dom/CharacterData.java | 144 +++ libjava/org/w3c/dom/Comment.java | 24 + libjava/org/w3c/dom/DOMException.java | 117 ++ libjava/org/w3c/dom/DOMImplementation.java | 100 ++ libjava/org/w3c/dom/Document.java | 365 ++++++ libjava/org/w3c/dom/DocumentFragment.java | 52 + libjava/org/w3c/dom/DocumentType.java | 79 ++ libjava/org/w3c/dom/Element.java | 302 +++++ libjava/org/w3c/dom/Entity.java | 68 + libjava/org/w3c/dom/EntityReference.java | 39 + libjava/org/w3c/dom/NamedNodeMap.java | 156 +++ libjava/org/w3c/dom/Node.java | 390 ++++++ libjava/org/w3c/dom/NodeList.java | 41 + libjava/org/w3c/dom/Notation.java | 40 + .../org/w3c/dom/ProcessingInstruction.java | 40 + libjava/org/w3c/dom/Text.java | 56 + libjava/org/w3c/dom/ranges/DocumentRange.java | 33 + libjava/org/w3c/dom/ranges/Range.java | 399 ++++++ .../org/w3c/dom/ranges/RangeException.java | 39 + .../w3c/dom/traversal/DocumentTraversal.java | 90 ++ libjava/org/w3c/dom/traversal/NodeFilter.java | 142 +++ .../org/w3c/dom/traversal/NodeIterator.java | 108 ++ libjava/org/w3c/dom/traversal/TreeWalker.java | 167 +++ libjava/org/xml/sax/AttributeList.java | 191 +++ libjava/org/xml/sax/Attributes.java | 243 ++++ libjava/org/xml/sax/ContentHandler.java | 374 ++++++ libjava/org/xml/sax/DTDHandler.java | 108 ++ libjava/org/xml/sax/DocumentHandler.java | 230 ++++ libjava/org/xml/sax/EntityResolver.java | 110 ++ libjava/org/xml/sax/ErrorHandler.java | 123 ++ libjava/org/xml/sax/HandlerBase.java | 368 ++++++ libjava/org/xml/sax/InputSource.java | 321 +++++ libjava/org/xml/sax/Locator.java | 126 ++ libjava/org/xml/sax/Parser.java | 207 ++++ libjava/org/xml/sax/SAXException.java | 144 +++ .../xml/sax/SAXNotRecognizedException.java | 44 + .../org/xml/sax/SAXNotSupportedException.java | 44 + libjava/org/xml/sax/SAXParseException.java | 264 ++++ libjava/org/xml/sax/XMLFilter.java | 65 + libjava/org/xml/sax/XMLReader.java | 415 +++++++ libjava/org/xml/sax/ext/DeclHandler.java | 131 ++ libjava/org/xml/sax/ext/LexicalHandler.java | 161 +++ .../xml/sax/helpers/AttributeListImpl.java | 310 +++++ .../org/xml/sax/helpers/AttributesImpl.java | 606 +++++++++ .../org/xml/sax/helpers/DefaultHandler.java | 447 +++++++ libjava/org/xml/sax/helpers/LocatorImpl.java | 212 ++++ .../org/xml/sax/helpers/NamespaceSupport.java | 689 +++++++++++ .../org/xml/sax/helpers/ParserAdapter.java | 1008 +++++++++++++++ .../org/xml/sax/helpers/ParserFactory.java | 129 ++ .../org/xml/sax/helpers/XMLFilterImpl.java | 769 ++++++++++++ .../org/xml/sax/helpers/XMLReaderAdapter.java | 526 ++++++++ .../org/xml/sax/helpers/XMLReaderFactory.java | 136 ++ 57 files changed, 12784 insertions(+), 65 deletions(-) create mode 100644 libjava/org/w3c/dom/Attr.java create mode 100644 libjava/org/w3c/dom/CDATASection.java create mode 100644 libjava/org/w3c/dom/CharacterData.java create mode 100644 libjava/org/w3c/dom/Comment.java create mode 100644 libjava/org/w3c/dom/DOMException.java create mode 100644 libjava/org/w3c/dom/DOMImplementation.java create mode 100644 libjava/org/w3c/dom/Document.java create mode 100644 libjava/org/w3c/dom/DocumentFragment.java create mode 100644 libjava/org/w3c/dom/DocumentType.java create mode 100644 libjava/org/w3c/dom/Element.java create mode 100644 libjava/org/w3c/dom/Entity.java create mode 100644 libjava/org/w3c/dom/EntityReference.java create mode 100644 libjava/org/w3c/dom/NamedNodeMap.java create mode 100644 libjava/org/w3c/dom/Node.java create mode 100644 libjava/org/w3c/dom/NodeList.java create mode 100644 libjava/org/w3c/dom/Notation.java create mode 100644 libjava/org/w3c/dom/ProcessingInstruction.java create mode 100644 libjava/org/w3c/dom/Text.java create mode 100644 libjava/org/w3c/dom/ranges/DocumentRange.java create mode 100644 libjava/org/w3c/dom/ranges/Range.java create mode 100644 libjava/org/w3c/dom/ranges/RangeException.java create mode 100644 libjava/org/w3c/dom/traversal/DocumentTraversal.java create mode 100644 libjava/org/w3c/dom/traversal/NodeFilter.java create mode 100644 libjava/org/w3c/dom/traversal/NodeIterator.java create mode 100644 libjava/org/w3c/dom/traversal/TreeWalker.java create mode 100644 libjava/org/xml/sax/AttributeList.java create mode 100644 libjava/org/xml/sax/Attributes.java create mode 100644 libjava/org/xml/sax/ContentHandler.java create mode 100644 libjava/org/xml/sax/DTDHandler.java create mode 100644 libjava/org/xml/sax/DocumentHandler.java create mode 100644 libjava/org/xml/sax/EntityResolver.java create mode 100644 libjava/org/xml/sax/ErrorHandler.java create mode 100644 libjava/org/xml/sax/HandlerBase.java create mode 100644 libjava/org/xml/sax/InputSource.java create mode 100644 libjava/org/xml/sax/Locator.java create mode 100644 libjava/org/xml/sax/Parser.java create mode 100644 libjava/org/xml/sax/SAXException.java create mode 100644 libjava/org/xml/sax/SAXNotRecognizedException.java create mode 100644 libjava/org/xml/sax/SAXNotSupportedException.java create mode 100644 libjava/org/xml/sax/SAXParseException.java create mode 100644 libjava/org/xml/sax/XMLFilter.java create mode 100644 libjava/org/xml/sax/XMLReader.java create mode 100644 libjava/org/xml/sax/ext/DeclHandler.java create mode 100644 libjava/org/xml/sax/ext/LexicalHandler.java create mode 100644 libjava/org/xml/sax/helpers/AttributeListImpl.java create mode 100644 libjava/org/xml/sax/helpers/AttributesImpl.java create mode 100644 libjava/org/xml/sax/helpers/DefaultHandler.java create mode 100644 libjava/org/xml/sax/helpers/LocatorImpl.java create mode 100644 libjava/org/xml/sax/helpers/NamespaceSupport.java create mode 100644 libjava/org/xml/sax/helpers/ParserAdapter.java create mode 100644 libjava/org/xml/sax/helpers/ParserFactory.java create mode 100644 libjava/org/xml/sax/helpers/XMLFilterImpl.java create mode 100644 libjava/org/xml/sax/helpers/XMLReaderAdapter.java create mode 100644 libjava/org/xml/sax/helpers/XMLReaderFactory.java diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 08d25674983..a28900b0a77 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,46 @@ +2001-07-10 Anthony Green + + * Makefile.in: Rebuilt. + * Makefile.am: Add new files. + * org/w3c/dom/Attr.java, org/w3c/dom/CDATASection.java, + org/w3c/dom/CharacterData.java, org/w3c/dom/Comment.java, + org/w3c/dom/DOMException.java, org/w3c/dom/DOMImplementation.java, + org/w3c/dom/Document.java, org/w3c/dom/DocumentFragment.java, + org/w3c/dom/DocumentType.java, org/w3c/dom/Element.java, + org/w3c/dom/Entity.java, org/w3c/dom/EntityReference.java, + org/w3c/dom/NamedNodeMap.java, org/w3c/dom/Node.java, + org/w3c/dom/NodeList.java, org/w3c/dom/Notation.java, + org/w3c/dom/ProcessingInstruction.java, org/w3c/dom/Text.java, + org/w3c/dom/ranges/DocumentRange.java, + org/w3c/dom/ranges/Range.java, + org/w3c/dom/ranges/RangeException.java, + org/w3c/dom/traversal/DocumentTraversal.java, + org/w3c/dom/traversal/NodeFilter.java, + org/w3c/dom/traversal/NodeIterator.java, + org/w3c/dom/traversal/TreeWalker.java, + org/xml/sax/ext/DeclHandler.java, + org/xml/sax/ext/LexicalHandler.java, + org/xml/sax/helpers/AttributeListImpl.java, + org/xml/sax/helpers/AttributesImpl.java, + org/xml/sax/helpers/DefaultHandler.java, + org/xml/sax/helpers/LocatorImpl.java, + org/xml/sax/helpers/NamespaceSupport.java, + org/xml/sax/helpers/ParserAdapter.java, + org/xml/sax/helpers/ParserFactory.java, + org/xml/sax/helpers/XMLFilterImpl.java, + org/xml/sax/helpers/XMLReaderAdapter.java, + org/xml/sax/helpers/XMLReaderFactory.java, + org/xml/sax/AttributeList.java, org/xml/sax/Attributes.java, + org/xml/sax/ContentHandler.java, org/xml/sax/DTDHandler.java, + org/xml/sax/DocumentHandler.java, org/xml/sax/EntityResolver.java, + org/xml/sax/ErrorHandler.java, org/xml/sax/HandlerBase.java, + org/xml/sax/InputSource.java, org/xml/sax/Locator.java, + org/xml/sax/Parser.java, org/xml/sax/SAXException.java, + org/xml/sax/SAXNotRecognizedException.java, + org/xml/sax/SAXNotSupportedException.java, + org/xml/sax/SAXParseException.java, org/xml/sax/XMLFilter.java, + org/xml/sax/XMLReader.java: New files. + 2001-07-10 Alexandre Petit-Bianco * Makefile.am: Added `java/lang/ThreadLocal.java'. diff --git a/libjava/Makefile.am b/libjava/Makefile.am index a0af81a175d..27e92f3d1c8 100644 --- a/libjava/Makefile.am +++ b/libjava/Makefile.am @@ -188,7 +188,7 @@ libgcj.jar: $(built_java_source_files) $(java_source_files) $(x_java_source_file test "$$fail" = no -@rm -f tmp-list libgcj.jar ## Note that we explicitly want to include directory information. - find java gnu -type d -o -type f -name '*.class' | \ + find java gnu org -type d -o -type f -name '*.class' | \ sed -e '/\/\./d' -e '/\/xlib/d' | \ $(ZIP) cfM0E@ $@ @@ -977,7 +977,6 @@ java/util/TooManyListenersException.java \ java/util/Vector.java \ java/util/WeakHashMap.java - ## List of all .java files to be compiled. Please keep this list ## alphabetical. Please put files from java/lang, java/io, and java/util ## into core_java_source_files. Please put files from gnu/gcj/convert @@ -1252,6 +1251,60 @@ java/util/zip/ZipException.java \ java/util/zip/ZipFile.java \ java/util/zip/ZipInputStream.java \ java/util/zip/ZipOutputStream.java \ +org/w3c/dom/Attr.java \ +org/w3c/dom/CDATASection.java \ +org/w3c/dom/CharacterData.java \ +org/w3c/dom/Comment.java \ +org/w3c/dom/DOMException.java \ +org/w3c/dom/DOMImplementation.java \ +org/w3c/dom/Document.java \ +org/w3c/dom/DocumentFragment.java \ +org/w3c/dom/DocumentType.java \ +org/w3c/dom/Element.java \ +org/w3c/dom/Entity.java \ +org/w3c/dom/EntityReference.java \ +org/w3c/dom/NamedNodeMap.java \ +org/w3c/dom/Node.java \ +org/w3c/dom/NodeList.java \ +org/w3c/dom/Notation.java \ +org/w3c/dom/ProcessingInstruction.java \ +org/w3c/dom/Text.java \ +org/w3c/dom/ranges/DocumentRange.java \ +org/w3c/dom/ranges/Range.java \ +org/w3c/dom/ranges/RangeException.java \ +org/w3c/dom/traversal/DocumentTraversal.java \ +org/w3c/dom/traversal/NodeFilter.java \ +org/w3c/dom/traversal/NodeIterator.java \ +org/w3c/dom/traversal/TreeWalker.java \ +org/xml/sax/ext/DeclHandler.java \ +org/xml/sax/ext/LexicalHandler.java \ +org/xml/sax/helpers/AttributeListImpl.java \ +org/xml/sax/helpers/AttributesImpl.java \ +org/xml/sax/helpers/DefaultHandler.java \ +org/xml/sax/helpers/LocatorImpl.java \ +org/xml/sax/helpers/NamespaceSupport.java \ +org/xml/sax/helpers/ParserAdapter.java \ +org/xml/sax/helpers/ParserFactory.java \ +org/xml/sax/helpers/XMLFilterImpl.java \ +org/xml/sax/helpers/XMLReaderAdapter.java \ +org/xml/sax/helpers/XMLReaderFactory.java \ +org/xml/sax/AttributeList.java \ +org/xml/sax/Attributes.java \ +org/xml/sax/ContentHandler.java \ +org/xml/sax/DTDHandler.java \ +org/xml/sax/DocumentHandler.java \ +org/xml/sax/EntityResolver.java \ +org/xml/sax/ErrorHandler.java \ +org/xml/sax/HandlerBase.java \ +org/xml/sax/InputSource.java \ +org/xml/sax/Locator.java \ +org/xml/sax/Parser.java \ +org/xml/sax/SAXException.java \ +org/xml/sax/SAXNotRecognizedException.java \ +org/xml/sax/SAXNotSupportedException.java \ +org/xml/sax/SAXParseException.java \ +org/xml/sax/XMLFilter.java \ +org/xml/sax/XMLReader.java \ $(awt_java_source_files) \ $(convert_source_files) diff --git a/libjava/Makefile.in b/libjava/Makefile.in index 93f58f62e43..d44bbdd7a86 100644 --- a/libjava/Makefile.in +++ b/libjava/Makefile.in @@ -1,4 +1,4 @@ -# Makefile.in generated automatically by automake 1.4a from Makefile.am +# Makefile.in generated automatically by automake 1.4 from Makefile.am # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation @@ -46,10 +46,9 @@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_FLAG = transform = @program_transform_name@ NORMAL_INSTALL = : @@ -123,26 +122,26 @@ libgcj_basedir = @libgcj_basedir@ mkinstalldirs = @mkinstalldirs@ AUTOMAKE_OPTIONS = foreign -@TESTSUBDIR_TRUE@SUBDIRS = $(DIRLTDL) testsuite gcj include -@TESTSUBDIR_FALSE@SUBDIRS = $(DIRLTDL) gcj include -@USE_LIBDIR_TRUE@toolexeclibdir = $(libdir)$(MULTISUBDIR) -@USE_LIBDIR_FALSE@toolexeclibdir = $(toolexecdir)/lib$(MULTISUBDIR) -@USE_LIBDIR_FALSE@toolexecdir = $(exec_prefix)/$(target_alias) -@XLIB_AWT_TRUE@cond_x_ltlibrary = libgcjx.la +@TESTSUBDIR_TRUE@SUBDIRS = @TESTSUBDIR_TRUE@$(DIRLTDL) testsuite gcj include +@TESTSUBDIR_FALSE@SUBDIRS = @TESTSUBDIR_FALSE@$(DIRLTDL) gcj include +@USE_LIBDIR_TRUE@toolexeclibdir = @USE_LIBDIR_TRUE@$(libdir)$(MULTISUBDIR) +@USE_LIBDIR_FALSE@toolexeclibdir = @USE_LIBDIR_FALSE@$(toolexecdir)/lib$(MULTISUBDIR) +@USE_LIBDIR_FALSE@toolexecdir = @USE_LIBDIR_FALSE@$(exec_prefix)/$(target_alias) +@XLIB_AWT_TRUE@cond_x_ltlibrary = @XLIB_AWT_TRUE@libgcjx.la @XLIB_AWT_FALSE@cond_x_ltlibrary = toolexeclib_LTLIBRARIES = libgcj.la $(cond_x_ltlibrary) toolexeclib_DATA = libgcj.spec data_DATA = libgcj.jar -@NATIVE_TRUE@bin_PROGRAMS = jv-convert gij +@NATIVE_TRUE@bin_PROGRAMS = @NATIVE_TRUE@jv-convert gij bin_SCRIPTS = addr2name.awk -@CANADIAN_TRUE@@NULL_TARGET_TRUE@ZIP = $(MULTIBUILDTOP)../$(COMPPATH)/fastjar/jar$(EXEEXT) -@CANADIAN_TRUE@@NULL_TARGET_FALSE@ZIP = jar -@CANADIAN_FALSE@ZIP = $(MULTIBUILDTOP)../$(COMPPATH)/fastjar/jar$(EXEEXT) -@CANADIAN_TRUE@GCJH = gcjh -@CANADIAN_FALSE@GCJH = $(MULTIBUILDTOP)../$(COMPPATH)/gcc/gcjh$(EXEEXT) +@CANADIAN_TRUE@@NULL_TARGET_TRUE@ZIP = @CANADIAN_TRUE@@NULL_TARGET_TRUE@$(MULTIBUILDTOP)../$(COMPPATH)/fastjar/jar$(EXEEXT) +@CANADIAN_TRUE@@NULL_TARGET_FALSE@ZIP = @CANADIAN_TRUE@@NULL_TARGET_FALSE@jar +@CANADIAN_FALSE@ZIP = @CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/fastjar/jar$(EXEEXT) +@CANADIAN_TRUE@GCJH = @CANADIAN_TRUE@gcjh +@CANADIAN_FALSE@GCJH = @CANADIAN_FALSE@$(MULTIBUILDTOP)../$(COMPPATH)/gcc/gcjh$(EXEEXT) GCJ_WITH_FLAGS = $(GCJ) --encoding=UTF-8 @@ -157,38 +156,50 @@ JAVAC = $(GCJ_WITH_FLAGS) -C GCC_UNWIND_INCLUDE = @GCC_UNWIND_INCLUDE@ WARNINGS = -W -Wall -AM_CXXFLAGS = -fno-rtti -fnon-call-exceptions -fdollars-in-identifiers @LIBGCJ_CXXFLAGS@ @X_CFLAGS@ $(WARNINGS) -D_GNU_SOURCE -DPREFIX="\"$(prefix)\"" +AM_CXXFLAGS = -fno-rtti -fnon-call-exceptions \ + -fdollars-in-identifiers \ + @LIBGCJ_CXXFLAGS@ @X_CFLAGS@ $(WARNINGS) -D_GNU_SOURCE \ + -DPREFIX="\"$(prefix)\"" -@USING_GCC_TRUE@AM_CFLAGS = @LIBGCJ_CFLAGS@ $(WARNINGS) -@USING_GCC_FALSE@AM_CFLAGS = @LIBGCJ_CFLAGS@ +@USING_GCC_TRUE@AM_CFLAGS = @USING_GCC_TRUE@@LIBGCJ_CFLAGS@ $(WARNINGS) +@USING_GCC_FALSE@AM_CFLAGS = @USING_GCC_FALSE@@LIBGCJ_CFLAGS@ JCFLAGS = -g JC1FLAGS = @LIBGCJ_JAVAFLAGS@ $(GCJFLAGS) LIBFFIINCS = @LIBFFIINCS@ -INCLUDES = -I$(top_srcdir) -Iinclude -I$(top_srcdir)/include $(GCINCS) $(THREADINCS) $(INCLTDL) $(GCC_UNWIND_INCLUDE) $(ZINCS) $(LIBFFIINCS) +INCLUDES = -I$(top_srcdir) -Iinclude -I$(top_srcdir)/include \ + $(GCINCS) $(THREADINCS) $(INCLTDL) \ + $(GCC_UNWIND_INCLUDE) $(ZINCS) $(LIBFFIINCS) nat_files = $(nat_source_files:.cc=.lo) x_nat_files = $(x_nat_source_files:.cc=.lo) c_files = $(c_source_files:.c=.lo) -javao_files = $(java_source_files:.java=.lo) $(built_java_source_files:.java=.lo) +javao_files = $(java_source_files:.java=.lo) \ + $(built_java_source_files:.java=.lo) x_javao_files = $(x_java_source_files:.java=.lo) -libgcj_la_SOURCES = prims.cc posix.cc jni.cc exception.cc resolve.cc defineclass.cc interpret.cc name-finder.cc $(nat_source_files) +libgcj_la_SOURCES = prims.cc posix.cc jni.cc exception.cc \ + resolve.cc defineclass.cc interpret.cc name-finder.cc \ + $(nat_source_files) -EXTRA_libgcj_la_SOURCES = boehm.cc nogc.cc posix-threads.cc no-threads.cc $(c_source_files) $(java_source_files) $(built_java_source_files) +EXTRA_libgcj_la_SOURCES = boehm.cc nogc.cc posix-threads.cc no-threads.cc \ + $(c_source_files) $(java_source_files) $(built_java_source_files) -libgcj_la_DEPENDENCIES = libgcj.jar $(javao_files) $(c_files) $(GCOBJS) $(THREADOBJS) $(LIBLTDL) +libgcj_la_DEPENDENCIES = libgcj.jar $(javao_files) \ + $(c_files) $(GCOBJS) $(THREADOBJS) $(LIBLTDL) -libgcj_la_LIBADD = $(javao_files) $(c_files) $(GCOBJS) $(THREADOBJS) +libgcj_la_LIBADD = $(javao_files) $(c_files) $(GCOBJS) \ + $(THREADOBJS) # Include THREADLIBS here to ensure that the correct version of # certain linuxthread functions get linked: -libgcj_la_LDFLAGS = -rpath $(toolexeclibdir) $(THREADLIBS) $(LIBLTDL) -version-info `grep -v '^\#' $(srcdir)/libtool-version` +libgcj_la_LDFLAGS = -rpath $(toolexeclibdir) $(THREADLIBS) $(LIBLTDL) \ + -version-info `grep -v '^\#' $(srcdir)/libtool-version` libgcj_la_LINK = $(LIBLINK) @@ -196,7 +207,9 @@ libgcjx_la_SOURCES = $(x_nat_source_files) EXTRA_libgcjx_la_SOURCES = $(x_java_source_files) libgcjx_la_DEPENDENCIES = libgcj.jar $(x_javao_files) libgcjx_la_LIBADD = $(x_javao_files) -libgcjx_la_LDFLAGS = @X_PRE_LIBS@ @X_LIBS@ -lX11 @X_EXTRA_LIBS@ -rpath $(toolexeclibdir) -version-info `grep -v '^\#' $(srcdir)/libtool-version` +libgcjx_la_LDFLAGS = @X_PRE_LIBS@ @X_LIBS@ -lX11 @X_EXTRA_LIBS@ \ + -rpath $(toolexeclibdir) \ + -version-info `grep -v '^\#' $(srcdir)/libtool-version` libgcjx_la_LINK = $(LIBLINK) @@ -205,7 +218,10 @@ CLEANFILES = tmp-list libgcj.jar SUFFIXES = .class .java .h -nat_headers = $(ordinary_java_source_files:.java=.h) $(built_java_source_files:.java=.h) java/io/ObjectOutputStream$$PutField.h java/io/ObjectInputStream$$GetField.h +nat_headers = $(ordinary_java_source_files:.java=.h) \ + $(built_java_source_files:.java=.h) \ + java/io/ObjectOutputStream$$PutField.h \ + java/io/ObjectInputStream$$GetField.h x_nat_headers = $(x_java_source_files:.java=.h) @@ -214,18 +230,21 @@ extra_headers = java/lang/Object.h java/lang/Class.h NM = nm -@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@noinst_PROGRAMS = gen-from-JIS +@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@noinst_PROGRAMS = @NATIVE_TRUE@@MAINTAINER_MODE_TRUE@gen-from-JIS CONVERT_DIR = gnu/gcj/convert jv_convert_SOURCES = EXTRA_jv_convert_SOURCES = $(convert_source_files) -jv_convert_LDFLAGS = --main=gnu.gcj.convert.Convert -rpath $(toolexeclibdir) -shared-libgcc +jv_convert_LDFLAGS = --main=gnu.gcj.convert.Convert \ + -rpath $(toolexeclibdir) -shared-libgcc jv_convert_LINK = $(GCJLINK) -jv_convert_LDADD = $(convert_source_files:.java=.lo) libgcj.la $(GCLIBS) $(THREADLIBS) $(ZLIBS) -L$(here)/.libs +jv_convert_LDADD = $(convert_source_files:.java=.lo) libgcj.la \ + $(GCLIBS) $(THREADLIBS) $(ZLIBS) -L$(here)/.libs -jv_convert_DEPENDENCIES = $(convert_source_files:.java=.lo) $(GCDEPS) $(THREADDEPS) $(ZDEPS) libgcj.la libgcj.spec +jv_convert_DEPENDENCIES = $(convert_source_files:.java=.lo) \ + $(GCDEPS) $(THREADDEPS) $(ZDEPS) libgcj.la libgcj.spec gij_SOURCES = gij.cc @@ -235,49 +254,966 @@ gij_LDADD = libgcj.la $(GCLIBS) $(THREADLIBS) $(ZLIBS) -L$(here)/.libs gij_DEPENDENCIES = $(GCDEPS) $(THREADDEPS) $(ZDEPS) libgcj.la libgcj.spec gen_from_JIS_SOURCES = -EXTRA_gen_from_JIS_SOURCES = $(srcdir)/$(CONVERT_DIR)/gen-from-JIS.c $(srcdir)/$(CONVERT_DIR)/make-trie.c $(srcdir)/$(CONVERT_DIR)/JIS0201.h $(srcdir)/$(CONVERT_DIR)/JIS0208.h $(srcdir)/$(CONVERT_DIR)/JIS0212.h +EXTRA_gen_from_JIS_SOURCES = $(srcdir)/$(CONVERT_DIR)/gen-from-JIS.c \ + $(srcdir)/$(CONVERT_DIR)/make-trie.c \ + $(srcdir)/$(CONVERT_DIR)/JIS0201.h \ + $(srcdir)/$(CONVERT_DIR)/JIS0208.h \ + $(srcdir)/$(CONVERT_DIR)/JIS0212.h gen_from_JIS_LDADD = $(CONVERT_DIR)/gen-from-JIS.o $(CONVERT_DIR)/make-trie.o -gen_from_JIS_DEPENDENCIES = $(CONVERT_DIR)/gen-from-JIS.o $(CONVERT_DIR)/make-trie.o - - -convert_source_files = gnu/gcj/convert/BytesToUnicode.java gnu/gcj/convert/Convert.java gnu/gcj/convert/Input_8859_1.java gnu/gcj/convert/Input_ASCII.java gnu/gcj/convert/Input_EUCJIS.java gnu/gcj/convert/Input_JavaSrc.java gnu/gcj/convert/Input_SJIS.java gnu/gcj/convert/Input_UTF8.java gnu/gcj/convert/Input_iconv.java gnu/gcj/convert/IOConverter.java gnu/gcj/convert/Output_8859_1.java gnu/gcj/convert/Output_ASCII.java gnu/gcj/convert/Output_EUCJIS.java gnu/gcj/convert/Output_JavaSrc.java gnu/gcj/convert/Output_SJIS.java gnu/gcj/convert/Output_UTF8.java gnu/gcj/convert/Output_iconv.java gnu/gcj/convert/UnicodeToBytes.java +gen_from_JIS_DEPENDENCIES = $(CONVERT_DIR)/gen-from-JIS.o \ + $(CONVERT_DIR)/make-trie.o + + +convert_source_files = \ +gnu/gcj/convert/BytesToUnicode.java \ +gnu/gcj/convert/Convert.java \ +gnu/gcj/convert/Input_8859_1.java \ +gnu/gcj/convert/Input_ASCII.java \ +gnu/gcj/convert/Input_EUCJIS.java \ +gnu/gcj/convert/Input_JavaSrc.java \ +gnu/gcj/convert/Input_SJIS.java \ +gnu/gcj/convert/Input_UTF8.java \ +gnu/gcj/convert/Input_iconv.java \ +gnu/gcj/convert/IOConverter.java \ +gnu/gcj/convert/Output_8859_1.java \ +gnu/gcj/convert/Output_ASCII.java \ +gnu/gcj/convert/Output_EUCJIS.java \ +gnu/gcj/convert/Output_JavaSrc.java \ +gnu/gcj/convert/Output_SJIS.java \ +gnu/gcj/convert/Output_UTF8.java \ +gnu/gcj/convert/Output_iconv.java \ +gnu/gcj/convert/UnicodeToBytes.java special_java_source_files = java/lang/Class.java java/lang/Object.java -awt_java_source_files = gnu/awt/LightweightRedirector.java gnu/awt/j2d/AbstractGraphicsState.java gnu/awt/j2d/DirectRasterGraphics.java gnu/awt/j2d/Graphics2DImpl.java gnu/awt/j2d/IntegerGraphicsState.java gnu/awt/j2d/MappedRaster.java gnu/gcj/awt/BitMaskExtent.java gnu/gcj/awt/Buffers.java gnu/gcj/awt/ComponentDataBlitOp.java gnu/gcj/awt/GLightweightPeer.java gnu/java/beans/editors/ColorEditor.java gnu/java/beans/editors/FontEditor.java gnu/java/beans/editors/NativeBooleanEditor.java gnu/java/beans/editors/NativeByteEditor.java gnu/java/beans/editors/NativeDoubleEditor.java gnu/java/beans/editors/NativeFloatEditor.java gnu/java/beans/editors/NativeIntEditor.java gnu/java/beans/editors/NativeLongEditor.java gnu/java/beans/editors/NativeShortEditor.java gnu/java/beans/editors/StringEditor.java gnu/java/beans/info/ComponentBeanInfo.java gnu/java/beans/BeanInfoEmbryo.java gnu/java/beans/EmptyBeanInfo.java gnu/java/beans/ExplicitBeanInfo.java gnu/java/beans/IntrospectionIncubator.java java/applet/Applet.java java/applet/AppletStub.java java/applet/AppletContext.java java/applet/AudioClip.java java/awt/AWTError.java java/awt/AWTEvent.java java/awt/AWTEventMulticaster.java java/awt/AWTException.java java/awt/AWTPermission.java java/awt/ActiveEvent.java java/awt/Adjustable.java java/awt/BorderLayout.java java/awt/Button.java java/awt/Canvas.java java/awt/CardLayout.java java/awt/Checkbox.java java/awt/CheckboxGroup.java java/awt/CheckboxMenuItem.java java/awt/Choice.java java/awt/Color.java java/awt/Component.java java/awt/ComponentOrientation.java java/awt/Container.java java/awt/Cursor.java java/awt/Dialog.java java/awt/Dimension.java java/awt/Event.java java/awt/EventDispatchThread.java java/awt/EventQueue.java java/awt/FileDialog.java java/awt/FlowLayout.java java/awt/Font.java java/awt/FontMetrics.java java/awt/Frame.java java/awt/Graphics.java java/awt/Graphics2D.java java/awt/GraphicsConfiguration.java java/awt/GridBagConstraints.java java/awt/GridLayout.java java/awt/IllegalComponentStateException.java java/awt/Image.java java/awt/Insets.java java/awt/ItemSelectable.java java/awt/Label.java java/awt/LayoutManager.java java/awt/LayoutManager2.java java/awt/List.java java/awt/Menu.java java/awt/MenuBar.java java/awt/MenuComponent.java java/awt/MenuContainer.java java/awt/MenuItem.java java/awt/MenuShortcut.java java/awt/Paint.java java/awt/PaintContext.java java/awt/Panel.java java/awt/Point.java java/awt/Polygon.java java/awt/PopupMenu.java java/awt/Rectangle.java java/awt/RenderingHints.java java/awt/ScrollPane.java java/awt/Scrollbar.java java/awt/Shape.java java/awt/SystemColor.java java/awt/TextArea.java java/awt/TextComponent.java java/awt/TextField.java java/awt/Toolkit.java java/awt/Transparency.java java/awt/Window.java java/awt/color/ColorSpace.java java/awt/color/ICC_ColorSpace.java java/awt/color/ICC_Profile.java java/awt/datatransfer/Clipboard.java java/awt/event/AWTEventListener.java java/awt/event/ActionEvent.java java/awt/event/ActionListener.java java/awt/event/AdjustmentEvent.java java/awt/event/AdjustmentListener.java java/awt/event/ComponentAdapter.java java/awt/event/ComponentEvent.java java/awt/event/ComponentListener.java java/awt/event/ContainerAdapter.java java/awt/event/ContainerEvent.java java/awt/event/ContainerListener.java java/awt/event/FocusAdapter.java java/awt/event/FocusEvent.java java/awt/event/FocusListener.java java/awt/event/HierarchyBoundsAdapter.java java/awt/event/HierarchyBoundsListener.java java/awt/event/HierarchyEvent.java java/awt/event/HierarchyListener.java java/awt/event/InputEvent.java java/awt/event/InputMethodEvent.java java/awt/event/InputMethodListener.java java/awt/event/InvocationEvent.java java/awt/event/ItemEvent.java java/awt/event/ItemListener.java java/awt/event/KeyAdapter.java java/awt/event/KeyEvent.java java/awt/event/KeyListener.java java/awt/event/MouseAdapter.java java/awt/event/MouseEvent.java java/awt/event/MouseListener.java java/awt/event/MouseMotionAdapter.java java/awt/event/MouseMotionListener.java java/awt/event/PaintEvent.java java/awt/event/TextEvent.java java/awt/event/TextListener.java java/awt/event/WindowAdapter.java java/awt/event/WindowEvent.java java/awt/event/WindowListener.java java/awt/geom/AffineTransform.java java/awt/geom/Dimension2D.java java/awt/geom/Ellipse2D.java java/awt/geom/IllegalPathStateException.java java/awt/geom/Line2D.java java/awt/geom/NoninvertibleTransformException.java java/awt/geom/PathIterator.java java/awt/geom/Point2D.java java/awt/geom/Rectangle2D.java java/awt/geom/RectangularShape.java java/awt/geom/RoundRectangle2D.java java/awt/image/BufferedImage.java java/awt/image/ColorModel.java java/awt/image/ComponentColorModel.java java/awt/image/ComponentSampleModel.java java/awt/image/DataBuffer.java java/awt/image/DataBufferByte.java java/awt/image/DataBufferInt.java java/awt/image/DataBufferUShort.java java/awt/image/DirectColorModel.java java/awt/image/ImageConsumer.java java/awt/image/ImageObserver.java java/awt/image/ImageProducer.java java/awt/image/IndexColorModel.java java/awt/image/PackedColorModel.java java/awt/image/Raster.java java/awt/image/RasterOp.java java/awt/image/SampleModel.java java/awt/image/SinglePixelPackedSampleModel.java java/awt/image/WritableRaster.java java/awt/peer/ButtonPeer.java java/awt/peer/CanvasPeer.java java/awt/peer/CheckboxMenuItemPeer.java java/awt/peer/CheckboxPeer.java java/awt/peer/ChoicePeer.java java/awt/peer/ComponentPeer.java java/awt/peer/ContainerPeer.java java/awt/peer/DialogPeer.java java/awt/peer/FileDialogPeer.java java/awt/peer/FontPeer.java java/awt/peer/FramePeer.java java/awt/peer/LabelPeer.java java/awt/peer/LightweightPeer.java java/awt/peer/ListPeer.java java/awt/peer/MenuBarPeer.java java/awt/peer/MenuComponentPeer.java java/awt/peer/MenuItemPeer.java java/awt/peer/MenuPeer.java java/awt/peer/PanelPeer.java java/awt/peer/PopupMenuPeer.java java/awt/peer/ScrollPanePeer.java java/awt/peer/ScrollbarPeer.java java/awt/peer/TextAreaPeer.java java/awt/peer/TextComponentPeer.java java/awt/peer/TextFieldPeer.java java/awt/peer/WindowPeer.java java/beans/beancontext/BeanContext.java java/beans/beancontext/BeanContextChild.java java/beans/beancontext/BeanContextChildComponentProxy.java java/beans/beancontext/BeanContextChildSupport.java java/beans/beancontext/BeanContextContainerProxy.java java/beans/beancontext/BeanContextEvent.java java/beans/beancontext/BeanContextMembershipEvent.java java/beans/beancontext/BeanContextMembershipListener.java java/beans/beancontext/BeanContextProxy.java java/beans/beancontext/BeanContextServiceAvailableEvent.java java/beans/beancontext/BeanContextServiceProvider.java java/beans/beancontext/BeanContextServiceProviderBeanInfo.java java/beans/beancontext/BeanContextServiceRevokedEvent.java java/beans/beancontext/BeanContextServiceRevokedListener.java java/beans/beancontext/BeanContextServices.java java/beans/beancontext/BeanContextServicesListener.java java/beans/BeanDescriptor.java java/beans/BeanInfo.java java/beans/Beans.java java/beans/Customizer.java java/beans/DesignMode.java java/beans/EventSetDescriptor.java java/beans/FeatureDescriptor.java java/beans/IndexedPropertyDescriptor.java java/beans/IntrospectionException.java java/beans/Introspector.java java/beans/MethodDescriptor.java java/beans/ParameterDescriptor.java java/beans/PropertyChangeEvent.java java/beans/PropertyChangeListener.java java/beans/PropertyChangeSupport.java java/beans/PropertyDescriptor.java java/beans/PropertyEditor.java java/beans/PropertyEditorManager.java java/beans/PropertyEditorSupport.java java/beans/PropertyVetoException.java java/beans/SimpleBeanInfo.java java/beans/VetoableChangeListener.java java/beans/VetoableChangeSupport.java java/beans/Visibility.java - - -built_java_source_files = java/lang/ConcreteProcess.java gnu/classpath/Configuration.java - - -core_java_source_files = java/lang/AbstractMethodError.java java/lang/ArithmeticException.java java/lang/ArrayIndexOutOfBoundsException.java java/lang/ArrayStoreException.java java/lang/Boolean.java java/lang/Byte.java java/lang/Character.java java/lang/ClassCastException.java java/lang/ClassCircularityError.java java/lang/ClassFormatError.java java/lang/ClassLoader.java java/lang/ClassNotFoundException.java java/lang/CloneNotSupportedException.java java/lang/Cloneable.java java/lang/Comparable.java java/lang/Compiler.java java/lang/Double.java java/lang/Error.java java/lang/Exception.java java/lang/ExceptionInInitializerError.java java/lang/Float.java java/lang/IllegalAccessError.java java/lang/IllegalAccessException.java java/lang/IllegalArgumentException.java java/lang/IllegalMonitorStateException.java java/lang/IllegalStateException.java java/lang/IllegalThreadStateException.java java/lang/IncompatibleClassChangeError.java java/lang/IndexOutOfBoundsException.java java/lang/InstantiationError.java java/lang/InstantiationException.java java/lang/Integer.java java/lang/InternalError.java java/lang/InterruptedException.java java/lang/LinkageError.java java/lang/Long.java java/lang/Math.java java/lang/NegativeArraySizeException.java java/lang/NoClassDefFoundError.java java/lang/NoSuchFieldError.java java/lang/NoSuchFieldException.java java/lang/NoSuchMethodError.java java/lang/NoSuchMethodException.java java/lang/NullPointerException.java java/lang/Number.java java/lang/NumberFormatException.java java/lang/OutOfMemoryError.java java/lang/Package.java java/lang/Process.java java/lang/Runnable.java java/lang/Runtime.java java/lang/RuntimeException.java java/lang/RuntimePermission.java java/lang/SecurityException.java java/lang/SecurityManager.java java/lang/Short.java java/lang/StackOverflowError.java java/lang/String.java java/lang/StringBuffer.java java/lang/StringIndexOutOfBoundsException.java java/lang/System.java java/lang/Thread.java java/lang/ThreadDeath.java java/lang/ThreadGroup.java java/lang/ThreadLocal.java java/lang/Throwable.java java/lang/UnknownError.java java/lang/UnsatisfiedLinkError.java java/lang/UnsupportedOperationException.java java/lang/VerifyError.java java/lang/VirtualMachineError.java java/lang/Void.java java/io/BufferedInputStream.java java/io/BufferedOutputStream.java java/io/BufferedReader.java java/io/BufferedWriter.java java/io/ByteArrayInputStream.java java/io/ByteArrayOutputStream.java java/io/CharArrayReader.java java/io/CharArrayWriter.java java/io/CharConversionException.java java/io/DataInput.java java/io/DataInputStream.java java/io/DataOutput.java java/io/DataOutputStream.java java/io/EOFException.java java/io/Externalizable.java java/io/File.java java/io/FileDescriptor.java java/io/FileFilter.java java/io/FileInputStream.java java/io/FileNotFoundException.java java/io/FileOutputStream.java java/io/FilePermission.java java/io/FileReader.java java/io/FileWriter.java java/io/FilenameFilter.java java/io/FilterInputStream.java java/io/FilterOutputStream.java java/io/FilterReader.java java/io/FilterWriter.java java/io/IOException.java java/io/InputStream.java java/io/InputStreamReader.java java/io/InterruptedIOException.java java/io/InvalidClassException.java java/io/InvalidObjectException.java java/io/LineNumberInputStream.java java/io/LineNumberReader.java java/io/NotActiveException.java java/io/NotSerializableException.java java/io/ObjectInput.java java/io/ObjectInputStream.java java/io/ObjectInputValidation.java java/io/ObjectOutput.java java/io/ObjectOutputStream.java java/io/ObjectStreamClass.java java/io/ObjectStreamConstants.java java/io/ObjectStreamException.java java/io/ObjectStreamField.java java/io/OptionalDataException.java java/io/OutputStream.java java/io/OutputStreamWriter.java java/io/PipedInputStream.java java/io/PipedOutputStream.java java/io/PipedReader.java java/io/PipedWriter.java java/io/PrintStream.java java/io/PrintWriter.java java/io/PushbackInputStream.java java/io/PushbackReader.java java/io/RandomAccessFile.java java/io/Reader.java java/io/SequenceInputStream.java java/io/Serializable.java java/io/SerializablePermission.java java/io/StreamCorruptedException.java java/io/StreamTokenizer.java java/io/StringBufferInputStream.java java/io/StringReader.java java/io/StringWriter.java java/io/SyncFailedException.java java/io/UTFDataFormatException.java java/io/UnsupportedEncodingException.java java/io/WriteAbortedException.java java/io/Writer.java java/util/AbstractCollection.java java/util/AbstractList.java java/util/AbstractMap.java java/util/AbstractSequentialList.java java/util/AbstractSet.java java/util/ArrayList.java java/util/Arrays.java java/util/BasicMapEntry.java java/util/BitSet.java java/util/Calendar.java java/util/Collection.java java/util/Collections.java java/util/Comparator.java java/util/ConcurrentModificationException.java java/util/Date.java java/util/Dictionary.java java/util/EmptyStackException.java java/util/Enumeration.java java/util/EventListener.java java/util/EventObject.java java/util/GregorianCalendar.java java/util/HashMap.java java/util/HashSet.java java/util/Hashtable.java java/util/Iterator.java java/util/LinkedList.java java/util/List.java java/util/ListIterator.java java/util/ListResourceBundle.java java/util/Locale.java java/util/Map.java java/util/MissingResourceException.java java/util/NoSuchElementException.java java/util/Observable.java java/util/Observer.java java/util/Properties.java java/util/PropertyPermission.java java/util/PropertyResourceBundle.java java/util/Random.java java/util/ResourceBundle.java java/util/Set.java java/util/SimpleTimeZone.java java/util/SortedMap.java java/util/SortedSet.java java/util/Stack.java java/util/StringTokenizer.java java/util/TimeZone.java java/util/Timer.java java/util/TimerTask.java java/util/TreeMap.java java/util/TreeSet.java java/util/TooManyListenersException.java java/util/Vector.java java/util/WeakHashMap.java - - -ordinary_java_source_files = $(core_java_source_files) gnu/gcj/RawData.java gnu/gcj/io/DefaultMimeTypes.java gnu/gcj/io/MimeTypes.java gnu/gcj/io/SimpleSHSStream.java gnu/gcj/math/MPN.java gnu/gcj/protocol/file/Connection.java gnu/gcj/protocol/file/Handler.java gnu/gcj/protocol/http/Connection.java gnu/gcj/protocol/http/Handler.java gnu/gcj/protocol/jar/Connection.java gnu/gcj/protocol/jar/Handler.java gnu/gcj/runtime/FileDeleter.java gnu/gcj/runtime/FirstThread.java gnu/gcj/runtime/VMClassLoader.java gnu/gcj/text/BaseBreakIterator.java gnu/gcj/text/CharacterBreakIterator.java gnu/gcj/text/LineBreakIterator.java gnu/gcj/text/LocaleData_en.java gnu/gcj/text/LocaleData_en_US.java gnu/gcj/text/SentenceBreakIterator.java gnu/gcj/text/WordBreakIterator.java gnu/gcj/util/EnumerationChain.java gnu/java/io/ClassLoaderObjectInputStream.java gnu/java/io/NullOutputStream.java gnu/java/io/ObjectIdentityWrapper.java gnu/java/lang/ArrayHelper.java gnu/java/lang/ClassHelper.java gnu/java/lang/reflect/TypeSignature.java gnu/java/locale/Calendar.java gnu/java/locale/Calendar_de.java gnu/java/locale/Calendar_en.java gnu/java/locale/Calendar_nl.java gnu/java/security/provider/DefaultPolicy.java gnu/java/security/provider/Gnu.java gnu/java/security/provider/SHA.java gnu/java/security/provider/SHA1PRNG.java java/lang/ref/PhantomReference.java java/lang/ref/Reference.java java/lang/ref/ReferenceQueue.java java/lang/ref/SoftReference.java java/lang/ref/WeakReference.java java/lang/reflect/AccessibleObject.java java/lang/reflect/Array.java java/lang/reflect/Constructor.java java/lang/reflect/Field.java java/lang/reflect/InvocationTargetException.java java/lang/reflect/Member.java java/lang/reflect/Method.java java/lang/reflect/Modifier.java java/lang/reflect/ReflectPermission.java java/math/BigDecimal.java java/math/BigInteger.java java/net/BindException.java java/net/ConnectException.java java/net/ContentHandler.java java/net/ContentHandlerFactory.java java/net/DatagramPacket.java java/net/DatagramSocket.java java/net/DatagramSocketImpl.java java/net/FileNameMap.java java/net/HttpURLConnection.java java/net/InetAddress.java java/net/JarURLConnection.java java/net/MalformedURLException.java java/net/MulticastSocket.java java/net/NetPermission.java java/net/NoRouteToHostException.java java/net/PlainDatagramSocketImpl.java java/net/PlainSocketImpl.java java/net/ProtocolException.java java/net/ServerSocket.java java/net/Socket.java java/net/SocketException.java java/net/SocketImpl.java java/net/SocketImplFactory.java java/net/SocketOptions.java java/net/SocketPermission.java java/net/URL.java java/net/URLClassLoader.java java/net/URLConnection.java java/net/URLDecoder.java java/net/URLEncoder.java java/net/URLStreamHandler.java java/net/URLStreamHandlerFactory.java java/net/UnknownHostException.java java/net/UnknownServiceException.java java/security/AccessControlContext.java java/security/AccessControlException.java java/security/AccessController.java java/security/AlgorithmParameterGenerator.java java/security/AlgorithmParameters.java java/security/AlgorithmParameterGeneratorSpi.java java/security/AlgorithmParametersSpi.java java/security/AllPermission.java java/security/BasicPermission.java java/security/Certificate.java java/security/CodeSource.java java/security/DigestException.java java/security/DigestOutputStream.java java/security/DummyKeyPairGenerator.java java/security/DummySignature.java java/security/DigestInputStream.java java/security/DomainCombiner.java java/security/DummyMessageDigest.java java/security/GeneralSecurityException.java java/security/Guard.java java/security/GuardedObject.java java/security/Identity.java java/security/IdentityScope.java java/security/InvalidAlgorithmParameterException.java java/security/InvalidKeyException.java java/security/InvalidParameterException.java java/security/Key.java java/security/KeyFactorySpi.java java/security/KeyPairGenerator.java java/security/KeyStoreException.java java/security/KeyException.java java/security/KeyManagementException.java java/security/KeyPairGeneratorSpi.java java/security/KeyStoreSpi.java java/security/KeyFactory.java java/security/KeyPair.java java/security/KeyStore.java java/security/MessageDigest.java java/security/MessageDigestSpi.java java/security/NoSuchAlgorithmException.java java/security/NoSuchProviderException.java java/security/Permission.java java/security/Principal.java java/security/PrivilegedExceptionAction.java java/security/PublicKey.java java/security/PermissionCollection.java java/security/PrivateKey.java java/security/ProtectionDomain.java java/security/Permissions.java java/security/PrivilegedAction.java java/security/Provider.java java/security/Policy.java java/security/PrivilegedActionException.java java/security/ProviderException.java java/security/SecureClassLoader.java java/security/SecureRandomSpi.java java/security/SecurityPermission.java java/security/SignatureException.java java/security/SignedObject.java java/security/SecureRandom.java java/security/Security.java java/security/Signature.java java/security/SignatureSpi.java java/security/Signer.java java/security/UnrecoverableKeyException.java java/security/UnresolvedPermission.java java/security/acl/Acl.java java/security/acl/AclNotFoundException.java java/security/acl/LastOwnerException.java java/security/acl/Owner.java java/security/acl/AclEntry.java java/security/acl/Group.java java/security/acl/NotOwnerException.java java/security/acl/Permission.java java/security/cert/CRL.java java/security/cert/CRLException.java java/security/cert/Certificate.java java/security/cert/CertificateEncodingException.java java/security/cert/CertificateException.java java/security/cert/CertificateExpiredException.java java/security/cert/CertificateFactory.java java/security/cert/CertificateFactorySpi.java java/security/cert/CertificateNotYetValidException.java java/security/cert/CertificateParsingException.java java/security/cert/X509CRL.java java/security/cert/X509CRLEntry.java java/security/cert/X509Certificate.java java/security/cert/X509Extension.java java/security/interfaces/DSAKey.java java/security/interfaces/DSAKeyPairGenerator.java java/security/interfaces/DSAParams.java java/security/interfaces/DSAPrivateKey.java java/security/interfaces/DSAPublicKey.java java/security/interfaces/RSAKey.java java/security/interfaces/RSAPrivateCrtKey.java java/security/interfaces/RSAPrivateKey.java java/security/interfaces/RSAPublicKey.java java/security/spec/AlgorithmParameterSpec.java java/security/spec/DSAParameterSpec.java java/security/spec/DSAPrivateKeySpec.java java/security/spec/DSAPublicKeySpec.java java/security/spec/EncodedKeySpec.java java/security/spec/InvalidKeySpecException.java java/security/spec/InvalidParameterSpecException.java java/security/spec/KeySpec.java java/security/spec/PKCS8EncodedKeySpec.java java/security/spec/RSAKeyGenParameterSpec.java java/security/spec/RSAPrivateCrtKeySpec.java java/security/spec/RSAPrivateKeySpec.java java/security/spec/RSAPublicKeySpec.java java/security/spec/X509EncodedKeySpec.java java/sql/Array.java java/sql/BatchUpdateException.java java/sql/Blob.java java/sql/CallableStatement.java java/sql/Clob.java java/sql/Connection.java java/sql/DataTruncation.java java/sql/DatabaseMetaData.java java/sql/Date.java java/sql/Driver.java java/sql/DriverManager.java java/sql/DriverPropertyInfo.java java/sql/PreparedStatement.java java/sql/Ref.java java/sql/ResultSet.java java/sql/ResultSetMetaData.java java/sql/SQLData.java java/sql/SQLException.java java/sql/SQLInput.java java/sql/SQLOutput.java java/sql/SQLWarning.java java/sql/Statement.java java/sql/Struct.java java/sql/Time.java java/sql/Timestamp.java java/sql/Types.java java/text/BreakIterator.java java/text/CharacterIterator.java java/text/ChoiceFormat.java java/text/CollationElementIterator.java java/text/CollationKey.java java/text/Collator.java java/text/DateFormat.java java/text/DateFormatSymbols.java java/text/DecimalFormat.java java/text/DecimalFormatSymbols.java java/text/FieldPosition.java java/text/Format.java java/text/MessageFormat.java java/text/NumberFormat.java java/text/ParseException.java java/text/ParsePosition.java java/text/RuleBasedCollator.java java/text/SimpleDateFormat.java java/text/StringCharacterIterator.java java/util/jar/Attributes.java java/util/jar/JarEntry.java java/util/jar/JarException.java java/util/jar/JarFile.java java/util/jar/JarInputStream.java java/util/jar/JarOutputStream.java java/util/jar/Manifest.java java/util/zip/Adler32.java java/util/zip/CRC32.java java/util/zip/CheckedInputStream.java java/util/zip/CheckedOutputStream.java java/util/zip/Checksum.java java/util/zip/DataFormatException.java java/util/zip/Deflater.java java/util/zip/DeflaterOutputStream.java java/util/zip/GZIPInputStream.java java/util/zip/GZIPOutputStream.java java/util/zip/Inflater.java java/util/zip/InflaterInputStream.java java/util/zip/ZipConstants.java java/util/zip/ZipEntry.java java/util/zip/ZipException.java java/util/zip/ZipFile.java java/util/zip/ZipInputStream.java java/util/zip/ZipOutputStream.java $(awt_java_source_files) $(convert_source_files) +awt_java_source_files = \ +gnu/awt/LightweightRedirector.java \ +gnu/awt/j2d/AbstractGraphicsState.java \ +gnu/awt/j2d/DirectRasterGraphics.java \ +gnu/awt/j2d/Graphics2DImpl.java \ +gnu/awt/j2d/IntegerGraphicsState.java \ +gnu/awt/j2d/MappedRaster.java \ +gnu/gcj/awt/BitMaskExtent.java \ +gnu/gcj/awt/Buffers.java \ +gnu/gcj/awt/ComponentDataBlitOp.java \ +gnu/gcj/awt/GLightweightPeer.java \ +gnu/java/beans/editors/ColorEditor.java \ +gnu/java/beans/editors/FontEditor.java \ +gnu/java/beans/editors/NativeBooleanEditor.java \ +gnu/java/beans/editors/NativeByteEditor.java \ +gnu/java/beans/editors/NativeDoubleEditor.java \ +gnu/java/beans/editors/NativeFloatEditor.java \ +gnu/java/beans/editors/NativeIntEditor.java \ +gnu/java/beans/editors/NativeLongEditor.java \ +gnu/java/beans/editors/NativeShortEditor.java \ +gnu/java/beans/editors/StringEditor.java \ +gnu/java/beans/info/ComponentBeanInfo.java \ +gnu/java/beans/BeanInfoEmbryo.java \ +gnu/java/beans/EmptyBeanInfo.java \ +gnu/java/beans/ExplicitBeanInfo.java \ +gnu/java/beans/IntrospectionIncubator.java \ +java/applet/Applet.java \ +java/applet/AppletStub.java \ +java/applet/AppletContext.java \ +java/applet/AudioClip.java \ +java/awt/AWTError.java \ +java/awt/AWTEvent.java \ +java/awt/AWTEventMulticaster.java \ +java/awt/AWTException.java \ +java/awt/AWTPermission.java \ +java/awt/ActiveEvent.java \ +java/awt/Adjustable.java \ +java/awt/BorderLayout.java \ +java/awt/Button.java \ +java/awt/Canvas.java \ +java/awt/CardLayout.java \ +java/awt/Checkbox.java \ +java/awt/CheckboxGroup.java \ +java/awt/CheckboxMenuItem.java \ +java/awt/Choice.java \ +java/awt/Color.java \ +java/awt/Component.java \ +java/awt/ComponentOrientation.java \ +java/awt/Container.java \ +java/awt/Cursor.java \ +java/awt/Dialog.java \ +java/awt/Dimension.java \ +java/awt/Event.java \ +java/awt/EventDispatchThread.java \ +java/awt/EventQueue.java \ +java/awt/FileDialog.java \ +java/awt/FlowLayout.java \ +java/awt/Font.java \ +java/awt/FontMetrics.java \ +java/awt/Frame.java \ +java/awt/Graphics.java \ +java/awt/Graphics2D.java \ +java/awt/GraphicsConfiguration.java \ +java/awt/GridBagConstraints.java \ +java/awt/GridLayout.java \ +java/awt/IllegalComponentStateException.java \ +java/awt/Image.java \ +java/awt/Insets.java \ +java/awt/ItemSelectable.java \ +java/awt/Label.java \ +java/awt/LayoutManager.java \ +java/awt/LayoutManager2.java \ +java/awt/List.java \ +java/awt/Menu.java \ +java/awt/MenuBar.java \ +java/awt/MenuComponent.java \ +java/awt/MenuContainer.java \ +java/awt/MenuItem.java \ +java/awt/MenuShortcut.java \ +java/awt/Paint.java \ +java/awt/PaintContext.java \ +java/awt/Panel.java \ +java/awt/Point.java \ +java/awt/Polygon.java \ +java/awt/PopupMenu.java \ +java/awt/Rectangle.java \ +java/awt/RenderingHints.java \ +java/awt/ScrollPane.java \ +java/awt/Scrollbar.java \ +java/awt/Shape.java \ +java/awt/SystemColor.java \ +java/awt/TextArea.java \ +java/awt/TextComponent.java \ +java/awt/TextField.java \ +java/awt/Toolkit.java \ +java/awt/Transparency.java \ +java/awt/Window.java \ +java/awt/color/ColorSpace.java \ +java/awt/color/ICC_ColorSpace.java \ +java/awt/color/ICC_Profile.java \ +java/awt/datatransfer/Clipboard.java \ +java/awt/event/AWTEventListener.java \ +java/awt/event/ActionEvent.java \ +java/awt/event/ActionListener.java \ +java/awt/event/AdjustmentEvent.java \ +java/awt/event/AdjustmentListener.java \ +java/awt/event/ComponentAdapter.java \ +java/awt/event/ComponentEvent.java \ +java/awt/event/ComponentListener.java \ +java/awt/event/ContainerAdapter.java \ +java/awt/event/ContainerEvent.java \ +java/awt/event/ContainerListener.java \ +java/awt/event/FocusAdapter.java \ +java/awt/event/FocusEvent.java \ +java/awt/event/FocusListener.java \ +java/awt/event/HierarchyBoundsAdapter.java \ +java/awt/event/HierarchyBoundsListener.java \ +java/awt/event/HierarchyEvent.java \ +java/awt/event/HierarchyListener.java \ +java/awt/event/InputEvent.java \ +java/awt/event/InputMethodEvent.java \ +java/awt/event/InputMethodListener.java \ +java/awt/event/InvocationEvent.java \ +java/awt/event/ItemEvent.java \ +java/awt/event/ItemListener.java \ +java/awt/event/KeyAdapter.java \ +java/awt/event/KeyEvent.java \ +java/awt/event/KeyListener.java \ +java/awt/event/MouseAdapter.java \ +java/awt/event/MouseEvent.java \ +java/awt/event/MouseListener.java \ +java/awt/event/MouseMotionAdapter.java \ +java/awt/event/MouseMotionListener.java \ +java/awt/event/PaintEvent.java \ +java/awt/event/TextEvent.java \ +java/awt/event/TextListener.java \ +java/awt/event/WindowAdapter.java \ +java/awt/event/WindowEvent.java \ +java/awt/event/WindowListener.java \ +java/awt/geom/AffineTransform.java \ +java/awt/geom/Dimension2D.java \ +java/awt/geom/Ellipse2D.java \ +java/awt/geom/IllegalPathStateException.java \ +java/awt/geom/Line2D.java \ +java/awt/geom/NoninvertibleTransformException.java \ +java/awt/geom/PathIterator.java \ +java/awt/geom/Point2D.java \ +java/awt/geom/Rectangle2D.java \ +java/awt/geom/RectangularShape.java \ +java/awt/geom/RoundRectangle2D.java \ +java/awt/image/BufferedImage.java \ +java/awt/image/ColorModel.java \ +java/awt/image/ComponentColorModel.java \ +java/awt/image/ComponentSampleModel.java \ +java/awt/image/DataBuffer.java \ +java/awt/image/DataBufferByte.java \ +java/awt/image/DataBufferInt.java \ +java/awt/image/DataBufferUShort.java \ +java/awt/image/DirectColorModel.java \ +java/awt/image/ImageConsumer.java \ +java/awt/image/ImageObserver.java \ +java/awt/image/ImageProducer.java \ +java/awt/image/IndexColorModel.java \ +java/awt/image/PackedColorModel.java \ +java/awt/image/Raster.java \ +java/awt/image/RasterOp.java \ +java/awt/image/SampleModel.java \ +java/awt/image/SinglePixelPackedSampleModel.java \ +java/awt/image/WritableRaster.java \ +java/awt/peer/ButtonPeer.java \ +java/awt/peer/CanvasPeer.java \ +java/awt/peer/CheckboxMenuItemPeer.java \ +java/awt/peer/CheckboxPeer.java \ +java/awt/peer/ChoicePeer.java \ +java/awt/peer/ComponentPeer.java \ +java/awt/peer/ContainerPeer.java \ +java/awt/peer/DialogPeer.java \ +java/awt/peer/FileDialogPeer.java \ +java/awt/peer/FontPeer.java \ +java/awt/peer/FramePeer.java \ +java/awt/peer/LabelPeer.java \ +java/awt/peer/LightweightPeer.java \ +java/awt/peer/ListPeer.java \ +java/awt/peer/MenuBarPeer.java \ +java/awt/peer/MenuComponentPeer.java \ +java/awt/peer/MenuItemPeer.java \ +java/awt/peer/MenuPeer.java \ +java/awt/peer/PanelPeer.java \ +java/awt/peer/PopupMenuPeer.java \ +java/awt/peer/ScrollPanePeer.java \ +java/awt/peer/ScrollbarPeer.java \ +java/awt/peer/TextAreaPeer.java \ +java/awt/peer/TextComponentPeer.java \ +java/awt/peer/TextFieldPeer.java \ +java/awt/peer/WindowPeer.java \ +java/beans/beancontext/BeanContext.java \ +java/beans/beancontext/BeanContextChild.java \ +java/beans/beancontext/BeanContextChildComponentProxy.java \ +java/beans/beancontext/BeanContextChildSupport.java \ +java/beans/beancontext/BeanContextContainerProxy.java \ +java/beans/beancontext/BeanContextEvent.java \ +java/beans/beancontext/BeanContextMembershipEvent.java \ +java/beans/beancontext/BeanContextMembershipListener.java \ +java/beans/beancontext/BeanContextProxy.java \ +java/beans/beancontext/BeanContextServiceAvailableEvent.java \ +java/beans/beancontext/BeanContextServiceProvider.java \ +java/beans/beancontext/BeanContextServiceProviderBeanInfo.java \ +java/beans/beancontext/BeanContextServiceRevokedEvent.java \ +java/beans/beancontext/BeanContextServiceRevokedListener.java \ +java/beans/beancontext/BeanContextServices.java \ +java/beans/beancontext/BeanContextServicesListener.java \ +java/beans/BeanDescriptor.java \ +java/beans/BeanInfo.java \ +java/beans/Beans.java \ +java/beans/Customizer.java \ +java/beans/DesignMode.java \ +java/beans/EventSetDescriptor.java \ +java/beans/FeatureDescriptor.java \ +java/beans/IndexedPropertyDescriptor.java \ +java/beans/IntrospectionException.java \ +java/beans/Introspector.java \ +java/beans/MethodDescriptor.java \ +java/beans/ParameterDescriptor.java \ +java/beans/PropertyChangeEvent.java \ +java/beans/PropertyChangeListener.java \ +java/beans/PropertyChangeSupport.java \ +java/beans/PropertyDescriptor.java \ +java/beans/PropertyEditor.java \ +java/beans/PropertyEditorManager.java \ +java/beans/PropertyEditorSupport.java \ +java/beans/PropertyVetoException.java \ +java/beans/SimpleBeanInfo.java \ +java/beans/VetoableChangeListener.java \ +java/beans/VetoableChangeSupport.java \ +java/beans/Visibility.java + + +built_java_source_files = java/lang/ConcreteProcess.java \ + gnu/classpath/Configuration.java + + +core_java_source_files = \ +java/lang/AbstractMethodError.java \ +java/lang/ArithmeticException.java \ +java/lang/ArrayIndexOutOfBoundsException.java \ +java/lang/ArrayStoreException.java \ +java/lang/Boolean.java \ +java/lang/Byte.java \ +java/lang/Character.java \ +java/lang/ClassCastException.java \ +java/lang/ClassCircularityError.java \ +java/lang/ClassFormatError.java \ +java/lang/ClassLoader.java \ +java/lang/ClassNotFoundException.java \ +java/lang/CloneNotSupportedException.java \ +java/lang/Cloneable.java \ +java/lang/Comparable.java \ +java/lang/Compiler.java \ +java/lang/Double.java \ +java/lang/Error.java \ +java/lang/Exception.java \ +java/lang/ExceptionInInitializerError.java \ +java/lang/Float.java \ +java/lang/IllegalAccessError.java \ +java/lang/IllegalAccessException.java \ +java/lang/IllegalArgumentException.java \ +java/lang/IllegalMonitorStateException.java \ +java/lang/IllegalStateException.java \ +java/lang/IllegalThreadStateException.java \ +java/lang/IncompatibleClassChangeError.java \ +java/lang/IndexOutOfBoundsException.java \ +java/lang/InstantiationError.java \ +java/lang/InstantiationException.java \ +java/lang/Integer.java \ +java/lang/InternalError.java \ +java/lang/InterruptedException.java \ +java/lang/LinkageError.java \ +java/lang/Long.java \ +java/lang/Math.java \ +java/lang/NegativeArraySizeException.java \ +java/lang/NoClassDefFoundError.java \ +java/lang/NoSuchFieldError.java \ +java/lang/NoSuchFieldException.java \ +java/lang/NoSuchMethodError.java \ +java/lang/NoSuchMethodException.java \ +java/lang/NullPointerException.java \ +java/lang/Number.java \ +java/lang/NumberFormatException.java \ +java/lang/OutOfMemoryError.java \ +java/lang/Package.java \ +java/lang/Process.java \ +java/lang/Runnable.java \ +java/lang/Runtime.java \ +java/lang/RuntimeException.java \ +java/lang/RuntimePermission.java \ +java/lang/SecurityException.java \ +java/lang/SecurityManager.java \ +java/lang/Short.java \ +java/lang/StackOverflowError.java \ +java/lang/String.java \ +java/lang/StringBuffer.java \ +java/lang/StringIndexOutOfBoundsException.java \ +java/lang/System.java \ +java/lang/Thread.java \ +java/lang/ThreadDeath.java \ +java/lang/ThreadGroup.java \ +java/lang/ThreadLocal.java \ +java/lang/Throwable.java \ +java/lang/UnknownError.java \ +java/lang/UnsatisfiedLinkError.java \ +java/lang/UnsupportedOperationException.java \ +java/lang/VerifyError.java \ +java/lang/VirtualMachineError.java \ +java/lang/Void.java \ +java/io/BufferedInputStream.java \ +java/io/BufferedOutputStream.java \ +java/io/BufferedReader.java \ +java/io/BufferedWriter.java \ +java/io/ByteArrayInputStream.java \ +java/io/ByteArrayOutputStream.java \ +java/io/CharArrayReader.java \ +java/io/CharArrayWriter.java \ +java/io/CharConversionException.java \ +java/io/DataInput.java \ +java/io/DataInputStream.java \ +java/io/DataOutput.java \ +java/io/DataOutputStream.java \ +java/io/EOFException.java \ +java/io/Externalizable.java \ +java/io/File.java \ +java/io/FileDescriptor.java \ +java/io/FileFilter.java \ +java/io/FileInputStream.java \ +java/io/FileNotFoundException.java \ +java/io/FileOutputStream.java \ +java/io/FilePermission.java \ +java/io/FileReader.java \ +java/io/FileWriter.java \ +java/io/FilenameFilter.java \ +java/io/FilterInputStream.java \ +java/io/FilterOutputStream.java \ +java/io/FilterReader.java \ +java/io/FilterWriter.java \ +java/io/IOException.java \ +java/io/InputStream.java \ +java/io/InputStreamReader.java \ +java/io/InterruptedIOException.java \ +java/io/InvalidClassException.java \ +java/io/InvalidObjectException.java \ +java/io/LineNumberInputStream.java \ +java/io/LineNumberReader.java \ +java/io/NotActiveException.java \ +java/io/NotSerializableException.java \ +java/io/ObjectInput.java \ +java/io/ObjectInputStream.java \ +java/io/ObjectInputValidation.java \ +java/io/ObjectOutput.java \ +java/io/ObjectOutputStream.java \ +java/io/ObjectStreamClass.java \ +java/io/ObjectStreamConstants.java \ +java/io/ObjectStreamException.java \ +java/io/ObjectStreamField.java \ +java/io/OptionalDataException.java \ +java/io/OutputStream.java \ +java/io/OutputStreamWriter.java \ +java/io/PipedInputStream.java \ +java/io/PipedOutputStream.java \ +java/io/PipedReader.java \ +java/io/PipedWriter.java \ +java/io/PrintStream.java \ +java/io/PrintWriter.java \ +java/io/PushbackInputStream.java \ +java/io/PushbackReader.java \ +java/io/RandomAccessFile.java \ +java/io/Reader.java \ +java/io/SequenceInputStream.java \ +java/io/Serializable.java \ +java/io/SerializablePermission.java \ +java/io/StreamCorruptedException.java \ +java/io/StreamTokenizer.java \ +java/io/StringBufferInputStream.java \ +java/io/StringReader.java \ +java/io/StringWriter.java \ +java/io/SyncFailedException.java \ +java/io/UTFDataFormatException.java \ +java/io/UnsupportedEncodingException.java \ +java/io/WriteAbortedException.java \ +java/io/Writer.java \ +java/util/AbstractCollection.java \ +java/util/AbstractList.java \ +java/util/AbstractMap.java \ +java/util/AbstractSequentialList.java \ +java/util/AbstractSet.java \ +java/util/ArrayList.java \ +java/util/Arrays.java \ +java/util/BasicMapEntry.java \ +java/util/BitSet.java \ +java/util/Calendar.java \ +java/util/Collection.java \ +java/util/Collections.java \ +java/util/Comparator.java \ +java/util/ConcurrentModificationException.java \ +java/util/Date.java \ +java/util/Dictionary.java \ +java/util/EmptyStackException.java \ +java/util/Enumeration.java \ +java/util/EventListener.java \ +java/util/EventObject.java \ +java/util/GregorianCalendar.java \ +java/util/HashMap.java \ +java/util/HashSet.java \ +java/util/Hashtable.java \ +java/util/Iterator.java \ +java/util/LinkedList.java \ +java/util/List.java \ +java/util/ListIterator.java \ +java/util/ListResourceBundle.java \ +java/util/Locale.java \ +java/util/Map.java \ +java/util/MissingResourceException.java \ +java/util/NoSuchElementException.java \ +java/util/Observable.java \ +java/util/Observer.java \ +java/util/Properties.java \ +java/util/PropertyPermission.java \ +java/util/PropertyResourceBundle.java \ +java/util/Random.java \ +java/util/ResourceBundle.java \ +java/util/Set.java \ +java/util/SimpleTimeZone.java \ +java/util/SortedMap.java \ +java/util/SortedSet.java \ +java/util/Stack.java \ +java/util/StringTokenizer.java \ +java/util/TimeZone.java \ +java/util/Timer.java \ +java/util/TimerTask.java \ +java/util/TreeMap.java \ +java/util/TreeSet.java \ +java/util/TooManyListenersException.java \ +java/util/Vector.java \ +java/util/WeakHashMap.java + + +ordinary_java_source_files = $(core_java_source_files) \ +gnu/gcj/RawData.java \ +gnu/gcj/io/DefaultMimeTypes.java \ +gnu/gcj/io/MimeTypes.java \ +gnu/gcj/io/SimpleSHSStream.java \ +gnu/gcj/math/MPN.java \ +gnu/gcj/protocol/file/Connection.java \ +gnu/gcj/protocol/file/Handler.java \ +gnu/gcj/protocol/http/Connection.java \ +gnu/gcj/protocol/http/Handler.java \ +gnu/gcj/protocol/jar/Connection.java \ +gnu/gcj/protocol/jar/Handler.java \ +gnu/gcj/runtime/FileDeleter.java \ +gnu/gcj/runtime/FirstThread.java \ +gnu/gcj/runtime/VMClassLoader.java \ +gnu/gcj/text/BaseBreakIterator.java \ +gnu/gcj/text/CharacterBreakIterator.java \ +gnu/gcj/text/LineBreakIterator.java \ +gnu/gcj/text/LocaleData_en.java \ +gnu/gcj/text/LocaleData_en_US.java \ +gnu/gcj/text/SentenceBreakIterator.java \ +gnu/gcj/text/WordBreakIterator.java \ +gnu/gcj/util/EnumerationChain.java \ +gnu/java/io/ClassLoaderObjectInputStream.java \ +gnu/java/io/NullOutputStream.java \ +gnu/java/io/ObjectIdentityWrapper.java \ +gnu/java/lang/ArrayHelper.java \ +gnu/java/lang/ClassHelper.java \ +gnu/java/lang/reflect/TypeSignature.java \ +gnu/java/locale/Calendar.java \ +gnu/java/locale/Calendar_de.java \ +gnu/java/locale/Calendar_en.java \ +gnu/java/locale/Calendar_nl.java \ +gnu/java/security/provider/DefaultPolicy.java \ +gnu/java/security/provider/Gnu.java \ +gnu/java/security/provider/SHA.java \ +gnu/java/security/provider/SHA1PRNG.java \ +java/lang/ref/PhantomReference.java \ +java/lang/ref/Reference.java \ +java/lang/ref/ReferenceQueue.java \ +java/lang/ref/SoftReference.java \ +java/lang/ref/WeakReference.java \ +java/lang/reflect/AccessibleObject.java \ +java/lang/reflect/Array.java \ +java/lang/reflect/Constructor.java \ +java/lang/reflect/Field.java \ +java/lang/reflect/InvocationTargetException.java \ +java/lang/reflect/Member.java \ +java/lang/reflect/Method.java \ +java/lang/reflect/Modifier.java \ +java/lang/reflect/ReflectPermission.java \ +java/math/BigDecimal.java \ +java/math/BigInteger.java \ +java/net/BindException.java \ +java/net/ConnectException.java \ +java/net/ContentHandler.java \ +java/net/ContentHandlerFactory.java \ +java/net/DatagramPacket.java \ +java/net/DatagramSocket.java \ +java/net/DatagramSocketImpl.java \ +java/net/FileNameMap.java \ +java/net/HttpURLConnection.java \ +java/net/InetAddress.java \ +java/net/JarURLConnection.java \ +java/net/MalformedURLException.java \ +java/net/MulticastSocket.java \ +java/net/NetPermission.java \ +java/net/NoRouteToHostException.java \ +java/net/PlainDatagramSocketImpl.java \ +java/net/PlainSocketImpl.java \ +java/net/ProtocolException.java \ +java/net/ServerSocket.java \ +java/net/Socket.java \ +java/net/SocketException.java \ +java/net/SocketImpl.java \ +java/net/SocketImplFactory.java \ +java/net/SocketOptions.java \ +java/net/SocketPermission.java \ +java/net/URL.java \ +java/net/URLClassLoader.java \ +java/net/URLConnection.java \ +java/net/URLDecoder.java \ +java/net/URLEncoder.java \ +java/net/URLStreamHandler.java \ +java/net/URLStreamHandlerFactory.java \ +java/net/UnknownHostException.java \ +java/net/UnknownServiceException.java \ +java/security/AccessControlContext.java \ +java/security/AccessControlException.java \ +java/security/AccessController.java \ +java/security/AlgorithmParameterGenerator.java \ +java/security/AlgorithmParameters.java \ +java/security/AlgorithmParameterGeneratorSpi.java \ +java/security/AlgorithmParametersSpi.java \ +java/security/AllPermission.java \ +java/security/BasicPermission.java \ +java/security/Certificate.java \ +java/security/CodeSource.java \ +java/security/DigestException.java \ +java/security/DigestOutputStream.java \ +java/security/DummyKeyPairGenerator.java \ +java/security/DummySignature.java \ +java/security/DigestInputStream.java \ +java/security/DomainCombiner.java \ +java/security/DummyMessageDigest.java \ +java/security/GeneralSecurityException.java \ +java/security/Guard.java \ +java/security/GuardedObject.java \ +java/security/Identity.java \ +java/security/IdentityScope.java \ +java/security/InvalidAlgorithmParameterException.java \ +java/security/InvalidKeyException.java \ +java/security/InvalidParameterException.java \ +java/security/Key.java \ +java/security/KeyFactorySpi.java \ +java/security/KeyPairGenerator.java \ +java/security/KeyStoreException.java \ +java/security/KeyException.java \ +java/security/KeyManagementException.java \ +java/security/KeyPairGeneratorSpi.java \ +java/security/KeyStoreSpi.java \ +java/security/KeyFactory.java \ +java/security/KeyPair.java \ +java/security/KeyStore.java \ +java/security/MessageDigest.java \ +java/security/MessageDigestSpi.java \ +java/security/NoSuchAlgorithmException.java \ +java/security/NoSuchProviderException.java \ +java/security/Permission.java \ +java/security/Principal.java \ +java/security/PrivilegedExceptionAction.java \ +java/security/PublicKey.java \ +java/security/PermissionCollection.java \ +java/security/PrivateKey.java \ +java/security/ProtectionDomain.java \ +java/security/Permissions.java \ +java/security/PrivilegedAction.java \ +java/security/Provider.java \ +java/security/Policy.java \ +java/security/PrivilegedActionException.java \ +java/security/ProviderException.java \ +java/security/SecureClassLoader.java \ +java/security/SecureRandomSpi.java \ +java/security/SecurityPermission.java \ +java/security/SignatureException.java \ +java/security/SignedObject.java \ +java/security/SecureRandom.java \ +java/security/Security.java \ +java/security/Signature.java \ +java/security/SignatureSpi.java \ +java/security/Signer.java \ +java/security/UnrecoverableKeyException.java \ +java/security/UnresolvedPermission.java \ +java/security/acl/Acl.java \ +java/security/acl/AclNotFoundException.java \ +java/security/acl/LastOwnerException.java \ +java/security/acl/Owner.java \ +java/security/acl/AclEntry.java \ +java/security/acl/Group.java \ +java/security/acl/NotOwnerException.java \ +java/security/acl/Permission.java \ +java/security/cert/CRL.java \ +java/security/cert/CRLException.java \ +java/security/cert/Certificate.java \ +java/security/cert/CertificateEncodingException.java \ +java/security/cert/CertificateException.java \ +java/security/cert/CertificateExpiredException.java \ +java/security/cert/CertificateFactory.java \ +java/security/cert/CertificateFactorySpi.java \ +java/security/cert/CertificateNotYetValidException.java \ +java/security/cert/CertificateParsingException.java \ +java/security/cert/X509CRL.java \ +java/security/cert/X509CRLEntry.java \ +java/security/cert/X509Certificate.java \ +java/security/cert/X509Extension.java \ +java/security/interfaces/DSAKey.java \ +java/security/interfaces/DSAKeyPairGenerator.java \ +java/security/interfaces/DSAParams.java \ +java/security/interfaces/DSAPrivateKey.java \ +java/security/interfaces/DSAPublicKey.java \ +java/security/interfaces/RSAKey.java \ +java/security/interfaces/RSAPrivateCrtKey.java \ +java/security/interfaces/RSAPrivateKey.java \ +java/security/interfaces/RSAPublicKey.java \ +java/security/spec/AlgorithmParameterSpec.java \ +java/security/spec/DSAParameterSpec.java \ +java/security/spec/DSAPrivateKeySpec.java \ +java/security/spec/DSAPublicKeySpec.java \ +java/security/spec/EncodedKeySpec.java \ +java/security/spec/InvalidKeySpecException.java \ +java/security/spec/InvalidParameterSpecException.java \ +java/security/spec/KeySpec.java \ +java/security/spec/PKCS8EncodedKeySpec.java \ +java/security/spec/RSAKeyGenParameterSpec.java \ +java/security/spec/RSAPrivateCrtKeySpec.java \ +java/security/spec/RSAPrivateKeySpec.java \ +java/security/spec/RSAPublicKeySpec.java \ +java/security/spec/X509EncodedKeySpec.java \ +java/sql/Array.java \ +java/sql/BatchUpdateException.java \ +java/sql/Blob.java \ +java/sql/CallableStatement.java \ +java/sql/Clob.java \ +java/sql/Connection.java \ +java/sql/DataTruncation.java \ +java/sql/DatabaseMetaData.java \ +java/sql/Date.java \ +java/sql/Driver.java \ +java/sql/DriverManager.java \ +java/sql/DriverPropertyInfo.java \ +java/sql/PreparedStatement.java \ +java/sql/Ref.java \ +java/sql/ResultSet.java \ +java/sql/ResultSetMetaData.java \ +java/sql/SQLData.java \ +java/sql/SQLException.java \ +java/sql/SQLInput.java \ +java/sql/SQLOutput.java \ +java/sql/SQLWarning.java \ +java/sql/Statement.java \ +java/sql/Struct.java \ +java/sql/Time.java \ +java/sql/Timestamp.java \ +java/sql/Types.java \ +java/text/BreakIterator.java \ +java/text/CharacterIterator.java \ +java/text/ChoiceFormat.java \ +java/text/CollationElementIterator.java \ +java/text/CollationKey.java \ +java/text/Collator.java \ +java/text/DateFormat.java \ +java/text/DateFormatSymbols.java \ +java/text/DecimalFormat.java \ +java/text/DecimalFormatSymbols.java \ +java/text/FieldPosition.java \ +java/text/Format.java \ +java/text/MessageFormat.java \ +java/text/NumberFormat.java \ +java/text/ParseException.java \ +java/text/ParsePosition.java \ +java/text/RuleBasedCollator.java \ +java/text/SimpleDateFormat.java \ +java/text/StringCharacterIterator.java \ +java/util/jar/Attributes.java \ +java/util/jar/JarEntry.java \ +java/util/jar/JarException.java \ +java/util/jar/JarFile.java \ +java/util/jar/JarInputStream.java \ +java/util/jar/JarOutputStream.java \ +java/util/jar/Manifest.java \ +java/util/zip/Adler32.java \ +java/util/zip/CRC32.java \ +java/util/zip/CheckedInputStream.java \ +java/util/zip/CheckedOutputStream.java \ +java/util/zip/Checksum.java \ +java/util/zip/DataFormatException.java \ +java/util/zip/Deflater.java \ +java/util/zip/DeflaterOutputStream.java \ +java/util/zip/GZIPInputStream.java \ +java/util/zip/GZIPOutputStream.java \ +java/util/zip/Inflater.java \ +java/util/zip/InflaterInputStream.java \ +java/util/zip/ZipConstants.java \ +java/util/zip/ZipEntry.java \ +java/util/zip/ZipException.java \ +java/util/zip/ZipFile.java \ +java/util/zip/ZipInputStream.java \ +java/util/zip/ZipOutputStream.java \ +org/w3c/dom/Attr.java \ +org/w3c/dom/CDATASection.java \ +org/w3c/dom/CharacterData.java \ +org/w3c/dom/Comment.java \ +org/w3c/dom/DOMException.java \ +org/w3c/dom/DOMImplementation.java \ +org/w3c/dom/Document.java \ +org/w3c/dom/DocumentFragment.java \ +org/w3c/dom/DocumentType.java \ +org/w3c/dom/Element.java \ +org/w3c/dom/Entity.java \ +org/w3c/dom/EntityReference.java \ +org/w3c/dom/NamedNodeMap.java \ +org/w3c/dom/Node.java \ +org/w3c/dom/NodeList.java \ +org/w3c/dom/Notation.java \ +org/w3c/dom/ProcessingInstruction.java \ +org/w3c/dom/Text.java \ +org/w3c/dom/ranges/DocumentRange.java \ +org/w3c/dom/ranges/Range.java \ +org/w3c/dom/ranges/RangeException.java \ +org/w3c/dom/traversal/DocumentTraversal.java \ +org/w3c/dom/traversal/NodeFilter.java \ +org/w3c/dom/traversal/NodeIterator.java \ +org/w3c/dom/traversal/TreeWalker.java \ +org/xml/sax/ext/DeclHandler.java \ +org/xml/sax/ext/LexicalHandler.java \ +org/xml/sax/helpers/AttributeListImpl.java \ +org/xml/sax/helpers/AttributesImpl.java \ +org/xml/sax/helpers/DefaultHandler.java \ +org/xml/sax/helpers/LocatorImpl.java \ +org/xml/sax/helpers/NamespaceSupport.java \ +org/xml/sax/helpers/ParserAdapter.java \ +org/xml/sax/helpers/ParserFactory.java \ +org/xml/sax/helpers/XMLFilterImpl.java \ +org/xml/sax/helpers/XMLReaderAdapter.java \ +org/xml/sax/helpers/XMLReaderFactory.java \ +org/xml/sax/AttributeList.java \ +org/xml/sax/Attributes.java \ +org/xml/sax/ContentHandler.java \ +org/xml/sax/DTDHandler.java \ +org/xml/sax/DocumentHandler.java \ +org/xml/sax/EntityResolver.java \ +org/xml/sax/ErrorHandler.java \ +org/xml/sax/HandlerBase.java \ +org/xml/sax/InputSource.java \ +org/xml/sax/Locator.java \ +org/xml/sax/Parser.java \ +org/xml/sax/SAXException.java \ +org/xml/sax/SAXNotRecognizedException.java \ +org/xml/sax/SAXNotSupportedException.java \ +org/xml/sax/SAXParseException.java \ +org/xml/sax/XMLFilter.java \ +org/xml/sax/XMLReader.java \ +$(awt_java_source_files) \ +$(convert_source_files) java_source_files = $(special_java_source_files) $(ordinary_java_source_files) -c_source_files = java/lang/dtoa.c java/lang/k_rem_pio2.c java/lang/s_tan.c java/lang/e_acos.c java/lang/k_sin.c java/lang/strtod.c java/lang/e_asin.c java/lang/k_tan.c java/lang/w_acos.c java/lang/e_atan2.c java/lang/mprec.c java/lang/w_asin.c java/lang/e_exp.c java/lang/s_atan.c java/lang/w_atan2.c java/lang/e_fmod.c java/lang/s_ceil.c java/lang/w_exp.c java/lang/e_log.c java/lang/s_copysign.c java/lang/w_fmod.c java/lang/e_pow.c java/lang/s_cos.c java/lang/w_log.c java/lang/e_rem_pio2.c java/lang/s_fabs.c java/lang/w_pow.c java/lang/e_remainder.c java/lang/s_floor.c java/lang/w_remainder.c java/lang/e_scalb.c java/lang/s_rint.c java/lang/w_sqrt.c java/lang/e_sqrt.c java/lang/s_scalbn.c java/lang/sf_rint.c java/lang/k_cos.c java/lang/s_sin.c java/lang/sf_fabs.c +c_source_files = \ + java/lang/dtoa.c java/lang/k_rem_pio2.c java/lang/s_tan.c \ + java/lang/e_acos.c java/lang/k_sin.c java/lang/strtod.c \ + java/lang/e_asin.c java/lang/k_tan.c java/lang/w_acos.c \ + java/lang/e_atan2.c java/lang/mprec.c java/lang/w_asin.c \ + java/lang/e_exp.c java/lang/s_atan.c java/lang/w_atan2.c \ + java/lang/e_fmod.c java/lang/s_ceil.c java/lang/w_exp.c \ + java/lang/e_log.c java/lang/s_copysign.c java/lang/w_fmod.c \ + java/lang/e_pow.c java/lang/s_cos.c java/lang/w_log.c \ + java/lang/e_rem_pio2.c java/lang/s_fabs.c java/lang/w_pow.c \ + java/lang/e_remainder.c java/lang/s_floor.c java/lang/w_remainder.c \ + java/lang/e_scalb.c java/lang/s_rint.c java/lang/w_sqrt.c \ + java/lang/e_sqrt.c java/lang/s_scalbn.c java/lang/sf_rint.c \ + java/lang/k_cos.c java/lang/s_sin.c java/lang/sf_fabs.c #java/awt/natToolkit.cc -nat_source_files = gnu/gcj/convert/JIS0208_to_Unicode.cc gnu/gcj/convert/JIS0212_to_Unicode.cc gnu/gcj/convert/Unicode_to_JIS.cc gnu/gcj/convert/natIconv.cc gnu/gcj/convert/natInput_EUCJIS.cc gnu/gcj/convert/natInput_SJIS.cc gnu/gcj/convert/natOutput_EUCJIS.cc gnu/gcj/convert/natOutput_SJIS.cc gnu/gcj/io/natSimpleSHSStream.cc gnu/gcj/io/shs.cc java/io/natFile.cc java/io/natFileDescriptor.cc java/io/natObjectInputStream.cc java/io/natObjectOutputStream.cc java/lang/natCharacter.cc java/lang/natClass.cc java/lang/natClassLoader.cc java/lang/natConcreteProcess.cc java/lang/natDouble.cc java/lang/natFloat.cc java/lang/natMath.cc java/lang/natObject.cc java/lang/natRuntime.cc java/lang/natString.cc java/lang/natStringBuffer.cc java/lang/natSystem.cc java/lang/natThread.cc java/lang/natThrowable.cc java/lang/reflect/natArray.cc java/lang/reflect/natConstructor.cc java/lang/reflect/natField.cc java/lang/reflect/natMethod.cc java/net/natInetAddress.cc java/net/natPlainDatagramSocketImpl.cc java/net/natPlainSocketImpl.cc java/text/natCollator.cc java/util/zip/natDeflater.cc java/util/zip/natInflater.cc - - -x_java_source_files = gnu/gcj/xlib/Clip.java gnu/gcj/xlib/Colormap.java gnu/gcj/xlib/Display.java gnu/gcj/xlib/Drawable.java gnu/gcj/xlib/Font.java gnu/gcj/xlib/GC.java gnu/gcj/xlib/Pixmap.java gnu/gcj/xlib/Screen.java gnu/gcj/xlib/Visual.java gnu/gcj/xlib/WMSizeHints.java gnu/gcj/xlib/Window.java gnu/gcj/xlib/WindowAttributes.java gnu/gcj/xlib/XAnyEvent.java gnu/gcj/xlib/XButtonEvent.java gnu/gcj/xlib/XColor.java gnu/gcj/xlib/XConfigureEvent.java gnu/gcj/xlib/XConnectException.java gnu/gcj/xlib/XEvent.java gnu/gcj/xlib/XException.java gnu/gcj/xlib/XExposeEvent.java gnu/gcj/xlib/XID.java gnu/gcj/xlib/XImage.java gnu/gcj/xlib/XUnmapEvent.java gnu/awt/xlib/XCanvasPeer.java gnu/awt/xlib/XEventLoop.java gnu/awt/xlib/XEventQueue.java gnu/awt/xlib/XFontMetrics.java gnu/awt/xlib/XFramePeer.java gnu/awt/xlib/XGraphics.java gnu/awt/xlib/XGraphicsConfiguration.java gnu/awt/xlib/XPanelPeer.java gnu/awt/xlib/XToolkit.java - - -x_nat_source_files = gnu/gcj/xlib/natClip.cc gnu/gcj/xlib/natColormap.cc gnu/gcj/xlib/natDisplay.cc gnu/gcj/xlib/natDrawable.cc gnu/gcj/xlib/natFont.cc gnu/gcj/xlib/natGC.cc gnu/gcj/xlib/natPixmap.cc gnu/gcj/xlib/natScreen.cc gnu/gcj/xlib/natVisual.cc gnu/gcj/xlib/natWMSizeHints.cc gnu/gcj/xlib/natWindow.cc gnu/gcj/xlib/natWindowAttributes.cc gnu/gcj/xlib/natXAnyEvent.cc gnu/gcj/xlib/natXButtonEvent.cc gnu/gcj/xlib/natXColor.cc gnu/gcj/xlib/natXConfigureEvent.cc gnu/gcj/xlib/natXException.cc gnu/gcj/xlib/natXExposeEvent.cc gnu/gcj/xlib/natXImage.cc gnu/gcj/xlib/natXUnmapEvent.cc +nat_source_files = \ +gnu/gcj/convert/JIS0208_to_Unicode.cc \ +gnu/gcj/convert/JIS0212_to_Unicode.cc \ +gnu/gcj/convert/Unicode_to_JIS.cc \ +gnu/gcj/convert/natIconv.cc \ +gnu/gcj/convert/natInput_EUCJIS.cc \ +gnu/gcj/convert/natInput_SJIS.cc \ +gnu/gcj/convert/natOutput_EUCJIS.cc \ +gnu/gcj/convert/natOutput_SJIS.cc \ +gnu/gcj/io/natSimpleSHSStream.cc \ +gnu/gcj/io/shs.cc \ +java/io/natFile.cc \ +java/io/natFileDescriptor.cc \ +java/io/natObjectInputStream.cc \ +java/io/natObjectOutputStream.cc \ +java/lang/natCharacter.cc \ +java/lang/natClass.cc \ +java/lang/natClassLoader.cc \ +java/lang/natConcreteProcess.cc \ +java/lang/natDouble.cc \ +java/lang/natFloat.cc \ +java/lang/natMath.cc \ +java/lang/natObject.cc \ +java/lang/natRuntime.cc \ +java/lang/natString.cc \ +java/lang/natStringBuffer.cc \ +java/lang/natSystem.cc \ +java/lang/natThread.cc \ +java/lang/natThrowable.cc \ +java/lang/reflect/natArray.cc \ +java/lang/reflect/natConstructor.cc \ +java/lang/reflect/natField.cc \ +java/lang/reflect/natMethod.cc \ +java/net/natInetAddress.cc \ +java/net/natPlainDatagramSocketImpl.cc \ +java/net/natPlainSocketImpl.cc \ +java/text/natCollator.cc \ +java/util/zip/natDeflater.cc \ +java/util/zip/natInflater.cc + + +x_java_source_files = \ +gnu/gcj/xlib/Clip.java \ +gnu/gcj/xlib/Colormap.java \ +gnu/gcj/xlib/Display.java \ +gnu/gcj/xlib/Drawable.java \ +gnu/gcj/xlib/Font.java \ +gnu/gcj/xlib/GC.java \ +gnu/gcj/xlib/Pixmap.java \ +gnu/gcj/xlib/Screen.java \ +gnu/gcj/xlib/Visual.java \ +gnu/gcj/xlib/WMSizeHints.java \ +gnu/gcj/xlib/Window.java \ +gnu/gcj/xlib/WindowAttributes.java \ +gnu/gcj/xlib/XAnyEvent.java \ +gnu/gcj/xlib/XButtonEvent.java \ +gnu/gcj/xlib/XColor.java \ +gnu/gcj/xlib/XConfigureEvent.java \ +gnu/gcj/xlib/XConnectException.java \ +gnu/gcj/xlib/XEvent.java \ +gnu/gcj/xlib/XException.java \ +gnu/gcj/xlib/XExposeEvent.java \ +gnu/gcj/xlib/XID.java \ +gnu/gcj/xlib/XImage.java \ +gnu/gcj/xlib/XUnmapEvent.java \ +gnu/awt/xlib/XCanvasPeer.java \ +gnu/awt/xlib/XEventLoop.java \ +gnu/awt/xlib/XEventQueue.java \ +gnu/awt/xlib/XFontMetrics.java \ +gnu/awt/xlib/XFramePeer.java \ +gnu/awt/xlib/XGraphics.java \ +gnu/awt/xlib/XGraphicsConfiguration.java \ +gnu/awt/xlib/XPanelPeer.java \ +gnu/awt/xlib/XToolkit.java + + +x_nat_source_files = \ +gnu/gcj/xlib/natClip.cc \ +gnu/gcj/xlib/natColormap.cc \ +gnu/gcj/xlib/natDisplay.cc \ +gnu/gcj/xlib/natDrawable.cc \ +gnu/gcj/xlib/natFont.cc \ +gnu/gcj/xlib/natGC.cc \ +gnu/gcj/xlib/natPixmap.cc \ +gnu/gcj/xlib/natScreen.cc \ +gnu/gcj/xlib/natVisual.cc \ +gnu/gcj/xlib/natWMSizeHints.cc \ +gnu/gcj/xlib/natWindow.cc \ +gnu/gcj/xlib/natWindowAttributes.cc \ +gnu/gcj/xlib/natXAnyEvent.cc \ +gnu/gcj/xlib/natXButtonEvent.cc \ +gnu/gcj/xlib/natXColor.cc \ +gnu/gcj/xlib/natXConfigureEvent.cc \ +gnu/gcj/xlib/natXException.cc \ +gnu/gcj/xlib/natXExposeEvent.cc \ +gnu/gcj/xlib/natXImage.cc \ +gnu/gcj/xlib/natXUnmapEvent.cc # Work around what appears to be a GNU make bug handling MAKEFLAGS # values defined in terms of make variables, as is the case for CC and # friends when we are called from the top level Makefile. -AM_MAKEFLAGS = "AR_FLAGS=$(AR_FLAGS)" "CC_FOR_BUILD=$(CC_FOR_BUILD)" "CFLAGS=$(CFLAGS)" "CXXFLAGS=$(CXXFLAGS)" "CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" "CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" "INSTALL=$(INSTALL)" "INSTALL_DATA=$(INSTALL_DATA)" "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" "INSTALL_SCRIPT=$(INSTALL_SCRIPT)" "JC1FLAGS=$(JC1FLAGS)" "LDFLAGS=$(LDFLAGS)" "LIBCFLAGS=$(LIBCFLAGS)" "LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" "MAKE=$(MAKE)" "MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" "PICFLAG=$(PICFLAG)" "PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" "SHELL=$(SHELL)" "exec_prefix=$(exec_prefix)" "infodir=$(infodir)" "libdir=$(libdir)" "prefix=$(prefix)" "AR=$(AR)" "AS=$(AS)" "CC=$(CC)" "CXX=$(CXX)" "LD=$(LD)" "LIBCFLAGS=$(LIBCFLAGS)" "NM=$(NM)" "PICFLAG=$(PICFLAG)" "RANLIB=$(RANLIB)" "DESTDIR=$(DESTDIR)" +AM_MAKEFLAGS = \ + "AR_FLAGS=$(AR_FLAGS)" \ + "CC_FOR_BUILD=$(CC_FOR_BUILD)" \ + "CFLAGS=$(CFLAGS)" \ + "CXXFLAGS=$(CXXFLAGS)" \ + "CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \ + "CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" \ + "INSTALL=$(INSTALL)" \ + "INSTALL_DATA=$(INSTALL_DATA)" \ + "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \ + "INSTALL_SCRIPT=$(INSTALL_SCRIPT)" \ + "JC1FLAGS=$(JC1FLAGS)" \ + "LDFLAGS=$(LDFLAGS)" \ + "LIBCFLAGS=$(LIBCFLAGS)" \ + "LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" \ + "MAKE=$(MAKE)" \ + "MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \ + "PICFLAG=$(PICFLAG)" \ + "PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \ + "SHELL=$(SHELL)" \ + "exec_prefix=$(exec_prefix)" \ + "infodir=$(infodir)" \ + "libdir=$(libdir)" \ + "prefix=$(prefix)" \ + "AR=$(AR)" \ + "AS=$(AS)" \ + "CC=$(CC)" \ + "CXX=$(CXX)" \ + "LD=$(LD)" \ + "LIBCFLAGS=$(LIBCFLAGS)" \ + "NM=$(NM)" \ + "PICFLAG=$(PICFLAG)" \ + "RANLIB=$(RANLIB)" \ + "DESTDIR=$(DESTDIR)" CONFIG_STATUS_DEPENDENCIES = $(srcdir)/configure.host @@ -708,8 +1644,8 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \ .deps/java/lang/StringIndexOutOfBoundsException.P \ .deps/java/lang/System.P .deps/java/lang/Thread.P \ .deps/java/lang/ThreadDeath.P .deps/java/lang/ThreadGroup.P \ -.deps/java/lang/Throwable.P .deps/java/lang/UnknownError.P \ -.deps/java/lang/UnsatisfiedLinkError.P \ +.deps/java/lang/ThreadLocal.P .deps/java/lang/Throwable.P \ +.deps/java/lang/UnknownError.P .deps/java/lang/UnsatisfiedLinkError.P \ .deps/java/lang/UnsupportedOperationException.P \ .deps/java/lang/VerifyError.P .deps/java/lang/VirtualMachineError.P \ .deps/java/lang/Void.P .deps/java/lang/dtoa.P .deps/java/lang/e_acos.P \ @@ -938,8 +1874,44 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \ .deps/java/util/zip/ZipInputStream.P \ .deps/java/util/zip/ZipOutputStream.P .deps/java/util/zip/natDeflater.P \ .deps/java/util/zip/natInflater.P .deps/jni.P .deps/name-finder.P \ -.deps/no-threads.P .deps/nogc.P .deps/posix-threads.P .deps/posix.P \ -.deps/prims.P .deps/resolve.P +.deps/no-threads.P .deps/nogc.P .deps/org/w3c/dom/Attr.P \ +.deps/org/w3c/dom/CDATASection.P .deps/org/w3c/dom/CharacterData.P \ +.deps/org/w3c/dom/Comment.P .deps/org/w3c/dom/DOMException.P \ +.deps/org/w3c/dom/DOMImplementation.P .deps/org/w3c/dom/Document.P \ +.deps/org/w3c/dom/DocumentFragment.P .deps/org/w3c/dom/DocumentType.P \ +.deps/org/w3c/dom/Element.P .deps/org/w3c/dom/Entity.P \ +.deps/org/w3c/dom/EntityReference.P .deps/org/w3c/dom/NamedNodeMap.P \ +.deps/org/w3c/dom/Node.P .deps/org/w3c/dom/NodeList.P \ +.deps/org/w3c/dom/Notation.P .deps/org/w3c/dom/ProcessingInstruction.P \ +.deps/org/w3c/dom/Text.P .deps/org/w3c/dom/ranges/DocumentRange.P \ +.deps/org/w3c/dom/ranges/Range.P \ +.deps/org/w3c/dom/ranges/RangeException.P \ +.deps/org/w3c/dom/traversal/DocumentTraversal.P \ +.deps/org/w3c/dom/traversal/NodeFilter.P \ +.deps/org/w3c/dom/traversal/NodeIterator.P \ +.deps/org/w3c/dom/traversal/TreeWalker.P \ +.deps/org/xml/sax/AttributeList.P .deps/org/xml/sax/Attributes.P \ +.deps/org/xml/sax/ContentHandler.P .deps/org/xml/sax/DTDHandler.P \ +.deps/org/xml/sax/DocumentHandler.P .deps/org/xml/sax/EntityResolver.P \ +.deps/org/xml/sax/ErrorHandler.P .deps/org/xml/sax/HandlerBase.P \ +.deps/org/xml/sax/InputSource.P .deps/org/xml/sax/Locator.P \ +.deps/org/xml/sax/Parser.P .deps/org/xml/sax/SAXException.P \ +.deps/org/xml/sax/SAXNotRecognizedException.P \ +.deps/org/xml/sax/SAXNotSupportedException.P \ +.deps/org/xml/sax/SAXParseException.P .deps/org/xml/sax/XMLFilter.P \ +.deps/org/xml/sax/XMLReader.P .deps/org/xml/sax/ext/DeclHandler.P \ +.deps/org/xml/sax/ext/LexicalHandler.P \ +.deps/org/xml/sax/helpers/AttributeListImpl.P \ +.deps/org/xml/sax/helpers/AttributesImpl.P \ +.deps/org/xml/sax/helpers/DefaultHandler.P \ +.deps/org/xml/sax/helpers/LocatorImpl.P \ +.deps/org/xml/sax/helpers/NamespaceSupport.P \ +.deps/org/xml/sax/helpers/ParserAdapter.P \ +.deps/org/xml/sax/helpers/ParserFactory.P \ +.deps/org/xml/sax/helpers/XMLFilterImpl.P \ +.deps/org/xml/sax/helpers/XMLReaderAdapter.P \ +.deps/org/xml/sax/helpers/XMLReaderFactory.P .deps/posix-threads.P \ +.deps/posix.P .deps/prims.P .deps/resolve.P SOURCES = $(libgcj_la_SOURCES) $(EXTRA_libgcj_la_SOURCES) $(libgcjx_la_SOURCES) $(EXTRA_libgcjx_la_SOURCES) $(jv_convert_SOURCES) $(EXTRA_jv_convert_SOURCES) $(gij_SOURCES) $(gen_from_JIS_SOURCES) $(EXTRA_gen_from_JIS_SOURCES) OBJECTS = $(libgcj_la_OBJECTS) $(libgcjx_la_OBJECTS) $(jv_convert_OBJECTS) $(gij_OBJECTS) $(gen_from_JIS_OBJECTS) @@ -1042,8 +2014,8 @@ install-binPROGRAMS: $(bin_PROGRAMS) $(mkinstalldirs) $(DESTDIR)$(bindir) @list='$(bin_PROGRAMS)'; for p in $$list; do \ if test -f $$p; then \ - echo " $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ - $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + echo " $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ + $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ else :; fi; \ done @@ -1367,7 +2339,7 @@ uninstall: uninstall-recursive all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(SCRIPTS) $(DATA) all-redirect: all-recursive install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install + $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install installdirs: installdirs-recursive installdirs-am: $(mkinstalldirs) $(DESTDIR)$(toolexeclibdir) $(DESTDIR)$(bindir) \ @@ -1471,7 +2443,7 @@ libgcj.jar: $(built_java_source_files) $(java_source_files) $(x_java_source_file done; \ test "$$fail" = no -@rm -f tmp-list libgcj.jar - find java gnu -type d -o -type f -name '*.class' | \ + find java gnu org -type d -o -type f -name '*.class' | \ sed -e '/\/\./d' -e '/\/xlib/d' | \ $(ZIP) cfM0E@ $@ diff --git a/libjava/org/w3c/dom/Attr.java b/libjava/org/w3c/dom/Attr.java new file mode 100644 index 00000000000..f54467fa212 --- /dev/null +++ b/libjava/org/w3c/dom/Attr.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2000 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + */ + +package org.w3c.dom; + +/** + * The Attr interface represents an attribute in an + * Element object. Typically the allowable values for the + * attribute are defined in a document type definition. + *

Attr objects inherit the Node interface, but + * since they are not actually child nodes of the element they describe, the + * DOM does not consider them part of the document tree. Thus, the + * Node attributes parentNode, + * previousSibling, and nextSibling have a + * null value for Attr objects. The DOM takes the + * view that attributes are properties of elements rather than having a + * separate identity from the elements they are associated with; this should + * make it more efficient to implement such features as default attributes + * associated with all elements of a given type. Furthermore, + * Attr nodes may not be immediate children of a + * DocumentFragment. However, they can be associated with + * Element nodes contained within a + * DocumentFragment. In short, users and implementors of the + * DOM need to be aware that Attr nodes have some things in + * common with other objects inheriting the Node interface, but + * they also are quite distinct. + *

The attribute's effective value is determined as follows: if this + * attribute has been explicitly assigned any value, that value is the + * attribute's effective value; otherwise, if there is a declaration for + * this attribute, and that declaration includes a default value, then that + * default value is the attribute's effective value; otherwise, the + * attribute does not exist on this element in the structure model until it + * has been explicitly added. Note that the nodeValue attribute + * on the Attr instance can also be used to retrieve the string + * version of the attribute's value(s). + *

In XML, where the value of an attribute can contain entity references, + * the child nodes of the Attr node may be either + * Text or EntityReference nodes (when these are + * in use; see the description of EntityReference for + * discussion). Because the DOM Core is not aware of attribute types, it + * treats all attribute values as simple strings, even if the DTD or schema + * declares them as having tokenized types. + *

See also the Document Object Model (DOM) Level 2 Core Specification. + */ +public interface Attr extends Node { + /** + * Returns the name of this attribute. + */ + public String getName(); + + /** + * If this attribute was explicitly given a value in the original + * document, this is true; otherwise, it is + * false. Note that the implementation is in charge of this + * attribute, not the user. If the user changes the value of the + * attribute (even if it ends up having the same value as the default + * value) then the specified flag is automatically flipped + * to true. To re-specify the attribute as the default + * value from the DTD, the user must delete the attribute. The + * implementation will then make a new attribute available with + * specified set to false and the default + * value (if one exists). + *
In summary: If the attribute has an assigned value in the document + * then specified is true, and the value is + * the assigned value. If the attribute has no assigned value in the + * document and has a default value in the DTD, then + * specified is false, and the value is the + * default value in the DTD. If the attribute has no assigned value in + * the document and has a value of #IMPLIED in the DTD, then the + * attribute does not appear in the structure model of the document. If + * the ownerElement attribute is null (i.e. + * because it was just created or was set to null by the + * various removal and cloning operations) specified is + * true. + */ + public boolean getSpecified(); + + /** + * On retrieval, the value of the attribute is returned as a string. + * Character and general entity references are replaced with their + * values. See also the method getAttribute on the + * Element interface. + *
On setting, this creates a Text node with the unparsed + * contents of the string. I.e. any characters that an XML processor + * would recognize as markup are instead treated as literal text. See + * also the method setAttribute on the Element + * interface. + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. + */ + public String getValue(); + public void setValue(String value) + throws DOMException; + + /** + * The Element node this attribute is attached to or + * null if this attribute is not in use. + * @since DOM Level 2 + */ + public Element getOwnerElement(); + +} diff --git a/libjava/org/w3c/dom/CDATASection.java b/libjava/org/w3c/dom/CDATASection.java new file mode 100644 index 00000000000..d9972ef0e1c --- /dev/null +++ b/libjava/org/w3c/dom/CDATASection.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2000 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + */ + +package org.w3c.dom; + +/** + * CDATA sections are used to escape blocks of text containing characters that + * would otherwise be regarded as markup. The only delimiter that is + * recognized in a CDATA section is the "]]>" string that ends the CDATA + * section. CDATA sections cannot be nested. Their primary purpose is for + * including material such as XML fragments, without needing to escape all + * the delimiters. + *

The DOMString attribute of the Text node holds + * the text that is contained by the CDATA section. Note that this may + * contain characters that need to be escaped outside of CDATA sections and + * that, depending on the character encoding ("charset") chosen for + * serialization, it may be impossible to write out some characters as part + * of a CDATA section. + *

The CDATASection interface inherits from the + * CharacterData interface through the Text + * interface. Adjacent CDATASection nodes are not merged by use + * of the normalize method of the Node interface. + * Because no markup is recognized within a CDATASection, + * character numeric references cannot be used as an escape mechanism when + * serializing. Therefore, action needs to be taken when serializing a + * CDATASection with a character encoding where some of the + * contained characters cannot be represented. Failure to do so would not + * produce well-formed XML.One potential solution in the serialization + * process is to end the CDATA section before the character, output the + * character using a character reference or entity reference, and open a new + * CDATA section for any further characters in the text node. Note, however, + * that some code conversion libraries at the time of writing do not return + * an error or exception when a character is missing from the encoding, + * making the task of ensuring that data is not corrupted on serialization + * more difficult. + *

See also the Document Object Model (DOM) Level 2 Core Specification. + */ +public interface CDATASection extends Text { +} diff --git a/libjava/org/w3c/dom/CharacterData.java b/libjava/org/w3c/dom/CharacterData.java new file mode 100644 index 00000000000..d459252e0f3 --- /dev/null +++ b/libjava/org/w3c/dom/CharacterData.java @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2000 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + */ + +package org.w3c.dom; + +/** + * The CharacterData interface extends Node with a set of + * attributes and methods for accessing character data in the DOM. For + * clarity this set is defined here rather than on each object that uses + * these attributes and methods. No DOM objects correspond directly to + * CharacterData, though Text and others do + * inherit the interface from it. All offsets in this interface + * start from 0. + *

As explained in the DOMString interface, text strings in + * the DOM are represented in UTF-16, i.e. as a sequence of 16-bit units. In + * the following, the term 16-bit units is used whenever necessary to + * indicate that indexing on CharacterData is done in 16-bit units. + *

See also the Document Object Model (DOM) Level 2 Core Specification. + */ +public interface CharacterData extends Node { + /** + * The character data of the node that implements this interface. The DOM + * implementation may not put arbitrary limits on the amount of data + * that may be stored in a CharacterData node. However, + * implementation limits may mean that the entirety of a node's data may + * not fit into a single DOMString. In such cases, the user + * may call substringData to retrieve the data in + * appropriately sized pieces. + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. + * @exception DOMException + * DOMSTRING_SIZE_ERR: Raised when it would return more characters than + * fit in a DOMString variable on the implementation + * platform. + */ + public String getData() + throws DOMException; + public void setData(String data) + throws DOMException; + + /** + * The number of 16-bit units that are available through data + * and the substringData method below. This may have the + * value zero, i.e., CharacterData nodes may be empty. + */ + public int getLength(); + + /** + * Extracts a range of data from the node. + * @param offsetStart offset of substring to extract. + * @param countThe number of 16-bit units to extract. + * @return The specified substring. If the sum of offset and + * count exceeds the length, then all 16-bit + * units to the end of the data are returned. + * @exception DOMException + * INDEX_SIZE_ERR: Raised if the specified offset is + * negative or greater than the number of 16-bit units in + * data, or if the specified count is + * negative. + *
DOMSTRING_SIZE_ERR: Raised if the specified range of text does + * not fit into a DOMString. + */ + public String substringData(int offset, + int count) + throws DOMException; + + /** + * Append the string to the end of the character data of the node. Upon + * success, data provides access to the concatenation of + * data and the DOMString specified. + * @param argThe DOMString to append. + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + */ + public void appendData(String arg) + throws DOMException; + + /** + * Insert a string at the specified 16-bit unit offset. + * @param offsetThe character offset at which to insert. + * @param argThe DOMString to insert. + * @exception DOMException + * INDEX_SIZE_ERR: Raised if the specified offset is + * negative or greater than the number of 16-bit units in + * data. + *
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + */ + public void insertData(int offset, + String arg) + throws DOMException; + + /** + * Remove a range of 16-bit units from the node. Upon success, + * data and length reflect the change. + * @param offsetThe offset from which to start removing. + * @param countThe number of 16-bit units to delete. If the sum of + * offset and count exceeds + * length then all 16-bit units from offset + * to the end of the data are deleted. + * @exception DOMException + * INDEX_SIZE_ERR: Raised if the specified offset is + * negative or greater than the number of 16-bit units in + * data, or if the specified count is + * negative. + *
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + */ + public void deleteData(int offset, + int count) + throws DOMException; + + /** + * Replace the characters starting at the specified 16-bit unit offset + * with the specified string. + * @param offsetThe offset from which to start replacing. + * @param countThe number of 16-bit units to replace. If the sum of + * offset and count exceeds + * length, then all 16-bit units to the end of the data + * are replaced; (i.e., the effect is the same as a remove + * method call with the same range, followed by an append + * method invocation). + * @param argThe DOMString with which the range must be + * replaced. + * @exception DOMException + * INDEX_SIZE_ERR: Raised if the specified offset is + * negative or greater than the number of 16-bit units in + * data, or if the specified count is + * negative. + *
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + */ + public void replaceData(int offset, + int count, + String arg) + throws DOMException; + +} diff --git a/libjava/org/w3c/dom/Comment.java b/libjava/org/w3c/dom/Comment.java new file mode 100644 index 00000000000..7c37d965f09 --- /dev/null +++ b/libjava/org/w3c/dom/Comment.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2000 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + */ + +package org.w3c.dom; + +/** + * This interface inherits from CharacterData and represents the + * content of a comment, i.e., all the characters between the starting ' + * <!--' and ending '-->'. Note that this is + * the definition of a comment in XML, and, in practice, HTML, although some + * HTML tools may implement the full SGML comment structure. + *

See also the Document Object Model (DOM) Level 2 Core Specification. + */ +public interface Comment extends CharacterData { +} diff --git a/libjava/org/w3c/dom/DOMException.java b/libjava/org/w3c/dom/DOMException.java new file mode 100644 index 00000000000..41ad08a6d96 --- /dev/null +++ b/libjava/org/w3c/dom/DOMException.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2000 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + */ + +package org.w3c.dom; + +/** + * DOM operations only raise exceptions in "exceptional" circumstances, i.e., + * when an operation is impossible to perform (either for logical reasons, + * because data is lost, or because the implementation has become unstable). + * In general, DOM methods return specific error values in ordinary + * processing situations, such as out-of-bound errors when using + * NodeList. + *

Implementations should raise other exceptions under other circumstances. + * For example, implementations should raise an implementation-dependent + * exception if a null argument is passed. + *

Some languages and object systems do not support the concept of + * exceptions. For such systems, error conditions may be indicated using + * native error reporting mechanisms. For some bindings, for example, + * methods may return error codes similar to those listed in the + * corresponding method descriptions. + *

See also the Document Object Model (DOM) Level 2 Core Specification. + */ +public class DOMException extends RuntimeException { + public DOMException(short code, String message) { + super(message); + this.code = code; + } + /** @serial */ + public short code; + // ExceptionCode + /** + * If index or size is negative, or greater than the allowed value + */ + public static final short INDEX_SIZE_ERR = 1; + /** + * If the specified range of text does not fit into a DOMString + */ + public static final short DOMSTRING_SIZE_ERR = 2; + /** + * If any node is inserted somewhere it doesn't belong + */ + public static final short HIERARCHY_REQUEST_ERR = 3; + /** + * If a node is used in a different document than the one that created it + * (that doesn't support it) + */ + public static final short WRONG_DOCUMENT_ERR = 4; + /** + * If an invalid or illegal character is specified, such as in a name. See + * production 2 in the XML specification for the definition of a legal + * character, and production 5 for the definition of a legal name + * character. + */ + public static final short INVALID_CHARACTER_ERR = 5; + /** + * If data is specified for a node which does not support data + */ + public static final short NO_DATA_ALLOWED_ERR = 6; + /** + * If an attempt is made to modify an object where modifications are not + * allowed + */ + public static final short NO_MODIFICATION_ALLOWED_ERR = 7; + /** + * If an attempt is made to reference a node in a context where it does + * not exist + */ + public static final short NOT_FOUND_ERR = 8; + /** + * If the implementation does not support the requested type of object or + * operation. + */ + public static final short NOT_SUPPORTED_ERR = 9; + /** + * If an attempt is made to add an attribute that is already in use + * elsewhere + */ + public static final short INUSE_ATTRIBUTE_ERR = 10; + /** + * If an attempt is made to use an object that is not, or is no longer, + * usable. + * @since DOM Level 2 + */ + public static final short INVALID_STATE_ERR = 11; + /** + * If an invalid or illegal string is specified. + * @since DOM Level 2 + */ + public static final short SYNTAX_ERR = 12; + /** + * If an attempt is made to modify the type of the underlying object. + * @since DOM Level 2 + */ + public static final short INVALID_MODIFICATION_ERR = 13; + /** + * If an attempt is made to create or change an object in a way which is + * incorrect with regard to namespaces. + * @since DOM Level 2 + */ + public static final short NAMESPACE_ERR = 14; + /** + * If a parameter or an operation is not supported by the underlying + * object. + * @since DOM Level 2 + */ + public static final short INVALID_ACCESS_ERR = 15; + +} diff --git a/libjava/org/w3c/dom/DOMImplementation.java b/libjava/org/w3c/dom/DOMImplementation.java new file mode 100644 index 00000000000..b11d7158431 --- /dev/null +++ b/libjava/org/w3c/dom/DOMImplementation.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2000 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + */ + +package org.w3c.dom; + +/** + * The DOMImplementation interface provides a number of methods + * for performing operations that are independent of any particular instance + * of the document object model. + *

See also the Document Object Model (DOM) Level 2 Core Specification. + */ +public interface DOMImplementation { + /** + * Test if the DOM implementation implements a specific feature. + * @param featureThe name of the feature to test (case-insensitive). The + * values used by DOM features are defined throughout the DOM Level 2 + * specifications and listed in the section. The name must be an XML + * name. To avoid possible conflicts, as a convention, names referring + * to features defined outside the DOM specification should be made + * unique by reversing the name of the Internet domain name of the + * person (or the organization that the person belongs to) who defines + * the feature, component by component, and using this as a prefix. + * For instance, the W3C SVG Working Group defines the feature + * "org.w3c.dom.svg". + * @param versionThis is the version number of the feature to test. In + * Level 2, the string can be either "2.0" or "1.0". If the version is + * not specified, supporting any version of the feature causes the + * method to return true. + * @return true if the feature is implemented in the + * specified version, false otherwise. + */ + public boolean hasFeature(String feature, + String version); + + /** + * Creates an empty DocumentType node. Entity declarations + * and notations are not made available. Entity reference expansions and + * default attribute additions do not occur. It is expected that a + * future version of the DOM will provide a way for populating a + * DocumentType. + *
HTML-only DOM implementations do not need to implement this method. + * @param qualifiedNameThe qualified name of the document type to be + * created. + * @param publicIdThe external subset public identifier. + * @param systemIdThe external subset system identifier. + * @return A new DocumentType node with + * Node.ownerDocument set to null. + * @exception DOMException + * INVALID_CHARACTER_ERR: Raised if the specified qualified name + * contains an illegal character. + *
NAMESPACE_ERR: Raised if the qualifiedName is + * malformed. + * @since DOM Level 2 + */ + public DocumentType createDocumentType(String qualifiedName, + String publicId, + String systemId) + throws DOMException; + + /** + * Creates an XML Document object of the specified type with + * its document element. HTML-only DOM implementations do not need to + * implement this method. + * @param namespaceURIThe namespace URI of the document element to create. + * @param qualifiedNameThe qualified name of the document element to be + * created. + * @param doctypeThe type of document to be created or null. + * When doctype is not null, its + * Node.ownerDocument attribute is set to the document + * being created. + * @return A new Document object. + * @exception DOMException + * INVALID_CHARACTER_ERR: Raised if the specified qualified name + * contains an illegal character. + *
NAMESPACE_ERR: Raised if the qualifiedName is + * malformed, if the qualifiedName has a prefix and the + * namespaceURI is null, or if the + * qualifiedName has a prefix that is "xml" and the + * namespaceURI is different from " + * http://www.w3.org/XML/1998/namespace" . + *
WRONG_DOCUMENT_ERR: Raised if doctype has already + * been used with a different document or was created from a different + * implementation. + * @since DOM Level 2 + */ + public Document createDocument(String namespaceURI, + String qualifiedName, + DocumentType doctype) + throws DOMException; + +} diff --git a/libjava/org/w3c/dom/Document.java b/libjava/org/w3c/dom/Document.java new file mode 100644 index 00000000000..2db27c96410 --- /dev/null +++ b/libjava/org/w3c/dom/Document.java @@ -0,0 +1,365 @@ +/* + * Copyright (c) 2000 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + */ + +package org.w3c.dom; + +/** + * The Document interface represents the entire HTML or XML + * document. Conceptually, it is the root of the document tree, and provides + * the primary access to the document's data. + *

Since elements, text nodes, comments, processing instructions, etc. + * cannot exist outside the context of a Document, the + * Document interface also contains the factory methods needed + * to create these objects. The Node objects created have a + * ownerDocument attribute which associates them with the + * Document within whose context they were created. + *

See also the Document Object Model (DOM) Level 2 Core Specification. + */ +public interface Document extends Node { + /** + * The Document Type Declaration (see DocumentType) + * associated with this document. For HTML documents as well as XML + * documents without a document type declaration this returns + * null. The DOM Level 2 does not support editing the + * Document Type Declaration. docType cannot be altered in + * any way, including through the use of methods inherited from the + * Node interface, such as insertNode or + * removeNode. + */ + public DocumentType getDoctype(); + + /** + * The DOMImplementation object that handles this document. A + * DOM application may use objects from multiple implementations. + */ + public DOMImplementation getImplementation(); + + /** + * This is a convenience attribute that allows direct access to the child + * node that is the root element of the document. For HTML documents, + * this is the element with the tagName "HTML". + */ + public Element getDocumentElement(); + + /** + * Creates an element of the type specified. Note that the instance + * returned implements the Element interface, so attributes + * can be specified directly on the returned object. + *
In addition, if there are known attributes with default values, + * Attr nodes representing them are automatically created + * and attached to the element. + *
To create an element with a qualified name and namespace URI, use + * the createElementNS method. + * @param tagNameThe name of the element type to instantiate. For XML, + * this is case-sensitive. For HTML, the tagName + * parameter may be provided in any case, but it must be mapped to the + * canonical uppercase form by the DOM implementation. + * @return A new Element object with the + * nodeName attribute set to tagName, and + * localName, prefix, and + * namespaceURI set to null. + * @exception DOMException + * INVALID_CHARACTER_ERR: Raised if the specified name contains an + * illegal character. + */ + public Element createElement(String tagName) + throws DOMException; + + /** + * Creates an empty DocumentFragment object. + * @return A new DocumentFragment. + */ + public DocumentFragment createDocumentFragment(); + + /** + * Creates a Text node given the specified string. + * @param dataThe data for the node. + * @return The new Text object. + */ + public Text createTextNode(String data); + + /** + * Creates a Comment node given the specified string. + * @param dataThe data for the node. + * @return The new Comment object. + */ + public Comment createComment(String data); + + /** + * Creates a CDATASection node whose value is the specified + * string. + * @param dataThe data for the CDATASection contents. + * @return The new CDATASection object. + * @exception DOMException + * NOT_SUPPORTED_ERR: Raised if this document is an HTML document. + */ + public CDATASection createCDATASection(String data) + throws DOMException; + + /** + * Creates a ProcessingInstruction node given the specified + * name and data strings. + * @param targetThe target part of the processing instruction. + * @param dataThe data for the node. + * @return The new ProcessingInstruction object. + * @exception DOMException + * INVALID_CHARACTER_ERR: Raised if the specified target contains an + * illegal character. + *
NOT_SUPPORTED_ERR: Raised if this document is an HTML document. + */ + public ProcessingInstruction createProcessingInstruction(String target, + String data) + throws DOMException; + + /** + * Creates an Attr of the given name. Note that the + * Attr instance can then be set on an Element + * using the setAttributeNode method. + *
To create an attribute with a qualified name and namespace URI, use + * the createAttributeNS method. + * @param nameThe name of the attribute. + * @return A new Attr object with the nodeName + * attribute set to name, and localName, + * prefix, and namespaceURI set to + * null. The value of the attribute is the empty string. + * @exception DOMException + * INVALID_CHARACTER_ERR: Raised if the specified name contains an + * illegal character. + */ + public Attr createAttribute(String name) + throws DOMException; + + /** + * Creates an EntityReference object. In addition, if the + * referenced entity is known, the child list of the + * EntityReference node is made the same as that of the + * corresponding Entity node.If any descendant of the + * Entity node has an unbound namespace prefix, the + * corresponding descendant of the created EntityReference + * node is also unbound; (its namespaceURI is + * null). The DOM Level 2 does not support any mechanism to + * resolve namespace prefixes. + * @param nameThe name of the entity to reference. + * @return The new EntityReference object. + * @exception DOMException + * INVALID_CHARACTER_ERR: Raised if the specified name contains an + * illegal character. + *
NOT_SUPPORTED_ERR: Raised if this document is an HTML document. + */ + public EntityReference createEntityReference(String name) + throws DOMException; + + /** + * Returns a NodeList of all the Elements with a + * given tag name in the order in which they are encountered in a + * preorder traversal of the Document tree. + * @param tagnameThe name of the tag to match on. The special value "*" + * matches all tags. + * @return A new NodeList object containing all the matched + * Elements. + */ + public NodeList getElementsByTagName(String tagname); + + /** + * Imports a node from another document to this document. The returned + * node has no parent; (parentNode is null). + * The source node is not altered or removed from the original document; + * this method creates a new copy of the source node. + *
For all nodes, importing a node creates a node object owned by the + * importing document, with attribute values identical to the source + * node's nodeName and nodeType, plus the + * attributes related to namespaces (prefix, + * localName, and namespaceURI). As in the + * cloneNode operation on a Node, the source + * node is not altered. + *
Additional information is copied as appropriate to the + * nodeType, attempting to mirror the behavior expected if + * a fragment of XML or HTML source was copied from one document to + * another, recognizing that the two documents may have different DTDs + * in the XML case. The following list describes the specifics for each + * type of node. + *

+ *
ATTRIBUTE_NODE
+ *
The ownerElement attribute + * is set to null and the specified flag is + * set to true on the generated Attr. The + * descendants of the source Attr are recursively imported + * and the resulting nodes reassembled to form the corresponding subtree. + * Note that the deep parameter has no effect on + * Attr nodes; they always carry their children with them + * when imported.
+ *
DOCUMENT_FRAGMENT_NODE
+ *
If the deep option + * was set to true, the descendants of the source element + * are recursively imported and the resulting nodes reassembled to form + * the corresponding subtree. Otherwise, this simply generates an empty + * DocumentFragment.
+ *
DOCUMENT_NODE
+ *
Document + * nodes cannot be imported.
+ *
DOCUMENT_TYPE_NODE
+ *
DocumentType + * nodes cannot be imported.
+ *
ELEMENT_NODE
+ *
Specified attribute nodes of the + * source element are imported, and the generated Attr + * nodes are attached to the generated Element. Default + * attributes are not copied, though if the document being imported into + * defines default attributes for this element name, those are assigned. + * If the importNode deep parameter was set to + * true, the descendants of the source element are + * recursively imported and the resulting nodes reassembled to form the + * corresponding subtree.
+ *
ENTITY_NODE
+ *
Entity nodes can be + * imported, however in the current release of the DOM the + * DocumentType is readonly. Ability to add these imported + * nodes to a DocumentType will be considered for addition + * to a future release of the DOM.On import, the publicId, + * systemId, and notationName attributes are + * copied. If a deep import is requested, the descendants + * of the the source Entity are recursively imported and + * the resulting nodes reassembled to form the corresponding subtree.
+ *
+ * ENTITY_REFERENCE_NODE
+ *
Only the EntityReference itself is + * copied, even if a deep import is requested, since the + * source and destination documents might have defined the entity + * differently. If the document being imported into provides a + * definition for this entity name, its value is assigned.
+ *
NOTATION_NODE
+ *
+ * Notation nodes can be imported, however in the current + * release of the DOM the DocumentType is readonly. Ability + * to add these imported nodes to a DocumentType will be + * considered for addition to a future release of the DOM.On import, the + * publicId and systemId attributes are copied. + * Note that the deep parameter has no effect on + * Notation nodes since they never have any children.
+ *
+ * PROCESSING_INSTRUCTION_NODE
+ *
The imported node copies its + * target and data values from those of the + * source node.
+ *
TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE
+ *
These three + * types of nodes inheriting from CharacterData copy their + * data and length attributes from those of + * the source node.
+ * + * @param importedNodeThe node to import. + * @param deepIf true, recursively import the subtree under + * the specified node; if false, import only the node + * itself, as explained above. This has no effect on Attr + * , EntityReference, and Notation nodes. + * @return The imported node that belongs to this Document. + * @exception DOMException + * NOT_SUPPORTED_ERR: Raised if the type of node being imported is not + * supported. + * @since DOM Level 2 + */ + public Node importNode(Node importedNode, + boolean deep) + throws DOMException; + + /** + * Creates an element of the given qualified name and namespace URI. + * HTML-only DOM implementations do not need to implement this method. + * @param namespaceURIThe namespace URI of the element to create. + * @param qualifiedNameThe qualified name of the element type to + * instantiate. + * @return A new Element object with the following + * attributes:AttributeValueNode.nodeName + * qualifiedNameNode.namespaceURI + * namespaceURINode.prefixprefix, extracted + * from qualifiedName, or null if there is + * no prefixNode.localNamelocal name, extracted from + * qualifiedNameElement.tagName + * qualifiedName + * @exception DOMException + * INVALID_CHARACTER_ERR: Raised if the specified qualified name + * contains an illegal character. + *
NAMESPACE_ERR: Raised if the qualifiedName is + * malformed, if the qualifiedName has a prefix and the + * namespaceURI is null, or if the + * qualifiedName has a prefix that is "xml" and the + * namespaceURI is different from " + * http://www.w3.org/XML/1998/namespace" . + * @since DOM Level 2 + */ + public Element createElementNS(String namespaceURI, + String qualifiedName) + throws DOMException; + + /** + * Creates an attribute of the given qualified name and namespace URI. + * HTML-only DOM implementations do not need to implement this method. + * @param namespaceURIThe namespace URI of the attribute to create. + * @param qualifiedNameThe qualified name of the attribute to instantiate. + * @return A new Attr object with the following attributes: + * AttributeValueNode.nodeNamequalifiedName + * Node.namespaceURInamespaceURI + * Node.prefixprefix, extracted from + * qualifiedName, or null if there is no + * prefixNode.localNamelocal name, extracted from + * qualifiedNameAttr.name + * qualifiedNameNode.nodeValuethe empty + * string + * @exception DOMException + * INVALID_CHARACTER_ERR: Raised if the specified qualified name + * contains an illegal character. + *
NAMESPACE_ERR: Raised if the qualifiedName is + * malformed, if the qualifiedName has a prefix and the + * namespaceURI is null, if the + * qualifiedName has a prefix that is "xml" and the + * namespaceURI is different from " + * http://www.w3.org/XML/1998/namespace", or if the + * qualifiedName is "xmlns" and the + * namespaceURI is different from " + * http://www.w3.org/2000/xmlns/". + * @since DOM Level 2 + */ + public Attr createAttributeNS(String namespaceURI, + String qualifiedName) + throws DOMException; + + /** + * Returns a NodeList of all the Elements with a + * given local name and namespace URI in the order in which they are + * encountered in a preorder traversal of the Document tree. + * @param namespaceURIThe namespace URI of the elements to match on. The + * special value "*" matches all namespaces. + * @param localNameThe local name of the elements to match on. The + * special value "*" matches all local names. + * @return A new NodeList object containing all the matched + * Elements. + * @since DOM Level 2 + */ + public NodeList getElementsByTagNameNS(String namespaceURI, + String localName); + + /** + * Returns the Element whose ID is given by + * elementId. If no such element exists, returns + * null. Behavior is not defined if more than one element + * has this ID. The DOM implementation must have + * information that says which attributes are of type ID. Attributes + * with the name "ID" are not of type ID unless so defined. + * Implementations that do not know whether attributes are of type ID or + * not are expected to return null. + * @param elementIdThe unique id value for an element. + * @return The matching element. + * @since DOM Level 2 + */ + public Element getElementById(String elementId); + +} diff --git a/libjava/org/w3c/dom/DocumentFragment.java b/libjava/org/w3c/dom/DocumentFragment.java new file mode 100644 index 00000000000..9579eb7ec71 --- /dev/null +++ b/libjava/org/w3c/dom/DocumentFragment.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2000 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + */ + +package org.w3c.dom; + +/** + * DocumentFragment is a "lightweight" or "minimal" + * Document object. It is very common to want to be able to + * extract a portion of a document's tree or to create a new fragment of a + * document. Imagine implementing a user command like cut or rearranging a + * document by moving fragments around. It is desirable to have an object + * which can hold such fragments and it is quite natural to use a Node for + * this purpose. While it is true that a Document object could + * fulfill this role, a Document object can potentially be a + * heavyweight object, depending on the underlying implementation. What is + * really needed for this is a very lightweight object. + * DocumentFragment is such an object. + *

Furthermore, various operations -- such as inserting nodes as children + * of another Node -- may take DocumentFragment + * objects as arguments; this results in all the child nodes of the + * DocumentFragment being moved to the child list of this node. + *

The children of a DocumentFragment node are zero or more + * nodes representing the tops of any sub-trees defining the structure of + * the document. DocumentFragment nodes do not need to be + * well-formed XML documents (although they do need to follow the rules + * imposed upon well-formed XML parsed entities, which can have multiple top + * nodes). For example, a DocumentFragment might have only one + * child and that child node could be a Text node. Such a + * structure model represents neither an HTML document nor a well-formed XML + * document. + *

When a DocumentFragment is inserted into a + * Document (or indeed any other Node that may + * take children) the children of the DocumentFragment and not + * the DocumentFragment itself are inserted into the + * Node. This makes the DocumentFragment very + * useful when the user wishes to create nodes that are siblings; the + * DocumentFragment acts as the parent of these nodes so that + * the user can use the standard methods from the Node + * interface, such as insertBefore and appendChild. + *

See also the Document Object Model (DOM) Level 2 Core Specification. + */ +public interface DocumentFragment extends Node { +} diff --git a/libjava/org/w3c/dom/DocumentType.java b/libjava/org/w3c/dom/DocumentType.java new file mode 100644 index 00000000000..0bbcfac4857 --- /dev/null +++ b/libjava/org/w3c/dom/DocumentType.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2000 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + */ + +package org.w3c.dom; + +/** + * Each Document has a doctype attribute whose value + * is either null or a DocumentType object. The + * DocumentType interface in the DOM Core provides an interface + * to the list of entities that are defined for the document, and little + * else because the effect of namespaces and the various XML schema efforts + * on DTD representation are not clearly understood as of this writing. + *

The DOM Level 2 doesn't support editing DocumentType nodes. + *

See also the Document Object Model (DOM) Level 2 Core Specification. + */ +public interface DocumentType extends Node { + /** + * The name of DTD; i.e., the name immediately following the + * DOCTYPE keyword. + */ + public String getName(); + + /** + * A NamedNodeMap containing the general entities, both + * external and internal, declared in the DTD. Parameter entities are + * not contained. Duplicates are discarded. For example in: + *

<!DOCTYPE 
+     * ex SYSTEM "ex.dtd" [ <!ENTITY foo "foo"> <!ENTITY bar 
+     * "bar"> <!ENTITY bar "bar2"> <!ENTITY % baz "baz"> 
+     * ]> <ex/>
+ * the interface provides access to foo + * and the first declaration of bar but not the second + * declaration of bar or baz. Every node in + * this map also implements the Entity interface. + *
The DOM Level 2 does not support editing entities, therefore + * entities cannot be altered in any way. + */ + public NamedNodeMap getEntities(); + + /** + * A NamedNodeMap containing the notations declared in the + * DTD. Duplicates are discarded. Every node in this map also implements + * the Notation interface. + *
The DOM Level 2 does not support editing notations, therefore + * notations cannot be altered in any way. + */ + public NamedNodeMap getNotations(); + + /** + * The public identifier of the external subset. + * @since DOM Level 2 + */ + public String getPublicId(); + + /** + * The system identifier of the external subset. + * @since DOM Level 2 + */ + public String getSystemId(); + + /** + * The internal subset as a string.The actual content returned depends on + * how much information is available to the implementation. This may + * vary depending on various parameters, including the XML processor + * used to build the document. + * @since DOM Level 2 + */ + public String getInternalSubset(); + +} diff --git a/libjava/org/w3c/dom/Element.java b/libjava/org/w3c/dom/Element.java new file mode 100644 index 00000000000..85277faac60 --- /dev/null +++ b/libjava/org/w3c/dom/Element.java @@ -0,0 +1,302 @@ +/* + * Copyright (c) 2000 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + */ + +package org.w3c.dom; + +/** + * The Element interface represents an element in an HTML or XML + * document. Elements may have attributes associated with them; since the + * Element interface inherits from Node, the + * generic Node interface attribute attributes may + * be used to retrieve the set of all attributes for an element. There are + * methods on the Element interface to retrieve either an + * Attr object by name or an attribute value by name. In XML, + * where an attribute value may contain entity references, an + * Attr object should be retrieved to examine the possibly + * fairly complex sub-tree representing the attribute value. On the other + * hand, in HTML, where all attributes have simple string values, methods to + * directly access an attribute value can safely be used as a convenience.In + * DOM Level 2, the method normalize is inherited from the + * Node interface where it was moved. + *

See also the Document Object Model (DOM) Level 2 Core Specification. + */ +public interface Element extends Node { + /** + * The name of the element. For example, in: + *

 <elementExample 
+     * id="demo"> ... </elementExample> , 
+ * tagName has + * the value "elementExample". Note that this is + * case-preserving in XML, as are all of the operations of the DOM. The + * HTML DOM returns the tagName of an HTML element in the + * canonical uppercase form, regardless of the case in the source HTML + * document. + */ + public String getTagName(); + + /** + * Retrieves an attribute value by name. + * @param nameThe name of the attribute to retrieve. + * @return The Attr value as a string, or the empty string + * if that attribute does not have a specified or default value. + */ + public String getAttribute(String name); + + /** + * Adds a new attribute. If an attribute with that name is already present + * in the element, its value is changed to be that of the value + * parameter. This value is a simple string; it is not parsed as it is + * being set. So any markup (such as syntax to be recognized as an + * entity reference) is treated as literal text, and needs to be + * appropriately escaped by the implementation when it is written out. + * In order to assign an attribute value that contains entity + * references, the user must create an Attr node plus any + * Text and EntityReference nodes, build the + * appropriate subtree, and use setAttributeNode to assign + * it as the value of an attribute. + *
To set an attribute with a qualified name and namespace URI, use + * the setAttributeNS method. + * @param nameThe name of the attribute to create or alter. + * @param valueValue to set in string form. + * @exception DOMException + * INVALID_CHARACTER_ERR: Raised if the specified name contains an + * illegal character. + *
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + */ + public void setAttribute(String name, + String value) + throws DOMException; + + /** + * Removes an attribute by name. If the removed attribute is known to have + * a default value, an attribute immediately appears containing the + * default value as well as the corresponding namespace URI, local name, + * and prefix when applicable. + *
To remove an attribute by local name and namespace URI, use the + * removeAttributeNS method. + * @param nameThe name of the attribute to remove. + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + */ + public void removeAttribute(String name) + throws DOMException; + + /** + * Retrieves an attribute node by name. + *
To retrieve an attribute node by qualified name and namespace URI, + * use the getAttributeNodeNS method. + * @param nameThe name (nodeName) of the attribute to + * retrieve. + * @return The Attr node with the specified name ( + * nodeName) or null if there is no such + * attribute. + */ + public Attr getAttributeNode(String name); + + /** + * Adds a new attribute node. If an attribute with that name ( + * nodeName) is already present in the element, it is + * replaced by the new one. + *
To add a new attribute node with a qualified name and namespace + * URI, use the setAttributeNodeNS method. + * @param newAttrThe Attr node to add to the attribute list. + * @return If the newAttr attribute replaces an existing + * attribute, the replaced Attr node is returned, + * otherwise null is returned. + * @exception DOMException + * WRONG_DOCUMENT_ERR: Raised if newAttr was created from a + * different document than the one that created the element. + *
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + *
INUSE_ATTRIBUTE_ERR: Raised if newAttr is already an + * attribute of another Element object. The DOM user must + * explicitly clone Attr nodes to re-use them in other + * elements. + */ + public Attr setAttributeNode(Attr newAttr) + throws DOMException; + + /** + * Removes the specified attribute node. If the removed Attr + * has a default value it is immediately replaced. The replacing + * attribute has the same namespace URI and local name, as well as the + * original prefix, when applicable. + * @param oldAttrThe Attr node to remove from the attribute + * list. + * @return The Attr node that was removed. + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + *
NOT_FOUND_ERR: Raised if oldAttr is not an attribute + * of the element. + */ + public Attr removeAttributeNode(Attr oldAttr) + throws DOMException; + + /** + * Returns a NodeList of all descendant Elements + * with a given tag name, in the order in which they are encountered in + * a preorder traversal of this Element tree. + * @param nameThe name of the tag to match on. The special value "*" + * matches all tags. + * @return A list of matching Element nodes. + */ + public NodeList getElementsByTagName(String name); + + /** + * Retrieves an attribute value by local name and namespace URI. HTML-only + * DOM implementations do not need to implement this method. + * @param namespaceURIThe namespace URI of the attribute to retrieve. + * @param localNameThe local name of the attribute to retrieve. + * @return The Attr value as a string, or the empty string + * if that attribute does not have a specified or default value. + * @since DOM Level 2 + */ + public String getAttributeNS(String namespaceURI, + String localName); + + /** + * Adds a new attribute. If an attribute with the same local name and + * namespace URI is already present on the element, its prefix is + * changed to be the prefix part of the qualifiedName, and + * its value is changed to be the value parameter. This + * value is a simple string; it is not parsed as it is being set. So any + * markup (such as syntax to be recognized as an entity reference) is + * treated as literal text, and needs to be appropriately escaped by the + * implementation when it is written out. In order to assign an + * attribute value that contains entity references, the user must create + * an Attr node plus any Text and + * EntityReference nodes, build the appropriate subtree, + * and use setAttributeNodeNS or + * setAttributeNode to assign it as the value of an + * attribute. + *
HTML-only DOM implementations do not need to implement this method. + * @param namespaceURIThe namespace URI of the attribute to create or + * alter. + * @param qualifiedNameThe qualified name of the attribute to create or + * alter. + * @param valueThe value to set in string form. + * @exception DOMException + * INVALID_CHARACTER_ERR: Raised if the specified qualified name + * contains an illegal character. + *
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + *
NAMESPACE_ERR: Raised if the qualifiedName is + * malformed, if the qualifiedName has a prefix and the + * namespaceURI is null, if the + * qualifiedName has a prefix that is "xml" and the + * namespaceURI is different from " + * http://www.w3.org/XML/1998/namespace", or if the + * qualifiedName is "xmlns" and the + * namespaceURI is different from " + * http://www.w3.org/2000/xmlns/". + * @since DOM Level 2 + */ + public void setAttributeNS(String namespaceURI, + String qualifiedName, + String value) + throws DOMException; + + /** + * Removes an attribute by local name and namespace URI. If the removed + * attribute has a default value it is immediately replaced. The + * replacing attribute has the same namespace URI and local name, as + * well as the original prefix. + *
HTML-only DOM implementations do not need to implement this method. + * @param namespaceURIThe namespace URI of the attribute to remove. + * @param localNameThe local name of the attribute to remove. + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + * @since DOM Level 2 + */ + public void removeAttributeNS(String namespaceURI, + String localName) + throws DOMException; + + /** + * Retrieves an Attr node by local name and namespace URI. + * HTML-only DOM implementations do not need to implement this method. + * @param namespaceURIThe namespace URI of the attribute to retrieve. + * @param localNameThe local name of the attribute to retrieve. + * @return The Attr node with the specified attribute local + * name and namespace URI or null if there is no such + * attribute. + * @since DOM Level 2 + */ + public Attr getAttributeNodeNS(String namespaceURI, + String localName); + + /** + * Adds a new attribute. If an attribute with that local name and that + * namespace URI is already present in the element, it is replaced by + * the new one. + *
HTML-only DOM implementations do not need to implement this method. + * @param newAttrThe Attr node to add to the attribute list. + * @return If the newAttr attribute replaces an existing + * attribute with the same local name and namespace URI, the replaced + * Attr node is returned, otherwise null is + * returned. + * @exception DOMException + * WRONG_DOCUMENT_ERR: Raised if newAttr was created from a + * different document than the one that created the element. + *
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + *
INUSE_ATTRIBUTE_ERR: Raised if newAttr is already an + * attribute of another Element object. The DOM user must + * explicitly clone Attr nodes to re-use them in other + * elements. + * @since DOM Level 2 + */ + public Attr setAttributeNodeNS(Attr newAttr) + throws DOMException; + + /** + * Returns a NodeList of all the descendant + * Elements with a given local name and namespace URI in + * the order in which they are encountered in a preorder traversal of + * this Element tree. + *
HTML-only DOM implementations do not need to implement this method. + * @param namespaceURIThe namespace URI of the elements to match on. The + * special value "*" matches all namespaces. + * @param localNameThe local name of the elements to match on. The + * special value "*" matches all local names. + * @return A new NodeList object containing all the matched + * Elements. + * @since DOM Level 2 + */ + public NodeList getElementsByTagNameNS(String namespaceURI, + String localName); + + /** + * Returns true when an attribute with a given name is + * specified on this element or has a default value, false + * otherwise. + * @param nameThe name of the attribute to look for. + * @return true if an attribute with the given name is + * specified on this element or has a default value, false + * otherwise. + * @since DOM Level 2 + */ + public boolean hasAttribute(String name); + + /** + * Returns true when an attribute with a given local name and + * namespace URI is specified on this element or has a default value, + * false otherwise. HTML-only DOM implementations do not + * need to implement this method. + * @param namespaceURIThe namespace URI of the attribute to look for. + * @param localNameThe local name of the attribute to look for. + * @return true if an attribute with the given local name + * and namespace URI is specified or has a default value on this + * element, false otherwise. + * @since DOM Level 2 + */ + public boolean hasAttributeNS(String namespaceURI, + String localName); + +} diff --git a/libjava/org/w3c/dom/Entity.java b/libjava/org/w3c/dom/Entity.java new file mode 100644 index 00000000000..51a69cb0001 --- /dev/null +++ b/libjava/org/w3c/dom/Entity.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2000 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + */ + +package org.w3c.dom; + +/** + * This interface represents an entity, either parsed or unparsed, in an XML + * document. Note that this models the entity itself not the entity + * declaration. Entity declaration modeling has been left for a + * later Level of the DOM specification. + *

The nodeName attribute that is inherited from + * Node contains the name of the entity. + *

An XML processor may choose to completely expand entities before the + * structure model is passed to the DOM; in this case there will be no + * EntityReference nodes in the document tree. + *

XML does not mandate that a non-validating XML processor read and + * process entity declarations made in the external subset or declared in + * external parameter entities. This means that parsed entities declared in + * the external subset need not be expanded by some classes of applications, + * and that the replacement value of the entity may not be available. When + * the replacement value is available, the corresponding Entity + * node's child list represents the structure of that replacement text. + * Otherwise, the child list is empty. + *

The DOM Level 2 does not support editing Entity nodes; if a + * user wants to make changes to the contents of an Entity, + * every related EntityReference node has to be replaced in the + * structure model by a clone of the Entity's contents, and + * then the desired changes must be made to each of those clones instead. + * Entity nodes and all their descendants are readonly. + *

An Entity node does not have any parent.If the entity + * contains an unbound namespace prefix, the namespaceURI of + * the corresponding node in the Entity node subtree is + * null. The same is true for EntityReference + * nodes that refer to this entity, when they are created using the + * createEntityReference method of the Document + * interface. The DOM Level 2 does not support any mechanism to resolve + * namespace prefixes. + *

See also the Document Object Model (DOM) Level 2 Core Specification. + */ +public interface Entity extends Node { + /** + * The public identifier associated with the entity, if specified. If the + * public identifier was not specified, this is null. + */ + public String getPublicId(); + + /** + * The system identifier associated with the entity, if specified. If the + * system identifier was not specified, this is null. + */ + public String getSystemId(); + + /** + * For unparsed entities, the name of the notation for the entity. For + * parsed entities, this is null. + */ + public String getNotationName(); + +} diff --git a/libjava/org/w3c/dom/EntityReference.java b/libjava/org/w3c/dom/EntityReference.java new file mode 100644 index 00000000000..31c854d8c6e --- /dev/null +++ b/libjava/org/w3c/dom/EntityReference.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2000 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + */ + +package org.w3c.dom; + +/** + * EntityReference objects may be inserted into the structure + * model when an entity reference is in the source document, or when the + * user wishes to insert an entity reference. Note that character references + * and references to predefined entities are considered to be expanded by + * the HTML or XML processor so that characters are represented by their + * Unicode equivalent rather than by an entity reference. Moreover, the XML + * processor may completely expand references to entities while building the + * structure model, instead of providing EntityReference + * objects. If it does provide such objects, then for a given + * EntityReference node, it may be that there is no + * Entity node representing the referenced entity. If such an + * Entity exists, then the subtree of the + * EntityReference node is in general a copy of the + * Entity node subtree. However, this may not be true when an + * entity contains an unbound namespace prefix. In such a case, because the + * namespace prefix resolution depends on where the entity reference is, the + * descendants of the EntityReference node may be bound to + * different namespace URIs. + *

As for Entity nodes, EntityReference nodes and + * all their descendants are readonly. + *

See also the Document Object Model (DOM) Level 2 Core Specification. + */ +public interface EntityReference extends Node { +} diff --git a/libjava/org/w3c/dom/NamedNodeMap.java b/libjava/org/w3c/dom/NamedNodeMap.java new file mode 100644 index 00000000000..d57ba8d0e88 --- /dev/null +++ b/libjava/org/w3c/dom/NamedNodeMap.java @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2000 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + */ + +package org.w3c.dom; + +/** + * Objects implementing the NamedNodeMap interface are used to + * represent collections of nodes that can be accessed by name. Note that + * NamedNodeMap does not inherit from NodeList; + * NamedNodeMaps are not maintained in any particular order. + * Objects contained in an object implementing NamedNodeMap may + * also be accessed by an ordinal index, but this is simply to allow + * convenient enumeration of the contents of a NamedNodeMap, + * and does not imply that the DOM specifies an order to these Nodes. + *

NamedNodeMap objects in the DOM are live. + *

See also the Document Object Model (DOM) Level 2 Core Specification. + */ +public interface NamedNodeMap { + /** + * Retrieves a node specified by name. + * @param nameThe nodeName of a node to retrieve. + * @return A Node (of any type) with the specified + * nodeName, or null if it does not identify + * any node in this map. + */ + public Node getNamedItem(String name); + + /** + * Adds a node using its nodeName attribute. If a node with + * that name is already present in this map, it is replaced by the new + * one. + *
As the nodeName attribute is used to derive the name + * which the node must be stored under, multiple nodes of certain types + * (those that have a "special" string value) cannot be stored as the + * names would clash. This is seen as preferable to allowing nodes to be + * aliased. + * @param argA node to store in this map. The node will later be + * accessible using the value of its nodeName attribute. + * @return If the new Node replaces an existing node the + * replaced Node is returned, otherwise null + * is returned. + * @exception DOMException + * WRONG_DOCUMENT_ERR: Raised if arg was created from a + * different document than the one that created this map. + *
NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly. + *
INUSE_ATTRIBUTE_ERR: Raised if arg is an + * Attr that is already an attribute of another + * Element object. The DOM user must explicitly clone + * Attr nodes to re-use them in other elements. + */ + public Node setNamedItem(Node arg) + throws DOMException; + + /** + * Removes a node specified by name. When this map contains the attributes + * attached to an element, if the removed attribute is known to have a + * default value, an attribute immediately appears containing the + * default value as well as the corresponding namespace URI, local name, + * and prefix when applicable. + * @param nameThe nodeName of the node to remove. + * @return The node removed from this map if a node with such a name + * exists. + * @exception DOMException + * NOT_FOUND_ERR: Raised if there is no node named name in + * this map. + *
NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly. + */ + public Node removeNamedItem(String name) + throws DOMException; + + /** + * Returns the indexth item in the map. If index + * is greater than or equal to the number of nodes in this map, this + * returns null. + * @param indexIndex into this map. + * @return The node at the indexth position in the map, or + * null if that is not a valid index. + */ + public Node item(int index); + + /** + * The number of nodes in this map. The range of valid child node indices + * is 0 to length-1 inclusive. + */ + public int getLength(); + + /** + * Retrieves a node specified by local name and namespace URI. HTML-only + * DOM implementations do not need to implement this method. + * @param namespaceURIThe namespace URI of the node to retrieve. + * @param localNameThe local name of the node to retrieve. + * @return A Node (of any type) with the specified local + * name and namespace URI, or null if they do not + * identify any node in this map. + * @since DOM Level 2 + */ + public Node getNamedItemNS(String namespaceURI, + String localName); + + /** + * Adds a node using its namespaceURI and + * localName. If a node with that namespace URI and that + * local name is already present in this map, it is replaced by the new + * one. + *
HTML-only DOM implementations do not need to implement this method. + * @param argA node to store in this map. The node will later be + * accessible using the value of its namespaceURI and + * localName attributes. + * @return If the new Node replaces an existing node the + * replaced Node is returned, otherwise null + * is returned. + * @exception DOMException + * WRONG_DOCUMENT_ERR: Raised if arg was created from a + * different document than the one that created this map. + *
NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly. + *
INUSE_ATTRIBUTE_ERR: Raised if arg is an + * Attr that is already an attribute of another + * Element object. The DOM user must explicitly clone + * Attr nodes to re-use them in other elements. + * @since DOM Level 2 + */ + public Node setNamedItemNS(Node arg) + throws DOMException; + + /** + * Removes a node specified by local name and namespace URI. A removed + * attribute may be known to have a default value when this map contains + * the attributes attached to an element, as returned by the attributes + * attribute of the Node interface. If so, an attribute + * immediately appears containing the default value as well as the + * corresponding namespace URI, local name, and prefix when applicable. + *
HTML-only DOM implementations do not need to implement this method. + * @param namespaceURIThe namespace URI of the node to remove. + * @param localNameThe local name of the node to remove. + * @return The node removed from this map if a node with such a local + * name and namespace URI exists. + * @exception DOMException + * NOT_FOUND_ERR: Raised if there is no node with the specified + * namespaceURI and localName in this map. + *
NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly. + * @since DOM Level 2 + */ + public Node removeNamedItemNS(String namespaceURI, + String localName) + throws DOMException; + +} diff --git a/libjava/org/w3c/dom/Node.java b/libjava/org/w3c/dom/Node.java new file mode 100644 index 00000000000..ef650a27605 --- /dev/null +++ b/libjava/org/w3c/dom/Node.java @@ -0,0 +1,390 @@ +/* + * Copyright (c) 2000 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + */ + +package org.w3c.dom; + +/** + * The Node interface is the primary datatype for the entire + * Document Object Model. It represents a single node in the document tree. + * While all objects implementing the Node interface expose + * methods for dealing with children, not all objects implementing the + * Node interface may have children. For example, + * Text nodes may not have children, and adding children to + * such nodes results in a DOMException being raised. + *

The attributes nodeName, nodeValue and + * attributes are included as a mechanism to get at node + * information without casting down to the specific derived interface. In + * cases where there is no obvious mapping of these attributes for a + * specific nodeType (e.g., nodeValue for an + * Element or attributes for a Comment + * ), this returns null. Note that the specialized interfaces + * may contain additional and more convenient mechanisms to get and set the + * relevant information. + *

See also the Document Object Model (DOM) Level 2 Core Specification. + */ +public interface Node { + // NodeType + /** + * The node is an Element. + */ + public static final short ELEMENT_NODE = 1; + /** + * The node is an Attr. + */ + public static final short ATTRIBUTE_NODE = 2; + /** + * The node is a Text node. + */ + public static final short TEXT_NODE = 3; + /** + * The node is a CDATASection. + */ + public static final short CDATA_SECTION_NODE = 4; + /** + * The node is an EntityReference. + */ + public static final short ENTITY_REFERENCE_NODE = 5; + /** + * The node is an Entity. + */ + public static final short ENTITY_NODE = 6; + /** + * The node is a ProcessingInstruction. + */ + public static final short PROCESSING_INSTRUCTION_NODE = 7; + /** + * The node is a Comment. + */ + public static final short COMMENT_NODE = 8; + /** + * The node is a Document. + */ + public static final short DOCUMENT_NODE = 9; + /** + * The node is a DocumentType. + */ + public static final short DOCUMENT_TYPE_NODE = 10; + /** + * The node is a DocumentFragment. + */ + public static final short DOCUMENT_FRAGMENT_NODE = 11; + /** + * The node is a Notation. + */ + public static final short NOTATION_NODE = 12; + + /** + * The name of this node, depending on its type; see the table above. + */ + public String getNodeName(); + + /** + * The value of this node, depending on its type; see the table above. + * When it is defined to be null, setting it has no effect. + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. + * @exception DOMException + * DOMSTRING_SIZE_ERR: Raised when it would return more characters than + * fit in a DOMString variable on the implementation + * platform. + */ + public String getNodeValue() + throws DOMException; + public void setNodeValue(String nodeValue) + throws DOMException; + + /** + * A code representing the type of the underlying object, as defined above. + */ + public short getNodeType(); + + /** + * The parent of this node. All nodes, except Attr, + * Document, DocumentFragment, + * Entity, and Notation may have a parent. + * However, if a node has just been created and not yet added to the + * tree, or if it has been removed from the tree, this is + * null. + */ + public Node getParentNode(); + + /** + * A NodeList that contains all children of this node. If + * there are no children, this is a NodeList containing no + * nodes. + */ + public NodeList getChildNodes(); + + /** + * The first child of this node. If there is no such node, this returns + * null. + */ + public Node getFirstChild(); + + /** + * The last child of this node. If there is no such node, this returns + * null. + */ + public Node getLastChild(); + + /** + * The node immediately preceding this node. If there is no such node, + * this returns null. + */ + public Node getPreviousSibling(); + + /** + * The node immediately following this node. If there is no such node, + * this returns null. + */ + public Node getNextSibling(); + + /** + * A NamedNodeMap containing the attributes of this node (if + * it is an Element) or null otherwise. + */ + public NamedNodeMap getAttributes(); + + /** + * The Document object associated with this node. This is + * also the Document object used to create new nodes. When + * this node is a Document or a DocumentType + * which is not used with any Document yet, this is + * null. + * @version DOM Level 2 + */ + public Document getOwnerDocument(); + + /** + * Inserts the node newChild before the existing child node + * refChild. If refChild is null, + * insert newChild at the end of the list of children. + *
If newChild is a DocumentFragment object, + * all of its children are inserted, in the same order, before + * refChild. If the newChild is already in the + * tree, it is first removed. + * @param newChildThe node to insert. + * @param refChildThe reference node, i.e., the node before which the new + * node must be inserted. + * @return The node being inserted. + * @exception DOMException + * HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not + * allow children of the type of the newChild node, or if + * the node to insert is one of this node's ancestors. + *
WRONG_DOCUMENT_ERR: Raised if newChild was created + * from a different document than the one that created this node. + *
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or + * if the parent of the node being inserted is readonly. + *
NOT_FOUND_ERR: Raised if refChild is not a child of + * this node. + */ + public Node insertBefore(Node newChild, + Node refChild) + throws DOMException; + + /** + * Replaces the child node oldChild with newChild + * in the list of children, and returns the oldChild node. + *
If newChild is a DocumentFragment object, + * oldChild is replaced by all of the + * DocumentFragment children, which are inserted in the + * same order. If the newChild is already in the tree, it + * is first removed. + * @param newChildThe new node to put in the child list. + * @param oldChildThe node being replaced in the list. + * @return The node replaced. + * @exception DOMException + * HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not + * allow children of the type of the newChild node, or if + * the node to put in is one of this node's ancestors. + *
WRONG_DOCUMENT_ERR: Raised if newChild was created + * from a different document than the one that created this node. + *
NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the parent of + * the new node is readonly. + *
NOT_FOUND_ERR: Raised if oldChild is not a child of + * this node. + */ + public Node replaceChild(Node newChild, + Node oldChild) + throws DOMException; + + /** + * Removes the child node indicated by oldChild from the list + * of children, and returns it. + * @param oldChildThe node being removed. + * @return The node removed. + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + *
NOT_FOUND_ERR: Raised if oldChild is not a child of + * this node. + */ + public Node removeChild(Node oldChild) + throws DOMException; + + /** + * Adds the node newChild to the end of the list of children + * of this node. If the newChild is already in the tree, it + * is first removed. + * @param newChildThe node to add.If it is a DocumentFragment + * object, the entire contents of the document fragment are moved + * into the child list of this node + * @return The node added. + * @exception DOMException + * HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not + * allow children of the type of the newChild node, or if + * the node to append is one of this node's ancestors. + *
WRONG_DOCUMENT_ERR: Raised if newChild was created + * from a different document than the one that created this node. + *
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + */ + public Node appendChild(Node newChild) + throws DOMException; + + /** + * Returns whether this node has any children. + * @return true if this node has any children, + * false otherwise. + */ + public boolean hasChildNodes(); + + /** + * Returns a duplicate of this node, i.e., serves as a generic copy + * constructor for nodes. The duplicate node has no parent; ( + * parentNode is null.). + *
Cloning an Element copies all attributes and their + * values, including those generated by the XML processor to represent + * defaulted attributes, but this method does not copy any text it + * contains unless it is a deep clone, since the text is contained in a + * child Text node. Cloning an Attribute + * directly, as opposed to be cloned as part of an Element + * cloning operation, returns a specified attribute ( + * specified is true). Cloning any other type + * of node simply returns a copy of this node. + *
Note that cloning an immutable subtree results in a mutable copy, + * but the children of an EntityReference clone are readonly + * . In addition, clones of unspecified Attr nodes are + * specified. And, cloning Document, + * DocumentType, Entity, and + * Notation nodes is implementation dependent. + * @param deepIf true, recursively clone the subtree under + * the specified node; if false, clone only the node + * itself (and its attributes, if it is an Element). + * @return The duplicate node. + */ + public Node cloneNode(boolean deep); + + /** + * Puts all Text nodes in the full depth of the sub-tree + * underneath this Node, including attribute nodes, into a + * "normal" form where only structure (e.g., elements, comments, + * processing instructions, CDATA sections, and entity references) + * separates Text nodes, i.e., there are neither adjacent + * Text nodes nor empty Text nodes. This can + * be used to ensure that the DOM view of a document is the same as if + * it were saved and re-loaded, and is useful when operations (such as + * XPointer lookups) that depend on a particular document tree + * structure are to be used.In cases where the document contains + * CDATASections, the normalize operation alone may not be + * sufficient, since XPointers do not differentiate between + * Text nodes and CDATASection nodes. + * @version DOM Level 2 + */ + public void normalize(); + + /** + * Tests whether the DOM implementation implements a specific feature and + * that feature is supported by this node. + * @param featureThe name of the feature to test. This is the same name + * which can be passed to the method hasFeature on + * DOMImplementation. + * @param versionThis is the version number of the feature to test. In + * Level 2, version 1, this is the string "2.0". If the version is not + * specified, supporting any version of the feature will cause the + * method to return true. + * @return Returns true if the specified feature is + * supported on this node, false otherwise. + * @since DOM Level 2 + */ + public boolean isSupported(String feature, + String version); + + /** + * The namespace URI of this node, or null if it is + * unspecified. + *
This is not a computed value that is the result of a namespace + * lookup based on an examination of the namespace declarations in + * scope. It is merely the namespace URI given at creation time. + *
For nodes of any type other than ELEMENT_NODE and + * ATTRIBUTE_NODE and nodes created with a DOM Level 1 + * method, such as createElement from the + * Document interface, this is always null.Per + * the Namespaces in XML Specification an attribute does not inherit + * its namespace from the element it is attached to. If an attribute is + * not explicitly given a namespace, it simply has no namespace. + * @since DOM Level 2 + */ + public String getNamespaceURI(); + + /** + * The namespace prefix of this node, or null if it is + * unspecified. + *
Note that setting this attribute, when permitted, changes the + * nodeName attribute, which holds the qualified name, as + * well as the tagName and name attributes of + * the Element and Attr interfaces, when + * applicable. + *
Note also that changing the prefix of an attribute that is known to + * have a default value, does not make a new attribute with the default + * value and the original prefix appear, since the + * namespaceURI and localName do not change. + *
For nodes of any type other than ELEMENT_NODE and + * ATTRIBUTE_NODE and nodes created with a DOM Level 1 + * method, such as createElement from the + * Document interface, this is always null. + * @exception DOMException + * INVALID_CHARACTER_ERR: Raised if the specified prefix contains an + * illegal character. + *
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + *
NAMESPACE_ERR: Raised if the specified prefix is + * malformed, if the namespaceURI of this node is + * null, if the specified prefix is "xml" and the + * namespaceURI of this node is different from " + * http://www.w3.org/XML/1998/namespace", if this node is an attribute + * and the specified prefix is "xmlns" and the + * namespaceURI of this node is different from " + * http://www.w3.org/2000/xmlns/", or if this node is an attribute and + * the qualifiedName of this node is "xmlns" . + * @since DOM Level 2 + */ + public String getPrefix(); + public void setPrefix(String prefix) + throws DOMException; + + /** + * Returns the local part of the qualified name of this node. + *
For nodes of any type other than ELEMENT_NODE and + * ATTRIBUTE_NODE and nodes created with a DOM Level 1 + * method, such as createElement from the + * Document interface, this is always null. + * @since DOM Level 2 + */ + public String getLocalName(); + + /** + * Returns whether this node (if it is an element) has any attributes. + * @return true if this node has any attributes, + * false otherwise. + * @since DOM Level 2 + */ + public boolean hasAttributes(); + +} diff --git a/libjava/org/w3c/dom/NodeList.java b/libjava/org/w3c/dom/NodeList.java new file mode 100644 index 00000000000..f4033f303d6 --- /dev/null +++ b/libjava/org/w3c/dom/NodeList.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2000 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + */ + +package org.w3c.dom; + +/** + * The NodeList interface provides the abstraction of an ordered + * collection of nodes, without defining or constraining how this collection + * is implemented. NodeList objects in the DOM are live. + *

The items in the NodeList are accessible via an integral + * index, starting from 0. + *

See also the Document Object Model (DOM) Level 2 Core Specification. + */ +public interface NodeList { + /** + * Returns the indexth item in the collection. If + * index is greater than or equal to the number of nodes in + * the list, this returns null. + * @param indexIndex into the collection. + * @return The node at the indexth position in the + * NodeList, or null if that is not a valid + * index. + */ + public Node item(int index); + + /** + * The number of nodes in the list. The range of valid child node indices + * is 0 to length-1 inclusive. + */ + public int getLength(); + +} diff --git a/libjava/org/w3c/dom/Notation.java b/libjava/org/w3c/dom/Notation.java new file mode 100644 index 00000000000..284e01551a1 --- /dev/null +++ b/libjava/org/w3c/dom/Notation.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2000 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + */ + +package org.w3c.dom; + +/** + * This interface represents a notation declared in the DTD. A notation either + * declares, by name, the format of an unparsed entity (see section 4.7 of + * the XML 1.0 specification ), or is used for formal declaration of + * processing instruction targets (see section 2.6 of the XML 1.0 + * specification ). The nodeName attribute inherited from + * Node is set to the declared name of the notation. + *

The DOM Level 1 does not support editing Notation nodes; + * they are therefore readonly. + *

A Notation node does not have any parent. + *

See also the Document Object Model (DOM) Level 2 Core Specification. + */ +public interface Notation extends Node { + /** + * The public identifier of this notation. If the public identifier was + * not specified, this is null. + */ + public String getPublicId(); + + /** + * The system identifier of this notation. If the system identifier was + * not specified, this is null. + */ + public String getSystemId(); + +} diff --git a/libjava/org/w3c/dom/ProcessingInstruction.java b/libjava/org/w3c/dom/ProcessingInstruction.java new file mode 100644 index 00000000000..e3cfd1b0d6e --- /dev/null +++ b/libjava/org/w3c/dom/ProcessingInstruction.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2000 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + */ + +package org.w3c.dom; + +/** + * The ProcessingInstruction interface represents a "processing + * instruction", used in XML as a way to keep processor-specific information + * in the text of the document. + *

See also the Document Object Model (DOM) Level 2 Core Specification. + */ +public interface ProcessingInstruction extends Node { + /** + * The target of this processing instruction. XML defines this as being + * the first token following the markup that begins the processing + * instruction. + */ + public String getTarget(); + + /** + * The content of this processing instruction. This is from the first non + * white space character after the target to the character immediately + * preceding the ?>. + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. + */ + public String getData(); + public void setData(String data) + throws DOMException; + +} diff --git a/libjava/org/w3c/dom/Text.java b/libjava/org/w3c/dom/Text.java new file mode 100644 index 00000000000..c7c9971e67e --- /dev/null +++ b/libjava/org/w3c/dom/Text.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2000 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + */ + +package org.w3c.dom; + +/** + * The Text interface inherits from CharacterData + * and represents the textual content (termed character data in XML) of an + * Element or Attr. If there is no markup inside + * an element's content, the text is contained in a single object + * implementing the Text interface that is the only child of + * the element. If there is markup, it is parsed into the information items + * (elements, comments, etc.) and Text nodes that form the list + * of children of the element. + *

When a document is first made available via the DOM, there is only one + * Text node for each block of text. Users may create adjacent + * Text nodes that represent the contents of a given element + * without any intervening markup, but should be aware that there is no way + * to represent the separations between these nodes in XML or HTML, so they + * will not (in general) persist between DOM editing sessions. The + * normalize() method on Node merges any such + * adjacent Text objects into a single node for each block of + * text. + *

See also the Document Object Model (DOM) Level 2 Core Specification. + */ +public interface Text extends CharacterData { + /** + * Breaks this node into two nodes at the specified offset, + * keeping both in the tree as siblings. After being split, this node + * will contain all the content up to the offset point. A + * new node of the same type, which contains all the content at and + * after the offset point, is returned. If the original + * node had a parent node, the new node is inserted as the next sibling + * of the original node. When the offset is equal to the + * length of this node, the new node has no data. + * @param offsetThe 16-bit unit offset at which to split, starting from + * 0. + * @return The new node, of the same type as this node. + * @exception DOMException + * INDEX_SIZE_ERR: Raised if the specified offset is negative or greater + * than the number of 16-bit units in data. + *
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. + */ + public Text splitText(int offset) + throws DOMException; + +} diff --git a/libjava/org/w3c/dom/ranges/DocumentRange.java b/libjava/org/w3c/dom/ranges/DocumentRange.java new file mode 100644 index 00000000000..f9b764ff4a8 --- /dev/null +++ b/libjava/org/w3c/dom/ranges/DocumentRange.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2000 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + */ + +package org.w3c.dom.ranges; + +/** + *

See also the Document Object Model (DOM) Level 2 Traversal and Range Specification. + * @since DOM Level 2 + */ +public interface DocumentRange { + /** + * This interface can be obtained from the object implementing the + * Document interface using binding-specific casting + * methods. + * @return The initial state of the Range returned from this method is + * such that both of its boundary-points are positioned at the + * beginning of the corresponding Document, before any content. The + * Range returned can only be used to select content associated with + * this Document, or with DocumentFragments and Attrs for which this + * Document is the ownerDocument. + */ + public Range createRange(); + +} diff --git a/libjava/org/w3c/dom/ranges/Range.java b/libjava/org/w3c/dom/ranges/Range.java new file mode 100644 index 00000000000..f4c3608eb08 --- /dev/null +++ b/libjava/org/w3c/dom/ranges/Range.java @@ -0,0 +1,399 @@ +/* + * Copyright (c) 2000 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + */ + +package org.w3c.dom.ranges; + +import org.w3c.dom.Node; +import org.w3c.dom.DocumentFragment; +import org.w3c.dom.DOMException; + +/** + *

See also the Document Object Model (DOM) Level 2 Traversal and Range Specification. + * @since DOM Level 2 + */ +public interface Range { + /** + * Node within which the Range begins + * @exception DOMException + * INVALID_STATE_ERR: Raised if detach() has already been + * invoked on this object. + */ + public Node getStartContainer() + throws DOMException; + + /** + * Offset within the starting node of the Range. + * @exception DOMException + * INVALID_STATE_ERR: Raised if detach() has already been + * invoked on this object. + */ + public int getStartOffset() + throws DOMException; + + /** + * Node within which the Range ends + * @exception DOMException + * INVALID_STATE_ERR: Raised if detach() has already been + * invoked on this object. + */ + public Node getEndContainer() + throws DOMException; + + /** + * Offset within the ending node of the Range. + * @exception DOMException + * INVALID_STATE_ERR: Raised if detach() has already been + * invoked on this object. + */ + public int getEndOffset() + throws DOMException; + + /** + * TRUE if the Range is collapsed + * @exception DOMException + * INVALID_STATE_ERR: Raised if detach() has already been + * invoked on this object. + */ + public boolean getCollapsed() + throws DOMException; + + /** + * The deepest common ancestor container of the Range's two + * boundary-points. + * @exception DOMException + * INVALID_STATE_ERR: Raised if detach() has already been + * invoked on this object. + */ + public Node getCommonAncestorContainer() + throws DOMException; + + /** + * Sets the attributes describing the start of the Range. + * @param refNodeThe refNode value. This parameter must be + * different from null. + * @param offsetThe startOffset value. + * @exception RangeException + * INVALID_NODE_TYPE_ERR: Raised if refNode or an ancestor + * of refNode is an Entity, Notation, or DocumentType + * node. + * @exception DOMException + * INDEX_SIZE_ERR: Raised if offset is negative or greater + * than the number of child units in refNode. Child units + * are 16-bit units if refNode is a type of CharacterData + * node (e.g., a Text or Comment node) or a ProcessingInstruction + * node. Child units are Nodes in all other cases. + *
INVALID_STATE_ERR: Raised if detach() has already + * been invoked on this object. + */ + public void setStart(Node refNode, + int offset) + throws RangeException, DOMException; + + /** + * Sets the attributes describing the end of a Range. + * @param refNodeThe refNode value. This parameter must be + * different from null. + * @param offsetThe endOffset value. + * @exception RangeException + * INVALID_NODE_TYPE_ERR: Raised if refNode or an ancestor + * of refNode is an Entity, Notation, or DocumentType + * node. + * @exception DOMException + * INDEX_SIZE_ERR: Raised if offset is negative or greater + * than the number of child units in refNode. Child units + * are 16-bit units if refNode is a type of CharacterData + * node (e.g., a Text or Comment node) or a ProcessingInstruction + * node. Child units are Nodes in all other cases. + *
INVALID_STATE_ERR: Raised if detach() has already + * been invoked on this object. + */ + public void setEnd(Node refNode, + int offset) + throws RangeException, DOMException; + + /** + * Sets the start position to be before a node + * @param refNodeRange starts before refNode + * @exception RangeException + * INVALID_NODE_TYPE_ERR: Raised if the root container of + * refNode is not an Attr, Document, or DocumentFragment + * node or if refNode is a Document, DocumentFragment, + * Attr, Entity, or Notation node. + * @exception DOMException + * INVALID_STATE_ERR: Raised if detach() has already been + * invoked on this object. + */ + public void setStartBefore(Node refNode) + throws RangeException, DOMException; + + /** + * Sets the start position to be after a node + * @param refNodeRange starts after refNode + * @exception RangeException + * INVALID_NODE_TYPE_ERR: Raised if the root container of + * refNode is not an Attr, Document, or DocumentFragment + * node or if refNode is a Document, DocumentFragment, + * Attr, Entity, or Notation node. + * @exception DOMException + * INVALID_STATE_ERR: Raised if detach() has already been + * invoked on this object. + */ + public void setStartAfter(Node refNode) + throws RangeException, DOMException; + + /** + * Sets the end position to be before a node. + * @param refNodeRange ends before refNode + * @exception RangeException + * INVALID_NODE_TYPE_ERR: Raised if the root container of + * refNode is not an Attr, Document, or DocumentFragment + * node or if refNode is a Document, DocumentFragment, + * Attr, Entity, or Notation node. + * @exception DOMException + * INVALID_STATE_ERR: Raised if detach() has already been + * invoked on this object. + */ + public void setEndBefore(Node refNode) + throws RangeException, DOMException; + + /** + * Sets the end of a Range to be after a node + * @param refNodeRange ends after refNode. + * @exception RangeException + * INVALID_NODE_TYPE_ERR: Raised if the root container of + * refNode is not an Attr, Document or DocumentFragment + * node or if refNode is a Document, DocumentFragment, + * Attr, Entity, or Notation node. + * @exception DOMException + * INVALID_STATE_ERR: Raised if detach() has already been + * invoked on this object. + */ + public void setEndAfter(Node refNode) + throws RangeException, DOMException; + + /** + * Collapse a Range onto one of its boundary-points + * @param toStartIf TRUE, collapses the Range onto its start; if FALSE, + * collapses it onto its end. + * @exception DOMException + * INVALID_STATE_ERR: Raised if detach() has already been + * invoked on this object. + */ + public void collapse(boolean toStart) + throws DOMException; + + /** + * Select a node and its contents + * @param refNodeThe node to select. + * @exception RangeException + * INVALID_NODE_TYPE_ERR: Raised if an ancestor of refNode + * is an Entity, Notation or DocumentType node or if + * refNode is a Document, DocumentFragment, Attr, Entity, + * or Notation node. + * @exception DOMException + * INVALID_STATE_ERR: Raised if detach() has already been + * invoked on this object. + */ + public void selectNode(Node refNode) + throws RangeException, DOMException; + + /** + * Select the contents within a node + * @param refNodeNode to select from + * @exception RangeException + * INVALID_NODE_TYPE_ERR: Raised if refNode or an ancestor + * of refNode is an Entity, Notation or DocumentType node. + * @exception DOMException + * INVALID_STATE_ERR: Raised if detach() has already been + * invoked on this object. + */ + public void selectNodeContents(Node refNode) + throws RangeException, DOMException; + + // CompareHow + /** + * Compare start boundary-point of sourceRange to start + * boundary-point of Range on which compareBoundaryPoints + * is invoked. + */ + public static final short START_TO_START = 0; + /** + * Compare start boundary-point of sourceRange to end + * boundary-point of Range on which compareBoundaryPoints + * is invoked. + */ + public static final short START_TO_END = 1; + /** + * Compare end boundary-point of sourceRange to end + * boundary-point of Range on which compareBoundaryPoints + * is invoked. + */ + public static final short END_TO_END = 2; + /** + * Compare end boundary-point of sourceRange to start + * boundary-point of Range on which compareBoundaryPoints + * is invoked. + */ + public static final short END_TO_START = 3; + + /** + * Compare the boundary-points of two Ranges in a document. + * @param howA code representing the type of comparison, as defined above. + * @param sourceRangeThe Range on which this current + * Range is compared to. + * @return -1, 0 or 1 depending on whether the corresponding + * boundary-point of the Range is respectively before, equal to, or + * after the corresponding boundary-point of sourceRange. + * @exception DOMException + * WRONG_DOCUMENT_ERR: Raised if the two Ranges are not in the same + * Document or DocumentFragment. + *
INVALID_STATE_ERR: Raised if detach() has already + * been invoked on this object. + */ + public short compareBoundaryPoints(short how, + Range sourceRange) + throws DOMException; + + /** + * Removes the contents of a Range from the containing document or + * document fragment without returning a reference to the removed + * content. + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if any portion of the content of + * the Range is read-only or any of the nodes that contain any of the + * content of the Range are read-only. + *
INVALID_STATE_ERR: Raised if detach() has already + * been invoked on this object. + */ + public void deleteContents() + throws DOMException; + + /** + * Moves the contents of a Range from the containing document or document + * fragment to a new DocumentFragment. + * @return A DocumentFragment containing the extracted contents. + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if any portion of the content of + * the Range is read-only or any of the nodes which contain any of the + * content of the Range are read-only. + *
HIERARCHY_REQUEST_ERR: Raised if a DocumentType node would be + * extracted into the new DocumentFragment. + *
INVALID_STATE_ERR: Raised if detach() has already + * been invoked on this object. + */ + public DocumentFragment extractContents() + throws DOMException; + + /** + * Duplicates the contents of a Range + * @return A DocumentFragment that contains content equivalent to this + * Range. + * @exception DOMException + * HIERARCHY_REQUEST_ERR: Raised if a DocumentType node would be + * extracted into the new DocumentFragment. + *
INVALID_STATE_ERR: Raised if detach() has already + * been invoked on this object. + */ + public DocumentFragment cloneContents() + throws DOMException; + + /** + * Inserts a node into the Document or DocumentFragment at the start of + * the Range. If the container is a Text node, this will be split at the + * start of the Range (as if the Text node's splitText method was + * performed at the insertion point) and the insertion will occur + * between the two resulting Text nodes. Adjacent Text nodes will not be + * automatically merged. If the node to be inserted is a + * DocumentFragment node, the children will be inserted rather than the + * DocumentFragment node itself. + * @param newNodeThe node to insert at the start of the Range + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if an ancestor container of the + * start of the Range is read-only. + *
WRONG_DOCUMENT_ERR: Raised if newNode and the + * container of the start of the Range were not created from the same + * document. + *
HIERARCHY_REQUEST_ERR: Raised if the container of the start of + * the Range is of a type that does not allow children of the type of + * newNode or if newNode is an ancestor of + * the container. + *
INVALID_STATE_ERR: Raised if detach() has already + * been invoked on this object. + * @exception RangeException + * INVALID_NODE_TYPE_ERR: Raised if newNode is an Attr, + * Entity, Notation, or Document node. + */ + public void insertNode(Node newNode) + throws DOMException, RangeException; + + /** + * Reparents the contents of the Range to the given node and inserts the + * node at the position of the start of the Range. + * @param newParentThe node to surround the contents with. + * @exception DOMException + * NO_MODIFICATION_ALLOWED_ERR: Raised if an ancestor container of + * either boundary-point of the Range is read-only. + *
WRONG_DOCUMENT_ERR: Raised if newParent and the + * container of the start of the Range were not created from the same + * document. + *
HIERARCHY_REQUEST_ERR: Raised if the container of the start of + * the Range is of a type that does not allow children of the type of + * newParent or if newParent is an ancestor + * of the container or if node would end up with a child + * node of a type not allowed by the type of node. + *
INVALID_STATE_ERR: Raised if detach() has already + * been invoked on this object. + * @exception RangeException + * BAD_BOUNDARYPOINTS_ERR: Raised if the Range partially selects a + * non-text node. + *
INVALID_NODE_TYPE_ERR: Raised if node is an Attr, + * Entity, DocumentType, Notation, Document, or DocumentFragment node. + */ + public void surroundContents(Node newParent) + throws DOMException, RangeException; + + /** + * Produces a new Range whose boundary-points are equal to the + * boundary-points of the Range. + * @return The duplicated Range. + * @exception DOMException + * INVALID_STATE_ERR: Raised if detach() has already been + * invoked on this object. + */ + public Range cloneRange() + throws DOMException; + + /** + * Returns the contents of a Range as a string. This string contains only + * the data characters, not any markup. + * @return The contents of the Range. + * @exception DOMException + * INVALID_STATE_ERR: Raised if detach() has already been + * invoked on this object. + */ + public String toString() + throws DOMException; + + /** + * Called to indicate that the Range is no longer in use and that the + * implementation may relinquish any resources associated with this + * Range. Subsequent calls to any methods or attribute getters on this + * Range will result in a DOMException being thrown with an + * error code of INVALID_STATE_ERR. + * @exception DOMException + * INVALID_STATE_ERR: Raised if detach() has already been + * invoked on this object. + */ + public void detach() + throws DOMException; + +} diff --git a/libjava/org/w3c/dom/ranges/RangeException.java b/libjava/org/w3c/dom/ranges/RangeException.java new file mode 100644 index 00000000000..abf9a9f09ad --- /dev/null +++ b/libjava/org/w3c/dom/ranges/RangeException.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2000 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + */ + +package org.w3c.dom.ranges; + +/** + * Range operations may throw a RangeException as specified in + * their method descriptions. + *

See also the Document Object Model (DOM) Level 2 Traversal and Range Specification. + * @since DOM Level 2 + */ +public class RangeException extends RuntimeException { + public RangeException(short code, String message) { + super(message); + this.code = code; + } + public short code; + // RangeExceptionCode + /** + * If the boundary-points of a Range do not meet specific requirements. + */ + public static final short BAD_BOUNDARYPOINTS_ERR = 1; + /** + * If the container of an boundary-point of a Range is being set to either + * a node of an invalid type or a node with an ancestor of an invalid + * type. + */ + public static final short INVALID_NODE_TYPE_ERR = 2; + +} diff --git a/libjava/org/w3c/dom/traversal/DocumentTraversal.java b/libjava/org/w3c/dom/traversal/DocumentTraversal.java new file mode 100644 index 00000000000..88e7a92d2be --- /dev/null +++ b/libjava/org/w3c/dom/traversal/DocumentTraversal.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2000 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + */ + +package org.w3c.dom.traversal; + +import org.w3c.dom.Node; +import org.w3c.dom.DOMException; + +/** + * DocumentTraversal contains methods that create iterators and + * tree-walkers to traverse a node and its children in document order (depth + * first, pre-order traversal, which is equivalent to the order in which the + * start tags occur in the text representation of the document). In DOMs + * which support the Traversal feature, DocumentTraversal will + * be implemented by the same objects that implement the Document interface. + *

See also the Document Object Model (DOM) Level 2 Traversal and Range Specification. + * @since DOM Level 2 + */ +public interface DocumentTraversal { + /** + * Create a new NodeIterator over the subtree rooted at the + * specified node. + * @param rootThe node which will be iterated together with its children. + * The iterator is initially positioned just before this node. The + * whatToShow flags and the filter, if any, are not + * considered when setting this position. The root must not be + * null. + * @param whatToShowThis flag specifies which node types may appear in + * the logical view of the tree presented by the iterator. See the + * description of NodeFilter for the set of possible + * SHOW_ values.These flags can be combined using + * OR. + * @param filterThe NodeFilter to be used with this + * TreeWalker, or null to indicate no filter. + * @param entityReferenceExpansionThe value of this flag determines + * whether entity reference nodes are expanded. + * @return The newly created NodeIterator. + * @exception DOMException + * NOT_SUPPORTED_ERR: Raised if the specified root is + * null. + */ + public NodeIterator createNodeIterator(Node root, + int whatToShow, + NodeFilter filter, + boolean entityReferenceExpansion) + throws DOMException; + + /** + * Create a new TreeWalker over the subtree rooted at the + * specified node. + * @param rootThe node which will serve as the root for the + * TreeWalker. The whatToShow flags and the + * NodeFilter are not considered when setting this value; + * any node type will be accepted as the root. The + * currentNode of the TreeWalker is + * initialized to this node, whether or not it is visible. The + * root functions as a stopping point for traversal + * methods that look upward in the document structure, such as + * parentNode and nextNode. The root must + * not be null. + * @param whatToShowThis flag specifies which node types may appear in + * the logical view of the tree presented by the tree-walker. See the + * description of NodeFilter for the set of possible + * SHOW_ values.These flags can be combined using OR. + * @param filterThe NodeFilter to be used with this + * TreeWalker, or null to indicate no filter. + * @param entityReferenceExpansionIf this flag is false, the contents of + * EntityReference nodes are not presented in the logical + * view. + * @return The newly created TreeWalker. + * @exception DOMException + * NOT_SUPPORTED_ERR: Raised if the specified root is + * null. + */ + public TreeWalker createTreeWalker(Node root, + int whatToShow, + NodeFilter filter, + boolean entityReferenceExpansion) + throws DOMException; + +} diff --git a/libjava/org/w3c/dom/traversal/NodeFilter.java b/libjava/org/w3c/dom/traversal/NodeFilter.java new file mode 100644 index 00000000000..8901059ee14 --- /dev/null +++ b/libjava/org/w3c/dom/traversal/NodeFilter.java @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2000 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + */ + +package org.w3c.dom.traversal; + +import org.w3c.dom.Node; + +/** + * Filters are objects that know how to "filter out" nodes. If a + * NodeIterator or TreeWalker is given a + * NodeFilter, it applies the filter before it returns the next + * node. If the filter says to accept the node, the traversal logic returns + * it; otherwise, traversal looks for the next node and pretends that the + * node that was rejected was not there. + *

The DOM does not provide any filters. NodeFilter is just an + * interface that users can implement to provide their own filters. + *

NodeFilters do not need to know how to traverse from node + * to node, nor do they need to know anything about the data structure that + * is being traversed. This makes it very easy to write filters, since the + * only thing they have to know how to do is evaluate a single node. One + * filter may be used with a number of different kinds of traversals, + * encouraging code reuse. + *

See also the Document Object Model (DOM) Level 2 Traversal and Range Specification. + * @since DOM Level 2 + */ +public interface NodeFilter { + // Constants returned by acceptNode + /** + * Accept the node. Navigation methods defined for + * NodeIterator or TreeWalker will return this + * node. + */ + public static final short FILTER_ACCEPT = 1; + /** + * Reject the node. Navigation methods defined for + * NodeIterator or TreeWalker will not return + * this node. For TreeWalker, the children of this node + * will also be rejected. NodeIterators treat this as a + * synonym for FILTER_SKIP. + */ + public static final short FILTER_REJECT = 2; + /** + * Skip this single node. Navigation methods defined for + * NodeIterator or TreeWalker will not return + * this node. For both NodeIterator and + * TreeWalker, the children of this node will still be + * considered. + */ + public static final short FILTER_SKIP = 3; + + // Constants for whatToShow + /** + * Show all Nodes. + */ + public static final int SHOW_ALL = 0xFFFFFFFF; + /** + * Show Element nodes. + */ + public static final int SHOW_ELEMENT = 0x00000001; + /** + * Show Attr nodes. This is meaningful only when creating an + * iterator or tree-walker with an attribute node as its + * root; in this case, it means that the attribute node + * will appear in the first position of the iteration or traversal. + * Since attributes are never children of other nodes, they do not + * appear when traversing over the document tree. + */ + public static final int SHOW_ATTRIBUTE = 0x00000002; + /** + * Show Text nodes. + */ + public static final int SHOW_TEXT = 0x00000004; + /** + * Show CDATASection nodes. + */ + public static final int SHOW_CDATA_SECTION = 0x00000008; + /** + * Show EntityReference nodes. + */ + public static final int SHOW_ENTITY_REFERENCE = 0x00000010; + /** + * Show Entity nodes. This is meaningful only when creating + * an iterator or tree-walker with an Entity node as its + * root; in this case, it means that the Entity + * node will appear in the first position of the traversal. Since + * entities are not part of the document tree, they do not appear when + * traversing over the document tree. + */ + public static final int SHOW_ENTITY = 0x00000020; + /** + * Show ProcessingInstruction nodes. + */ + public static final int SHOW_PROCESSING_INSTRUCTION = 0x00000040; + /** + * Show Comment nodes. + */ + public static final int SHOW_COMMENT = 0x00000080; + /** + * Show Document nodes. + */ + public static final int SHOW_DOCUMENT = 0x00000100; + /** + * Show DocumentType nodes. + */ + public static final int SHOW_DOCUMENT_TYPE = 0x00000200; + /** + * Show DocumentFragment nodes. + */ + public static final int SHOW_DOCUMENT_FRAGMENT = 0x00000400; + /** + * Show Notation nodes. This is meaningful only when creating + * an iterator or tree-walker with a Notation node as its + * root; in this case, it means that the + * Notation node will appear in the first position of the + * traversal. Since notations are not part of the document tree, they do + * not appear when traversing over the document tree. + */ + public static final int SHOW_NOTATION = 0x00000800; + + /** + * Test whether a specified node is visible in the logical view of a + * TreeWalker or NodeIterator. This function + * will be called by the implementation of TreeWalker and + * NodeIterator; it is not normally called directly from + * user code. (Though you could do so if you wanted to use the same + * filter to guide your own application logic.) + * @param nThe node to check to see if it passes the filter or not. + * @return a constant to determine whether the node is accepted, + * rejected, or skipped, as defined above. + */ + public short acceptNode(Node n); + +} diff --git a/libjava/org/w3c/dom/traversal/NodeIterator.java b/libjava/org/w3c/dom/traversal/NodeIterator.java new file mode 100644 index 00000000000..3563e80a8dd --- /dev/null +++ b/libjava/org/w3c/dom/traversal/NodeIterator.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2000 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + */ + +package org.w3c.dom.traversal; + +import org.w3c.dom.Node; +import org.w3c.dom.DOMException; + +/** + * Iterators are used to step through a set of nodes, e.g. the + * set of nodes in a NodeList, the document subtree governed by + * a particular Node, the results of a query, or any other set + * of nodes. The set of nodes to be iterated is determined by the + * implementation of the NodeIterator. DOM Level 2 specifies a + * single NodeIterator implementation for document-order + * traversal of a document subtree. Instances of these iterators are created + * by calling DocumentTraversal + * .createNodeIterator(). + *

See also the Document Object Model (DOM) Level 2 Traversal and Range Specification. + * @since DOM Level 2 + */ +public interface NodeIterator { + /** + * The root node of the NodeIterator, as specified when it + * was created. + */ + public Node getRoot(); + + /** + * This attribute determines which node types are presented via the + * iterator. The available set of constants is defined in the + * NodeFilter interface. Nodes not accepted by + * whatToShow will be skipped, but their children may still + * be considered. Note that this skip takes precedence over the filter, + * if any. + */ + public int getWhatToShow(); + + /** + * The NodeFilter used to screen nodes. + */ + public NodeFilter getFilter(); + + /** + * The value of this flag determines whether the children of entity + * reference nodes are visible to the iterator. If false, they and + * their descendants will be rejected. Note that this rejection takes + * precedence over whatToShow and the filter. Also note + * that this is currently the only situation where + * NodeIterators may reject a complete subtree rather than + * skipping individual nodes. + *
+ *
To produce a view of the document that has entity references + * expanded and does not expose the entity reference node itself, use + * the whatToShow flags to hide the entity reference node + * and set expandEntityReferences to true when creating the + * iterator. To produce a view of the document that has entity reference + * nodes but no entity expansion, use the whatToShow flags + * to show the entity reference node and set + * expandEntityReferences to false. + */ + public boolean getExpandEntityReferences(); + + /** + * Returns the next node in the set and advances the position of the + * iterator in the set. After a NodeIterator is created, + * the first call to nextNode() returns the first node in + * the set. + * @return The next Node in the set being iterated over, or + * null if there are no more members in that set. + * @exception DOMException + * INVALID_STATE_ERR: Raised if this method is called after the + * detach method was invoked. + */ + public Node nextNode() + throws DOMException; + + /** + * Returns the previous node in the set and moves the position of the + * NodeIterator backwards in the set. + * @return The previous Node in the set being iterated over, + * or null if there are no more members in that set. + * @exception DOMException + * INVALID_STATE_ERR: Raised if this method is called after the + * detach method was invoked. + */ + public Node previousNode() + throws DOMException; + + /** + * Detaches the NodeIterator from the set which it iterated + * over, releasing any computational resources and placing the iterator + * in the INVALID state. After detach has been invoked, + * calls to nextNode or previousNode will + * raise the exception INVALID_STATE_ERR. + */ + public void detach(); + +} diff --git a/libjava/org/w3c/dom/traversal/TreeWalker.java b/libjava/org/w3c/dom/traversal/TreeWalker.java new file mode 100644 index 00000000000..ed0292980a2 --- /dev/null +++ b/libjava/org/w3c/dom/traversal/TreeWalker.java @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2000 World Wide Web Consortium, + * (Massachusetts Institute of Technology, Institut National de + * Recherche en Informatique et en Automatique, Keio University). All + * Rights Reserved. This program is distributed under the W3C's Software + * Intellectual Property License. This program is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY; without even + * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. + * See W3C License http://www.w3.org/Consortium/Legal/ for more details. + */ + +package org.w3c.dom.traversal; + +import org.w3c.dom.Node; +import org.w3c.dom.DOMException; + +/** + * TreeWalker objects are used to navigate a document tree or + * subtree using the view of the document defined by their + * whatToShow flags and filter (if any). Any function which + * performs navigation using a TreeWalker will automatically + * support any view defined by a TreeWalker. + *

Omitting nodes from the logical view of a subtree can result in a + * structure that is substantially different from the same subtree in the + * complete, unfiltered document. Nodes that are siblings in the + * TreeWalker view may be children of different, widely + * separated nodes in the original view. For instance, consider a + * NodeFilter that skips all nodes except for Text nodes and + * the root node of a document. In the logical view that results, all text + * nodes will be siblings and appear as direct children of the root node, no + * matter how deeply nested the structure of the original document. + *

See also the Document Object Model (DOM) Level 2 Traversal and Range Specification. + * @since DOM Level 2 + */ +public interface TreeWalker { + /** + * The root node of the TreeWalker, as specified + * when it was created. + */ + public Node getRoot(); + + /** + * This attribute determines which node types are presented via the + * TreeWalker. The available set of constants is defined in + * the NodeFilter interface. Nodes not accepted by + * whatToShow will be skipped, but their children may still + * be considered. Note that this skip takes precedence over the filter, + * if any. + */ + public int getWhatToShow(); + + /** + * The filter used to screen nodes. + */ + public NodeFilter getFilter(); + + /** + * The value of this flag determines whether the children of entity + * reference nodes are visible to the TreeWalker. If false, + * they and their descendants will be rejected. Note that this + * rejection takes precedence over whatToShow and the + * filter, if any. + *
To produce a view of the document that has entity references + * expanded and does not expose the entity reference node itself, use + * the whatToShow flags to hide the entity reference node + * and set expandEntityReferences to true when creating the + * TreeWalker. To produce a view of the document that has + * entity reference nodes but no entity expansion, use the + * whatToShow flags to show the entity reference node and + * set expandEntityReferences to false. + */ + public boolean getExpandEntityReferences(); + + /** + * The node at which the TreeWalker is currently positioned. + *
Alterations to the DOM tree may cause the current node to no longer + * be accepted by the TreeWalker's associated filter. + * currentNode may also be explicitly set to any node, + * whether or not it is within the subtree specified by the + * root node or would be accepted by the filter and + * whatToShow flags. Further traversal occurs relative to + * currentNode even if it is not part of the current view, + * by applying the filters in the requested direction; if no traversal + * is possible, currentNode is not changed. + * @exception DOMException + * NOT_SUPPORTED_ERR: Raised if an attempt is made to set + * currentNode to null. + */ + public Node getCurrentNode(); + public void setCurrentNode(Node currentNode) + throws DOMException; + + /** + * Moves to and returns the closest visible ancestor node of the current + * node. If the search for parentNode attempts to step + * upward from the TreeWalker's root node, or + * if it fails to find a visible ancestor node, this method retains the + * current position and returns null. + * @return The new parent node, or null if the current node + * has no parent in the TreeWalker's logical view. + */ + public Node parentNode(); + + /** + * Moves the TreeWalker to the first visible child of the + * current node, and returns the new node. If the current node has no + * visible children, returns null, and retains the current + * node. + * @return The new node, or null if the current node has no + * visible children in the TreeWalker's logical view. + */ + public Node firstChild(); + + /** + * Moves the TreeWalker to the last visible child of the + * current node, and returns the new node. If the current node has no + * visible children, returns null, and retains the current + * node. + * @return The new node, or null if the current node has no + * children in the TreeWalker's logical view. + */ + public Node lastChild(); + + /** + * Moves the TreeWalker to the previous sibling of the + * current node, and returns the new node. If the current node has no + * visible previous sibling, returns null, and retains the + * current node. + * @return The new node, or null if the current node has no + * previous sibling. in the TreeWalker's logical view. + */ + public Node previousSibling(); + + /** + * Moves the TreeWalker to the next sibling of the current + * node, and returns the new node. If the current node has no visible + * next sibling, returns null, and retains the current node. + * @return The new node, or null if the current node has no + * next sibling. in the TreeWalker's logical view. + */ + public Node nextSibling(); + + /** + * Moves the TreeWalker to the previous visible node in + * document order relative to the current node, and returns the new + * node. If the current node has no previous node, or if the search for + * previousNode attempts to step upward from the + * TreeWalker's root node, returns + * null, and retains the current node. + * @return The new node, or null if the current node has no + * previous node in the TreeWalker's logical view. + */ + public Node previousNode(); + + /** + * Moves the TreeWalker to the next visible node in document + * order relative to the current node, and returns the new node. If the + * current node has no next node, or if the search for nextNode attempts + * to step upward from the TreeWalker's root + * node, returns null, and retains the current node. + * @return The new node, or null if the current node has no + * next node in the TreeWalker's logical view. + */ + public Node nextNode(); + +} diff --git a/libjava/org/xml/sax/AttributeList.java b/libjava/org/xml/sax/AttributeList.java new file mode 100644 index 00000000000..9ea9295e191 --- /dev/null +++ b/libjava/org/xml/sax/AttributeList.java @@ -0,0 +1,191 @@ +// SAX Attribute List Interface. +// No warranty; no copyright -- use this as you will. +// $Id: AttributeList.java,v 1.1 2000/10/02 02:43:16 sboag Exp $ + +package org.xml.sax; + +/** + * Interface for an element's attribute specifications. + * + *

+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

This is the original SAX1 interface for reporting an element's + * attributes. Unlike the new {@link org.xml.sax.Attributes Attributes} + * interface, it does not support Namespace-related information.

+ * + *

When an attribute list is supplied as part of a + * {@link org.xml.sax.DocumentHandler#startElement startElement} + * event, the list will return valid results only during the + * scope of the event; once the event handler returns control + * to the parser, the attribute list is invalid. To save a + * persistent copy of the attribute list, use the SAX1 + * {@link org.xml.sax.helpers.AttributeListImpl AttributeListImpl} + * helper class.

+ * + *

An attribute list includes only attributes that have been + * specified or defaulted: #IMPLIED attributes will not be included.

+ * + *

There are two ways for the SAX application to obtain information + * from the AttributeList. First, it can iterate through the entire + * list:

+ * + *
+ * public void startElement (String name, AttributeList atts) {
+ *   for (int i = 0; i < atts.getLength(); i++) {
+ *     String name = atts.getName(i);
+ *     String type = atts.getType(i);
+ *     String value = atts.getValue(i);
+ *     [...]
+ *   }
+ * }
+ * 
+ * + *

(Note that the result of getLength() will be zero if there + * are no attributes.) + * + *

As an alternative, the application can request the value or + * type of specific attributes:

+ * + *
+ * public void startElement (String name, AttributeList atts) {
+ *   String identifier = atts.getValue("id");
+ *   String label = atts.getValue("label");
+ *   [...]
+ * }
+ * 
+ * + * @deprecated This interface has been replaced by the SAX2 + * {@link org.xml.sax.Attributes Attributes} + * interface, which includes Namespace support. + * @since SAX 1.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + * @see org.xml.sax.DocumentHandler#startElement startElement + * @see org.xml.sax.helpers.AttributeListImpl AttributeListImpl + */ +public interface AttributeList { + + + //////////////////////////////////////////////////////////////////// + // Iteration methods. + //////////////////////////////////////////////////////////////////// + + + /** + * Return the number of attributes in this list. + * + *

The SAX parser may provide attributes in any + * arbitrary order, regardless of the order in which they were + * declared or specified. The number of attributes may be + * zero.

+ * + * @return The number of attributes in the list. + */ + public abstract int getLength (); + + + /** + * Return the name of an attribute in this list (by position). + * + *

The names must be unique: the SAX parser shall not include the + * same attribute twice. Attributes without values (those declared + * #IMPLIED without a value specified in the start tag) will be + * omitted from the list.

+ * + *

If the attribute name has a namespace prefix, the prefix + * will still be attached.

+ * + * @param i The index of the attribute in the list (starting at 0). + * @return The name of the indexed attribute, or null + * if the index is out of range. + * @see #getLength + */ + public abstract String getName (int i); + + + /** + * Return the type of an attribute in the list (by position). + * + *

The attribute type is one of the strings "CDATA", "ID", + * "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES", + * or "NOTATION" (always in upper case).

+ * + *

If the parser has not read a declaration for the attribute, + * or if the parser does not report attribute types, then it must + * return the value "CDATA" as stated in the XML 1.0 Recommentation + * (clause 3.3.3, "Attribute-Value Normalization").

+ * + *

For an enumerated attribute that is not a notation, the + * parser will report the type as "NMTOKEN".

+ * + * @param i The index of the attribute in the list (starting at 0). + * @return The attribute type as a string, or + * null if the index is out of range. + * @see #getLength + * @see #getType(java.lang.String) + */ + public abstract String getType (int i); + + + /** + * Return the value of an attribute in the list (by position). + * + *

If the attribute value is a list of tokens (IDREFS, + * ENTITIES, or NMTOKENS), the tokens will be concatenated + * into a single string separated by whitespace.

+ * + * @param i The index of the attribute in the list (starting at 0). + * @return The attribute value as a string, or + * null if the index is out of range. + * @see #getLength + * @see #getValue(java.lang.String) + */ + public abstract String getValue (int i); + + + + //////////////////////////////////////////////////////////////////// + // Lookup methods. + //////////////////////////////////////////////////////////////////// + + + /** + * Return the type of an attribute in the list (by name). + * + *

The return value is the same as the return value for + * getType(int).

+ * + *

If the attribute name has a namespace prefix in the document, + * the application must include the prefix here.

+ * + * @param name The name of the attribute. + * @return The attribute type as a string, or null if no + * such attribute exists. + * @see #getType(int) + */ + public abstract String getType (String name); + + + /** + * Return the value of an attribute in the list (by name). + * + *

The return value is the same as the return value for + * getValue(int).

+ * + *

If the attribute name has a namespace prefix in the document, + * the application must include the prefix here.

+ * + * @param i The index of the attribute in the list. + * @return The attribute value as a string, or null if + * no such attribute exists. + * @see #getValue(int) + */ + public abstract String getValue (String name); + +} + +// end of AttributeList.java diff --git a/libjava/org/xml/sax/Attributes.java b/libjava/org/xml/sax/Attributes.java new file mode 100644 index 00000000000..f10067a9288 --- /dev/null +++ b/libjava/org/xml/sax/Attributes.java @@ -0,0 +1,243 @@ +// Attributes.java - attribute list with Namespace support +// Written by David Megginson, sax@megginson.com +// NO WARRANTY! This class is in the public domain. + +// $Id: Attributes.java,v 1.1 2000/10/02 02:43:16 sboag Exp $ + + +package org.xml.sax; + + +/** + * Interface for a list of XML attributes. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

This interface allows access to a list of attributes in + * three different ways:

+ * + *
    + *
  1. by attribute index;
  2. + *
  3. by Namespace-qualified name; or
  4. + *
  5. by qualified (prefixed) name.
  6. + *
+ * + *

The list will not contain attributes that were declared + * #IMPLIED but not specified in the start tag. It will also not + * contain attributes used as Namespace declarations (xmlns*) unless + * the http://xml.org/sax/features/namespace-prefixes + * feature is set to true (it is false by + * default).

+ * + *

If the namespace-prefixes feature (see above) is false, + * access by qualified name may not be available; if the + * http://xml.org/sax/features/namespaces + * feature is false, access by Namespace-qualified names + * may not be available.

+ * + *

This interface replaces the now-deprecated SAX1 {@link + * org.xml.sax.AttributeList AttributeList} interface, which does not + * contain Namespace support. In addition to Namespace support, it + * adds the getIndex methods (below).

+ * + *

The order of attributes in the list is unspecified, and will + * vary from implementation to implementation.

+ * + * @since SAX 2.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + * @see org.xml.sax.helpers.AttributeListImpl + */ +public interface Attributes +{ + + + //////////////////////////////////////////////////////////////////// + // Indexed access. + //////////////////////////////////////////////////////////////////// + + + /** + * Return the number of attributes in the list. + * + *

Once you know the number of attributes, you can iterate + * through the list.

+ * + * @return The number of attributes in the list. + * @see #getURI(int) + * @see #getLocalName(int) + * @see #getQName(int) + * @see #getType(int) + * @see #getValue(int) + */ + public abstract int getLength (); + + + /** + * Look up an attribute's Namespace URI by index. + * + * @param index The attribute index (zero-based). + * @return The Namespace URI, or the empty string if none + * is available, or null if the index is out of + * range. + * @see #getLength + */ + public abstract String getURI (int index); + + + /** + * Look up an attribute's local name by index. + * + * @param index The attribute index (zero-based). + * @return The local name, or the empty string if Namespace + * processing is not being performed, or null + * if the index is out of range. + * @see #getLength + */ + public abstract String getLocalName (int index); + + + /** + * Look up an attribute's XML 1.0 qualified name by index. + * + * @param index The attribute index (zero-based). + * @return The XML 1.0 qualified name, or the empty string + * if none is available, or null if the index + * is out of range. + * @see #getLength + */ + public abstract String getQName (int index); + + + /** + * Look up an attribute's type by index. + * + *

The attribute type is one of the strings "CDATA", "ID", + * "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", "ENTITIES", + * or "NOTATION" (always in upper case).

+ * + *

If the parser has not read a declaration for the attribute, + * or if the parser does not report attribute types, then it must + * return the value "CDATA" as stated in the XML 1.0 Recommentation + * (clause 3.3.3, "Attribute-Value Normalization").

+ * + *

For an enumerated attribute that is not a notation, the + * parser will report the type as "NMTOKEN".

+ * + * @param index The attribute index (zero-based). + * @return The attribute's type as a string, or null if the + * index is out of range. + * @see #getLength + */ + public abstract String getType (int index); + + + /** + * Look up an attribute's value by index. + * + *

If the attribute value is a list of tokens (IDREFS, + * ENTITIES, or NMTOKENS), the tokens will be concatenated + * into a single string with each token separated by a + * single space.

+ * + * @param index The attribute index (zero-based). + * @return The attribute's value as a string, or null if the + * index is out of range. + * @see #getLength + */ + public abstract String getValue (int index); + + + + //////////////////////////////////////////////////////////////////// + // Name-based query. + //////////////////////////////////////////////////////////////////// + + + /** + * Look up the index of an attribute by Namespace name. + * + * @param uri The Namespace URI, or the empty string if + * the name has no Namespace URI. + * @param localName The attribute's local name. + * @return The index of the attribute, or -1 if it does not + * appear in the list. + */ + public int getIndex (String uri, String localPart); + + + /** + * Look up the index of an attribute by XML 1.0 qualified name. + * + * @param qName The qualified (prefixed) name. + * @return The index of the attribute, or -1 if it does not + * appear in the list. + */ + public int getIndex (String qName); + + + /** + * Look up an attribute's type by Namespace name. + * + *

See {@link #getType(int) getType(int)} for a description + * of the possible types.

+ * + * @param uri The Namespace URI, or the empty String if the + * name has no Namespace URI. + * @param localName The local name of the attribute. + * @return The attribute type as a string, or null if the + * attribute is not in the list or if Namespace + * processing is not being performed. + */ + public abstract String getType (String uri, String localName); + + + /** + * Look up an attribute's type by XML 1.0 qualified name. + * + *

See {@link #getType(int) getType(int)} for a description + * of the possible types.

+ * + * @param qName The XML 1.0 qualified name. + * @return The attribute type as a string, or null if the + * attribute is not in the list or if qualified names + * are not available. + */ + public abstract String getType (String qName); + + + /** + * Look up an attribute's value by Namespace name. + * + *

See {@link #getValue(int) getValue(int)} for a description + * of the possible values.

+ * + * @param uri The Namespace URI, or the empty String if the + * name has no Namespace URI. + * @param localName The local name of the attribute. + * @return The attribute value as a string, or null if the + * attribute is not in the list. + */ + public abstract String getValue (String uri, String localName); + + + /** + * Look up an attribute's value by XML 1.0 qualified name. + * + *

See {@link #getValue(int) getValue(int)} for a description + * of the possible values.

+ * + * @param qName The XML 1.0 qualified name. + * @return The attribute value as a string, or null if the + * attribute is not in the list or if qualified names + * are not available. + */ + public abstract String getValue (String qName); + +} + +// end of Attributes.java diff --git a/libjava/org/xml/sax/ContentHandler.java b/libjava/org/xml/sax/ContentHandler.java new file mode 100644 index 00000000000..0d84d0eae99 --- /dev/null +++ b/libjava/org/xml/sax/ContentHandler.java @@ -0,0 +1,374 @@ +// ContentHandler.java - handle main document content. +// Written by David Megginson, sax@megginson.com +// NO WARRANTY! This class is in the public domain. + +// $Id: ContentHandler.java,v 1.1 2000/10/02 02:43:16 sboag Exp $ + +package org.xml.sax; + + +/** + * Receive notification of the logical content of a document. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

This is the main interface that most SAX applications + * implement: if the application needs to be informed of basic parsing + * events, it implements this interface and registers an instance with + * the SAX parser using the {@link org.xml.sax.XMLReader#setContentHandler + * setContentHandler} method. The parser uses the instance to report + * basic document-related events like the start and end of elements + * and character data.

+ * + *

The order of events in this interface is very important, and + * mirrors the order of information in the document itself. For + * example, all of an element's content (character data, processing + * instructions, and/or subelements) will appear, in order, between + * the startElement event and the corresponding endElement event.

+ * + *

This interface is similar to the now-deprecated SAX 1.0 + * DocumentHandler interface, but it adds support for Namespaces + * and for reporting skipped entities (in non-validating XML + * processors).

+ * + *

Implementors should note that there is also a Java class + * {@link java.net.ContentHandler ContentHandler} in the java.net + * package; that means that it's probably a bad idea to do

+ * + *
+ * import java.net.*; + * import org.xml.sax.*; + *
+ * + *

In fact, "import ...*" is usually a sign of sloppy programming + * anyway, so the user should consider this a feature rather than a + * bug.

+ * + * @since SAX 2.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + * @see org.xml.sax.XMLReader + * @see org.xml.sax.DTDHandler + * @see org.xml.sax.ErrorHandler + */ +public interface ContentHandler +{ + + /** + * Receive an object for locating the origin of SAX document events. + * + *

SAX parsers are strongly encouraged (though not absolutely + * required) to supply a locator: if it does so, it must supply + * the locator to the application by invoking this method before + * invoking any of the other methods in the ContentHandler + * interface.

+ * + *

The locator allows the application to determine the end + * position of any document-related event, even if the parser is + * not reporting an error. Typically, the application will + * use this information for reporting its own errors (such as + * character content that does not match an application's + * business rules). The information returned by the locator + * is probably not sufficient for use with a search engine.

+ * + *

Note that the locator will return correct information only + * during the invocation of the events in this interface. The + * application should not attempt to use it at any other time.

+ * + * @param locator An object that can return the location of + * any SAX document event. + * @see org.xml.sax.Locator + */ + public void setDocumentLocator (Locator locator); + + + /** + * Receive notification of the beginning of a document. + * + *

The SAX parser will invoke this method only once, before any + * other methods in this interface or in {@link org.xml.sax.DTDHandler + * DTDHandler} (except for {@link #setDocumentLocator + * setDocumentLocator}).

+ * + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see #endDocument + */ + public void startDocument () + throws SAXException; + + + /** + * Receive notification of the end of a document. + * + *

The SAX parser will invoke this method only once, and it will + * be the last method invoked during the parse. The parser shall + * not invoke this method until it has either abandoned parsing + * (because of an unrecoverable error) or reached the end of + * input.

+ * + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see #startDocument + */ + public void endDocument() + throws SAXException; + + + /** + * Begin the scope of a prefix-URI Namespace mapping. + * + *

The information from this event is not necessary for + * normal Namespace processing: the SAX XML reader will + * automatically replace prefixes for element and attribute + * names when the http://xml.org/sax/features/namespaces + * feature is true (the default).

+ * + *

There are cases, however, when applications need to + * use prefixes in character data or in attribute values, + * where they cannot safely be expanded automatically; the + * start/endPrefixMapping event supplies the information + * to the application to expand prefixes in those contexts + * itself, if necessary.

+ * + *

Note that start/endPrefixMapping events are not + * guaranteed to be properly nested relative to each-other: + * all startPrefixMapping events will occur before the + * corresponding {@link #startElement startElement} event, + * and all {@link #endPrefixMapping endPrefixMapping} + * events will occur after the corresponding {@link #endElement + * endElement} event, but their order is not otherwise + * guaranteed.

+ * + *

There should never be start/endPrefixMapping events for the + * "xml" prefix, since it is predeclared and immutable.

+ * + * @param prefix The Namespace prefix being declared. + * @param uri The Namespace URI the prefix is mapped to. + * @exception org.xml.sax.SAXException The client may throw + * an exception during processing. + * @see #endPrefixMapping + * @see #startElement + */ + public void startPrefixMapping (String prefix, String uri) + throws SAXException; + + + /** + * End the scope of a prefix-URI mapping. + * + *

See {@link #startPrefixMapping startPrefixMapping} for + * details. This event will always occur after the corresponding + * {@link #endElement endElement} event, but the order of + * {@link #endPrefixMapping endPrefixMapping} events is not otherwise + * guaranteed.

+ * + * @param prefix The prefix that was being mapping. + * @exception org.xml.sax.SAXException The client may throw + * an exception during processing. + * @see #startPrefixMapping + * @see #endElement + */ + public void endPrefixMapping (String prefix) + throws SAXException; + + + /** + * Receive notification of the beginning of an element. + * + *

The Parser will invoke this method at the beginning of every + * element in the XML document; there will be a corresponding + * {@link #endElement endElement} event for every startElement event + * (even when the element is empty). All of the element's content will be + * reported, in order, before the corresponding endElement + * event.

+ * + *

This event allows up to three name components for each + * element:

+ * + *
    + *
  1. the Namespace URI;
  2. + *
  3. the local name; and
  4. + *
  5. the qualified (prefixed) name.
  6. + *
+ * + *

Any or all of these may be provided, depending on the + * values of the http://xml.org/sax/features/namespaces + * and the http://xml.org/sax/features/namespace-prefixes + * properties:

+ * + *
    + *
  • the Namespace URI and local name are required when + * the namespaces property is true (the default), and are + * optional when the namespaces property is false (if one is + * specified, both must be);
  • + *
  • the qualified name is required when the namespace-prefixes property + * is true, and is optional when the namespace-prefixes property + * is false (the default).
  • + *
+ * + *

Note that the attribute list provided will contain only + * attributes with explicit values (specified or defaulted): + * #IMPLIED attributes will be omitted. The attribute list + * will contain attributes used for Namespace declarations + * (xmlns* attributes) only if the + * http://xml.org/sax/features/namespace-prefixes + * property is true (it is false by default, and support for a + * true value is optional).

+ * + * @param uri The Namespace URI, or the empty string if the + * element has no Namespace URI or if Namespace + * processing is not being performed. + * @param localName The local name (without prefix), or the + * empty string if Namespace processing is not being + * performed. + * @param qName The qualified name (with prefix), or the + * empty string if qualified names are not available. + * @param atts The attributes attached to the element. If + * there are no attributes, it shall be an empty + * Attributes object. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see #endElement + * @see org.xml.sax.Attributes + */ + public void startElement (String namespaceURI, String localName, + String qName, Attributes atts) + throws SAXException; + + + /** + * Receive notification of the end of an element. + * + *

The SAX parser will invoke this method at the end of every + * element in the XML document; there will be a corresponding + * {@link #startElement startElement} event for every endElement + * event (even when the element is empty).

+ * + *

For information on the names, see startElement.

+ * + * @param uri The Namespace URI, or the empty string if the + * element has no Namespace URI or if Namespace + * processing is not being performed. + * @param localName The local name (without prefix), or the + * empty string if Namespace processing is not being + * performed. + * @param qName The qualified XML 1.0 name (with prefix), or the + * empty string if qualified names are not available. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + */ + public void endElement (String namespaceURI, String localName, + String qName) + throws SAXException; + + + /** + * Receive notification of character data. + * + *

The Parser will call this method to report each chunk of + * character data. SAX parsers may return all contiguous character + * data in a single chunk, or they may split it into several + * chunks; however, all of the characters in any single event + * must come from the same external entity so that the Locator + * provides useful information.

+ * + *

The application must not attempt to read from the array + * outside of the specified range.

+ * + *

Note that some parsers will report whitespace in element + * content using the {@link #ignorableWhitespace ignorableWhitespace} + * method rather than this one (validating parsers must + * do so).

+ * + * @param ch The characters from the XML document. + * @param start The start position in the array. + * @param length The number of characters to read from the array. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see #ignorableWhitespace + * @see org.xml.sax.Locator + */ + public void characters (char ch[], int start, int length) + throws SAXException; + + + /** + * Receive notification of ignorable whitespace in element content. + * + *

Validating Parsers must use this method to report each chunk + * of whitespace in element content (see the W3C XML 1.0 recommendation, + * section 2.10): non-validating parsers may also use this method + * if they are capable of parsing and using content models.

+ * + *

SAX parsers may return all contiguous whitespace in a single + * chunk, or they may split it into several chunks; however, all of + * the characters in any single event must come from the same + * external entity, so that the Locator provides useful + * information.

+ * + *

The application must not attempt to read from the array + * outside of the specified range.

+ * + * @param ch The characters from the XML document. + * @param start The start position in the array. + * @param length The number of characters to read from the array. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see #characters + */ + public void ignorableWhitespace (char ch[], int start, int length) + throws SAXException; + + + /** + * Receive notification of a processing instruction. + * + *

The Parser will invoke this method once for each processing + * instruction found: note that processing instructions may occur + * before or after the main document element.

+ * + *

A SAX parser must never report an XML declaration (XML 1.0, + * section 2.8) or a text declaration (XML 1.0, section 4.3.1) + * using this method.

+ * + * @param target The processing instruction target. + * @param data The processing instruction data, or null if + * none was supplied. The data does not include any + * whitespace separating it from the target. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + */ + public void processingInstruction (String target, String data) + throws SAXException; + + + /** + * Receive notification of a skipped entity. + * + *

The Parser will invoke this method once for each entity + * skipped. Non-validating processors may skip entities if they + * have not seen the declarations (because, for example, the + * entity was declared in an external DTD subset). All processors + * may skip external entities, depending on the values of the + * http://xml.org/sax/features/external-general-entities + * and the + * http://xml.org/sax/features/external-parameter-entities + * properties.

+ * + * @param name The name of the skipped entity. If it is a + * parameter entity, the name will begin with '%', and if + * it is the external DTD subset, it will be the string + * "[dtd]". + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + */ + public void skippedEntity (String name) + throws SAXException; +} + +// end of ContentHandler.java diff --git a/libjava/org/xml/sax/DTDHandler.java b/libjava/org/xml/sax/DTDHandler.java new file mode 100644 index 00000000000..509a0069ba8 --- /dev/null +++ b/libjava/org/xml/sax/DTDHandler.java @@ -0,0 +1,108 @@ +// SAX DTD handler. +// No warranty; no copyright -- use this as you will. +// $Id: DTDHandler.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ + +package org.xml.sax; + +/** + * Receive notification of basic DTD-related events. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

If a SAX application needs information about notations and + * unparsed entities, then the application implements this + * interface and registers an instance with the SAX parser using + * the parser's setDTDHandler method. The parser uses the + * instance to report notation and unparsed entity declarations to + * the application.

+ * + *

Note that this interface includes only those DTD events that + * the XML recommendation requires processors to report: + * notation and unparsed entity declarations.

+ * + *

The SAX parser may report these events in any order, regardless + * of the order in which the notations and unparsed entities were + * declared; however, all DTD events must be reported after the + * document handler's startDocument event, and before the first + * startElement event.

+ * + *

It is up to the application to store the information for + * future use (perhaps in a hash table or object tree). + * If the application encounters attributes of type "NOTATION", + * "ENTITY", or "ENTITIES", it can use the information that it + * obtained through this interface to find the entity and/or + * notation corresponding with the attribute value.

+ * + * @since SAX 1.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + * @see org.xml.sax.Parser#setDTDHandler + * @see org.xml.sax.HandlerBase + */ +public interface DTDHandler { + + + /** + * Receive notification of a notation declaration event. + * + *

It is up to the application to record the notation for later + * reference, if necessary.

+ * + *

At least one of publicId and systemId must be non-null. + * If a system identifier is present, and it is a URL, the SAX + * parser must resolve it fully before passing it to the + * application through this event.

+ * + *

There is no guarantee that the notation declaration will be + * reported before any unparsed entities that use it.

+ * + * @param name The notation name. + * @param publicId The notation's public identifier, or null if + * none was given. + * @param systemId The notation's system identifier, or null if + * none was given. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see #unparsedEntityDecl + * @see org.xml.sax.AttributeList + */ + public abstract void notationDecl (String name, + String publicId, + String systemId) + throws SAXException; + + + /** + * Receive notification of an unparsed entity declaration event. + * + *

Note that the notation name corresponds to a notation + * reported by the {@link #notationDecl notationDecl} event. + * It is up to the application to record the entity for later + * reference, if necessary.

+ * + *

If the system identifier is a URL, the parser must resolve it + * fully before passing it to the application.

+ * + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @param name The unparsed entity's name. + * @param publicId The entity's public identifier, or null if none + * was given. + * @param systemId The entity's system identifier. + * @param notation name The name of the associated notation. + * @see #notationDecl + * @see org.xml.sax.AttributeList + */ + public abstract void unparsedEntityDecl (String name, + String publicId, + String systemId, + String notationName) + throws SAXException; + +} + +// end of DTDHandler.java diff --git a/libjava/org/xml/sax/DocumentHandler.java b/libjava/org/xml/sax/DocumentHandler.java new file mode 100644 index 00000000000..be0a189c45b --- /dev/null +++ b/libjava/org/xml/sax/DocumentHandler.java @@ -0,0 +1,230 @@ +// SAX document handler. +// No warranty; no copyright -- use this as you will. +// $Id: DocumentHandler.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ + +package org.xml.sax; + +/** + * Receive notification of general document events. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

This was the main event-handling interface for SAX1; in + * SAX2, it has been replaced by {@link org.xml.sax.ContentHandler + * ContentHandler}, which provides Namespace support and reporting + * of skipped entities. This interface is included in SAX2 only + * to support legacy SAX1 applications.

+ * + *

The order of events in this interface is very important, and + * mirrors the order of information in the document itself. For + * example, all of an element's content (character data, processing + * instructions, and/or subelements) will appear, in order, between + * the startElement event and the corresponding endElement event.

+ * + *

Application writers who do not want to implement the entire + * interface can derive a class from HandlerBase, which implements + * the default functionality; parser writers can instantiate + * HandlerBase to obtain a default handler. The application can find + * the location of any document event using the Locator interface + * supplied by the Parser through the setDocumentLocator method.

+ * + * @deprecated This interface has been replaced by the SAX2 + * {@link org.xml.sax.ContentHandler ContentHandler} + * interface, which includes Namespace support. + * @since SAX 1.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + * @see org.xml.sax.Parser#setDocumentHandler + * @see org.xml.sax.Locator + * @see org.xml.sax.HandlerBase + */ +public interface DocumentHandler { + + + /** + * Receive an object for locating the origin of SAX document events. + * + *

SAX parsers are strongly encouraged (though not absolutely + * required) to supply a locator: if it does so, it must supply + * the locator to the application by invoking this method before + * invoking any of the other methods in the DocumentHandler + * interface.

+ * + *

The locator allows the application to determine the end + * position of any document-related event, even if the parser is + * not reporting an error. Typically, the application will + * use this information for reporting its own errors (such as + * character content that does not match an application's + * business rules). The information returned by the locator + * is probably not sufficient for use with a search engine.

+ * + *

Note that the locator will return correct information only + * during the invocation of the events in this interface. The + * application should not attempt to use it at any other time.

+ * + * @param locator An object that can return the location of + * any SAX document event. + * @see org.xml.sax.Locator + */ + public abstract void setDocumentLocator (Locator locator); + + + /** + * Receive notification of the beginning of a document. + * + *

The SAX parser will invoke this method only once, before any + * other methods in this interface or in DTDHandler (except for + * setDocumentLocator).

+ * + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + */ + public abstract void startDocument () + throws SAXException; + + + /** + * Receive notification of the end of a document. + * + *

The SAX parser will invoke this method only once, and it will + * be the last method invoked during the parse. The parser shall + * not invoke this method until it has either abandoned parsing + * (because of an unrecoverable error) or reached the end of + * input.

+ * + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + */ + public abstract void endDocument () + throws SAXException; + + + /** + * Receive notification of the beginning of an element. + * + *

The Parser will invoke this method at the beginning of every + * element in the XML document; there will be a corresponding + * endElement() event for every startElement() event (even when the + * element is empty). All of the element's content will be + * reported, in order, before the corresponding endElement() + * event.

+ * + *

If the element name has a namespace prefix, the prefix will + * still be attached. Note that the attribute list provided will + * contain only attributes with explicit values (specified or + * defaulted): #IMPLIED attributes will be omitted.

+ * + * @param name The element type name. + * @param atts The attributes attached to the element, if any. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see #endElement + * @see org.xml.sax.AttributeList + */ + public abstract void startElement (String name, AttributeList atts) + throws SAXException; + + + /** + * Receive notification of the end of an element. + * + *

The SAX parser will invoke this method at the end of every + * element in the XML document; there will be a corresponding + * startElement() event for every endElement() event (even when the + * element is empty).

+ * + *

If the element name has a namespace prefix, the prefix will + * still be attached to the name.

+ * + * @param name The element type name + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + */ + public abstract void endElement (String name) + throws SAXException; + + + /** + * Receive notification of character data. + * + *

The Parser will call this method to report each chunk of + * character data. SAX parsers may return all contiguous character + * data in a single chunk, or they may split it into several + * chunks; however, all of the characters in any single event + * must come from the same external entity, so that the Locator + * provides useful information.

+ * + *

The application must not attempt to read from the array + * outside of the specified range.

+ * + *

Note that some parsers will report whitespace using the + * ignorableWhitespace() method rather than this one (validating + * parsers must do so).

+ * + * @param ch The characters from the XML document. + * @param start The start position in the array. + * @param length The number of characters to read from the array. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see #ignorableWhitespace + * @see org.xml.sax.Locator + */ + public abstract void characters (char ch[], int start, int length) + throws SAXException; + + + /** + * Receive notification of ignorable whitespace in element content. + * + *

Validating Parsers must use this method to report each chunk + * of ignorable whitespace (see the W3C XML 1.0 recommendation, + * section 2.10): non-validating parsers may also use this method + * if they are capable of parsing and using content models.

+ * + *

SAX parsers may return all contiguous whitespace in a single + * chunk, or they may split it into several chunks; however, all of + * the characters in any single event must come from the same + * external entity, so that the Locator provides useful + * information.

+ * + *

The application must not attempt to read from the array + * outside of the specified range.

+ * + * @param ch The characters from the XML document. + * @param start The start position in the array. + * @param length The number of characters to read from the array. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see #characters + */ + public abstract void ignorableWhitespace (char ch[], int start, int length) + throws SAXException; + + + /** + * Receive notification of a processing instruction. + * + *

The Parser will invoke this method once for each processing + * instruction found: note that processing instructions may occur + * before or after the main document element.

+ * + *

A SAX parser should never report an XML declaration (XML 1.0, + * section 2.8) or a text declaration (XML 1.0, section 4.3.1) + * using this method.

+ * + * @param target The processing instruction target. + * @param data The processing instruction data, or null if + * none was supplied. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + */ + public abstract void processingInstruction (String target, String data) + throws SAXException; + +} + +// end of DocumentHandler.java diff --git a/libjava/org/xml/sax/EntityResolver.java b/libjava/org/xml/sax/EntityResolver.java new file mode 100644 index 00000000000..3270471453a --- /dev/null +++ b/libjava/org/xml/sax/EntityResolver.java @@ -0,0 +1,110 @@ +// SAX entity resolver. +// No warranty; no copyright -- use this as you will. +// $Id: EntityResolver.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ + +package org.xml.sax; + +import java.io.IOException; + + +/** + * Basic interface for resolving entities. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

If a SAX application needs to implement customized handling + * for external entities, it must implement this interface and + * register an instance with the SAX driver using the + * {@link org.xml.sax.XMLReader#setEntityResolver setEntityResolver} + * method.

+ * + *

The XML reader will then allow the application to intercept any + * external entities (including the external DTD subset and external + * parameter entities, if any) before including them.

+ * + *

Many SAX applications will not need to implement this interface, + * but it will be especially useful for applications that build + * XML documents from databases or other specialised input sources, + * or for applications that use URI types other than URLs.

+ * + *

The following resolver would provide the application + * with a special character stream for the entity with the system + * identifier "http://www.myhost.com/today":

+ * + *
+ * import org.xml.sax.EntityResolver;
+ * import org.xml.sax.InputSource;
+ *
+ * public class MyResolver implements EntityResolver {
+ *   public InputSource resolveEntity (String publicId, String systemId)
+ *   {
+ *     if (systemId.equals("http://www.myhost.com/today")) {
+ *              // return a special input source
+ *       MyReader reader = new MyReader();
+ *       return new InputSource(reader);
+ *     } else {
+ *              // use the default behaviour
+ *       return null;
+ *     }
+ *   }
+ * }
+ * 
+ * + *

The application can also use this interface to redirect system + * identifiers to local URIs or to look up replacements in a catalog + * (possibly by using the public identifier).

+ * + * @since SAX 1.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + * @see org.xml.sax.Parser#setEntityResolver + * @see org.xml.sax.InputSource + */ +public interface EntityResolver { + + + /** + * Allow the application to resolve external entities. + * + *

The Parser will call this method before opening any external + * entity except the top-level document entity (including the + * external DTD subset, external entities referenced within the + * DTD, and external entities referenced within the document + * element): the application may request that the parser resolve + * the entity itself, that it use an alternative URI, or that it + * use an entirely different input source.

+ * + *

Application writers can use this method to redirect external + * system identifiers to secure and/or local URIs, to look up + * public identifiers in a catalogue, or to read an entity from a + * database or other input source (including, for example, a dialog + * box).

+ * + *

If the system identifier is a URL, the SAX parser must + * resolve it fully before reporting it to the application.

+ * + * @param publicId The public identifier of the external entity + * being referenced, or null if none was supplied. + * @param systemId The system identifier of the external entity + * being referenced. + * @return An InputSource object describing the new input source, + * or null to request that the parser open a regular + * URI connection to the system identifier. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @exception java.io.IOException A Java-specific IO exception, + * possibly the result of creating a new InputStream + * or Reader for the InputSource. + * @see org.xml.sax.InputSource + */ + public abstract InputSource resolveEntity (String publicId, + String systemId) + throws SAXException, IOException; + +} + +// end of EntityResolver.java diff --git a/libjava/org/xml/sax/ErrorHandler.java b/libjava/org/xml/sax/ErrorHandler.java new file mode 100644 index 00000000000..8b3e090cd6d --- /dev/null +++ b/libjava/org/xml/sax/ErrorHandler.java @@ -0,0 +1,123 @@ +// SAX error handler. +// No warranty; no copyright -- use this as you will. +// $Id: ErrorHandler.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ + +package org.xml.sax; + + +/** + * Basic interface for SAX error handlers. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

If a SAX application needs to implement customized error + * handling, it must implement this interface and then register an + * instance with the XML reader using the + * {@link org.xml.sax.XMLReader#setErrorHandler setErrorHandler} + * method. The parser will then report all errors and warnings + * through this interface.

+ * + *

WARNING: If an application does not + * register an ErrorHandler, XML parsing errors will go unreported + * and bizarre behaviour may result.

+ * + *

For XML processing errors, a SAX driver must use this interface + * instead of throwing an exception: it is up to the application + * to decide whether to throw an exception for different types of + * errors and warnings. Note, however, that there is no requirement that + * the parser continue to provide useful information after a call to + * {@link #fatalError fatalError} (in other words, a SAX driver class + * could catch an exception and report a fatalError).

+ * + * @since SAX 1.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + * @see org.xml.sax.Parser#setErrorHandler + * @see org.xml.sax.SAXParseException + */ +public interface ErrorHandler { + + + /** + * Receive notification of a warning. + * + *

SAX parsers will use this method to report conditions that + * are not errors or fatal errors as defined by the XML 1.0 + * recommendation. The default behaviour is to take no action.

+ * + *

The SAX parser must continue to provide normal parsing events + * after invoking this method: it should still be possible for the + * application to process the document through to the end.

+ * + *

Filters may use this method to report other, non-XML warnings + * as well.

+ * + * @param exception The warning information encapsulated in a + * SAX parse exception. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.SAXParseException + */ + public abstract void warning (SAXParseException exception) + throws SAXException; + + + /** + * Receive notification of a recoverable error. + * + *

This corresponds to the definition of "error" in section 1.2 + * of the W3C XML 1.0 Recommendation. For example, a validating + * parser would use this callback to report the violation of a + * validity constraint. The default behaviour is to take no + * action.

+ * + *

The SAX parser must continue to provide normal parsing events + * after invoking this method: it should still be possible for the + * application to process the document through to the end. If the + * application cannot do so, then the parser should report a fatal + * error even if the XML 1.0 recommendation does not require it to + * do so.

+ * + *

Filters may use this method to report other, non-XML errors + * as well.

+ * + * @param exception The error information encapsulated in a + * SAX parse exception. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.SAXParseException + */ + public abstract void error (SAXParseException exception) + throws SAXException; + + + /** + * Receive notification of a non-recoverable error. + * + *

This corresponds to the definition of "fatal error" in + * section 1.2 of the W3C XML 1.0 Recommendation. For example, a + * parser would use this callback to report the violation of a + * well-formedness constraint.

+ * + *

The application must assume that the document is unusable + * after the parser has invoked this method, and should continue + * (if at all) only for the sake of collecting addition error + * messages: in fact, SAX parsers are free to stop reporting any + * other events once this method has been invoked.

+ * + * @param exception The error information encapsulated in a + * SAX parse exception. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.SAXParseException + */ + public abstract void fatalError (SAXParseException exception) + throws SAXException; + +} + +// end of ErrorHandler.java diff --git a/libjava/org/xml/sax/HandlerBase.java b/libjava/org/xml/sax/HandlerBase.java new file mode 100644 index 00000000000..297aced7aaa --- /dev/null +++ b/libjava/org/xml/sax/HandlerBase.java @@ -0,0 +1,368 @@ +// SAX default handler base class. +// No warranty; no copyright -- use this as you will. +// $Id: HandlerBase.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ + +package org.xml.sax; + +/** + * Default base class for handlers. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

This class implements the default behaviour for four SAX1 + * interfaces: EntityResolver, DTDHandler, DocumentHandler, + * and ErrorHandler. It is now obsolete, but is included in SAX2 to + * support legacy SAX1 applications. SAX2 applications should use + * the {@link org.xml.sax.helpers.DefaultHandler DefaultHandler} + * class instead.

+ * + *

Application writers can extend this class when they need to + * implement only part of an interface; parser writers can + * instantiate this class to provide default handlers when the + * application has not supplied its own.

+ * + *

Note that the use of this class is optional.

+ * + * @deprecated This class works with the deprecated + * {@link org.xml.sax.DocumentHandler DocumentHandler} + * interface. It has been replaced by the SAX2 + * {@link org.xml.sax.helpers.DefaultHandler DefaultHandler} + * class. + * @since SAX 1.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + * @see org.xml.sax.EntityResolver + * @see org.xml.sax.DTDHandler + * @see org.xml.sax.DocumentHandler + * @see org.xml.sax.ErrorHandler + */ +public class HandlerBase + implements EntityResolver, DTDHandler, DocumentHandler, ErrorHandler +{ + + + //////////////////////////////////////////////////////////////////// + // Default implementation of the EntityResolver interface. + //////////////////////////////////////////////////////////////////// + + /** + * Resolve an external entity. + * + *

Always return null, so that the parser will use the system + * identifier provided in the XML document. This method implements + * the SAX default behaviour: application writers can override it + * in a subclass to do special translations such as catalog lookups + * or URI redirection.

+ * + * @param publicId The public identifer, or null if none is + * available. + * @param systemId The system identifier provided in the XML + * document. + * @return The new input source, or null to require the + * default behaviour. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.EntityResolver#resolveEntity + */ + public InputSource resolveEntity (String publicId, String systemId) + throws SAXException + { + return null; + } + + + + //////////////////////////////////////////////////////////////////// + // Default implementation of DTDHandler interface. + //////////////////////////////////////////////////////////////////// + + + /** + * Receive notification of a notation declaration. + * + *

By default, do nothing. Application writers may override this + * method in a subclass if they wish to keep track of the notations + * declared in a document.

+ * + * @param name The notation name. + * @param publicId The notation public identifier, or null if not + * available. + * @param systemId The notation system identifier. + * @see org.xml.sax.DTDHandler#notationDecl + */ + public void notationDecl (String name, String publicId, String systemId) + { + // no op + } + + + /** + * Receive notification of an unparsed entity declaration. + * + *

By default, do nothing. Application writers may override this + * method in a subclass to keep track of the unparsed entities + * declared in a document.

+ * + * @param name The entity name. + * @param publicId The entity public identifier, or null if not + * available. + * @param systemId The entity system identifier. + * @param notationName The name of the associated notation. + * @see org.xml.sax.DTDHandler#unparsedEntityDecl + */ + public void unparsedEntityDecl (String name, String publicId, + String systemId, String notationName) + { + // no op + } + + + + //////////////////////////////////////////////////////////////////// + // Default implementation of DocumentHandler interface. + //////////////////////////////////////////////////////////////////// + + + /** + * Receive a Locator object for document events. + * + *

By default, do nothing. Application writers may override this + * method in a subclass if they wish to store the locator for use + * with other document events.

+ * + * @param locator A locator for all SAX document events. + * @see org.xml.sax.DocumentHandler#setDocumentLocator + * @see org.xml.sax.Locator + */ + public void setDocumentLocator (Locator locator) + { + // no op + } + + + /** + * Receive notification of the beginning of the document. + * + *

By default, do nothing. Application writers may override this + * method in a subclass to take specific actions at the beginning + * of a document (such as allocating the root node of a tree or + * creating an output file).

+ * + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.DocumentHandler#startDocument + */ + public void startDocument () + throws SAXException + { + // no op + } + + + /** + * Receive notification of the end of the document. + * + *

By default, do nothing. Application writers may override this + * method in a subclass to take specific actions at the beginning + * of a document (such as finalising a tree or closing an output + * file).

+ * + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.DocumentHandler#endDocument + */ + public void endDocument () + throws SAXException + { + // no op + } + + + /** + * Receive notification of the start of an element. + * + *

By default, do nothing. Application writers may override this + * method in a subclass to take specific actions at the start of + * each element (such as allocating a new tree node or writing + * output to a file).

+ * + * @param name The element type name. + * @param attributes The specified or defaulted attributes. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.DocumentHandler#startElement + */ + public void startElement (String name, AttributeList attributes) + throws SAXException + { + // no op + } + + + /** + * Receive notification of the end of an element. + * + *

By default, do nothing. Application writers may override this + * method in a subclass to take specific actions at the end of + * each element (such as finalising a tree node or writing + * output to a file).

+ * + * @param name The element type name. + * @param attributes The specified or defaulted attributes. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.DocumentHandler#endElement + */ + public void endElement (String name) + throws SAXException + { + // no op + } + + + /** + * Receive notification of character data inside an element. + * + *

By default, do nothing. Application writers may override this + * method to take specific actions for each chunk of character data + * (such as adding the data to a node or buffer, or printing it to + * a file).

+ * + * @param ch The characters. + * @param start The start position in the character array. + * @param length The number of characters to use from the + * character array. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.DocumentHandler#characters + */ + public void characters (char ch[], int start, int length) + throws SAXException + { + // no op + } + + + /** + * Receive notification of ignorable whitespace in element content. + * + *

By default, do nothing. Application writers may override this + * method to take specific actions for each chunk of ignorable + * whitespace (such as adding data to a node or buffer, or printing + * it to a file).

+ * + * @param ch The whitespace characters. + * @param start The start position in the character array. + * @param length The number of characters to use from the + * character array. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.DocumentHandler#ignorableWhitespace + */ + public void ignorableWhitespace (char ch[], int start, int length) + throws SAXException + { + // no op + } + + + /** + * Receive notification of a processing instruction. + * + *

By default, do nothing. Application writers may override this + * method in a subclass to take specific actions for each + * processing instruction, such as setting status variables or + * invoking other methods.

+ * + * @param target The processing instruction target. + * @param data The processing instruction data, or null if + * none is supplied. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.DocumentHandler#processingInstruction + */ + public void processingInstruction (String target, String data) + throws SAXException + { + // no op + } + + + + //////////////////////////////////////////////////////////////////// + // Default implementation of the ErrorHandler interface. + //////////////////////////////////////////////////////////////////// + + + /** + * Receive notification of a parser warning. + * + *

The default implementation does nothing. Application writers + * may override this method in a subclass to take specific actions + * for each warning, such as inserting the message in a log file or + * printing it to the console.

+ * + * @param e The warning information encoded as an exception. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.ErrorHandler#warning + * @see org.xml.sax.SAXParseException + */ + public void warning (SAXParseException e) + throws SAXException + { + // no op + } + + + /** + * Receive notification of a recoverable parser error. + * + *

The default implementation does nothing. Application writers + * may override this method in a subclass to take specific actions + * for each error, such as inserting the message in a log file or + * printing it to the console.

+ * + * @param e The warning information encoded as an exception. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.ErrorHandler#warning + * @see org.xml.sax.SAXParseException + */ + public void error (SAXParseException e) + throws SAXException + { + // no op + } + + + /** + * Report a fatal XML parsing error. + * + *

The default implementation throws a SAXParseException. + * Application writers may override this method in a subclass if + * they need to take specific actions for each fatal error (such as + * collecting all of the errors into a single report): in any case, + * the application must stop all regular processing when this + * method is invoked, since the document is no longer reliable, and + * the parser may no longer report parsing events.

+ * + * @param e The error information encoded as an exception. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.ErrorHandler#fatalError + * @see org.xml.sax.SAXParseException + */ + public void fatalError (SAXParseException e) + throws SAXException + { + throw e; + } + +} + +// end of HandlerBase.java diff --git a/libjava/org/xml/sax/InputSource.java b/libjava/org/xml/sax/InputSource.java new file mode 100644 index 00000000000..985ca220387 --- /dev/null +++ b/libjava/org/xml/sax/InputSource.java @@ -0,0 +1,321 @@ +// SAX input source. +// No warranty; no copyright -- use this as you will. +// $Id: InputSource.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ + +package org.xml.sax; + +import java.io.Reader; +import java.io.InputStream; + +/** + * A single input source for an XML entity. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

This class allows a SAX application to encapsulate information + * about an input source in a single object, which may include + * a public identifier, a system identifier, a byte stream (possibly + * with a specified encoding), and/or a character stream.

+ * + *

There are two places that the application will deliver this + * input source to the parser: as the argument to the Parser.parse + * method, or as the return value of the EntityResolver.resolveEntity + * method.

+ * + *

The SAX parser will use the InputSource object to determine how + * to read XML input. If there is a character stream available, the + * parser will read that stream directly; if not, the parser will use + * a byte stream, if available; if neither a character stream nor a + * byte stream is available, the parser will attempt to open a URI + * connection to the resource identified by the system + * identifier.

+ * + *

An InputSource object belongs to the application: the SAX parser + * shall never modify it in any way (it may modify a copy if + * necessary).

+ * + * @since SAX 1.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + * @see org.xml.sax.Parser#parse + * @see org.xml.sax.EntityResolver#resolveEntity + * @see java.io.InputStream + * @see java.io.Reader + */ +public class InputSource { + + /** + * Zero-argument default constructor. + * + * @see #setPublicId + * @see #setSystemId + * @see #setByteStream + * @see #setCharacterStream + * @see #setEncoding + */ + public InputSource () + { + } + + + /** + * Create a new input source with a system identifier. + * + *

Applications may use setPublicId to include a + * public identifier as well, or setEncoding to specify + * the character encoding, if known.

+ * + *

If the system identifier is a URL, it must be full resolved.

+ * + * @param systemId The system identifier (URI). + * @see #setPublicId + * @see #setSystemId + * @see #setByteStream + * @see #setEncoding + * @see #setCharacterStream + */ + public InputSource (String systemId) + { + setSystemId(systemId); + } + + + /** + * Create a new input source with a byte stream. + * + *

Application writers may use setSystemId to provide a base + * for resolving relative URIs, setPublicId to include a + * public identifier, and/or setEncoding to specify the object's + * character encoding.

+ * + * @param byteStream The raw byte stream containing the document. + * @see #setPublicId + * @see #setSystemId + * @see #setEncoding + * @see #setByteStream + * @see #setCharacterStream + */ + public InputSource (InputStream byteStream) + { + setByteStream(byteStream); + } + + + /** + * Create a new input source with a character stream. + * + *

Application writers may use setSystemId() to provide a base + * for resolving relative URIs, and setPublicId to include a + * public identifier.

+ * + *

The character stream shall not include a byte order mark.

+ * + * @see #setPublicId + * @see #setSystemId + * @see #setByteStream + * @see #setCharacterStream + */ + public InputSource (Reader characterStream) + { + setCharacterStream(characterStream); + } + + + /** + * Set the public identifier for this input source. + * + *

The public identifier is always optional: if the application + * writer includes one, it will be provided as part of the + * location information.

+ * + * @param publicId The public identifier as a string. + * @see #getPublicId + * @see org.xml.sax.Locator#getPublicId + * @see org.xml.sax.SAXParseException#getPublicId + */ + public void setPublicId (String publicId) + { + this.publicId = publicId; + } + + + /** + * Get the public identifier for this input source. + * + * @return The public identifier, or null if none was supplied. + * @see #setPublicId + */ + public String getPublicId () + { + return publicId; + } + + + /** + * Set the system identifier for this input source. + * + *

The system identifier is optional if there is a byte stream + * or a character stream, but it is still useful to provide one, + * since the application can use it to resolve relative URIs + * and can include it in error messages and warnings (the parser + * will attempt to open a connection to the URI only if + * there is no byte stream or character stream specified).

+ * + *

If the application knows the character encoding of the + * object pointed to by the system identifier, it can register + * the encoding using the setEncoding method.

+ * + *

If the system ID is a URL, it must be fully resolved.

+ * + * @param systemId The system identifier as a string. + * @see #setEncoding + * @see #getSystemId + * @see org.xml.sax.Locator#getSystemId + * @see org.xml.sax.SAXParseException#getSystemId + */ + public void setSystemId (String systemId) + { + this.systemId = systemId; + } + + + /** + * Get the system identifier for this input source. + * + *

The getEncoding method will return the character encoding + * of the object pointed to, or null if unknown.

+ * + *

If the system ID is a URL, it will be fully resolved.

+ * + * @return The system identifier. + * @see #setSystemId + * @see #getEncoding + */ + public String getSystemId () + { + return systemId; + } + + + /** + * Set the byte stream for this input source. + * + *

The SAX parser will ignore this if there is also a character + * stream specified, but it will use a byte stream in preference + * to opening a URI connection itself.

+ * + *

If the application knows the character encoding of the + * byte stream, it should set it with the setEncoding method.

+ * + * @param byteStream A byte stream containing an XML document or + * other entity. + * @see #setEncoding + * @see #getByteStream + * @see #getEncoding + * @see java.io.InputStream + */ + public void setByteStream (InputStream byteStream) + { + this.byteStream = byteStream; + } + + + /** + * Get the byte stream for this input source. + * + *

The getEncoding method will return the character + * encoding for this byte stream, or null if unknown.

+ * + * @return The byte stream, or null if none was supplied. + * @see #getEncoding + * @see #setByteStream + */ + public InputStream getByteStream () + { + return byteStream; + } + + + /** + * Set the character encoding, if known. + * + *

The encoding must be a string acceptable for an + * XML encoding declaration (see section 4.3.3 of the XML 1.0 + * recommendation).

+ * + *

This method has no effect when the application provides a + * character stream.

+ * + * @param encoding A string describing the character encoding. + * @see #setSystemId + * @see #setByteStream + * @see #getEncoding + */ + public void setEncoding (String encoding) + { + this.encoding = encoding; + } + + + /** + * Get the character encoding for a byte stream or URI. + * + * @return The encoding, or null if none was supplied. + * @see #setByteStream + * @see #getSystemId + * @see #getByteStream + */ + public String getEncoding () + { + return encoding; + } + + + /** + * Set the character stream for this input source. + * + *

If there is a character stream specified, the SAX parser + * will ignore any byte stream and will not attempt to open + * a URI connection to the system identifier.

+ * + * @param characterStream The character stream containing the + * XML document or other entity. + * @see #getCharacterStream + * @see java.io.Reader + */ + public void setCharacterStream (Reader characterStream) + { + this.characterStream = characterStream; + } + + + /** + * Get the character stream for this input source. + * + * @return The character stream, or null if none was supplied. + * @see #setCharacterStream + */ + public Reader getCharacterStream () + { + return characterStream; + } + + + + //////////////////////////////////////////////////////////////////// + // Internal state. + //////////////////////////////////////////////////////////////////// + + private String publicId; + private String systemId; + private InputStream byteStream; + private String encoding; + private Reader characterStream; + +} + +// end of InputSource.java diff --git a/libjava/org/xml/sax/Locator.java b/libjava/org/xml/sax/Locator.java new file mode 100644 index 00000000000..be55656042e --- /dev/null +++ b/libjava/org/xml/sax/Locator.java @@ -0,0 +1,126 @@ +// SAX locator interface for document events. +// No warranty; no copyright -- use this as you will. +// $Id: Locator.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ + +package org.xml.sax; + + +/** + * Interface for associating a SAX event with a document location. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

If a SAX parser provides location information to the SAX + * application, it does so by implementing this interface and then + * passing an instance to the application using the content + * handler's {@link org.xml.sax.ContentHandler#setDocumentLocator + * setDocumentLocator} method. The application can use the + * object to obtain the location of any other content handler event + * in the XML source document.

+ * + *

Note that the results returned by the object will be valid only + * during the scope of each content handler method: the application + * will receive unpredictable results if it attempts to use the + * locator at any other time.

+ * + *

SAX parsers are not required to supply a locator, but they are + * very strongly encouraged to do so. If the parser supplies a + * locator, it must do so before reporting any other document events. + * If no locator has been set by the time the application receives + * the {@link org.xml.sax.ContentHandler#startDocument startDocument} + * event, the application should assume that a locator is not + * available.

+ * + * @since SAX 1.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + * @see org.xml.sax.ContentHandler#setDocumentLocator + */ +public interface Locator { + + + /** + * Return the public identifier for the current document event. + * + *

The return value is the public identifier of the document + * entity or of the external parsed entity in which the markup + * triggering the event appears.

+ * + * @return A string containing the public identifier, or + * null if none is available. + * @see #getSystemId + */ + public abstract String getPublicId (); + + + /** + * Return the system identifier for the current document event. + * + *

The return value is the system identifier of the document + * entity or of the external parsed entity in which the markup + * triggering the event appears.

+ * + *

If the system identifier is a URL, the parser must resolve it + * fully before passing it to the application.

+ * + * @return A string containing the system identifier, or null + * if none is available. + * @see #getPublicId + */ + public abstract String getSystemId (); + + + /** + * Return the line number where the current document event ends. + * + *

Warning: The return value from the method + * is intended only as an approximation for the sake of error + * reporting; it is not intended to provide sufficient information + * to edit the character content of the original XML document.

+ * + *

The return value is an approximation of the line number + * in the document entity or external parsed entity where the + * markup triggering the event appears.

+ * + *

If possible, the SAX driver should provide the line position + * of the first character after the text associated with the document + * event. The first line in the document is line 1.

+ * + * @return The line number, or -1 if none is available. + * @see #getColumnNumber + */ + public abstract int getLineNumber (); + + + /** + * Return the column number where the current document event ends. + * + *

Warning: The return value from the method + * is intended only as an approximation for the sake of error + * reporting; it is not intended to provide sufficient information + * to edit the character content of the original XML document.

+ * + *

The return value is an approximation of the column number + * in the document entity or external parsed entity where the + * markup triggering the event appears.

+ * + *

If possible, the SAX driver should provide the line position + * of the first character after the text associated with the document + * event.

+ * + *

If possible, the SAX driver should provide the line position + * of the first character after the text associated with the document + * event. The first column in each line is column 1.

+ * + * @return The column number, or -1 if none is available. + * @see #getLineNumber + */ + public abstract int getColumnNumber (); + +} + +// end of Locator.java diff --git a/libjava/org/xml/sax/Parser.java b/libjava/org/xml/sax/Parser.java new file mode 100644 index 00000000000..e775ca97c87 --- /dev/null +++ b/libjava/org/xml/sax/Parser.java @@ -0,0 +1,207 @@ +// SAX parser interface. +// No warranty; no copyright -- use this as you will. +// $Id: Parser.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ + +package org.xml.sax; + +import java.io.IOException; +import java.util.Locale; + + +/** + * Basic interface for SAX (Simple API for XML) parsers. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

This was the main event supplier interface for SAX1; it has + * been replaced in SAX2 by {@link org.xml.sax.XMLReader XMLReader}, + * which includes Namespace support and sophisticated configurability + * and extensibility.

+ * + *

All SAX1 parsers must implement this basic interface: it allows + * applications to register handlers for different types of events + * and to initiate a parse from a URI, or a character stream.

+ * + *

All SAX1 parsers must also implement a zero-argument constructor + * (though other constructors are also allowed).

+ * + *

SAX1 parsers are reusable but not re-entrant: the application + * may reuse a parser object (possibly with a different input source) + * once the first parse has completed successfully, but it may not + * invoke the parse() methods recursively within a parse.

+ * + * @deprecated This interface has been replaced by the SAX2 + * {@link org.xml.sax.XMLReader XMLReader} + * interface, which includes Namespace support. + * @since SAX 1.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + * @see org.xml.sax.EntityResolver + * @see org.xml.sax.DTDHandler + * @see org.xml.sax.DocumentHandler + * @see org.xml.sax.ErrorHandler + * @see org.xml.sax.HandlerBase + * @see org.xml.sax.InputSource + */ +public interface Parser +{ + + /** + * Allow an application to request a locale for errors and warnings. + * + *

SAX parsers are not required to provide localisation for errors + * and warnings; if they cannot support the requested locale, + * however, they must throw a SAX exception. Applications may + * not request a locale change in the middle of a parse.

+ * + * @param locale A Java Locale object. + * @exception org.xml.sax.SAXException Throws an exception + * (using the previous or default locale) if the + * requested locale is not supported. + * @see org.xml.sax.SAXException + * @see org.xml.sax.SAXParseException + */ + public abstract void setLocale (Locale locale) + throws SAXException; + + + /** + * Allow an application to register a custom entity resolver. + * + *

If the application does not register an entity resolver, the + * SAX parser will resolve system identifiers and open connections + * to entities itself (this is the default behaviour implemented in + * HandlerBase).

+ * + *

Applications may register a new or different entity resolver + * in the middle of a parse, and the SAX parser must begin using + * the new resolver immediately.

+ * + * @param resolver The object for resolving entities. + * @see EntityResolver + * @see HandlerBase + */ + public abstract void setEntityResolver (EntityResolver resolver); + + + /** + * Allow an application to register a DTD event handler. + * + *

If the application does not register a DTD handler, all DTD + * events reported by the SAX parser will be silently + * ignored (this is the default behaviour implemented by + * HandlerBase).

+ * + *

Applications may register a new or different + * handler in the middle of a parse, and the SAX parser must + * begin using the new handler immediately.

+ * + * @param handler The DTD handler. + * @see DTDHandler + * @see HandlerBase + */ + public abstract void setDTDHandler (DTDHandler handler); + + + /** + * Allow an application to register a document event handler. + * + *

If the application does not register a document handler, all + * document events reported by the SAX parser will be silently + * ignored (this is the default behaviour implemented by + * HandlerBase).

+ * + *

Applications may register a new or different handler in the + * middle of a parse, and the SAX parser must begin using the new + * handler immediately.

+ * + * @param handler The document handler. + * @see DocumentHandler + * @see HandlerBase + */ + public abstract void setDocumentHandler (DocumentHandler handler); + + + /** + * Allow an application to register an error event handler. + * + *

If the application does not register an error event handler, + * all error events reported by the SAX parser will be silently + * ignored, except for fatalError, which will throw a SAXException + * (this is the default behaviour implemented by HandlerBase).

+ * + *

Applications may register a new or different handler in the + * middle of a parse, and the SAX parser must begin using the new + * handler immediately.

+ * + * @param handler The error handler. + * @see ErrorHandler + * @see SAXException + * @see HandlerBase + */ + public abstract void setErrorHandler (ErrorHandler handler); + + + /** + * Parse an XML document. + * + *

The application can use this method to instruct the SAX parser + * to begin parsing an XML document from any valid input + * source (a character stream, a byte stream, or a URI).

+ * + *

Applications may not invoke this method while a parse is in + * progress (they should create a new Parser instead for each + * additional XML document). Once a parse is complete, an + * application may reuse the same Parser object, possibly with a + * different input source.

+ * + * @param source The input source for the top-level of the + * XML document. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @exception java.io.IOException An IO exception from the parser, + * possibly from a byte stream or character stream + * supplied by the application. + * @see org.xml.sax.InputSource + * @see #parse(java.lang.String) + * @see #setEntityResolver + * @see #setDTDHandler + * @see #setDocumentHandler + * @see #setErrorHandler + */ + public abstract void parse (InputSource source) + throws SAXException, IOException; + + + /** + * Parse an XML document from a system identifier (URI). + * + *

This method is a shortcut for the common case of reading a + * document from a system identifier. It is the exact + * equivalent of the following:

+ * + *
+     * parse(new InputSource(systemId));
+     * 
+ * + *

If the system identifier is a URL, it must be fully resolved + * by the application before it is passed to the parser.

+ * + * @param systemId The system identifier (URI). + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @exception java.io.IOException An IO exception from the parser, + * possibly from a byte stream or character stream + * supplied by the application. + * @see #parse(org.xml.sax.InputSource) + */ + public abstract void parse (String systemId) + throws SAXException, IOException; + +} + +// end of Parser.java diff --git a/libjava/org/xml/sax/SAXException.java b/libjava/org/xml/sax/SAXException.java new file mode 100644 index 00000000000..69537e91706 --- /dev/null +++ b/libjava/org/xml/sax/SAXException.java @@ -0,0 +1,144 @@ +// SAX exception class. +// No warranty; no copyright -- use this as you will. +// $Id: SAXException.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ + +package org.xml.sax; + +/** + * Encapsulate a general SAX error or warning. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

This class can contain basic error or warning information from + * either the XML parser or the application: a parser writer or + * application writer can subclass it to provide additional + * functionality. SAX handlers may throw this exception or + * any exception subclassed from it.

+ * + *

If the application needs to pass through other types of + * exceptions, it must wrap those exceptions in a SAXException + * or an exception derived from a SAXException.

+ * + *

If the parser or application needs to include information about a + * specific location in an XML document, it should use the + * {@link org.xml.sax.SAXParseException SAXParseException} subclass.

+ * + * @since SAX 1.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + * @see org.xml.sax.SAXParseException + */ +public class SAXException extends Exception { + + + /** + * Create a new SAXException. + * + * @param message The error or warning message. + * @see org.xml.sax.Parser#setLocale + */ + public SAXException (String message) { + super(message); + this.exception = null; + } + + + /** + * Create a new SAXException wrapping an existing exception. + * + *

The existing exception will be embedded in the new + * one, and its message will become the default message for + * the SAXException.

+ * + * @param e The exception to be wrapped in a SAXException. + */ + public SAXException (Exception e) + { + super(); + this.exception = e; + } + + + /** + * Create a new SAXException from an existing exception. + * + *

The existing exception will be embedded in the new + * one, but the new exception will have its own message.

+ * + * @param message The detail message. + * @param e The exception to be wrapped in a SAXException. + * @see org.xml.sax.Parser#setLocale + */ + public SAXException (String message, Exception e) + { + super(message); + this.exception = e; + } + + + /** + * Return a detail message for this exception. + * + *

If there is an embedded exception, and if the SAXException + * has no detail message of its own, this method will return + * the detail message from the embedded exception.

+ * + * @return The error or warning message. + * @see org.xml.sax.Parser#setLocale + */ + public String getMessage () + { + String message = super.getMessage(); + + if (message == null && exception != null) { + return exception.getMessage(); + } else { + return message; + } + } + + + /** + * Return the embedded exception, if any. + * + * @return The embedded exception, or null if there is none. + */ + public Exception getException () + { + return exception; + } + + + /** + * Override toString to pick up any embedded exception. + * + * @return A string representation of this exception. + */ + public String toString () + { + if (exception != null) { + return exception.toString(); + } else { + return super.toString(); + } + } + + + + ////////////////////////////////////////////////////////////////////// + // Internal state. + ////////////////////////////////////////////////////////////////////// + + + /** + * @serial The embedded exception if tunnelling, or null. + */ + private Exception exception; + +} + +// end of SAXException.java diff --git a/libjava/org/xml/sax/SAXNotRecognizedException.java b/libjava/org/xml/sax/SAXNotRecognizedException.java new file mode 100644 index 00000000000..0fbc4c85ba9 --- /dev/null +++ b/libjava/org/xml/sax/SAXNotRecognizedException.java @@ -0,0 +1,44 @@ +// SAXNotRecognizedException.java - unrecognized feature or value. +// Written by David Megginson, sax@megginson.com +// NO WARRANTY! This class is in the Public Domain. + +// $Id: SAXNotRecognizedException.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ + + +package org.xml.sax; + + +/** + * Exception class for an unrecognized identifier. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

An XMLReader will throw this exception when it finds an + * unrecognized feature or property identifier; SAX applications and + * extensions may use this class for other, similar purposes.

+ * + * @since SAX 2.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + * @see org.xml.sax.SAXNotSupportedException + */ +public class SAXNotRecognizedException extends SAXException +{ + + /** + * Construct a new exception with the given message. + * + * @param message The text message of the exception. + */ + public SAXNotRecognizedException (String message) + { + super(message); + } + +} + +// end of SAXNotRecognizedException.java diff --git a/libjava/org/xml/sax/SAXNotSupportedException.java b/libjava/org/xml/sax/SAXNotSupportedException.java new file mode 100644 index 00000000000..3376d47cc5b --- /dev/null +++ b/libjava/org/xml/sax/SAXNotSupportedException.java @@ -0,0 +1,44 @@ +// SAXNotSupportedException.java - unsupported feature or value. +// Written by David Megginson, sax@megginson.com +// NO WARRANTY! This class is in the Public Domain. + +// $Id: SAXNotSupportedException.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ + + +package org.xml.sax; + +/** + * Exception class for an unsupported operation. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

An XMLReader will throw this exception when it recognizes a + * feature or property identifier, but cannot perform the requested + * operation (setting a state or value). Other SAX2 applications and + * extensions may use this class for similar purposes.

+ * + * @since SAX 2.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + * @see org.xml.sax.SAXNotRecognizedException + */ +public class SAXNotSupportedException extends SAXException +{ + + /** + * Construct a new exception with the given message. + * + * @param message The text message of the exception. + */ + public SAXNotSupportedException (String message) + { + super(message); + } + +} + +// end of SAXNotSupportedException.java diff --git a/libjava/org/xml/sax/SAXParseException.java b/libjava/org/xml/sax/SAXParseException.java new file mode 100644 index 00000000000..bcfb94ebd25 --- /dev/null +++ b/libjava/org/xml/sax/SAXParseException.java @@ -0,0 +1,264 @@ +// SAX exception class. +// No warranty; no copyright -- use this as you will. +// $Id: SAXParseException.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ + +package org.xml.sax; + +/** + * Encapsulate an XML parse error or warning. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

This exception will include information for locating the error + * in the original XML document. Note that although the application + * will receive a SAXParseException as the argument to the handlers + * in the {@link org.xml.sax.ErrorHandler ErrorHandler} interface, + * the application is not actually required to throw the exception; + * instead, it can simply read the information in it and take a + * different action.

+ * + *

Since this exception is a subclass of {@link org.xml.sax.SAXException + * SAXException}, it inherits the ability to wrap another exception.

+ * + * @since SAX 1.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + * @see org.xml.sax.SAXException + * @see org.xml.sax.Locator + * @see org.xml.sax.ErrorHandler + */ +public class SAXParseException extends SAXException { + + + ////////////////////////////////////////////////////////////////////// + // Constructors. + ////////////////////////////////////////////////////////////////////// + + + /** + * Create a new SAXParseException from a message and a Locator. + * + *

This constructor is especially useful when an application is + * creating its own exception from within a {@link org.xml.sax.ContentHandler + * ContentHandler} callback.

+ * + * @param message The error or warning message. + * @param locator The locator object for the error or warning (may be + * null). + * @see org.xml.sax.Locator + * @see org.xml.sax.Parser#setLocale + */ + public SAXParseException (String message, Locator locator) { + super(message); + if (locator != null) { + init(locator.getPublicId(), locator.getSystemId(), + locator.getLineNumber(), locator.getColumnNumber()); + } else { + init(null, null, -1, -1); + } + } + + + /** + * Wrap an existing exception in a SAXParseException. + * + *

This constructor is especially useful when an application is + * creating its own exception from within a {@link org.xml.sax.ContentHandler + * ContentHandler} callback, and needs to wrap an existing exception that is not a + * subclass of {@link org.xml.sax.SAXException SAXException}.

+ * + * @param message The error or warning message, or null to + * use the message from the embedded exception. + * @param locator The locator object for the error or warning (may be + * null). + * @param e Any exception. + * @see org.xml.sax.Locator + * @see org.xml.sax.Parser#setLocale + */ + public SAXParseException (String message, Locator locator, + Exception e) { + super(message, e); + if (locator != null) { + init(locator.getPublicId(), locator.getSystemId(), + locator.getLineNumber(), locator.getColumnNumber()); + } else { + init(null, null, -1, -1); + } + } + + + /** + * Create a new SAXParseException. + * + *

This constructor is most useful for parser writers.

+ * + *

If the system identifier is a URL, the parser must resolve it + * fully before creating the exception.

+ * + * @param message The error or warning message. + * @param publicId The public identifer of the entity that generated + * the error or warning. + * @param systemId The system identifer of the entity that generated + * the error or warning. + * @param lineNumber The line number of the end of the text that + * caused the error or warning. + * @param columnNumber The column number of the end of the text that + * cause the error or warning. + * @see org.xml.sax.Parser#setLocale + */ + public SAXParseException (String message, String publicId, String systemId, + int lineNumber, int columnNumber) + { + super(message); + init(publicId, systemId, lineNumber, columnNumber); + } + + + /** + * Create a new SAXParseException with an embedded exception. + * + *

This constructor is most useful for parser writers who + * need to wrap an exception that is not a subclass of + * {@link org.xml.sax.SAXException SAXException}.

+ * + *

If the system identifier is a URL, the parser must resolve it + * fully before creating the exception.

+ * + * @param message The error or warning message, or null to use + * the message from the embedded exception. + * @param publicId The public identifer of the entity that generated + * the error or warning. + * @param systemId The system identifer of the entity that generated + * the error or warning. + * @param lineNumber The line number of the end of the text that + * caused the error or warning. + * @param columnNumber The column number of the end of the text that + * cause the error or warning. + * @param e Another exception to embed in this one. + * @see org.xml.sax.Parser#setLocale + */ + public SAXParseException (String message, String publicId, String systemId, + int lineNumber, int columnNumber, Exception e) + { + super(message, e); + init(publicId, systemId, lineNumber, columnNumber); + } + + + /** + * Internal initialization method. + * + * @param publicId The public identifier of the entity which generated the exception, + * or null. + * @param systemId The system identifier of the entity which generated the exception, + * or null. + * @param lineNumber The line number of the error, or -1. + * @param columnNumber The column number of the error, or -1. + */ + private void init (String publicId, String systemId, + int lineNumber, int columnNumber) + { + this.publicId = publicId; + this.systemId = systemId; + this.lineNumber = lineNumber; + this.columnNumber = columnNumber; + } + + + /** + * Get the public identifier of the entity where the exception occurred. + * + * @return A string containing the public identifier, or null + * if none is available. + * @see org.xml.sax.Locator#getPublicId + */ + public String getPublicId () + { + return this.publicId; + } + + + /** + * Get the system identifier of the entity where the exception occurred. + * + *

If the system identifier is a URL, it will be resolved + * fully.

+ * + * @return A string containing the system identifier, or null + * if none is available. + * @see org.xml.sax.Locator#getSystemId + */ + public String getSystemId () + { + return this.systemId; + } + + + /** + * The line number of the end of the text where the exception occurred. + * + * @return An integer representing the line number, or -1 + * if none is available. + * @see org.xml.sax.Locator#getLineNumber + */ + public int getLineNumber () + { + return this.lineNumber; + } + + + /** + * The column number of the end of the text where the exception occurred. + * + *

The first column in a line is position 1.

+ * + * @return An integer representing the column number, or -1 + * if none is available. + * @see org.xml.sax.Locator#getColumnNumber + */ + public int getColumnNumber () + { + return this.columnNumber; + } + + + + ////////////////////////////////////////////////////////////////////// + // Internal state. + ////////////////////////////////////////////////////////////////////// + + + /** + * @serial The public identifier, or null. + * @see #getPublicId + */ + private String publicId; + + + /** + * @serial The system identifier, or null. + * @see #getSystemId + */ + private String systemId; + + + /** + * @serial The line number, or -1. + * @see #getLineNumber + */ + private int lineNumber; + + + /** + * @serial The column number, or -1. + * @see #getColumnNumber + */ + private int columnNumber; + +} + +// end of SAXParseException.java diff --git a/libjava/org/xml/sax/XMLFilter.java b/libjava/org/xml/sax/XMLFilter.java new file mode 100644 index 00000000000..b10e8647ff0 --- /dev/null +++ b/libjava/org/xml/sax/XMLFilter.java @@ -0,0 +1,65 @@ +// XMLFilter.java - filter SAX2 events. +// Written by David Megginson, sax@megginson.com +// NO WARRANTY! This class is in the Public Domain. + +// $Id: XMLFilter.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ + + +package org.xml.sax; + + +/** + * Interface for an XML filter. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

An XML filter is like an XML reader, except that it obtains its + * events from another XML reader rather than a primary source like + * an XML document or database. Filters can modify a stream of + * events as they pass on to the final application.

+ * + *

The XMLFilterImpl helper class provides a convenient base + * for creating SAX2 filters, by passing on all {@link org.xml.sax.EntityResolver + * EntityResolver}, {@link org.xml.sax.DTDHandler DTDHandler}, + * {@link org.xml.sax.ContentHandler ContentHandler} and {@link org.xml.sax.ErrorHandler + * ErrorHandler} events automatically.

+ * + * @since SAX 2.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + * @see org.xml.sax.helpers.XMLFilterImpl + */ +public interface XMLFilter extends XMLReader +{ + + /** + * Set the parent reader. + * + *

This method allows the application to link the filter to + * a parent reader (which may be another filter). The argument + * may not be null.

+ * + * @param parent The parent reader. + */ + public abstract void setParent (XMLReader parent); + + + /** + * Get the parent reader. + * + *

This method allows the application to query the parent + * reader (which may be another filter). It is generally a + * bad idea to perform any operations on the parent reader + * directly: they should all pass through this filter.

+ * + * @return The parent filter, or null if none has been set. + */ + public abstract XMLReader getParent (); + +} + +// end of XMLFilter.java diff --git a/libjava/org/xml/sax/XMLReader.java b/libjava/org/xml/sax/XMLReader.java new file mode 100644 index 00000000000..26e382b9fa9 --- /dev/null +++ b/libjava/org/xml/sax/XMLReader.java @@ -0,0 +1,415 @@ +// XMLReader.java - read an XML document. +// Written by David Megginson, sax@megginson.com +// NO WARRANTY! This class is in the Public Domain. + +// $Id: XMLReader.java,v 1.1 2000/10/02 02:43:17 sboag Exp $ + +package org.xml.sax; + +import java.io.IOException; + + +/** + * Interface for reading an XML document using callbacks. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

Note: despite its name, this interface does + * not extend the standard Java {@link java.io.Reader Reader} + * interface, because reading XML is a fundamentally different activity + * than reading character data.

+ * + *

XMLReader is the interface that an XML parser's SAX2 driver must + * implement. This interface allows an application to set and + * query features and properties in the parser, to register + * event handlers for document processing, and to initiate + * a document parse.

+ * + *

All SAX interfaces are assumed to be synchronous: the + * {@link #parse parse} methods must not return until parsing + * is complete, and readers must wait for an event-handler callback + * to return before reporting the next event.

+ * + *

This interface replaces the (now deprecated) SAX 1.0 {@link + * org.xml.sax.Parser Parser} interface. The XMLReader interface + * contains two important enhancements over the old Parser + * interface:

+ * + *
    + *
  1. it adds a standard way to query and set features and + * properties; and
  2. + *
  3. it adds Namespace support, which is required for many + * higher-level XML standards.
  4. + *
+ * + *

There are adapters available to convert a SAX1 Parser to + * a SAX2 XMLReader and vice-versa.

+ * + * @since SAX 2.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + * @see org.xml.sax.XMLFilter + * @see org.xml.sax.helpers.ParserAdapter + * @see org.xml.sax.helpers.XMLReaderAdapter + */ +public interface XMLReader +{ + + + //////////////////////////////////////////////////////////////////// + // Configuration. + //////////////////////////////////////////////////////////////////// + + + /** + * Look up the value of a feature. + * + *

The feature name is any fully-qualified URI. It is + * possible for an XMLReader to recognize a feature name but + * to be unable to return its value; this is especially true + * in the case of an adapter for a SAX1 Parser, which has + * no way of knowing whether the underlying parser is + * performing validation or expanding external entities.

+ * + *

All XMLReaders are required to recognize the + * http://xml.org/sax/features/namespaces and the + * http://xml.org/sax/features/namespace-prefixes feature names.

+ * + *

Some feature values may be available only in specific + * contexts, such as before, during, or after a parse.

+ * + *

Typical usage is something like this:

+ * + *
+     * XMLReader r = new MySAXDriver();
+     *
+     *                         // try to activate validation
+     * try {
+     *   r.setFeature("http://xml.org/sax/features/validation", true);
+     * } catch (SAXException e) {
+     *   System.err.println("Cannot activate validation."); 
+     * }
+     *
+     *                         // register event handlers
+     * r.setContentHandler(new MyContentHandler());
+     * r.setErrorHandler(new MyErrorHandler());
+     *
+     *                         // parse the first document
+     * try {
+     *   r.parse("http://www.foo.com/mydoc.xml");
+     * } catch (IOException e) {
+     *   System.err.println("I/O exception reading XML document");
+     * } catch (SAXException e) {
+     *   System.err.println("XML exception reading document.");
+     * }
+     * 
+ * + *

Implementors are free (and encouraged) to invent their own features, + * using names built on their own URIs.

+ * + * @param name The feature name, which is a fully-qualified URI. + * @return The current state of the feature (true or false). + * @exception org.xml.sax.SAXNotRecognizedException When the + * XMLReader does not recognize the feature name. + * @exception org.xml.sax.SAXNotSupportedException When the + * XMLReader recognizes the feature name but + * cannot determine its value at this time. + * @see #setFeature + */ + public boolean getFeature (String name) + throws SAXNotRecognizedException, SAXNotSupportedException; + + + /** + * Set the state of a feature. + * + *

The feature name is any fully-qualified URI. It is + * possible for an XMLReader to recognize a feature name but + * to be unable to set its value; this is especially true + * in the case of an adapter for a SAX1 {@link org.xml.sax.Parser Parser}, + * which has no way of affecting whether the underlying parser is + * validating, for example.

+ * + *

All XMLReaders are required to support setting + * http://xml.org/sax/features/namespaces to true and + * http://xml.org/sax/features/namespace-prefixes to false.

+ * + *

Some feature values may be immutable or mutable only + * in specific contexts, such as before, during, or after + * a parse.

+ * + * @param name The feature name, which is a fully-qualified URI. + * @param state The requested state of the feature (true or false). + * @exception org.xml.sax.SAXNotRecognizedException When the + * XMLReader does not recognize the feature name. + * @exception org.xml.sax.SAXNotSupportedException When the + * XMLReader recognizes the feature name but + * cannot set the requested value. + * @see #getFeature + */ + public void setFeature (String name, boolean value) + throws SAXNotRecognizedException, SAXNotSupportedException; + + + /** + * Look up the value of a property. + * + *

The property name is any fully-qualified URI. It is + * possible for an XMLReader to recognize a property name but + * to be unable to return its state; this is especially true + * in the case of an adapter for a SAX1 {@link org.xml.sax.Parser + * Parser}.

+ * + *

XMLReaders are not required to recognize any specific + * property names, though an initial core set is documented for + * SAX2.

+ * + *

Some property values may be available only in specific + * contexts, such as before, during, or after a parse.

+ * + *

Implementors are free (and encouraged) to invent their own properties, + * using names built on their own URIs.

+ * + * @param name The property name, which is a fully-qualified URI. + * @return The current value of the property. + * @exception org.xml.sax.SAXNotRecognizedException When the + * XMLReader does not recognize the property name. + * @exception org.xml.sax.SAXNotSupportedException When the + * XMLReader recognizes the property name but + * cannot determine its value at this time. + * @see #setProperty + */ + public Object getProperty (String name) + throws SAXNotRecognizedException, SAXNotSupportedException; + + + /** + * Set the value of a property. + * + *

The property name is any fully-qualified URI. It is + * possible for an XMLReader to recognize a property name but + * to be unable to set its value; this is especially true + * in the case of an adapter for a SAX1 {@link org.xml.sax.Parser + * Parser}.

+ * + *

XMLReaders are not required to recognize setting + * any specific property names, though a core set is provided with + * SAX2.

+ * + *

Some property values may be immutable or mutable only + * in specific contexts, such as before, during, or after + * a parse.

+ * + *

This method is also the standard mechanism for setting + * extended handlers.

+ * + * @param name The property name, which is a fully-qualified URI. + * @param state The requested value for the property. + * @exception org.xml.sax.SAXNotRecognizedException When the + * XMLReader does not recognize the property name. + * @exception org.xml.sax.SAXNotSupportedException When the + * XMLReader recognizes the property name but + * cannot set the requested value. + */ + public void setProperty (String name, Object value) + throws SAXNotRecognizedException, SAXNotSupportedException; + + + + //////////////////////////////////////////////////////////////////// + // Event handlers. + //////////////////////////////////////////////////////////////////// + + + /** + * Allow an application to register an entity resolver. + * + *

If the application does not register an entity resolver, + * the XMLReader will perform its own default resolution.

+ * + *

Applications may register a new or different resolver in the + * middle of a parse, and the SAX parser must begin using the new + * resolver immediately.

+ * + * @param resolver The entity resolver. + * @exception java.lang.NullPointerException If the resolver + * argument is null. + * @see #getEntityResolver + */ + public void setEntityResolver (EntityResolver resolver); + + + /** + * Return the current entity resolver. + * + * @return The current entity resolver, or null if none + * has been registered. + * @see #setEntityResolver + */ + public EntityResolver getEntityResolver (); + + + /** + * Allow an application to register a DTD event handler. + * + *

If the application does not register a DTD handler, all DTD + * events reported by the SAX parser will be silently ignored.

+ * + *

Applications may register a new or different handler in the + * middle of a parse, and the SAX parser must begin using the new + * handler immediately.

+ * + * @param handler The DTD handler. + * @exception java.lang.NullPointerException If the handler + * argument is null. + * @see #getDTDHandler + */ + public void setDTDHandler (DTDHandler handler); + + + /** + * Return the current DTD handler. + * + * @return The current DTD handler, or null if none + * has been registered. + * @see #setDTDHandler + */ + public DTDHandler getDTDHandler (); + + + /** + * Allow an application to register a content event handler. + * + *

If the application does not register a content handler, all + * content events reported by the SAX parser will be silently + * ignored.

+ * + *

Applications may register a new or different handler in the + * middle of a parse, and the SAX parser must begin using the new + * handler immediately.

+ * + * @param handler The content handler. + * @exception java.lang.NullPointerException If the handler + * argument is null. + * @see #getContentHandler + */ + public void setContentHandler (ContentHandler handler); + + + /** + * Return the current content handler. + * + * @return The current content handler, or null if none + * has been registered. + * @see #setContentHandler + */ + public ContentHandler getContentHandler (); + + + /** + * Allow an application to register an error event handler. + * + *

If the application does not register an error handler, all + * error events reported by the SAX parser will be silently + * ignored; however, normal processing may not continue. It is + * highly recommended that all SAX applications implement an + * error handler to avoid unexpected bugs.

+ * + *

Applications may register a new or different handler in the + * middle of a parse, and the SAX parser must begin using the new + * handler immediately.

+ * + * @param handler The error handler. + * @exception java.lang.NullPointerException If the handler + * argument is null. + * @see #getErrorHandler + */ + public void setErrorHandler (ErrorHandler handler); + + + /** + * Return the current error handler. + * + * @return The current error handler, or null if none + * has been registered. + * @see #setErrorHandler + */ + public ErrorHandler getErrorHandler (); + + + + //////////////////////////////////////////////////////////////////// + // Parsing. + //////////////////////////////////////////////////////////////////// + + /** + * Parse an XML document. + * + *

The application can use this method to instruct the XML + * reader to begin parsing an XML document from any valid input + * source (a character stream, a byte stream, or a URI).

+ * + *

Applications may not invoke this method while a parse is in + * progress (they should create a new XMLReader instead for each + * nested XML document). Once a parse is complete, an + * application may reuse the same XMLReader object, possibly with a + * different input source.

+ * + *

During the parse, the XMLReader will provide information + * about the XML document through the registered event + * handlers.

+ * + *

This method is synchronous: it will not return until parsing + * has ended. If a client application wants to terminate + * parsing early, it should throw an exception.

+ * + * @param source The input source for the top-level of the + * XML document. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @exception java.io.IOException An IO exception from the parser, + * possibly from a byte stream or character stream + * supplied by the application. + * @see org.xml.sax.InputSource + * @see #parse(java.lang.String) + * @see #setEntityResolver + * @see #setDTDHandler + * @see #setContentHandler + * @see #setErrorHandler + */ + public void parse (InputSource input) + throws IOException, SAXException; + + + /** + * Parse an XML document from a system identifier (URI). + * + *

This method is a shortcut for the common case of reading a + * document from a system identifier. It is the exact + * equivalent of the following:

+ * + *
+     * parse(new InputSource(systemId));
+     * 
+ * + *

If the system identifier is a URL, it must be fully resolved + * by the application before it is passed to the parser.

+ * + * @param systemId The system identifier (URI). + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @exception java.io.IOException An IO exception from the parser, + * possibly from a byte stream or character stream + * supplied by the application. + * @see #parse(org.xml.sax.InputSource) + */ + public void parse (String systemId) + throws IOException, SAXException; + +} + +// end of XMLReader.java diff --git a/libjava/org/xml/sax/ext/DeclHandler.java b/libjava/org/xml/sax/ext/DeclHandler.java new file mode 100644 index 00000000000..1fede3428de --- /dev/null +++ b/libjava/org/xml/sax/ext/DeclHandler.java @@ -0,0 +1,131 @@ +// DeclHandler.java - Optional handler for DTD declaration events. +// Public Domain: no warranty. +// $Id: DeclHandler.java,v 1.1 2000/10/02 02:43:19 sboag Exp $ + +package org.xml.sax.ext; + +import org.xml.sax.SAXException; + + +/** + * SAX2 extension handler for DTD declaration events. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

This is an optional extension handler for SAX2 to provide + * information about DTD declarations in an XML document. XML + * readers are not required to support this handler.

+ * + *

Note that data-related DTD declarations (unparsed entities and + * notations) are already reported through the {@link + * org.xml.sax.DTDHandler DTDHandler} interface.

+ * + *

If you are using the declaration handler together with a lexical + * handler, all of the events will occur between the + * {@link org.xml.sax.ext.LexicalHandler#startDTD startDTD} and the + * {@link org.xml.sax.ext.LexicalHandler#endDTD endDTD} events.

+ * + *

To set the DeclHandler for an XML reader, use the + * {@link org.xml.sax.XMLReader#setProperty setProperty} method + * with the propertyId "http://xml.org/sax/handlers/DeclHandler". + * If the reader does not support declaration events, it will throw a + * {@link org.xml.sax.SAXNotRecognizedException SAXNotRecognizedException} + * or a + * {@link org.xml.sax.SAXNotSupportedException SAXNotSupportedException} + * when you attempt to register the handler.

+ * + * @since SAX 2.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0beta + * @see org.xml.sax.XMLReader + */ +public interface DeclHandler +{ + + /** + * Report an element type declaration. + * + *

The content model will consist of the string "EMPTY", the + * string "ANY", or a parenthesised group, optionally followed + * by an occurrence indicator. The model will be normalized so + * that all whitespace is removed,and will include the enclosing + * parentheses.

+ * + * @param name The element type name. + * @param model The content model as a normalized string. + * @exception SAXException The application may raise an exception. + */ + public abstract void elementDecl (String name, String model) + throws SAXException; + + + /** + * Report an attribute type declaration. + * + *

Only the effective (first) declaration for an attribute will + * be reported. The type will be one of the strings "CDATA", + * "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY", + * "ENTITIES", or "NOTATION", or a parenthesized token group with + * the separator "|" and all whitespace removed.

+ * + * @param eName The name of the associated element. + * @param aName The name of the attribute. + * @param type A string representing the attribute type. + * @param valueDefault A string representing the attribute default + * ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if + * none of these applies. + * @param value A string representing the attribute's default value, + * or null if there is none. + * @exception SAXException The application may raise an exception. + */ + public abstract void attributeDecl (String eName, + String aName, + String type, + String valueDefault, + String value) + throws SAXException; + + + /** + * Report an internal entity declaration. + * + *

Only the effective (first) declaration for each entity + * will be reported.

+ * + * @param name The name of the entity. If it is a parameter + * entity, the name will begin with '%'. + * @param value The replacement text of the entity. + * @exception SAXException The application may raise an exception. + * @see #externalEntityDecl + * @see org.xml.sax.DTDHandler#unparsedEntityDecl + */ + public abstract void internalEntityDecl (String name, String value) + throws SAXException; + + + /** + * Report a parsed external entity declaration. + * + *

Only the effective (first) declaration for each entity + * will be reported.

+ * + * @param name The name of the entity. If it is a parameter + * entity, the name will begin with '%'. + * @param publicId The declared public identifier of the entity, or + * null if none was declared. + * @param systemId The declared system identifier of the entity. + * @exception SAXException The application may raise an exception. + * @see #internalEntityDecl + * @see org.xml.sax.DTDHandler#unparsedEntityDecl + */ + public abstract void externalEntityDecl (String name, String publicId, + String systemId) + throws SAXException; + +} + +// end of DeclHandler.java diff --git a/libjava/org/xml/sax/ext/LexicalHandler.java b/libjava/org/xml/sax/ext/LexicalHandler.java new file mode 100644 index 00000000000..4ac1617ca00 --- /dev/null +++ b/libjava/org/xml/sax/ext/LexicalHandler.java @@ -0,0 +1,161 @@ +// LexicalHandler.java - optional handler for lexical parse events. +// Public Domain: no warranty. +// $Id: LexicalHandler.java,v 1.1 2000/10/02 02:43:20 sboag Exp $ + +package org.xml.sax.ext; + +import org.xml.sax.SAXException; + +/** + * SAX2 extension handler for lexical events. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

This is an optional extension handler for SAX2 to provide + * lexical information about an XML document, such as comments + * and CDATA section boundaries; XML readers are not required to + * support this handler.

+ * + *

The events in the lexical handler apply to the entire document, + * not just to the document element, and all lexical handler events + * must appear between the content handler's startDocument and + * endDocument events.

+ * + *

To set the LexicalHandler for an XML reader, use the + * {@link org.xml.sax.XMLReader#setProperty setProperty} method + * with the propertyId "http://xml.org/sax/handlers/LexicalHandler". + * If the reader does not support lexical events, it will throw a + * {@link org.xml.sax.SAXNotRecognizedException SAXNotRecognizedException} + * or a + * {@link org.xml.sax.SAXNotSupportedException SAXNotSupportedException} + * when you attempt to register the handler.

+ * + * @since SAX 2.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0beta + * @see org.xml.sax.XMLReader#setProperty + * @see org.xml.sax.SAXNotRecognizedException + * @see org.xml.sax.SAXNotSupportedException + */ +public interface LexicalHandler +{ + + /** + * Report the start of DTD declarations, if any. + * + *

Any declarations are assumed to be in the internal subset + * unless otherwise indicated by a {@link #startEntity startEntity} + * event.

+ * + *

Note that the start/endDTD events will appear within + * the start/endDocument events from ContentHandler and + * before the first startElement event.

+ * + * @param name The document type name. + * @param publicId The declared public identifier for the + * external DTD subset, or null if none was declared. + * @param systemId The declared system identifier for the + * external DTD subset, or null if none was declared. + * @exception SAXException The application may raise an + * exception. + * @see #endDTD + * @see #startEntity + */ + public abstract void startDTD (String name, String publicId, + String systemId) + throws SAXException; + + + /** + * Report the end of DTD declarations. + * + * @exception SAXException The application may raise an exception. + * @see #startDTD + */ + public abstract void endDTD () + throws SAXException; + + + /** + * Report the beginning of an entity in content. + * + *

NOTE: entity references in attribute + * values -- and the start and end of the document entity -- + * are never reported.

+ * + *

The start and end of the external DTD subset are reported + * using the pseudo-name "[dtd]". All other events must be + * properly nested within start/end entity events.

+ * + *

Note that skipped entities will be reported through the + * {@link org.xml.sax.ContentHandler#skippedEntity skippedEntity} + * event, which is part of the ContentHandler interface.

+ * + * @param name The name of the entity. If it is a parameter + * entity, the name will begin with '%'. + * @exception SAXException The application may raise an exception. + * @see #endEntity + * @see org.xml.sax.ext.DeclHandler#internalEntityDecl + * @see org.xml.sax.ext.DeclHandler#externalEntityDecl + */ + public abstract void startEntity (String name) + throws SAXException; + + + /** + * Report the end of an entity. + * + * @param name The name of the entity that is ending. + * @exception SAXException The application may raise an exception. + * @see #startEntity + */ + public abstract void endEntity (String name) + throws SAXException; + + + /** + * Report the start of a CDATA section. + * + *

The contents of the CDATA section will be reported through + * the regular {@link org.xml.sax.ContentHandler#characters + * characters} event.

+ * + * @exception SAXException The application may raise an exception. + * @see #endCDATA + */ + public abstract void startCDATA () + throws SAXException; + + + /** + * Report the end of a CDATA section. + * + * @exception SAXException The application may raise an exception. + * @see #startCDATA + */ + public abstract void endCDATA () + throws SAXException; + + + /** + * Report an XML comment anywhere in the document. + * + *

This callback will be used for comments inside or outside the + * document element, including comments in the external DTD + * subset (if read).

+ * + * @param ch An array holding the characters in the comment. + * @param start The starting position in the array. + * @param length The number of characters to use from the array. + * @exception SAXException The application may raise an exception. + */ + public abstract void comment (char ch[], int start, int length) + throws SAXException; + +} + +// end of LexicalHandler.java diff --git a/libjava/org/xml/sax/helpers/AttributeListImpl.java b/libjava/org/xml/sax/helpers/AttributeListImpl.java new file mode 100644 index 00000000000..69754728c1f --- /dev/null +++ b/libjava/org/xml/sax/helpers/AttributeListImpl.java @@ -0,0 +1,310 @@ +// SAX default implementation for AttributeList. +// No warranty; no copyright -- use this as you will. +// $Id: AttributeListImpl.java,v 1.1 2000/10/02 02:43:20 sboag Exp $ + +package org.xml.sax.helpers; + +import org.xml.sax.AttributeList; + +import java.util.Vector; + + +/** + * Default implementation for AttributeList. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

AttributeList implements the deprecated SAX1 {@link + * org.xml.sax.AttributeList AttributeList} interface, and has been + * replaced by the new SAX2 {@link org.xml.sax.helpers.AttributesImpl + * AttributesImpl} interface.

+ * + *

This class provides a convenience implementation of the SAX + * {@link org.xml.sax.AttributeList AttributeList} interface. This + * implementation is useful both for SAX parser writers, who can use + * it to provide attributes to the application, and for SAX application + * writers, who can use it to create a persistent copy of an element's + * attribute specifications:

+ * + *
+ * private AttributeList myatts;
+ *
+ * public void startElement (String name, AttributeList atts)
+ * {
+ *              // create a persistent copy of the attribute list
+ *              // for use outside this method
+ *   myatts = new AttributeListImpl(atts);
+ *   [...]
+ * }
+ * 
+ * + *

Please note that SAX parsers are not required to use this + * class to provide an implementation of AttributeList; it is + * supplied only as an optional convenience. In particular, + * parser writers are encouraged to invent more efficient + * implementations.

+ * + * @deprecated This class implements a deprecated interface, + * {@link org.xml.sax.AttributeList AttributeList}; + * that interface has been replaced by + * {@link org.xml.sax.Attributes Attributes}, + * which is implemented in the + * {@link org.xml.sax.helpers.AttributesImpl + * AttributesImpl} helper class. + * @since SAX 1.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + * @see org.xml.sax.AttributeList + * @see org.xml.sax.DocumentHandler#startElement + */ +public class AttributeListImpl implements AttributeList +{ + + /** + * Create an empty attribute list. + * + *

This constructor is most useful for parser writers, who + * will use it to create a single, reusable attribute list that + * can be reset with the clear method between elements.

+ * + * @see #addAttribute + * @see #clear + */ + public AttributeListImpl () + { + } + + + /** + * Construct a persistent copy of an existing attribute list. + * + *

This constructor is most useful for application writers, + * who will use it to create a persistent copy of an existing + * attribute list.

+ * + * @param atts The attribute list to copy + * @see org.xml.sax.DocumentHandler#startElement + */ + public AttributeListImpl (AttributeList atts) + { + setAttributeList(atts); + } + + + + //////////////////////////////////////////////////////////////////// + // Methods specific to this class. + //////////////////////////////////////////////////////////////////// + + + /** + * Set the attribute list, discarding previous contents. + * + *

This method allows an application writer to reuse an + * attribute list easily.

+ * + * @param atts The attribute list to copy. + */ + public void setAttributeList (AttributeList atts) + { + int count = atts.getLength(); + + clear(); + + for (int i = 0; i < count; i++) { + addAttribute(atts.getName(i), atts.getType(i), atts.getValue(i)); + } + } + + + /** + * Add an attribute to an attribute list. + * + *

This method is provided for SAX parser writers, to allow them + * to build up an attribute list incrementally before delivering + * it to the application.

+ * + * @param name The attribute name. + * @param type The attribute type ("NMTOKEN" for an enumeration). + * @param value The attribute value (must not be null). + * @see #removeAttribute + * @see org.xml.sax.DocumentHandler#startElement + */ + public void addAttribute (String name, String type, String value) + { + names.addElement(name); + types.addElement(type); + values.addElement(value); + } + + + /** + * Remove an attribute from the list. + * + *

SAX application writers can use this method to filter an + * attribute out of an AttributeList. Note that invoking this + * method will change the length of the attribute list and + * some of the attribute's indices.

+ * + *

If the requested attribute is not in the list, this is + * a no-op.

+ * + * @param name The attribute name. + * @see #addAttribute + */ + public void removeAttribute (String name) + { + int i = names.indexOf(name); + + if (i >= 0) { + names.removeElementAt(i); + types.removeElementAt(i); + values.removeElementAt(i); + } + } + + + /** + * Clear the attribute list. + * + *

SAX parser writers can use this method to reset the attribute + * list between DocumentHandler.startElement events. Normally, + * it will make sense to reuse the same AttributeListImpl object + * rather than allocating a new one each time.

+ * + * @see org.xml.sax.DocumentHandler#startElement + */ + public void clear () + { + names.removeAllElements(); + types.removeAllElements(); + values.removeAllElements(); + } + + + + //////////////////////////////////////////////////////////////////// + // Implementation of org.xml.sax.AttributeList + //////////////////////////////////////////////////////////////////// + + + /** + * Return the number of attributes in the list. + * + * @return The number of attributes in the list. + * @see org.xml.sax.AttributeList#getLength + */ + public int getLength () + { + return names.size(); + } + + + /** + * Get the name of an attribute (by position). + * + * @param i The position of the attribute in the list. + * @return The attribute name as a string, or null if there + * is no attribute at that position. + * @see org.xml.sax.AttributeList#getName(int) + */ + public String getName (int i) + { + if (i < 0) { + return null; + } + try { + return (String)names.elementAt(i); + } catch (ArrayIndexOutOfBoundsException e) { + return null; + } + } + + + /** + * Get the type of an attribute (by position). + * + * @param i The position of the attribute in the list. + * @return The attribute type as a string ("NMTOKEN" for an + * enumeration, and "CDATA" if no declaration was + * read), or null if there is no attribute at + * that position. + * @see org.xml.sax.AttributeList#getType(int) + */ + public String getType (int i) + { + if (i < 0) { + return null; + } + try { + return (String)types.elementAt(i); + } catch (ArrayIndexOutOfBoundsException e) { + return null; + } + } + + + /** + * Get the value of an attribute (by position). + * + * @param i The position of the attribute in the list. + * @return The attribute value as a string, or null if + * there is no attribute at that position. + * @see org.xml.sax.AttributeList#getValue(int) + */ + public String getValue (int i) + { + if (i < 0) { + return null; + } + try { + return (String)values.elementAt(i); + } catch (ArrayIndexOutOfBoundsException e) { + return null; + } + } + + + /** + * Get the type of an attribute (by name). + * + * @param name The attribute name. + * @return The attribute type as a string ("NMTOKEN" for an + * enumeration, and "CDATA" if no declaration was + * read). + * @see org.xml.sax.AttributeList#getType(java.lang.String) + */ + public String getType (String name) + { + return getType(names.indexOf(name)); + } + + + /** + * Get the value of an attribute (by name). + * + * @param name The attribute name. + * @see org.xml.sax.AttributeList#getValue(java.lang.String) + */ + public String getValue (String name) + { + return getValue(names.indexOf(name)); + } + + + + //////////////////////////////////////////////////////////////////// + // Internal state. + //////////////////////////////////////////////////////////////////// + + Vector names = new Vector(); + Vector types = new Vector(); + Vector values = new Vector(); + +} + +// end of AttributeListImpl.java diff --git a/libjava/org/xml/sax/helpers/AttributesImpl.java b/libjava/org/xml/sax/helpers/AttributesImpl.java new file mode 100644 index 00000000000..b714f39fdb8 --- /dev/null +++ b/libjava/org/xml/sax/helpers/AttributesImpl.java @@ -0,0 +1,606 @@ +// AttributesImpl.java - default implementation of Attributes. +// Written by David Megginson, sax@megginson.com +// NO WARRANTY! This class is in the public domain. + +// $Id: AttributesImpl.java,v 1.2 2001/05/31 16:03:17 garyp Exp $ + + +package org.xml.sax.helpers; + +import org.xml.sax.Attributes; + + +/** + * Default implementation of the Attributes interface. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

This class provides a default implementation of the SAX2 + * {@link org.xml.sax.Attributes Attributes} interface, with the + * addition of manipulators so that the list can be modified or + * reused.

+ * + *

There are two typical uses of this class:

+ * + *
    + *
  1. to take a persistent snapshot of an Attributes object + * in a {@link org.xml.sax.ContentHandler#startElement startElement} event; or
  2. + *
  3. to construct or modify an Attributes object in a SAX2 driver or filter.
  4. + *
+ * + *

This class replaces the now-deprecated SAX1 {@link + * org.xml.sax.helpers.AttributeListImpl AttributeListImpl} + * class; in addition to supporting the updated Attributes + * interface rather than the deprecated {@link org.xml.sax.AttributeList + * AttributeList} interface, it also includes a much more efficient + * implementation using a single array rather than a set of Vectors.

+ * + * @since SAX 2.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + */ +public class AttributesImpl implements Attributes +{ + + + //////////////////////////////////////////////////////////////////// + // Constructors. + //////////////////////////////////////////////////////////////////// + + + /** + * Construct a new, empty AttributesImpl object. + */ + public AttributesImpl () + { + length = 0; + data = null; + } + + + /** + * Copy an existing Attributes object. + * + *

This constructor is especially useful inside a + * {@link org.xml.sax.ContentHandler#startElement startElement} event.

+ * + * @param atts The existing Attributes object. + */ + public AttributesImpl (Attributes atts) + { + setAttributes(atts); + } + + + + //////////////////////////////////////////////////////////////////// + // Implementation of org.xml.sax.Attributes. + //////////////////////////////////////////////////////////////////// + + + /** + * Return the number of attributes in the list. + * + * @return The number of attributes in the list. + * @see org.xml.sax.Attributes#getLength + */ + public int getLength () + { + return length; + } + + + /** + * Return an attribute's Namespace URI. + * + * @param index The attribute's index (zero-based). + * @return The Namespace URI, the empty string if none is + * available, or null if the index is out of range. + * @see org.xml.sax.Attributes#getURI + */ + public String getURI (int index) + { + if (index >= 0 && index < length) { + return data[index*5]; + } else { + return null; + } + } + + + /** + * Return an attribute's local name. + * + * @param index The attribute's index (zero-based). + * @return The attribute's local name, the empty string if + * none is available, or null if the index if out of range. + * @see org.xml.sax.Attributes#getLocalName + */ + public String getLocalName (int index) + { + if (index >= 0 && index < length) { + return data[index*5+1]; + } else { + return null; + } + } + + + /** + * Return an attribute's qualified (prefixed) name. + * + * @param index The attribute's index (zero-based). + * @return The attribute's qualified name, the empty string if + * none is available, or null if the index is out of bounds. + * @see org.xml.sax.Attributes#getQName + */ + public String getQName (int index) + { + if (index >= 0 && index < length) { + return data[index*5+2]; + } else { + return null; + } + } + + + /** + * Return an attribute's type by index. + * + * @param index The attribute's index (zero-based). + * @return The attribute's type, "CDATA" if the type is unknown, or null + * if the index is out of bounds. + * @see org.xml.sax.Attributes#getType(int) + */ + public String getType (int index) + { + if (index >= 0 && index < length) { + return data[index*5+3]; + } else { + return null; + } + } + + + /** + * Return an attribute's value by index. + * + * @param index The attribute's index (zero-based). + * @return The attribute's value or null if the index is out of bounds. + * @see org.xml.sax.Attributes#getValue(int) + */ + public String getValue (int index) + { + if (index >= 0 && index < length) { + return data[index*5+4]; + } else { + return null; + } + } + + + /** + * Look up an attribute's index by Namespace name. + * + *

In many cases, it will be more efficient to look up the name once and + * use the index query methods rather than using the name query methods + * repeatedly.

+ * + * @param uri The attribute's Namespace URI, or the empty + * string if none is available. + * @param localName The attribute's local name. + * @return The attribute's index, or -1 if none matches. + * @see org.xml.sax.Attributes#getIndex(java.lang.String,java.lang.String) + */ + public int getIndex (String uri, String localName) + { + int max = length * 5; + for (int i = 0; i < max; i += 5) { + if (data[i].equals(uri) && data[i+1].equals(localName)) { + return i / 5; + } + } + return -1; + } + + + /** + * Look up an attribute's index by qualified (prefixed) name. + * + * @param qName The qualified name. + * @return The attribute's index, or -1 if none matches. + * @see org.xml.sax.Attributes#getIndex(java.lang.String) + */ + public int getIndex (String qName) + { + int max = length * 5; + for (int i = 0; i < max; i += 5) { + if (data[i+2].equals(qName)) { + return i / 5; + } + } + return -1; + } + + + /** + * Look up an attribute's type by Namespace-qualified name. + * + * @param uri The Namespace URI, or the empty string for a name + * with no explicit Namespace URI. + * @param localName The local name. + * @return The attribute's type, or null if there is no + * matching attribute. + * @see org.xml.sax.Attributes#getType(java.lang.String,java.lang.String) + */ + public String getType (String uri, String localName) + { + int max = length * 5; + for (int i = 0; i < max; i += 5) { + if (data[i].equals(uri) && data[i+1].equals(localName)) { + return data[i+3]; + } + } + return null; + } + + + /** + * Look up an attribute's type by qualified (prefixed) name. + * + * @param qName The qualified name. + * @return The attribute's type, or null if there is no + * matching attribute. + * @see org.xml.sax.Attributes#getType(java.lang.String) + */ + public String getType (String qName) + { + int max = length * 5; + for (int i = 0; i < max; i += 5) { + if (data[i+2].equals(qName)) { + return data[i+3]; + } + } + return null; + } + + + /** + * Look up an attribute's value by Namespace-qualified name. + * + * @param uri The Namespace URI, or the empty string for a name + * with no explicit Namespace URI. + * @param localName The local name. + * @return The attribute's value, or null if there is no + * matching attribute. + * @see org.xml.sax.Attributes#getValue(java.lang.String,java.lang.String) + */ + public String getValue (String uri, String localName) + { + int max = length * 5; + for (int i = 0; i < max; i += 5) { + if (data[i].equals(uri) && data[i+1].equals(localName)) { + return data[i+4]; + } + } + return null; + } + + + /** + * Look up an attribute's value by qualified (prefixed) name. + * + * @param qName The qualified name. + * @return The attribute's value, or null if there is no + * matching attribute. + * @see org.xml.sax.Attributes#getValue(java.lang.String) + */ + public String getValue (String qName) + { + int max = length * 5; + for (int i = 0; i < max; i += 5) { + if (data[i+2].equals(qName)) { + return data[i+4]; + } + } + return null; + } + + + + //////////////////////////////////////////////////////////////////// + // Manipulators. + //////////////////////////////////////////////////////////////////// + + + /** + * Clear the attribute list for reuse. + * + *

Note that no memory is actually freed by this call: + * the current arrays are kept so that they can be + * reused.

+ */ + public void clear () + { + length = 0; + } + + + /** + * Copy an entire Attributes object. + * + *

It may be more efficient to reuse an existing object + * rather than constantly allocating new ones.

+ * + * @param atts The attributes to copy. + */ + public void setAttributes (Attributes atts) + { + clear(); + length = atts.getLength(); + data = new String[length*5]; + for (int i = 0; i < length; i++) { + data[i*5] = atts.getURI(i); + data[i*5+1] = atts.getLocalName(i); + data[i*5+2] = atts.getQName(i); + data[i*5+3] = atts.getType(i); + data[i*5+4] = atts.getValue(i); + } + } + + + /** + * Add an attribute to the end of the list. + * + *

For the sake of speed, this method does no checking + * to see if the attribute is already in the list: that is + * the responsibility of the application.

+ * + * @param uri The Namespace URI, or the empty string if + * none is available or Namespace processing is not + * being performed. + * @param localName The local name, or the empty string if + * Namespace processing is not being performed. + * @param qName The qualified (prefixed) name, or the empty string + * if qualified names are not available. + * @param type The attribute type as a string. + * @param value The attribute value. + */ + public void addAttribute (String uri, String localName, String qName, + String type, String value) + { + ensureCapacity(length+1); + data[length*5] = uri; + data[length*5+1] = localName; + data[length*5+2] = qName; + data[length*5+3] = type; + data[length*5+4] = value; + length++; + } + + + /** + * Set an attribute in the list. + * + *

For the sake of speed, this method does no checking + * for name conflicts or well-formedness: such checks are the + * responsibility of the application.

+ * + * @param index The index of the attribute (zero-based). + * @param uri The Namespace URI, or the empty string if + * none is available or Namespace processing is not + * being performed. + * @param localName The local name, or the empty string if + * Namespace processing is not being performed. + * @param qName The qualified name, or the empty string + * if qualified names are not available. + * @param type The attribute type as a string. + * @param value The attribute value. + * @exception java.lang.ArrayIndexOutOfBoundsException When the + * supplied index does not point to an attribute + * in the list. + */ + public void setAttribute (int index, String uri, String localName, + String qName, String type, String value) + { + if (index >= 0 && index < length) { + data[index*5] = uri; + data[index*5+1] = localName; + data[index*5+2] = qName; + data[index*5+3] = type; + data[index*5+4] = value; + } else { + badIndex(index); + } + } + + + /** + * Remove an attribute from the list. + * + * @param index The index of the attribute (zero-based). + * @exception java.lang.ArrayIndexOutOfBoundsException When the + * supplied index does not point to an attribute + * in the list. + */ + public void removeAttribute (int index) + { + if (index >= 0 && index < length) { + data[index*5] = null; + data[index*5+1] = null; + data[index*5+2] = null; + data[index*5+3] = null; + data[index*5+4] = null; + if (index < length - 1) { + System.arraycopy(data, (index+1)*5, data, index*5, + (length-index-1)*5); + } + length--; + } else { + badIndex(index); + } + } + + + /** + * Set the Namespace URI of a specific attribute. + * + * @param index The index of the attribute (zero-based). + * @param uri The attribute's Namespace URI, or the empty + * string for none. + * @exception java.lang.ArrayIndexOutOfBoundsException When the + * supplied index does not point to an attribute + * in the list. + */ + public void setURI (int index, String uri) + { + if (index >= 0 && index < length) { + data[index*5] = uri; + } else { + badIndex(index); + } + } + + + /** + * Set the local name of a specific attribute. + * + * @param index The index of the attribute (zero-based). + * @param localName The attribute's local name, or the empty + * string for none. + * @exception java.lang.ArrayIndexOutOfBoundsException When the + * supplied index does not point to an attribute + * in the list. + */ + public void setLocalName (int index, String localName) + { + if (index >= 0 && index < length) { + data[index*5+1] = localName; + } else { + badIndex(index); + } + } + + + /** + * Set the qualified name of a specific attribute. + * + * @param index The index of the attribute (zero-based). + * @param qName The attribute's qualified name, or the empty + * string for none. + * @exception java.lang.ArrayIndexOutOfBoundsException When the + * supplied index does not point to an attribute + * in the list. + */ + public void setQName (int index, String qName) + { + if (index >= 0 && index < length) { + data[index*5+2] = qName; + } else { + badIndex(index); + } + } + + + /** + * Set the type of a specific attribute. + * + * @param index The index of the attribute (zero-based). + * @param type The attribute's type. + * @exception java.lang.ArrayIndexOutOfBoundsException When the + * supplied index does not point to an attribute + * in the list. + */ + public void setType (int index, String type) + { + if (index >= 0 && index < length) { + data[index*5+3] = type; + } else { + badIndex(index); + } + } + + + /** + * Set the value of a specific attribute. + * + * @param index The index of the attribute (zero-based). + * @param value The attribute's value. + * @exception java.lang.ArrayIndexOutOfBoundsException When the + * supplied index does not point to an attribute + * in the list. + */ + public void setValue (int index, String value) + { + if (index >= 0 && index < length) { + data[index*5+4] = value; + } else { + badIndex(index); + } + } + + + + //////////////////////////////////////////////////////////////////// + // Internal methods. + //////////////////////////////////////////////////////////////////// + + + /** + * Ensure the internal array's capacity. + * + * @param n The minimum number of attributes that the array must + * be able to hold. + */ + private void ensureCapacity (int n) + { + if (n > 0 && data == null) { + data = new String[25]; + } + + int max = data.length; + if (max >= n * 5) { + return; + } + + + while (max < n * 5) { + max *= 2; + } + String newData[] = new String[max]; + System.arraycopy(data, 0, newData, 0, length*5); + data = newData; + } + + + /** + * Report a bad array index in a manipulator. + * + * @param index The index to report. + * @exception java.lang.ArrayIndexOutOfBoundsException Always. + */ + private void badIndex (int index) + throws ArrayIndexOutOfBoundsException + { + String msg = + "Attempt to modify attribute at illegal index: " + index; + throw new ArrayIndexOutOfBoundsException(msg); + } + + + + //////////////////////////////////////////////////////////////////// + // Internal state. + //////////////////////////////////////////////////////////////////// + + int length; + String data []; + +} + +// end of AttributesImpl.java + diff --git a/libjava/org/xml/sax/helpers/DefaultHandler.java b/libjava/org/xml/sax/helpers/DefaultHandler.java new file mode 100644 index 00000000000..dfda9c39a94 --- /dev/null +++ b/libjava/org/xml/sax/helpers/DefaultHandler.java @@ -0,0 +1,447 @@ +// DefaultHandler.java - default implementation of the core handlers. +// Written by David Megginson, sax@megginson.com +// NO WARRANTY! This class is in the public domain. + +// $Id: DefaultHandler.java,v 1.1 2000/10/02 02:43:20 sboag Exp $ + +package org.xml.sax.helpers; + +import org.xml.sax.InputSource; +import org.xml.sax.Locator; +import org.xml.sax.Attributes; +import org.xml.sax.EntityResolver; +import org.xml.sax.DTDHandler; +import org.xml.sax.ContentHandler; +import org.xml.sax.ErrorHandler; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; + + +/** + * Default base class for SAX2 event handlers. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

This class is available as a convenience base class for SAX2 + * applications: it provides default implementations for all of the + * callbacks in the four core SAX2 handler classes:

+ * + *
    + *
  • {@link org.xml.sax.EntityResolver EntityResolver}
  • + *
  • {@link org.xml.sax.DTDHandler DTDHandler}
  • + *
  • {@link org.xml.sax.ContentHandler ContentHandler}
  • + *
  • {@link org.xml.sax.ErrorHandler ErrorHandler}
  • + *
+ * + *

Application writers can extend this class when they need to + * implement only part of an interface; parser writers can + * instantiate this class to provide default handlers when the + * application has not supplied its own.

+ * + *

This class replaces the deprecated SAX1 + * {@link org.xml.sax.HandlerBase HandlerBase} class.

+ * + * @since SAX 2.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + * @see org.xml.sax.EntityResolver + * @see org.xml.sax.DTDHandler + * @see org.xml.sax.ContentHandler + * @see org.xml.sax.ErrorHandler + */ +public class DefaultHandler + implements EntityResolver, DTDHandler, ContentHandler, ErrorHandler +{ + + + //////////////////////////////////////////////////////////////////// + // Default implementation of the EntityResolver interface. + //////////////////////////////////////////////////////////////////// + + /** + * Resolve an external entity. + * + *

Always return null, so that the parser will use the system + * identifier provided in the XML document. This method implements + * the SAX default behaviour: application writers can override it + * in a subclass to do special translations such as catalog lookups + * or URI redirection.

+ * + * @param publicId The public identifer, or null if none is + * available. + * @param systemId The system identifier provided in the XML + * document. + * @return The new input source, or null to require the + * default behaviour. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.EntityResolver#resolveEntity + */ + public InputSource resolveEntity (String publicId, String systemId) + throws SAXException + { + return null; + } + + + + //////////////////////////////////////////////////////////////////// + // Default implementation of DTDHandler interface. + //////////////////////////////////////////////////////////////////// + + + /** + * Receive notification of a notation declaration. + * + *

By default, do nothing. Application writers may override this + * method in a subclass if they wish to keep track of the notations + * declared in a document.

+ * + * @param name The notation name. + * @param publicId The notation public identifier, or null if not + * available. + * @param systemId The notation system identifier. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.DTDHandler#notationDecl + */ + public void notationDecl (String name, String publicId, String systemId) + throws SAXException + { + // no op + } + + + /** + * Receive notification of an unparsed entity declaration. + * + *

By default, do nothing. Application writers may override this + * method in a subclass to keep track of the unparsed entities + * declared in a document.

+ * + * @param name The entity name. + * @param publicId The entity public identifier, or null if not + * available. + * @param systemId The entity system identifier. + * @param notationName The name of the associated notation. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.DTDHandler#unparsedEntityDecl + */ + public void unparsedEntityDecl (String name, String publicId, + String systemId, String notationName) + throws SAXException + { + // no op + } + + + + //////////////////////////////////////////////////////////////////// + // Default implementation of ContentHandler interface. + //////////////////////////////////////////////////////////////////// + + + /** + * Receive a Locator object for document events. + * + *

By default, do nothing. Application writers may override this + * method in a subclass if they wish to store the locator for use + * with other document events.

+ * + * @param locator A locator for all SAX document events. + * @see org.xml.sax.ContentHandler#setDocumentLocator + * @see org.xml.sax.Locator + */ + public void setDocumentLocator (Locator locator) + { + // no op + } + + + /** + * Receive notification of the beginning of the document. + * + *

By default, do nothing. Application writers may override this + * method in a subclass to take specific actions at the beginning + * of a document (such as allocating the root node of a tree or + * creating an output file).

+ * + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.ContentHandler#startDocument + */ + public void startDocument () + throws SAXException + { + // no op + } + + + /** + * Receive notification of the end of the document. + * + *

By default, do nothing. Application writers may override this + * method in a subclass to take specific actions at the end + * of a document (such as finalising a tree or closing an output + * file).

+ * + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.ContentHandler#endDocument + */ + public void endDocument () + throws SAXException + { + // no op + } + + + /** + * Receive notification of the start of a Namespace mapping. + * + *

By default, do nothing. Application writers may override this + * method in a subclass to take specific actions at the start of + * each Namespace prefix scope (such as storing the prefix mapping).

+ * + * @param prefix The Namespace prefix being declared. + * @param uri The Namespace URI mapped to the prefix. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.ContentHandler#startPrefixMapping + */ + public void startPrefixMapping (String prefix, String uri) + throws SAXException + { + // no op + } + + + /** + * Receive notification of the end of a Namespace mapping. + * + *

By default, do nothing. Application writers may override this + * method in a subclass to take specific actions at the end of + * each prefix mapping.

+ * + * @param prefix The Namespace prefix being declared. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.ContentHandler#endPrefixMapping + */ + public void endPrefixMapping (String prefix) + throws SAXException + { + // no op + } + + + /** + * Receive notification of the start of an element. + * + *

By default, do nothing. Application writers may override this + * method in a subclass to take specific actions at the start of + * each element (such as allocating a new tree node or writing + * output to a file).

+ * + * @param name The element type name. + * @param attributes The specified or defaulted attributes. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.ContentHandler#startElement + */ + public void startElement (String uri, String localName, + String qName, Attributes attributes) + throws SAXException + { + // no op + } + + + /** + * Receive notification of the end of an element. + * + *

By default, do nothing. Application writers may override this + * method in a subclass to take specific actions at the end of + * each element (such as finalising a tree node or writing + * output to a file).

+ * + * @param name The element type name. + * @param attributes The specified or defaulted attributes. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.ContentHandler#endElement + */ + public void endElement (String uri, String localName, String qName) + throws SAXException + { + // no op + } + + + /** + * Receive notification of character data inside an element. + * + *

By default, do nothing. Application writers may override this + * method to take specific actions for each chunk of character data + * (such as adding the data to a node or buffer, or printing it to + * a file).

+ * + * @param ch The characters. + * @param start The start position in the character array. + * @param length The number of characters to use from the + * character array. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.ContentHandler#characters + */ + public void characters (char ch[], int start, int length) + throws SAXException + { + // no op + } + + + /** + * Receive notification of ignorable whitespace in element content. + * + *

By default, do nothing. Application writers may override this + * method to take specific actions for each chunk of ignorable + * whitespace (such as adding data to a node or buffer, or printing + * it to a file).

+ * + * @param ch The whitespace characters. + * @param start The start position in the character array. + * @param length The number of characters to use from the + * character array. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.ContentHandler#ignorableWhitespace + */ + public void ignorableWhitespace (char ch[], int start, int length) + throws SAXException + { + // no op + } + + + /** + * Receive notification of a processing instruction. + * + *

By default, do nothing. Application writers may override this + * method in a subclass to take specific actions for each + * processing instruction, such as setting status variables or + * invoking other methods.

+ * + * @param target The processing instruction target. + * @param data The processing instruction data, or null if + * none is supplied. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.ContentHandler#processingInstruction + */ + public void processingInstruction (String target, String data) + throws SAXException + { + // no op + } + + + /** + * Receive notification of a skipped entity. + * + *

By default, do nothing. Application writers may override this + * method in a subclass to take specific actions for each + * processing instruction, such as setting status variables or + * invoking other methods.

+ * + * @param name The name of the skipped entity. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.ContentHandler#processingInstruction + */ + public void skippedEntity (String name) + throws SAXException + { + // no op + } + + + + //////////////////////////////////////////////////////////////////// + // Default implementation of the ErrorHandler interface. + //////////////////////////////////////////////////////////////////// + + + /** + * Receive notification of a parser warning. + * + *

The default implementation does nothing. Application writers + * may override this method in a subclass to take specific actions + * for each warning, such as inserting the message in a log file or + * printing it to the console.

+ * + * @param e The warning information encoded as an exception. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.ErrorHandler#warning + * @see org.xml.sax.SAXParseException + */ + public void warning (SAXParseException e) + throws SAXException + { + // no op + } + + + /** + * Receive notification of a recoverable parser error. + * + *

The default implementation does nothing. Application writers + * may override this method in a subclass to take specific actions + * for each error, such as inserting the message in a log file or + * printing it to the console.

+ * + * @param e The warning information encoded as an exception. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.ErrorHandler#warning + * @see org.xml.sax.SAXParseException + */ + public void error (SAXParseException e) + throws SAXException + { + // no op + } + + + /** + * Report a fatal XML parsing error. + * + *

The default implementation throws a SAXParseException. + * Application writers may override this method in a subclass if + * they need to take specific actions for each fatal error (such as + * collecting all of the errors into a single report): in any case, + * the application must stop all regular processing when this + * method is invoked, since the document is no longer reliable, and + * the parser may no longer report parsing events.

+ * + * @param e The error information encoded as an exception. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @see org.xml.sax.ErrorHandler#fatalError + * @see org.xml.sax.SAXParseException + */ + public void fatalError (SAXParseException e) + throws SAXException + { + throw e; + } + +} + +// end of DefaultHandler.java diff --git a/libjava/org/xml/sax/helpers/LocatorImpl.java b/libjava/org/xml/sax/helpers/LocatorImpl.java new file mode 100644 index 00000000000..634044ccff2 --- /dev/null +++ b/libjava/org/xml/sax/helpers/LocatorImpl.java @@ -0,0 +1,212 @@ +// SAX default implementation for Locator. +// No warranty; no copyright -- use this as you will. +// $Id: LocatorImpl.java,v 1.1 2000/10/02 02:43:20 sboag Exp $ + +package org.xml.sax.helpers; + +import org.xml.sax.Locator; + + +/** + * Provide an optional convenience implementation of Locator. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

This class is available mainly for application writers, who + * can use it to make a persistent snapshot of a locator at any + * point during a document parse:

+ * + *
+ * Locator locator;
+ * Locator startloc;
+ *
+ * public void setLocator (Locator locator)
+ * {
+ *         // note the locator
+ *   this.locator = locator;
+ * }
+ *
+ * public void startDocument ()
+ * {
+ *         // save the location of the start of the document
+ *         // for future use.
+ *   Locator startloc = new LocatorImpl(locator);
+ * }
+ *
+ * + *

Normally, parser writers will not use this class, since it + * is more efficient to provide location information only when + * requested, rather than constantly updating a Locator object.

+ * + * @since SAX 1.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + * @see org.xml.sax.Locator Locator + */ +public class LocatorImpl implements Locator +{ + + + /** + * Zero-argument constructor. + * + *

This will not normally be useful, since the main purpose + * of this class is to make a snapshot of an existing Locator.

+ */ + public LocatorImpl () + { + } + + + /** + * Copy constructor. + * + *

Create a persistent copy of the current state of a locator. + * When the original locator changes, this copy will still keep + * the original values (and it can be used outside the scope of + * DocumentHandler methods).

+ * + * @param locator The locator to copy. + */ + public LocatorImpl (Locator locator) + { + setPublicId(locator.getPublicId()); + setSystemId(locator.getSystemId()); + setLineNumber(locator.getLineNumber()); + setColumnNumber(locator.getColumnNumber()); + } + + + + //////////////////////////////////////////////////////////////////// + // Implementation of org.xml.sax.Locator + //////////////////////////////////////////////////////////////////// + + + /** + * Return the saved public identifier. + * + * @return The public identifier as a string, or null if none + * is available. + * @see org.xml.sax.Locator#getPublicId + * @see #setPublicId + */ + public String getPublicId () + { + return publicId; + } + + + /** + * Return the saved system identifier. + * + * @return The system identifier as a string, or null if none + * is available. + * @see org.xml.sax.Locator#getSystemId + * @see #setSystemId + */ + public String getSystemId () + { + return systemId; + } + + + /** + * Return the saved line number (1-based). + * + * @return The line number as an integer, or -1 if none is available. + * @see org.xml.sax.Locator#getLineNumber + * @see #setLineNumber + */ + public int getLineNumber () + { + return lineNumber; + } + + + /** + * Return the saved column number (1-based). + * + * @return The column number as an integer, or -1 if none is available. + * @see org.xml.sax.Locator#getColumnNumber + * @see #setColumnNumber + */ + public int getColumnNumber () + { + return columnNumber; + } + + + + //////////////////////////////////////////////////////////////////// + // Setters for the properties (not in org.xml.sax.Locator) + //////////////////////////////////////////////////////////////////// + + + /** + * Set the public identifier for this locator. + * + * @param publicId The new public identifier, or null + * if none is available. + * @see #getPublicId + */ + public void setPublicId (String publicId) + { + this.publicId = publicId; + } + + + /** + * Set the system identifier for this locator. + * + * @param systemId The new system identifier, or null + * if none is available. + * @see #getSystemId + */ + public void setSystemId (String systemId) + { + this.systemId = systemId; + } + + + /** + * Set the line number for this locator (1-based). + * + * @param lineNumber The line number, or -1 if none is available. + * @see #getLineNumber + */ + public void setLineNumber (int lineNumber) + { + this.lineNumber = lineNumber; + } + + + /** + * Set the column number for this locator (1-based). + * + * @param columnNumber The column number, or -1 if none is available. + * @see #getColumnNumber + */ + public void setColumnNumber (int columnNumber) + { + this.columnNumber = columnNumber; + } + + + + //////////////////////////////////////////////////////////////////// + // Internal state. + //////////////////////////////////////////////////////////////////// + + private String publicId; + private String systemId; + private int lineNumber; + private int columnNumber; + +} + +// end of LocatorImpl.java diff --git a/libjava/org/xml/sax/helpers/NamespaceSupport.java b/libjava/org/xml/sax/helpers/NamespaceSupport.java new file mode 100644 index 00000000000..a4588c3d2c7 --- /dev/null +++ b/libjava/org/xml/sax/helpers/NamespaceSupport.java @@ -0,0 +1,689 @@ +// NamespaceSupport.java - generic Namespace support for SAX. +// Written by David Megginson, sax@megginson.com +// This class is in the Public Domain. NO WARRANTY! + +// $Id: NamespaceSupport.java,v 1.1 2000/10/02 02:43:20 sboag Exp $ + +package org.xml.sax.helpers; + +import java.util.EmptyStackException; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Vector; + + +/** + * Encapsulate Namespace logic for use by SAX drivers. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

This class encapsulates the logic of Namespace processing: + * it tracks the declarations currently in force for each context + * and automatically processes qualified XML 1.0 names into their + * Namespace parts; it can also be used in reverse for generating + * XML 1.0 from Namespaces.

+ * + *

Namespace support objects are reusable, but the reset method + * must be invoked between each session.

+ * + *

Here is a simple session:

+ * + *
+ * String parts[] = new String[3];
+ * NamespaceSupport support = new NamespaceSupport();
+ *
+ * support.pushContext();
+ * support.declarePrefix("", "http://www.w3.org/1999/xhtml");
+ * support.declarePrefix("dc", "http://www.purl.org/dc#");
+ *
+ * String parts[] = support.processName("p", parts, false);
+ * System.out.println("Namespace URI: " + parts[0]);
+ * System.out.println("Local name: " + parts[1]);
+ * System.out.println("Raw name: " + parts[2]);
+
+ * String parts[] = support.processName("dc:title", parts, false);
+ * System.out.println("Namespace URI: " + parts[0]);
+ * System.out.println("Local name: " + parts[1]);
+ * System.out.println("Raw name: " + parts[2]);
+
+ * support.popContext();
+ * 
+ * + *

Note that this class is optimized for the use case where most + * elements do not contain Namespace declarations: if the same + * prefix/URI mapping is repeated for each context (for example), this + * class will be somewhat less efficient.

+ * + * @since SAX 2.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + */ +public class NamespaceSupport +{ + + + //////////////////////////////////////////////////////////////////// + // Constants. + //////////////////////////////////////////////////////////////////// + + + /** + * The XML Namespace as a constant. + * + *

This is the Namespace URI that is automatically mapped + * to the "xml" prefix.

+ */ + public final static String XMLNS = + "http://www.w3.org/XML/1998/namespace"; + + + /** + * An empty enumeration. + */ + private final static Enumeration EMPTY_ENUMERATION = + new Vector().elements(); + + + //////////////////////////////////////////////////////////////////// + // Constructor. + //////////////////////////////////////////////////////////////////// + + + /** + * Create a new Namespace support object. + */ + public NamespaceSupport () + { + reset(); + } + + + + //////////////////////////////////////////////////////////////////// + // Context management. + //////////////////////////////////////////////////////////////////// + + + /** + * Reset this Namespace support object for reuse. + * + *

It is necessary to invoke this method before reusing the + * Namespace support object for a new session.

+ */ + public void reset () + { + contexts = new Context[32]; + contextPos = 0; + contexts[contextPos] = currentContext = new Context(); + currentContext.declarePrefix("xml", XMLNS); + } + + + /** + * Start a new Namespace context. + * + *

Normally, you should push a new context at the beginning + * of each XML element: the new context will automatically inherit + * the declarations of its parent context, but it will also keep + * track of which declarations were made within this context.

+ * + *

The Namespace support object always starts with a base context + * already in force: in this context, only the "xml" prefix is + * declared.

+ * + * @see #popContext + */ + public void pushContext () + { + int max = contexts.length; + contextPos++; + + // Extend the array if necessary + if (contextPos >= max) { + Context newContexts[] = new Context[max*2]; + System.arraycopy(contexts, 0, newContexts, 0, max); + max *= 2; + contexts = newContexts; + } + + // Allocate the context if necessary. + currentContext = contexts[contextPos]; + if (currentContext == null) { + contexts[contextPos] = currentContext = new Context(); + } + + // Set the parent, if any. + if (contextPos > 0) { + currentContext.setParent(contexts[contextPos - 1]); + } + } + + + /** + * Revert to the previous Namespace context. + * + *

Normally, you should pop the context at the end of each + * XML element. After popping the context, all Namespace prefix + * mappings that were previously in force are restored.

+ * + *

You must not attempt to declare additional Namespace + * prefixes after popping a context, unless you push another + * context first.

+ * + * @see #pushContext + */ + public void popContext () + { + contextPos--; + if (contextPos < 0) { + throw new EmptyStackException(); + } + currentContext = contexts[contextPos]; + } + + + + //////////////////////////////////////////////////////////////////// + // Operations within a context. + //////////////////////////////////////////////////////////////////// + + + /** + * Declare a Namespace prefix. + * + *

This method declares a prefix in the current Namespace + * context; the prefix will remain in force until this context + * is popped, unless it is shadowed in a descendant context.

+ * + *

To declare a default Namespace, use the empty string. The + * prefix must not be "xml" or "xmlns".

+ * + *

Note that you must not declare a prefix after + * you've pushed and popped another Namespace.

+ * + *

Note that there is an asymmetry in this library: while {@link + * #getPrefix getPrefix} will not return the default "" prefix, + * even if you have declared one; to check for a default prefix, + * you have to look it up explicitly using {@link #getURI getURI}. + * This asymmetry exists to make it easier to look up prefixes + * for attribute names, where the default prefix is not allowed.

+ * + * @param prefix The prefix to declare, or null for the empty + * string. + * @param uri The Namespace URI to associate with the prefix. + * @return true if the prefix was legal, false otherwise + * @see #processName + * @see #getURI + * @see #getPrefix + */ + public boolean declarePrefix (String prefix, String uri) + { + if (prefix.equals("xml") || prefix.equals("xmlns")) { + return false; + } else { + currentContext.declarePrefix(prefix, uri); + return true; + } + } + + + /** + * Process a raw XML 1.0 name. + * + *

This method processes a raw XML 1.0 name in the current + * context by removing the prefix and looking it up among the + * prefixes currently declared. The return value will be the + * array supplied by the caller, filled in as follows:

+ * + *
+ *
parts[0]
+ *
The Namespace URI, or an empty string if none is + * in use.
+ *
parts[1]
+ *
The local name (without prefix).
+ *
parts[2]
+ *
The original raw name.
+ *
+ * + *

All of the strings in the array will be internalized. If + * the raw name has a prefix that has not been declared, then + * the return value will be null.

+ * + *

Note that attribute names are processed differently than + * element names: an unprefixed element name will received the + * default Namespace (if any), while an unprefixed element name + * will not.

+ * + * @param qName The raw XML 1.0 name to be processed. + * @param parts An array supplied by the caller, capable of + * holding at least three members. + * @param isAttribute A flag indicating whether this is an + * attribute name (true) or an element name (false). + * @return The supplied array holding three internalized strings + * representing the Namespace URI (or empty string), the + * local name, and the raw XML 1.0 name; or null if there + * is an undeclared prefix. + * @see #declarePrefix + * @see java.lang.String#intern */ + public String [] processName (String qName, String parts[], + boolean isAttribute) + { + String myParts[] = currentContext.processName(qName, isAttribute); + if (myParts == null) { + return null; + } else { + parts[0] = myParts[0]; + parts[1] = myParts[1]; + parts[2] = myParts[2]; + return parts; + } + } + + + /** + * Look up a prefix and get the currently-mapped Namespace URI. + * + *

This method looks up the prefix in the current context. + * Use the empty string ("") for the default Namespace.

+ * + * @param prefix The prefix to look up. + * @return The associated Namespace URI, or null if the prefix + * is undeclared in this context. + * @see #getPrefix + * @see #getPrefixes + */ + public String getURI (String prefix) + { + return currentContext.getURI(prefix); + } + + + /** + * Return an enumeration of all prefixes currently declared. + * + *

Note: if there is a default prefix, it will not be + * returned in this enumeration; check for the default prefix + * using the {@link #getURI getURI} with an argument of "".

+ * + * @return An enumeration of all prefixes declared in the + * current context except for the empty (default) + * prefix. + * @see #getDeclaredPrefixes + * @see #getURI + */ + public Enumeration getPrefixes () + { + return currentContext.getPrefixes(); + } + + + /** + * Return one of the prefixes mapped to a Namespace URI. + * + *

If more than one prefix is currently mapped to the same + * URI, this method will make an arbitrary selection; if you + * want all of the prefixes, use the {@link #getPrefixes} + * method instead.

+ * + *

Note: this will never return the empty (default) prefix; + * to check for a default prefix, use the {@link #getURI getURI} + * method with an argument of "".

+ * + * @param uri The Namespace URI. + * @param isAttribute true if this prefix is for an attribute + * (and the default Namespace is not allowed). + * @return One of the prefixes currently mapped to the URI supplied, + * or null if none is mapped or if the URI is assigned to + * the default Namespace. + * @see #getPrefixes(java.lang.String) + * @see #getURI + */ + public String getPrefix (String uri) + { + return currentContext.getPrefix(uri); + } + + + /** + * Return an enumeration of all prefixes currently declared for a URI. + * + *

This method returns prefixes mapped to a specific Namespace + * URI. The xml: prefix will be included. If you want only one + * prefix that's mapped to the Namespace URI, and you don't care + * which one you get, use the {@link #getPrefix getPrefix} + * method instead.

+ * + *

Note: the empty (default) prefix is never included + * in this enumeration; to check for the presence of a default + * Namespace, use the {@link #getURI getURI} method with an + * argument of "".

+ * + * @param uri The Namespace URI. + * @return An enumeration of all prefixes declared in the + * current context. + * @see #getPrefix + * @see #getDeclaredPrefixes + * @see #getURI + */ + public Enumeration getPrefixes (String uri) + { + Vector prefixes = new Vector(); + Enumeration allPrefixes = getPrefixes(); + while (allPrefixes.hasMoreElements()) { + String prefix = (String)allPrefixes.nextElement(); + if (uri.equals(getURI(prefix))) { + prefixes.addElement(prefix); + } + } + return prefixes.elements(); + } + + + /** + * Return an enumeration of all prefixes declared in this context. + * + *

The empty (default) prefix will be included in this + * enumeration; note that this behaviour differs from that of + * {@link #getPrefix} and {@link #getPrefixes}.

+ * + * @return An enumeration of all prefixes declared in this + * context. + * @see #getPrefixes + * @see #getURI + */ + public Enumeration getDeclaredPrefixes () + { + return currentContext.getDeclaredPrefixes(); + } + + + + //////////////////////////////////////////////////////////////////// + // Internal state. + //////////////////////////////////////////////////////////////////// + + private Context contexts[]; + private Context currentContext; + private int contextPos; + + + + //////////////////////////////////////////////////////////////////// + // Internal classes. + //////////////////////////////////////////////////////////////////// + + /** + * Internal class for a single Namespace context. + * + *

This module caches and reuses Namespace contexts, so the number allocated + * will be equal to the element depth of the document, not to the total + * number of elements (i.e. 5-10 rather than tens of thousands).

+ */ + final class Context { + + /** + * Create the root-level Namespace context. + */ + Context () + { + copyTables(); + } + + + /** + * (Re)set the parent of this Namespace context. + * + * @param context The parent Namespace context object. + */ + void setParent (Context parent) + { + this.parent = parent; + declarations = null; + prefixTable = parent.prefixTable; + uriTable = parent.uriTable; + elementNameTable = parent.elementNameTable; + attributeNameTable = parent.attributeNameTable; + defaultNS = parent.defaultNS; + tablesDirty = false; + } + + + /** + * Declare a Namespace prefix for this context. + * + * @param prefix The prefix to declare. + * @param uri The associated Namespace URI. + * @see org.xml.sax.helpers.NamespaceSupport#declarePrefix + */ + void declarePrefix (String prefix, String uri) + { + // Lazy processing... + if (!tablesDirty) { + copyTables(); + } + if (declarations == null) { + declarations = new Vector(); + } + + prefix = prefix.intern(); + uri = uri.intern(); + if ("".equals(prefix)) { + if ("".equals(uri)) { + defaultNS = null; + } else { + defaultNS = uri; + } + } else { + prefixTable.put(prefix, uri); + uriTable.put(uri, prefix); // may wipe out another prefix + } + declarations.addElement(prefix); + } + + + /** + * Process a raw XML 1.0 name in this context. + * + * @param qName The raw XML 1.0 name. + * @param isAttribute true if this is an attribute name. + * @return An array of three strings containing the + * URI part (or empty string), the local part, + * and the raw name, all internalized, or null + * if there is an undeclared prefix. + * @see org.xml.sax.helpers.NamespaceSupport#processName + */ + String [] processName (String qName, boolean isAttribute) + { + String name[]; + Hashtable table; + + // Select the appropriate table. + if (isAttribute) { + table = elementNameTable; + } else { + table = attributeNameTable; + } + + // Start by looking in the cache, and + // return immediately if the name + // is already known in this content + name = (String[])table.get(qName); + if (name != null) { + return name; + } + + // We haven't seen this name in this + // context before. + name = new String[3]; + int index = qName.indexOf(':'); + + + // No prefix. + if (index == -1) { + if (isAttribute || defaultNS == null) { + name[0] = ""; + } else { + name[0] = defaultNS; + } + name[1] = qName.intern(); + name[2] = name[1]; + } + + // Prefix + else { + String prefix = qName.substring(0, index); + String local = qName.substring(index+1); + String uri; + if ("".equals(prefix)) { + uri = defaultNS; + } else { + uri = (String)prefixTable.get(prefix); + } + if (uri == null) { + return null; + } + name[0] = uri; + name[1] = local.intern(); + name[2] = qName.intern(); + } + + // Save in the cache for future use. + table.put(name[2], name); + tablesDirty = true; + return name; + } + + + /** + * Look up the URI associated with a prefix in this context. + * + * @param prefix The prefix to look up. + * @return The associated Namespace URI, or null if none is + * declared. + * @see org.xml.sax.helpers.NamespaceSupport#getURI + */ + String getURI (String prefix) + { + if ("".equals(prefix)) { + return defaultNS; + } else if (prefixTable == null) { + return null; + } else { + return (String)prefixTable.get(prefix); + } + } + + + /** + * Look up one of the prefixes associated with a URI in this context. + * + *

Since many prefixes may be mapped to the same URI, + * the return value may be unreliable.

+ * + * @param uri The URI to look up. + * @return The associated prefix, or null if none is declared. + * @see org.xml.sax.helpers.NamespaceSupport#getPrefix + */ + String getPrefix (String uri) + { + if (uriTable == null) { + return null; + } else { + return (String)uriTable.get(uri); + } + } + + + /** + * Return an enumeration of prefixes declared in this context. + * + * @return An enumeration of prefixes (possibly empty). + * @see org.xml.sax.helpers.NamespaceSupport#getDeclaredPrefixes + */ + Enumeration getDeclaredPrefixes () + { + if (declarations == null) { + return EMPTY_ENUMERATION; + } else { + return declarations.elements(); + } + } + + + /** + * Return an enumeration of all prefixes currently in force. + * + *

The default prefix, if in force, is not + * returned, and will have to be checked for separately.

+ * + * @return An enumeration of prefixes (never empty). + * @see org.xml.sax.helpers.NamespaceSupport#getPrefixes + */ + Enumeration getPrefixes () + { + if (prefixTable == null) { + return EMPTY_ENUMERATION; + } else { + return prefixTable.keys(); + } + } + + + + //////////////////////////////////////////////////////////////// + // Internal methods. + //////////////////////////////////////////////////////////////// + + + /** + * Copy on write for the internal tables in this context. + * + *

This class is optimized for the normal case where most + * elements do not contain Namespace declarations.

+ */ + private void copyTables () + { + if (prefixTable != null) { + prefixTable = (Hashtable)prefixTable.clone(); + } else { + prefixTable = new Hashtable(); + } + if (uriTable != null) { + uriTable = (Hashtable)uriTable.clone(); + } else { + uriTable = new Hashtable(); + } + elementNameTable = new Hashtable(); + attributeNameTable = new Hashtable(); + tablesDirty = true; + } + + + + //////////////////////////////////////////////////////////////// + // Protected state. + //////////////////////////////////////////////////////////////// + + Hashtable prefixTable; + Hashtable uriTable; + Hashtable elementNameTable; + Hashtable attributeNameTable; + String defaultNS = null; + + + + //////////////////////////////////////////////////////////////// + // Internal state. + //////////////////////////////////////////////////////////////// + + private Vector declarations = null; + private boolean tablesDirty = false; + private Context parent = null; + } +} + +// end of NamespaceSupport.java diff --git a/libjava/org/xml/sax/helpers/ParserAdapter.java b/libjava/org/xml/sax/helpers/ParserAdapter.java new file mode 100644 index 00000000000..06071b7bdd5 --- /dev/null +++ b/libjava/org/xml/sax/helpers/ParserAdapter.java @@ -0,0 +1,1008 @@ +// ParserAdapter.java - adapt a SAX1 Parser to a SAX2 XMLReader. +// Written by David Megginson, sax@megginson.com +// NO WARRANTY! This class is in the public domain. + +// $Id: ParserAdapter.java,v 1.1 2000/10/02 02:43:20 sboag Exp $ + +package org.xml.sax.helpers; + +import java.io.IOException; +import java.util.Enumeration; + +import org.xml.sax.Parser; // deprecated +import org.xml.sax.InputSource; +import org.xml.sax.Locator; +import org.xml.sax.AttributeList; // deprecated +import org.xml.sax.EntityResolver; +import org.xml.sax.DTDHandler; +import org.xml.sax.DocumentHandler; // deprecated +import org.xml.sax.ErrorHandler; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; + +import org.xml.sax.XMLReader; +import org.xml.sax.Attributes; +import org.xml.sax.ContentHandler; +import org.xml.sax.SAXNotRecognizedException; +import org.xml.sax.SAXNotSupportedException; + + +/** + * Adapt a SAX1 Parser as a SAX2 XMLReader. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

This class wraps a SAX1 {@link org.xml.sax.Parser Parser} + * and makes it act as a SAX2 {@link org.xml.sax.XMLReader XMLReader}, + * with feature, property, and Namespace support. Note + * that it is not possible to report {@link org.xml.sax.ContentHandler#skippedEntity + * skippedEntity} events, since SAX1 does not make that information available.

+ * + *

This adapter does not test for duplicate Namespace-qualified + * attribute names.

+ * + * @since SAX 2.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + * @see org.xml.sax.helpers.XMLReaderAdapter + * @see org.xml.sax.XMLReader + * @see org.xml.sax.Parser + */ +public class ParserAdapter implements XMLReader, DocumentHandler +{ + + + //////////////////////////////////////////////////////////////////// + // Constructors. + //////////////////////////////////////////////////////////////////// + + + /** + * Construct a new parser adapter. + * + *

Use the "org.xml.sax.parser" property to locate the + * embedded SAX1 driver.

+ * + * @exception org.xml.sax.SAXException If the embedded driver + * cannot be instantiated or if the + * org.xml.sax.parser property is not specified. + */ + public ParserAdapter () + throws SAXException + { + super(); + + String driver = System.getProperty("org.xml.sax.parser"); + + try { + setup(ParserFactory.makeParser()); + } catch (ClassNotFoundException e1) { + throw new + SAXException("Cannot find SAX1 driver class " + + driver, e1); + } catch (IllegalAccessException e2) { + throw new + SAXException("SAX1 driver class " + + driver + + " found but cannot be loaded", e2); + } catch (InstantiationException e3) { + throw new + SAXException("SAX1 driver class " + + driver + + " loaded but cannot be instantiated", e3); + } catch (ClassCastException e4) { + throw new + SAXException("SAX1 driver class " + + driver + + " does not implement org.xml.sax.Parser"); + } catch (NullPointerException e5) { + throw new + SAXException("System property org.xml.sax.parser not specified"); + } + } + + + /** + * Construct a new parser adapter. + * + *

Note that the embedded parser cannot be changed once the + * adapter is created; to embed a different parser, allocate + * a new ParserAdapter.

+ * + * @param parser The SAX1 parser to embed. + * @exception java.lang.NullPointerException If the parser parameter + * is null. + */ + public ParserAdapter (Parser parser) + { + super(); + setup(parser); + } + + + /** + * Internal setup method. + * + * @param parser The embedded parser. + * @exception java.lang.NullPointerException If the parser parameter + * is null. + */ + private void setup (Parser parser) + { + if (parser == null) { + throw new + NullPointerException("Parser argument must not be null"); + } + this.parser = parser; + atts = new AttributesImpl(); + nsSupport = new NamespaceSupport(); + attAdapter = new AttributeListAdapter(); + } + + + + //////////////////////////////////////////////////////////////////// + // Implementation of org.xml.sax.XMLReader. + //////////////////////////////////////////////////////////////////// + + + // + // Internal constants for the sake of convenience. + // + private final static String FEATURES = "http://xml.org/sax/features/"; + private final static String NAMESPACES = FEATURES + "namespaces"; + private final static String NAMESPACE_PREFIXES = FEATURES + "namespace-prefixes"; + private final static String VALIDATION = FEATURES + "validation"; + private final static String EXTERNAL_GENERAL = + FEATURES + "external-general-entities"; + private final static String EXTERNAL_PARAMETER = + FEATURES + "external-parameter-entities"; + + + /** + * Set a feature for the parser. + * + *

The only features supported are namespaces and + * namespace-prefixes.

+ * + * @param name The feature name, as a complete URI. + * @param state The requested feature state. + * @exception org.xml.sax.SAXNotRecognizedException If the feature + * name is not known. + * @exception org.xml.sax.SAXNotSupportedException If the feature + * state is not supported. + * @see org.xml.sax.XMLReader#setFeature + */ + public void setFeature (String name, boolean state) + throws SAXNotRecognizedException, SAXNotSupportedException + { + if (name.equals(NAMESPACES)) { + checkNotParsing("feature", name); + namespaces = state; + if (!namespaces && !prefixes) { + prefixes = true; + } + } else if (name.equals(NAMESPACE_PREFIXES)) { + checkNotParsing("feature", name); + prefixes = state; + if (!prefixes && !namespaces) { + namespaces = true; + } + } else if (name.equals(VALIDATION) || + name.equals(EXTERNAL_GENERAL) || + name.equals(EXTERNAL_PARAMETER)) { + throw new SAXNotSupportedException("Feature: " + name); + } else { + throw new SAXNotRecognizedException("Feature: " + name); + } + } + + + /** + * Check a parser feature. + * + *

The only features supported are namespaces and + * namespace-prefixes.

+ * + * @param name The feature name, as a complete URI. + * @return The current feature state. + * @exception org.xml.sax.SAXNotRecognizedException If the feature + * name is not known. + * @exception org.xml.sax.SAXNotSupportedException If querying the + * feature state is not supported. + * @see org.xml.sax.XMLReader#setFeature + */ + public boolean getFeature (String name) + throws SAXNotRecognizedException, SAXNotSupportedException + { + if (name.equals(NAMESPACES)) { + return namespaces; + } else if (name.equals(NAMESPACE_PREFIXES)) { + return prefixes; + } else if (name.equals(VALIDATION) || + name.equals(EXTERNAL_GENERAL) || + name.equals(EXTERNAL_PARAMETER)) { + throw new SAXNotSupportedException("Feature: " + name); + } else { + throw new SAXNotRecognizedException("Feature: " + name); + } + } + + + /** + * Set a parser property. + * + *

No special properties are currently supported.

+ * + * @param name The property name. + * @param value The property value. + * @exception org.xml.sax.SAXNotRecognizedException If the feature + * name is not known. + * @exception org.xml.sax.SAXNotSupportedException If the feature + * state is not supported. + * @see org.xml.sax.XMLReader#setProperty + */ + public void setProperty (String name, Object value) + throws SAXNotRecognizedException, SAXNotSupportedException + { + throw new SAXNotRecognizedException("Property: " + name); + } + + + /** + * Get a parser property. + * + *

No special properties are currently supported.

+ * + * @param name The property name. + * @return The property value. + * @exception org.xml.sax.SAXNotRecognizedException If the feature + * name is not known. + * @exception org.xml.sax.SAXNotSupportedException If the feature + * state is not supported. + * @see org.xml.sax.XMLReader#getProperty + */ + public Object getProperty (String name) + throws SAXNotRecognizedException, SAXNotSupportedException + { + throw new SAXNotRecognizedException("Property: " + name); + } + + + /** + * Set the entity resolver. + * + * @param resolver The new entity resolver. + * @exception java.lang.NullPointerException If the entity resolver + * parameter is null. + * @see org.xml.sax.XMLReader#setEntityResolver + */ + public void setEntityResolver (EntityResolver resolver) + { + if (resolver == null) { + throw new NullPointerException("Null entity resolver"); + } + entityResolver = resolver; + } + + + /** + * Return the current entity resolver. + * + * @return The current entity resolver, or null if none was supplied. + * @see org.xml.sax.XMLReader#getEntityResolver + */ + public EntityResolver getEntityResolver () + { + return entityResolver; + } + + + /** + * Set the DTD handler. + * + * @param resolver The new DTD handler. + * @exception java.lang.NullPointerException If the DTD handler + * parameter is null. + * @see org.xml.sax.XMLReader#setEntityResolver + */ + public void setDTDHandler (DTDHandler handler) + { + if (handler == null) { + throw new NullPointerException("Null DTD handler"); + } + dtdHandler = handler; + } + + + /** + * Return the current DTD handler. + * + * @return The current DTD handler, or null if none was supplied. + * @see org.xml.sax.XMLReader#getEntityResolver + */ + public DTDHandler getDTDHandler () + { + return dtdHandler; + } + + + /** + * Set the content handler. + * + * @param resolver The new content handler. + * @exception java.lang.NullPointerException If the content handler + * parameter is null. + * @see org.xml.sax.XMLReader#setEntityResolver + */ + public void setContentHandler (ContentHandler handler) + { + if (handler == null) { + throw new NullPointerException("Null content handler"); + } + contentHandler = handler; + } + + + /** + * Return the current content handler. + * + * @return The current content handler, or null if none was supplied. + * @see org.xml.sax.XMLReader#getEntityResolver + */ + public ContentHandler getContentHandler () + { + return contentHandler; + } + + + /** + * Set the error handler. + * + * @param resolver The new error handler. + * @exception java.lang.NullPointerException If the error handler + * parameter is null. + * @see org.xml.sax.XMLReader#setEntityResolver + */ + public void setErrorHandler (ErrorHandler handler) + { + if (handler == null) { + throw new NullPointerException("Null error handler"); + } + errorHandler = handler; + } + + + /** + * Return the current error handler. + * + * @return The current error handler, or null if none was supplied. + * @see org.xml.sax.XMLReader#getEntityResolver + */ + public ErrorHandler getErrorHandler () + { + return errorHandler; + } + + + /** + * Parse an XML document. + * + * @param systemId The absolute URL of the document. + * @exception java.io.IOException If there is a problem reading + * the raw content of the document. + * @exception org.xml.sax.SAXException If there is a problem + * processing the document. + * @see #parse(org.xml.sax.InputSource) + * @see org.xml.sax.Parser#parse(java.lang.String) + */ + public void parse (String systemId) + throws IOException, SAXException + { + parse(new InputSource(systemId)); + } + + + /** + * Parse an XML document. + * + * @param input An input source for the document. + * @exception java.io.IOException If there is a problem reading + * the raw content of the document. + * @exception org.xml.sax.SAXException If there is a problem + * processing the document. + * @see #parse(java.lang.String) + * @see org.xml.sax.Parser#parse(org.xml.sax.InputSource) + */ + public void parse (InputSource input) + throws IOException, SAXException + { + if (parsing) { + throw new SAXException("Parser is already in use"); + } + setupParser(); + parsing = true; + try { + parser.parse(input); + } finally { + parsing = false; + } + parsing = false; + } + + + + //////////////////////////////////////////////////////////////////// + // Implementation of org.xml.sax.DocumentHandler. + //////////////////////////////////////////////////////////////////// + + + /** + * Adapt a SAX1 document locator event. + * + * @param locator A document locator. + * @see org.xml.sax.ContentHandler#setDocumentLocator + */ + public void setDocumentLocator (Locator locator) + { + this.locator = locator; + if (contentHandler != null) { + contentHandler.setDocumentLocator(locator); + } + } + + + /** + * Adapt a SAX1 start document event. + * + * @exception org.xml.sax.SAXException The client may raise a + * processing exception. + * @see org.xml.sax.DocumentHandler#startDocument + */ + public void startDocument () + throws SAXException + { + if (contentHandler != null) { + contentHandler.startDocument(); + } + } + + + /** + * Adapt a SAX1 end document event. + * + * @exception org.xml.sax.SAXException The client may raise a + * processing exception. + * @see org.xml.sax.DocumentHandler#endDocument + */ + public void endDocument () + throws SAXException + { + if (contentHandler != null) { + contentHandler.endDocument(); + } + } + + + /** + * Adapt a SAX1 startElement event. + * + *

If necessary, perform Namespace processing.

+ * + * @param qName The qualified (prefixed) name. + * @param qAtts The XML 1.0 attribute list (with qnames). + */ + public void startElement (String qName, AttributeList qAtts) + throws SAXException + { + // If we're not doing Namespace + // processing, dispatch this quickly. + if (!namespaces) { + if (contentHandler != null) { + attAdapter.setAttributeList(qAtts); + contentHandler.startElement("", "", qName.intern(), + attAdapter); + } + return; + } + + + // OK, we're doing Namespace processing. + nsSupport.pushContext(); + boolean seenDecl = false; + atts.clear(); + + // Take a first pass and copy all + // attributes into the SAX2 attribute + // list, noting any Namespace + // declarations. + int length = qAtts.getLength(); + for (int i = 0; i < length; i++) { + String attQName = qAtts.getName(i); + String type = qAtts.getType(i); + String value = qAtts.getValue(i); + + // Found a declaration... + if (attQName.startsWith("xmlns")) { + String prefix; + int n = attQName.indexOf(':'); + if (n == -1) { + prefix = ""; + } else { + prefix = attQName.substring(n+1); + } + if (!nsSupport.declarePrefix(prefix, value)) { + reportError("Illegal Namespace prefix: " + prefix); + } + if (contentHandler != null) { + contentHandler.startPrefixMapping(prefix, value); + } + // We may still have to add this to + // the list. + if (prefixes) { + atts.addAttribute("", "", attQName.intern(), + type, value); + } + seenDecl = true; + + // This isn't a declaration. + } else { + String attName[] = processName(attQName, true); + atts.addAttribute(attName[0], attName[1], attName[2], + type, value); + } + } + + // If there was a Namespace declaration, + // we have to make a second pass just + // to be safe -- this will happen very + // rarely, possibly only once for each + // document. + if (seenDecl) { + length = atts.getLength(); + for (int i = 0; i < length; i++) { + String attQName = atts.getQName(i); + if (!attQName.startsWith("xmlns")) { + String attName[] = processName(attQName, true); + atts.setURI(i, attName[0]); + atts.setLocalName(i, attName[1]); + } + } + } + + // OK, finally report the event. + if (contentHandler != null) { + String name[] = processName(qName, false); + contentHandler.startElement(name[0], name[1], name[2], atts); + } + } + + + /** + * Adapt a SAX1 end element event. + * + * @param qName The qualified (prefixed) name. + * @exception org.xml.sax.SAXException The client may raise a + * processing exception. + * @see org.xml.sax.DocumentHandler#endElement + */ + public void endElement (String qName) + throws SAXException + { + // If we're not doing Namespace + // processing, dispatch this quickly. + if (!namespaces) { + if (contentHandler != null) { + contentHandler.endElement("", "", qName.intern()); + } + return; + } + + // Split the name. + String names[] = processName(qName, false); + if (contentHandler != null) { + contentHandler.endElement(names[0], names[1], names[2]); + Enumeration prefixes = nsSupport.getDeclaredPrefixes(); + while (prefixes.hasMoreElements()) { + String prefix = (String)prefixes.nextElement(); + contentHandler.endPrefixMapping(prefix); + } + } + nsSupport.popContext(); + } + + + /** + * Adapt a SAX1 characters event. + * + * @param ch An array of characters. + * @param start The starting position in the array. + * @param length The number of characters to use. + * @exception org.xml.sax.SAXException The client may raise a + * processing exception. + * @see org.xml.sax.DocumentHandler#characters + */ + public void characters (char ch[], int start, int length) + throws SAXException + { + if (contentHandler != null) { + contentHandler.characters(ch, start, length); + } + } + + + /** + * Adapt a SAX1 ignorable whitespace event. + * + * @param ch An array of characters. + * @param start The starting position in the array. + * @param length The number of characters to use. + * @exception org.xml.sax.SAXException The client may raise a + * processing exception. + * @see org.xml.sax.DocumentHandler#ignorableWhitespace + */ + public void ignorableWhitespace (char ch[], int start, int length) + throws SAXException + { + if (contentHandler != null) { + contentHandler.ignorableWhitespace(ch, start, length); + } + } + + + /** + * Adapt a SAX1 processing instruction event. + * + * @param target The processing instruction target. + * @param data The remainder of the processing instruction + * @exception org.xml.sax.SAXException The client may raise a + * processing exception. + * @see org.xml.sax.DocumentHandler#processingInstruction + */ + public void processingInstruction (String target, String data) + throws SAXException + { + if (contentHandler != null) { + contentHandler.processingInstruction(target, data); + } + } + + + + //////////////////////////////////////////////////////////////////// + // Internal utility methods. + //////////////////////////////////////////////////////////////////// + + + /** + * Initialize the parser before each run. + */ + private void setupParser () + { + nsSupport.reset(); + + if (entityResolver != null) { + parser.setEntityResolver(entityResolver); + } + if (dtdHandler != null) { + parser.setDTDHandler(dtdHandler); + } + if (errorHandler != null) { + parser.setErrorHandler(errorHandler); + } + parser.setDocumentHandler(this); + locator = null; + } + + + /** + * Process a qualified (prefixed) name. + * + *

If the name has an undeclared prefix, use only the qname + * and make an ErrorHandler.error callback in case the app is + * interested.

+ * + * @param qName The qualified (prefixed) name. + * @param isAttribute true if this is an attribute name. + * @return The name split into three parts. + * @exception org.xml.sax.SAXException The client may throw + * an exception if there is an error callback. + */ + private String [] processName (String qName, boolean isAttribute) + throws SAXException + { + String parts[] = nsSupport.processName(qName, nameParts, + isAttribute); + if (parts == null) { + parts = new String[3]; + parts[2] = qName.intern(); + reportError("Undeclared prefix: " + qName); + } + return parts; + } + + + /** + * Report a non-fatal error. + * + * @param message The error message. + * @exception org.xml.sax.SAXException The client may throw + * an exception. + */ + void reportError (String message) + throws SAXException + { + if (errorHandler == null) { + return; + } + + SAXParseException e; + if (locator != null) { + e = new SAXParseException(message, locator); + } else { + e = new SAXParseException(message, null, null, -1, -1); + } + errorHandler.error(e); + } + + + /** + * Throw an exception if we are parsing. + * + *

Use this method to detect illegal feature or + * property changes.

+ * + * @param type The type of thing (feature or property). + * @param name The feature or property name. + * @exception org.xml.sax.SAXNotSupportedException If a + * document is currently being parsed. + */ + private void checkNotParsing (String type, String name) + throws SAXNotSupportedException + { + if (parsing) { + throw new SAXNotSupportedException("Cannot change " + + type + ' ' + + name + " while parsing"); + + } + } + + + + //////////////////////////////////////////////////////////////////// + // Internal state. + //////////////////////////////////////////////////////////////////// + + private NamespaceSupport nsSupport; + private AttributeListAdapter attAdapter; + + private boolean parsing = false; + private String nameParts[] = new String[3]; + + private Parser parser = null; + + private AttributesImpl atts = null; + + // Features + private boolean namespaces = true; + private boolean prefixes = false; + + // Properties + + // Handlers + Locator locator; + + EntityResolver entityResolver = null; + DTDHandler dtdHandler = null; + ContentHandler contentHandler = null; + ErrorHandler errorHandler = null; + + + + //////////////////////////////////////////////////////////////////// + // Inner class to wrap an AttributeList when not doing NS proc. + //////////////////////////////////////////////////////////////////// + + + /** + * Adapt a SAX1 AttributeList as a SAX2 Attributes object. + * + *

This class is in the Public Domain, and comes with NO + * WARRANTY of any kind.

+ * + *

This wrapper class is used only when Namespace support + * is disabled -- it provides pretty much a direct mapping + * from SAX1 to SAX2, except that names and types are + * interned whenever requested.

+ */ + final class AttributeListAdapter implements Attributes + { + + /** + * Construct a new adapter. + */ + AttributeListAdapter () + { + } + + + /** + * Set the embedded AttributeList. + * + *

This method must be invoked before any of the others + * can be used.

+ * + * @param The SAX1 attribute list (with qnames). + */ + void setAttributeList (AttributeList qAtts) + { + this.qAtts = qAtts; + } + + + /** + * Return the length of the attribute list. + * + * @return The number of attributes in the list. + * @see org.xml.sax.Attributes#getLength + */ + public int getLength () + { + return qAtts.getLength(); + } + + + /** + * Return the Namespace URI of the specified attribute. + * + * @param The attribute's index. + * @return Always the empty string. + * @see org.xml.sax.Attributes#getURI + */ + public String getURI (int i) + { + return ""; + } + + + /** + * Return the local name of the specified attribute. + * + * @param The attribute's index. + * @return Always the empty string. + * @see org.xml.sax.Attributes#getLocalName + */ + public String getLocalName (int i) + { + return ""; + } + + + /** + * Return the qualified (prefixed) name of the specified attribute. + * + * @param The attribute's index. + * @return The attribute's qualified name, internalized. + */ + public String getQName (int i) + { + return qAtts.getName(i).intern(); + } + + + /** + * Return the type of the specified attribute. + * + * @param The attribute's index. + * @return The attribute's type as an internalized string. + */ + public String getType (int i) + { + return qAtts.getType(i).intern(); + } + + + /** + * Return the value of the specified attribute. + * + * @param The attribute's index. + * @return The attribute's value. + */ + public String getValue (int i) + { + return qAtts.getValue(i); + } + + + /** + * Look up an attribute index by Namespace name. + * + * @param uri The Namespace URI or the empty string. + * @param localName The local name. + * @return The attributes index, or -1 if none was found. + * @see org.xml.sax.Attributes#getIndex(java.lang.String,java.lang.String) + */ + public int getIndex (String uri, String localName) + { + return -1; + } + + + /** + * Look up an attribute index by qualified (prefixed) name. + * + * @param qName The qualified name. + * @return The attributes index, or -1 if none was found. + * @see org.xml.sax.Attributes#getIndex(java.lang.String) + */ + public int getIndex (String qName) + { + int max = atts.getLength(); + for (int i = 0; i < max; i++) { + if (qAtts.getName(i).equals(qName)) { + return i; + } + } + return -1; + } + + + /** + * Look up the type of an attribute by Namespace name. + * + * @param uri The Namespace URI + * @param localName The local name. + * @return The attribute's type as an internalized string. + */ + public String getType (String uri, String localName) + { + return null; + } + + + /** + * Look up the type of an attribute by qualified (prefixed) name. + * + * @param qName The qualified name. + * @return The attribute's type as an internalized string. + */ + public String getType (String qName) + { + return qAtts.getType(qName).intern(); + } + + + /** + * Look up the value of an attribute by Namespace name. + * + * @param uri The Namespace URI + * @param localName The local name. + * @return The attribute's value. + */ + public String getValue (String uri, String localName) + { + return null; + } + + + /** + * Look up the value of an attribute by qualified (prefixed) name. + * + * @param qName The qualified name. + * @return The attribute's value. + */ + public String getValue (String qName) + { + return qAtts.getValue(qName); + } + + private AttributeList qAtts; + } +} + +// end of ParserAdapter.java diff --git a/libjava/org/xml/sax/helpers/ParserFactory.java b/libjava/org/xml/sax/helpers/ParserFactory.java new file mode 100644 index 00000000000..9ca7b55002f --- /dev/null +++ b/libjava/org/xml/sax/helpers/ParserFactory.java @@ -0,0 +1,129 @@ +// SAX parser factory. +// No warranty; no copyright -- use this as you will. +// $Id: ParserFactory.java,v 1.1 2000/10/02 02:43:20 sboag Exp $ + +package org.xml.sax.helpers; + +import java.lang.ClassNotFoundException; +import java.lang.IllegalAccessException; +import java.lang.InstantiationException; +import java.lang.SecurityException; +import java.lang.ClassCastException; + +import org.xml.sax.Parser; + + +/** + * Java-specific class for dynamically loading SAX parsers. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

Note: This class is designed to work with the now-deprecated + * SAX1 {@link org.xml.sax.Parser Parser} class. SAX2 applications should use + * {@link org.xml.sax.helpers.XMLReaderFactory XMLReaderFactory} instead.

+ * + *

ParserFactory is not part of the platform-independent definition + * of SAX; it is an additional convenience class designed + * specifically for Java XML application writers. SAX applications + * can use the static methods in this class to allocate a SAX parser + * dynamically at run-time based either on the value of the + * `org.xml.sax.parser' system property or on a string containing the class + * name.

+ * + *

Note that the application still requires an XML parser that + * implements SAX1.

+ * + * @deprecated This class works with the deprecated + * {@link org.xml.sax.Parser Parser} + * interface. + * @since SAX 1.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + * @see org.xml.sax.Parser + * @see java.lang.Class + */ +public class ParserFactory { + + + /** + * Private null constructor. + */ + private ParserFactory () + { + } + + + /** + * Create a new SAX parser using the `org.xml.sax.parser' system property. + * + *

The named class must exist and must implement the + * {@link org.xml.sax.Parser Parser} interface.

+ * + * @exception java.lang.NullPointerException There is no value + * for the `org.xml.sax.parser' system property. + * @exception java.lang.ClassNotFoundException The SAX parser + * class was not found (check your CLASSPATH). + * @exception IllegalAccessException The SAX parser class was + * found, but you do not have permission to load + * it. + * @exception InstantiationException The SAX parser class was + * found but could not be instantiated. + * @exception java.lang.ClassCastException The SAX parser class + * was found and instantiated, but does not implement + * org.xml.sax.Parser. + * @see #makeParser(java.lang.String) + * @see org.xml.sax.Parser + */ + public static Parser makeParser () + throws ClassNotFoundException, + IllegalAccessException, + InstantiationException, + NullPointerException, + ClassCastException + { + String className = System.getProperty("org.xml.sax.parser"); + if (className == null) { + throw new NullPointerException("No value for sax.parser property"); + } else { + return makeParser(className); + } + } + + + /** + * Create a new SAX parser object using the class name provided. + * + *

The named class must exist and must implement the + * {@link org.xml.sax.Parser Parser} interface.

+ * + * @param className A string containing the name of the + * SAX parser class. + * @exception java.lang.ClassNotFoundException The SAX parser + * class was not found (check your CLASSPATH). + * @exception IllegalAccessException The SAX parser class was + * found, but you do not have permission to load + * it. + * @exception InstantiationException The SAX parser class was + * found but could not be instantiated. + * @exception java.lang.ClassCastException The SAX parser class + * was found and instantiated, but does not implement + * org.xml.sax.Parser. + * @see #makeParser() + * @see org.xml.sax.Parser + */ + public static Parser makeParser (String className) + throws ClassNotFoundException, + IllegalAccessException, + InstantiationException, + ClassCastException + { + return (Parser)(Class.forName(className).newInstance()); + } + +} + +// end of ParserFactory.java diff --git a/libjava/org/xml/sax/helpers/XMLFilterImpl.java b/libjava/org/xml/sax/helpers/XMLFilterImpl.java new file mode 100644 index 00000000000..5b1afaf6c2f --- /dev/null +++ b/libjava/org/xml/sax/helpers/XMLFilterImpl.java @@ -0,0 +1,769 @@ +// XMLFilterImpl.java - base SAX2 filter implementation. +// Written by David Megginson, sax@megginson.com +// NO WARRANTY! This class is in the Public Domain. + +// $Id: XMLFilterImpl.java,v 1.1 2000/10/02 02:43:20 sboag Exp $ + +package org.xml.sax.helpers; + +import java.io.IOException; + +import org.xml.sax.XMLReader; +import org.xml.sax.XMLFilter; +import org.xml.sax.InputSource; +import org.xml.sax.Locator; +import org.xml.sax.Attributes; +import org.xml.sax.EntityResolver; +import org.xml.sax.DTDHandler; +import org.xml.sax.ContentHandler; +import org.xml.sax.ErrorHandler; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; +import org.xml.sax.SAXNotSupportedException; +import org.xml.sax.SAXNotRecognizedException; + + +/** + * Base class for deriving an XML filter. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

This class is designed to sit between an {@link org.xml.sax.XMLReader + * XMLReader} and the client application's event handlers. By default, it + * does nothing but pass requests up to the reader and events + * on to the handlers unmodified, but subclasses can override + * specific methods to modify the event stream or the configuration + * requests as they pass through.

+ * + * @since SAX 2.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + * @see org.xml.sax.XMLFilter + * @see org.xml.sax.XMLReader + * @see org.xml.sax.EntityResolver + * @see org.xml.sax.DTDHandler + * @see org.xml.sax.ContentHandler + * @see org.xml.sax.ErrorHandler + */ +public class XMLFilterImpl + implements XMLFilter, EntityResolver, DTDHandler, ContentHandler, ErrorHandler +{ + + + //////////////////////////////////////////////////////////////////// + // Constructors. + //////////////////////////////////////////////////////////////////// + + + /** + * Construct an empty XML filter, with no parent. + * + *

This filter will have no parent: you must assign a parent + * before you start a parse or do any configuration with + * setFeature or setProperty.

+ * + * @see org.xml.sax.XMLReader#setFeature + * @see org.xml.sax.XMLReader#setProperty + */ + public XMLFilterImpl () + { + super(); + } + + + /** + * Construct an XML filter with the specified parent. + * + * @see #setParent + * @see #getParent + */ + public XMLFilterImpl (XMLReader parent) + { + super(); + setParent(parent); + } + + + + //////////////////////////////////////////////////////////////////// + // Implementation of org.xml.sax.XMLFilter. + //////////////////////////////////////////////////////////////////// + + + /** + * Set the parent reader. + * + *

This is the {@link org.xml.sax.XMLReader XMLReader} from which + * this filter will obtain its events and to which it will pass its + * configuration requests. The parent may itself be another filter.

+ * + *

If there is no parent reader set, any attempt to parse + * or to set or get a feature or property will fail.

+ * + * @param parent The parent XML reader. + * @exception java.lang.NullPointerException If the parent is null. + * @see #getParent + */ + public void setParent (XMLReader parent) + { + if (parent == null) { + throw new NullPointerException("Null parent"); + } + this.parent = parent; + } + + + /** + * Get the parent reader. + * + * @return The parent XML reader, or null if none is set. + * @see #setParent + */ + public XMLReader getParent () + { + return parent; + } + + + + //////////////////////////////////////////////////////////////////// + // Implementation of org.xml.sax.XMLReader. + //////////////////////////////////////////////////////////////////// + + + /** + * Set the state of a feature. + * + *

This will always fail if the parent is null.

+ * + * @param name The feature name. + * @param state The requested feature state. + * @exception org.xml.sax.SAXNotRecognizedException When the + * XMLReader does not recognize the feature name. + * @exception org.xml.sax.SAXNotSupportedException When the + * XMLReader recognizes the feature name but + * cannot set the requested value. + * @see org.xml.sax.XMLReader#setFeature + */ + public void setFeature (String name, boolean state) + throws SAXNotRecognizedException, SAXNotSupportedException + { + if (parent != null) { + parent.setFeature(name, state); + } else { + throw new SAXNotRecognizedException("Feature: " + name); + } + } + + + /** + * Look up the state of a feature. + * + *

This will always fail if the parent is null.

+ * + * @param name The feature name. + * @return The current state of the feature. + * @exception org.xml.sax.SAXNotRecognizedException When the + * XMLReader does not recognize the feature name. + * @exception org.xml.sax.SAXNotSupportedException When the + * XMLReader recognizes the feature name but + * cannot determine its state at this time. + * @see org.xml.sax.XMLReader#getFeature + */ + public boolean getFeature (String name) + throws SAXNotRecognizedException, SAXNotSupportedException + { + if (parent != null) { + return parent.getFeature(name); + } else { + throw new SAXNotRecognizedException("Feature: " + name); + } + } + + + /** + * Set the value of a property. + * + *

This will always fail if the parent is null.

+ * + * @param name The property name. + * @param state The requested property value. + * @exception org.xml.sax.SAXNotRecognizedException When the + * XMLReader does not recognize the property name. + * @exception org.xml.sax.SAXNotSupportedException When the + * XMLReader recognizes the property name but + * cannot set the requested value. + * @see org.xml.sax.XMLReader#setProperty + */ + public void setProperty (String name, Object value) + throws SAXNotRecognizedException, SAXNotSupportedException + { + if (parent != null) { + parent.setProperty(name, value); + } else { + throw new SAXNotRecognizedException("Property: " + name); + } + } + + + /** + * Look up the value of a property. + * + * @param name The property name. + * @return The current value of the property. + * @exception org.xml.sax.SAXNotRecognizedException When the + * XMLReader does not recognize the feature name. + * @exception org.xml.sax.SAXNotSupportedException When the + * XMLReader recognizes the property name but + * cannot determine its value at this time. + * @see org.xml.sax.XMLReader#setFeature + */ + public Object getProperty (String name) + throws SAXNotRecognizedException, SAXNotSupportedException + { + if (parent != null) { + return parent.getProperty(name); + } else { + throw new SAXNotRecognizedException("Property: " + name); + } + } + + + /** + * Set the entity resolver. + * + * @param resolver The new entity resolver. + * @exception java.lang.NullPointerException If the resolver + * is null. + * @see org.xml.sax.XMLReader#setEntityResolver + */ + public void setEntityResolver (EntityResolver resolver) + { + if (resolver == null) { + throw new NullPointerException("Null entity resolver"); + } else { + entityResolver = resolver; + } + } + + + /** + * Get the current entity resolver. + * + * @return The current entity resolver, or null if none was set. + * @see org.xml.sax.XMLReader#getEntityResolver + */ + public EntityResolver getEntityResolver () + { + return entityResolver; + } + + + /** + * Set the DTD event handler. + * + * @param resolver The new DTD handler. + * @exception java.lang.NullPointerException If the handler + * is null. + * @see org.xml.sax.XMLReader#setDTDHandler + */ + public void setDTDHandler (DTDHandler handler) + { + if (handler == null) { + throw new NullPointerException("Null DTD handler"); + } else { + dtdHandler = handler; + } + } + + + /** + * Get the current DTD event handler. + * + * @return The current DTD handler, or null if none was set. + * @see org.xml.sax.XMLReader#getDTDHandler + */ + public DTDHandler getDTDHandler () + { + return dtdHandler; + } + + + /** + * Set the content event handler. + * + * @param resolver The new content handler. + * @exception java.lang.NullPointerException If the handler + * is null. + * @see org.xml.sax.XMLReader#setContentHandler + */ + public void setContentHandler (ContentHandler handler) + { + if (handler == null) { + throw new NullPointerException("Null content handler"); + } else { + contentHandler = handler; + } + } + + + /** + * Get the content event handler. + * + * @return The current content handler, or null if none was set. + * @see org.xml.sax.XMLReader#getContentHandler + */ + public ContentHandler getContentHandler () + { + return contentHandler; + } + + + /** + * Set the error event handler. + * + * @param handle The new error handler. + * @exception java.lang.NullPointerException If the handler + * is null. + * @see org.xml.sax.XMLReader#setErrorHandler + */ + public void setErrorHandler (ErrorHandler handler) + { + if (handler == null) { + throw new NullPointerException("Null error handler"); + } else { + errorHandler = handler; + } + } + + + /** + * Get the current error event handler. + * + * @return The current error handler, or null if none was set. + * @see org.xml.sax.XMLReader#getErrorHandler + */ + public ErrorHandler getErrorHandler () + { + return errorHandler; + } + + + /** + * Parse a document. + * + * @param input The input source for the document entity. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @exception java.io.IOException An IO exception from the parser, + * possibly from a byte stream or character stream + * supplied by the application. + * @see org.xml.sax.XMLReader#parse(org.xml.sax.InputSource) + */ + public void parse (InputSource input) + throws SAXException, IOException + { + setupParse(); + parent.parse(input); + } + + + /** + * Parse a document. + * + * @param systemId The system identifier as a fully-qualified URI. + * @exception org.xml.sax.SAXException Any SAX exception, possibly + * wrapping another exception. + * @exception java.io.IOException An IO exception from the parser, + * possibly from a byte stream or character stream + * supplied by the application. + * @see org.xml.sax.XMLReader#parse(java.lang.String) + */ + public void parse (String systemId) + throws SAXException, IOException + { + parse(new InputSource(systemId)); + } + + + + //////////////////////////////////////////////////////////////////// + // Implementation of org.xml.sax.EntityResolver. + //////////////////////////////////////////////////////////////////// + + + /** + * Filter an external entity resolution. + * + * @param publicId The entity's public identifier, or null. + * @param systemId The entity's system identifier. + * @return A new InputSource or null for the default. + * @exception org.xml.sax.SAXException The client may throw + * an exception during processing. + * @exception java.io.IOException The client may throw an + * I/O-related exception while obtaining the + * new InputSource. + * @see org.xml.sax.EntityResolver#resolveEntity + */ + public InputSource resolveEntity (String publicId, String systemId) + throws SAXException, IOException + { + if (entityResolver != null) { + return entityResolver.resolveEntity(publicId, systemId); + } else { + return null; + } + } + + + + //////////////////////////////////////////////////////////////////// + // Implementation of org.xml.sax.DTDHandler. + //////////////////////////////////////////////////////////////////// + + + /** + * Filter a notation declaration event. + * + * @param name The notation name. + * @param publicId The notation's public identifier, or null. + * @param systemId The notation's system identifier, or null. + * @exception org.xml.sax.SAXException The client may throw + * an exception during processing. + * @see org.xml.sax.DTDHandler#notationDecl + */ + public void notationDecl (String name, String publicId, String systemId) + throws SAXException + { + if (dtdHandler != null) { + dtdHandler.notationDecl(name, publicId, systemId); + } + } + + + /** + * Filter an unparsed entity declaration event. + * + * @param name The entity name. + * @param publicId The entity's public identifier, or null. + * @param systemId The entity's system identifier, or null. + * @param notationName The name of the associated notation. + * @exception org.xml.sax.SAXException The client may throw + * an exception during processing. + * @see org.xml.sax.DTDHandler#unparsedEntityDecl + */ + public void unparsedEntityDecl (String name, String publicId, + String systemId, String notationName) + throws SAXException + { + if (dtdHandler != null) { + dtdHandler.unparsedEntityDecl(name, publicId, systemId, + notationName); + } + } + + + + //////////////////////////////////////////////////////////////////// + // Implementation of org.xml.sax.ContentHandler. + //////////////////////////////////////////////////////////////////// + + + /** + * Filter a new document locator event. + * + * @param locator The document locator. + * @see org.xml.sax.ContentHandler#setDocumentLocator + */ + public void setDocumentLocator (Locator locator) + { + this.locator = locator; + if (contentHandler != null) { + contentHandler.setDocumentLocator(locator); + } + } + + + /** + * Filter a start document event. + * + * @exception org.xml.sax.SAXException The client may throw + * an exception during processing. + * @see org.xml.sax.ContentHandler#startDocument + */ + public void startDocument () + throws SAXException + { + if (contentHandler != null) { + contentHandler.startDocument(); + } + } + + + /** + * Filter an end document event. + * + * @exception org.xml.sax.SAXException The client may throw + * an exception during processing. + * @see org.xml.sax.ContentHandler#endDocument + */ + public void endDocument () + throws SAXException + { + if (contentHandler != null) { + contentHandler.endDocument(); + } + } + + + /** + * Filter a start Namespace prefix mapping event. + * + * @param prefix The Namespace prefix. + * @param uri The Namespace URI. + * @exception org.xml.sax.SAXException The client may throw + * an exception during processing. + * @see org.xml.sax.ContentHandler#startPrefixMapping + */ + public void startPrefixMapping (String prefix, String uri) + throws SAXException + { + if (contentHandler != null) { + contentHandler.startPrefixMapping(prefix, uri); + } + } + + + /** + * Filter an end Namespace prefix mapping event. + * + * @param prefix The Namespace prefix. + * @exception org.xml.sax.SAXException The client may throw + * an exception during processing. + * @see org.xml.sax.ContentHandler#endPrefixMapping + */ + public void endPrefixMapping (String prefix) + throws SAXException + { + if (contentHandler != null) { + contentHandler.endPrefixMapping(prefix); + } + } + + + /** + * Filter a start element event. + * + * @param uri The element's Namespace URI, or the empty string. + * @param localName The element's local name, or the empty string. + * @param qName The element's qualified (prefixed) name, or the empty + * string. + * @param atts The element's attributes. + * @exception org.xml.sax.SAXException The client may throw + * an exception during processing. + * @see org.xml.sax.ContentHandler#startElement + */ + public void startElement (String uri, String localName, String qName, + Attributes atts) + throws SAXException + { + if (contentHandler != null) { + contentHandler.startElement(uri, localName, qName, atts); + } + } + + + /** + * Filter an end element event. + * + * @param uri The element's Namespace URI, or the empty string. + * @param localName The element's local name, or the empty string. + * @param qName The element's qualified (prefixed) name, or the empty + * string. + * @exception org.xml.sax.SAXException The client may throw + * an exception during processing. + * @see org.xml.sax.ContentHandler#endElement + */ + public void endElement (String uri, String localName, String qName) + throws SAXException + { + if (contentHandler != null) { + contentHandler.endElement(uri, localName, qName); + } + } + + + /** + * Filter a character data event. + * + * @param ch An array of characters. + * @param start The starting position in the array. + * @param length The number of characters to use from the array. + * @exception org.xml.sax.SAXException The client may throw + * an exception during processing. + * @see org.xml.sax.ContentHandler#characters + */ + public void characters (char ch[], int start, int length) + throws SAXException + { + if (contentHandler != null) { + contentHandler.characters(ch, start, length); + } + } + + + /** + * Filter an ignorable whitespace event. + * + * @param ch An array of characters. + * @param start The starting position in the array. + * @param length The number of characters to use from the array. + * @exception org.xml.sax.SAXException The client may throw + * an exception during processing. + * @see org.xml.sax.ContentHandler#ignorableWhitespace + */ + public void ignorableWhitespace (char ch[], int start, int length) + throws SAXException + { + if (contentHandler != null) { + contentHandler.ignorableWhitespace(ch, start, length); + } + } + + + /** + * Filter a processing instruction event. + * + * @param target The processing instruction target. + * @param data The text following the target. + * @exception org.xml.sax.SAXException The client may throw + * an exception during processing. + * @see org.xml.sax.ContentHandler#processingInstruction + */ + public void processingInstruction (String target, String data) + throws SAXException + { + if (contentHandler != null) { + contentHandler.processingInstruction(target, data); + } + } + + + /** + * Filter a skipped entity event. + * + * @param name The name of the skipped entity. + * @exception org.xml.sax.SAXException The client may throw + * an exception during processing. + * @see org.xml.sax.ContentHandler#skippedEntity + */ + public void skippedEntity (String name) + throws SAXException + { + if (contentHandler != null) { + contentHandler.skippedEntity(name); + } + } + + + + //////////////////////////////////////////////////////////////////// + // Implementation of org.xml.sax.ErrorHandler. + //////////////////////////////////////////////////////////////////// + + + /** + * Filter a warning event. + * + * @param e The nwarning as an exception. + * @exception org.xml.sax.SAXException The client may throw + * an exception during processing. + * @see org.xml.sax.ErrorHandler#warning + */ + public void warning (SAXParseException e) + throws SAXException + { + if (errorHandler != null) { + errorHandler.warning(e); + } + } + + + /** + * Filter an error event. + * + * @param e The error as an exception. + * @exception org.xml.sax.SAXException The client may throw + * an exception during processing. + * @see org.xml.sax.ErrorHandler#error + */ + public void error (SAXParseException e) + throws SAXException + { + if (errorHandler != null) { + errorHandler.error(e); + } + } + + + /** + * Filter a fatal error event. + * + * @param e The error as an exception. + * @exception org.xml.sax.SAXException The client may throw + * an exception during processing. + * @see org.xml.sax.ErrorHandler#fatalError + */ + public void fatalError (SAXParseException e) + throws SAXException + { + if (errorHandler != null) { + errorHandler.fatalError(e); + } + } + + + + //////////////////////////////////////////////////////////////////// + // Internal methods. + //////////////////////////////////////////////////////////////////// + + + /** + * Set up before a parse. + * + *

Before every parse, check whether the parent is + * non-null, and re-register the filter for all of the + * events.

+ */ + private void setupParse () + { + if (parent == null) { + throw new NullPointerException("No parent for filter"); + } + parent.setEntityResolver(this); + parent.setDTDHandler(this); + parent.setContentHandler(this); + parent.setErrorHandler(this); + } + + + + //////////////////////////////////////////////////////////////////// + // Internal state. + //////////////////////////////////////////////////////////////////// + + private XMLReader parent = null; + private Locator locator = null; + private EntityResolver entityResolver = null; + private DTDHandler dtdHandler = null; + private ContentHandler contentHandler = null; + private ErrorHandler errorHandler = null; + +} + +// end of XMLFilterImpl.java diff --git a/libjava/org/xml/sax/helpers/XMLReaderAdapter.java b/libjava/org/xml/sax/helpers/XMLReaderAdapter.java new file mode 100644 index 00000000000..4fb44d91d8e --- /dev/null +++ b/libjava/org/xml/sax/helpers/XMLReaderAdapter.java @@ -0,0 +1,526 @@ +// XMLReaderAdapter.java - adapt an SAX2 XMLReader to a SAX1 Parser +// Written by David Megginson, sax@megginson.com +// NO WARRANTY! This class is in the public domain. + +// $Id: XMLReaderAdapter.java,v 1.1 2000/10/02 02:43:20 sboag Exp $ + +package org.xml.sax.helpers; + +import java.io.IOException; +import java.util.Locale; + +import org.xml.sax.Parser; // deprecated +import org.xml.sax.Locator; +import org.xml.sax.InputSource; +import org.xml.sax.AttributeList; // deprecated +import org.xml.sax.EntityResolver; +import org.xml.sax.DTDHandler; +import org.xml.sax.DocumentHandler; // deprecated +import org.xml.sax.ErrorHandler; +import org.xml.sax.SAXException; + +import org.xml.sax.XMLReader; +import org.xml.sax.Attributes; +import org.xml.sax.ContentHandler; +import org.xml.sax.SAXNotSupportedException; + + +/** + * Adapt a SAX2 XMLReader as a SAX1 Parser. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

This class wraps a SAX2 {@link org.xml.sax.XMLReader XMLReader} + * and makes it act as a SAX1 {@link org.xml.sax.Parser Parser}. The XMLReader + * must support a true value for the + * http://xml.org/sax/features/namespace-prefixes property or parsing will fail + * with a {@link org.xml.sax.SAXException SAXException}; if the XMLReader + * supports a false value for the http://xml.org/sax/features/namespaces + * property, that will also be used to improve efficiency.

+ * + * @since SAX 2.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + * @see org.xml.sax.Parser + * @see org.xml.sax.XMLReader + */ +public class XMLReaderAdapter implements Parser, ContentHandler +{ + + + //////////////////////////////////////////////////////////////////// + // Constructor. + //////////////////////////////////////////////////////////////////// + + + /** + * Create a new adapter. + * + *

Use the "org.xml.sax.driver" property to locate the SAX2 + * driver to embed.

+ * + * @exception org.xml.sax.SAXException If the embedded driver + * cannot be instantiated or if the + * org.xml.sax.driver property is not specified. + */ + public XMLReaderAdapter () + throws SAXException + { + setup(XMLReaderFactory.createXMLReader()); + } + + + /** + * Create a new adapter. + * + *

Create a new adapter, wrapped around a SAX2 XMLReader. + * The adapter will make the XMLReader act like a SAX1 + * Parser.

+ * + * @param xmlReader The SAX2 XMLReader to wrap. + * @exception java.lang.NullPointerException If the argument is null. + */ + public XMLReaderAdapter (XMLReader xmlReader) + { + setup(xmlReader); + } + + + + /** + * Internal setup. + * + * @param xmlReader The embedded XMLReader. + */ + private void setup (XMLReader xmlReader) + { + if (xmlReader == null) { + throw new NullPointerException("XMLReader must not be null"); + } + this.xmlReader = xmlReader; + qAtts = new AttributesAdapter(); + } + + + + //////////////////////////////////////////////////////////////////// + // Implementation of org.xml.sax.Parser. + //////////////////////////////////////////////////////////////////// + + + /** + * Set the locale for error reporting. + * + *

This is not supported in SAX2, and will always throw + * an exception.

+ * + * @param The locale for error reporting. + * @see org.xml.sax.Parser#setLocale + */ + public void setLocale (Locale locale) + throws SAXException + { + throw new SAXNotSupportedException("setLocale not supported"); + } + + + /** + * Register the entity resolver. + * + * @param resolver The new resolver. + * @see org.xml.sax.Parser#setEntityResolver + */ + public void setEntityResolver (EntityResolver resolver) + { + xmlReader.setEntityResolver(resolver); + } + + + /** + * Register the DTD event handler. + * + * @param handler The new DTD event handler. + * @see org.xml.sax.Parser#setDTDHandler + */ + public void setDTDHandler (DTDHandler handler) + { + xmlReader.setDTDHandler(handler); + } + + + /** + * Register the SAX1 document event handler. + * + *

Note that the SAX1 document handler has no Namespace + * support.

+ * + * @param handler The new SAX1 document event handler. + * @see org.xml.sax.Parser#setDocumentHandler + */ + public void setDocumentHandler (DocumentHandler handler) + { + documentHandler = handler; + } + + + /** + * Register the error event handler. + * + * @param handler The new error event handler. + * @see org.xml.sax.Parser#setErrorHandler + */ + public void setErrorHandler (ErrorHandler handler) + { + xmlReader.setErrorHandler(handler); + } + + + /** + * Parse the document. + * + *

This method will throw an exception if the embedded + * XMLReader does not support the + * http://xml.org/sax/features/namespace-prefixes property.

+ * + * @param systemId The absolute URL of the document. + * @exception java.io.IOException If there is a problem reading + * the raw content of the document. + * @exception org.xml.sax.SAXException If there is a problem + * processing the document. + * @see #parse(org.xml.sax.InputSource) + * @see org.xml.sax.Parser#parse(java.lang.String) + */ + public void parse (String systemId) + throws IOException, SAXException + { + parse(new InputSource(systemId)); + } + + + /** + * Parse the document. + * + *

This method will throw an exception if the embedded + * XMLReader does not support the + * http://xml.org/sax/features/namespace-prefixes property.

+ * + * @param input An input source for the document. + * @exception java.io.IOException If there is a problem reading + * the raw content of the document. + * @exception org.xml.sax.SAXException If there is a problem + * processing the document. + * @see #parse(java.lang.String) + * @see org.xml.sax.Parser#parse(org.xml.sax.InputSource) + */ + public void parse (InputSource input) + throws IOException, SAXException + { + setupXMLReader(); + xmlReader.parse(input); + } + + + /** + * Set up the XML reader. + */ + private void setupXMLReader () + throws SAXException + { + xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true); + try { + xmlReader.setFeature("http://xml.org/sax/features/namespaces", + false); + } catch (SAXException e) { + // NO OP: it's just extra information, and we can ignore it + } + xmlReader.setContentHandler(this); + } + + + + //////////////////////////////////////////////////////////////////// + // Implementation of org.xml.sax.ContentHandler. + //////////////////////////////////////////////////////////////////// + + + /** + * Set a document locator. + * + * @param locator The document locator. + * @see org.xml.sax.ContentHandler#setDocumentLocator + */ + public void setDocumentLocator (Locator locator) + { + documentHandler.setDocumentLocator(locator); + } + + + /** + * Start document event. + * + * @exception org.xml.sax.SAXException The client may raise a + * processing exception. + * @see org.xml.sax.ContentHandler#startDocument + */ + public void startDocument () + throws SAXException + { + documentHandler.startDocument(); + } + + + /** + * End document event. + * + * @exception org.xml.sax.SAXException The client may raise a + * processing exception. + * @see org.xml.sax.ContentHandler#endDocument + */ + public void endDocument () + throws SAXException + { + documentHandler.endDocument(); + } + + + /** + * Adapt a SAX2 start prefix mapping event. + * + * @param prefix The prefix being mapped. + * @param uri The Namespace URI being mapped to. + * @see org.xml.sax.ContentHandler#startPrefixMapping + */ + public void startPrefixMapping (String prefix, String uri) + { + } + + + /** + * Adapt a SAX2 end prefix mapping event. + * + * @param prefix The prefix being mapped. + * @see org.xml.sax.ContentHandler#endPrefixMapping + */ + public void endPrefixMapping (String prefix) + { + } + + + /** + * Adapt a SAX2 start element event. + * + * @param uri The Namespace URI. + * @param localName The Namespace local name. + * @param qName The qualified (prefixed) name. + * @param atts The SAX2 attributes. + * @exception org.xml.sax.SAXException The client may raise a + * processing exception. + * @see org.xml.sax.ContentHandler#endDocument + */ + public void startElement (String uri, String localName, + String qName, Attributes atts) + throws SAXException + { + qAtts.setAttributes(atts); + documentHandler.startElement(qName, qAtts); + } + + + /** + * Adapt a SAX2 end element event. + * + * @param uri The Namespace URI. + * @param localName The Namespace local name. + * @param qName The qualified (prefixed) name. + * @exception org.xml.sax.SAXException The client may raise a + * processing exception. + * @see org.xml.sax.ContentHandler#endElement + */ + public void endElement (String uri, String localName, + String qName) + throws SAXException + { + documentHandler.endElement(qName); + } + + + /** + * Adapt a SAX2 characters event. + * + * @param ch An array of characters. + * @param start The starting position in the array. + * @param length The number of characters to use. + * @exception org.xml.sax.SAXException The client may raise a + * processing exception. + * @see org.xml.sax.ContentHandler#characters + */ + public void characters (char ch[], int start, int length) + throws SAXException + { + documentHandler.characters(ch, start, length); + } + + + /** + * Adapt a SAX2 ignorable whitespace event. + * + * @param ch An array of characters. + * @param start The starting position in the array. + * @param length The number of characters to use. + * @exception org.xml.sax.SAXException The client may raise a + * processing exception. + * @see org.xml.sax.ContentHandler#ignorableWhitespace + */ + public void ignorableWhitespace (char ch[], int start, int length) + throws SAXException + { + documentHandler.ignorableWhitespace(ch, start, length); + } + + + /** + * Adapt a SAX2 processing instruction event. + * + * @param target The processing instruction target. + * @param data The remainder of the processing instruction + * @exception org.xml.sax.SAXException The client may raise a + * processing exception. + * @see org.xml.sax.ContentHandler#processingInstruction + */ + public void processingInstruction (String target, String data) + throws SAXException + { + documentHandler.processingInstruction(target, data); + } + + + /** + * Adapt a SAX2 skipped entity event. + * + * @param name The name of the skipped entity. + * @see org.xml.sax.ContentHandler#skippedEntity + */ + public void skippedEntity (String name) + throws SAXException + { + } + + + + //////////////////////////////////////////////////////////////////// + // Internal state. + //////////////////////////////////////////////////////////////////// + + XMLReader xmlReader; + DocumentHandler documentHandler; + AttributesAdapter qAtts; + + + + //////////////////////////////////////////////////////////////////// + // Internal class. + //////////////////////////////////////////////////////////////////// + + + /** + * Internal class to wrap a SAX2 Attributes object for SAX1. + */ + final class AttributesAdapter implements AttributeList + { + AttributesAdapter () + { + } + + + /** + * Set the embedded Attributes object. + * + * @param The embedded SAX2 Attributes. + */ + void setAttributes (Attributes attributes) + { + this.attributes = attributes; + } + + + /** + * Return the number of attributes. + * + * @return The length of the attribute list. + * @see org.xml.sax.AttributeList#getLength + */ + public int getLength () + { + return attributes.getLength(); + } + + + /** + * Return the qualified (prefixed) name of an attribute by position. + * + * @return The qualified name. + * @see org.xml.sax.AttributeList#getName + */ + public String getName (int i) + { + return attributes.getQName(i); + } + + + /** + * Return the type of an attribute by position. + * + * @return The type. + * @see org.xml.sax.AttributeList#getType(int) + */ + public String getType (int i) + { + return attributes.getType(i); + } + + + /** + * Return the value of an attribute by position. + * + * @return The value. + * @see org.xml.sax.AttributeList#getValue(int) + */ + public String getValue (int i) + { + return attributes.getValue(i); + } + + + /** + * Return the type of an attribute by qualified (prefixed) name. + * + * @return The type. + * @see org.xml.sax.AttributeList#getType(java.lang.String) + */ + public String getType (String qName) + { + return attributes.getType(qName); + } + + + /** + * Return the value of an attribute by qualified (prefixed) name. + * + * @return The value. + * @see org.xml.sax.AttributeList#getValue(java.lang.String) + */ + public String getValue (String qName) + { + return attributes.getValue(qName); + } + + private Attributes attributes; + } + +} + +// end of XMLReaderAdapter.java diff --git a/libjava/org/xml/sax/helpers/XMLReaderFactory.java b/libjava/org/xml/sax/helpers/XMLReaderFactory.java new file mode 100644 index 00000000000..9443b27dcca --- /dev/null +++ b/libjava/org/xml/sax/helpers/XMLReaderFactory.java @@ -0,0 +1,136 @@ +// XMLReaderFactory.java - factory for creating a new reader. +// Written by David Megginson, sax@megginson.com +// NO WARRANTY! This class is in the Public Domain. + +// $Id: XMLReaderFactory.java,v 1.1 2000/10/02 02:43:20 sboag Exp $ + +package org.xml.sax.helpers; +import org.xml.sax.Parser; +import org.xml.sax.XMLReader; +import org.xml.sax.SAXException; + + +/** + * Factory for creating an XML reader. + * + *
+ * This module, both source code and documentation, is in the + * Public Domain, and comes with NO WARRANTY. + *
+ * + *

This class contains static methods for creating an XML reader + * from an explicit class name, or for creating an XML reader based + * on the value of the org.xml.sax.driver system + * property:

+ * + *
+ * try {
+ *   XMLReader myReader = XMLReaderFactory.createXMLReader();
+ * } catch (SAXException e) {
+ *   System.err.println(e.getMessage());
+ * }
+ * 
+ * + *

Note that these methods will not be usable in environments where + * system properties are not accessible or where the application or + * applet is not permitted to load classes dynamically.

+ * + *

Note to implementors: SAX implementations in specialized + * environments may replace this class with a different one optimized for the + * environment, as long as its method signatures remain the same.

+ * + * @since SAX 2.0 + * @author David Megginson, + * sax@megginson.com + * @version 2.0 + * @see org.xml.sax.XMLReader + */ +final public class XMLReaderFactory +{ + + /** + * Private constructor. + * + *

This constructor prevents the class from being instantiated.

+ */ + private XMLReaderFactory () + { + } + + + /** + * Attempt to create an XML reader from a system property. + * + *

This method uses the value of the system property + * "org.xml.sax.driver" as the full name of a Java class + * and tries to instantiate that class as a SAX2 + * XMLReader.

+ * + *

Note that many Java interpreters allow system properties + * to be specified on the command line.

+ * + * @return A new XMLReader. + * @exception org.xml.sax.SAXException If the value of the + * "org.xml.sax.driver" system property is null, + * or if the class cannot be loaded and instantiated. + * @see #createXMLReader(java.lang.String) + */ + public static XMLReader createXMLReader () + throws SAXException + { + String className = System.getProperty("org.xml.sax.driver"); + if (className == null) { + Parser parser; + try { + parser = ParserFactory.makeParser(); + } catch (Exception e) { + parser = null; + } + if (parser == null) { + throw new + SAXException("System property org.xml.sax.driver not specified"); + } else { + return new ParserAdapter(parser); + } + } else { + return createXMLReader(className); + } + } + + + /** + * Attempt to create an XML reader from a class name. + * + *

Given a class name, this method attempts to load + * and instantiate the class as an XML reader.

+ * + * @return A new XML reader. + * @exception org.xml.sax.SAXException If the class cannot be + * loaded, instantiated, and cast to XMLReader. + * @see #createXMLReader() + */ + public static XMLReader createXMLReader (String className) + throws SAXException + { + try { + return (XMLReader)(Class.forName(className).newInstance()); + } catch (ClassNotFoundException e1) { + throw new SAXException("SAX2 driver class " + className + + " not found", e1); + } catch (IllegalAccessException e2) { + throw new SAXException("SAX2 driver class " + className + + " found but cannot be loaded", e2); + } catch (InstantiationException e3) { + throw new SAXException("SAX2 driver class " + className + + " loaded but cannot be instantiated (no empty public constructor?)", + e3); + } catch (ClassCastException e4) { + throw new SAXException("SAX2 driver class " + className + + " does not implement XMLReader", e4); + } + + } + +} + +// end of XMLReaderFactory.java -- 2.30.2