Imported GNU Classpath 0.20
Imported GNU Classpath 0.20 * Makefile.am (AM_CPPFLAGS): Add classpath/include. * java/nio/charset/spi/CharsetProvider.java: New override file. * java/security/Security.java: Likewise. * sources.am: Regenerated. * Makefile.in: Likewise. From-SVN: r109831
This commit is contained in:
parent
bcb36c3e02
commit
2127637945
|
@ -1,3 +1,12 @@
|
|||
2006-01-16 Mark Wielaard <mark@klomp.org>
|
||||
|
||||
Imported GNU Classpath 0.20
|
||||
* Makefile.am (AM_CPPFLAGS): Add classpath/include.
|
||||
* java/nio/charset/spi/CharsetProvider.java: New override file.
|
||||
* java/security/Security.java: Likewise.
|
||||
* sources.am: Regenerated.
|
||||
* Makefile.in: Likewise.
|
||||
|
||||
2006-01-17 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
* configure.ac (dbexecdir): New substituted var.
|
||||
|
|
|
@ -152,6 +152,7 @@ LIBFFIINCS = @LIBFFIINCS@
|
|||
AM_CPPFLAGS = -I$(top_srcdir) \
|
||||
-Iinclude -I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/classpath/include \
|
||||
-Iclasspath/include \
|
||||
-I$(top_srcdir)/classpath/native/fdlibm \
|
||||
$(GCINCS) $(THREADINCS) $(INCLTDL) \
|
||||
$(GCC_UNWIND_INCLUDE) $(ZINCS) $(LIBFFIINCS)
|
||||
|
|
|
@ -192,24 +192,25 @@ am__DEPENDENCIES_2 = gnu/awt.lo gnu/awt/j2d.lo gnu/classpath.lo \
|
|||
java/util/jar.lo java/util/logging.lo java/util/prefs.lo \
|
||||
java/util/regex.lo java/util/zip.lo javax/accessibility.lo \
|
||||
javax/crypto.lo javax/crypto/interfaces.lo \
|
||||
javax/crypto/spec.lo javax/naming.lo javax/naming/directory.lo \
|
||||
javax/naming/event.lo javax/naming/ldap.lo javax/naming/spi.lo \
|
||||
javax/net.lo javax/net/ssl.lo javax/print.lo \
|
||||
javax/print/attribute.lo javax/print/attribute/standard.lo \
|
||||
javax/print/event.lo javax/security/auth.lo \
|
||||
javax/security/auth/callback.lo javax/security/auth/login.lo \
|
||||
javax/security/auth/spi.lo javax/security/auth/x500.lo \
|
||||
javax/security/cert.lo javax/security/sasl.lo \
|
||||
javax/sound/midi.lo javax/sound/midi/spi.lo \
|
||||
javax/sound/sampled.lo javax/sound/sampled/spi.lo javax/sql.lo \
|
||||
javax/swing.lo javax/swing/border.lo \
|
||||
javax/swing/colorchooser.lo javax/swing/event.lo \
|
||||
javax/swing/filechooser.lo javax/swing/plaf.lo \
|
||||
javax/swing/plaf/basic.lo javax/swing/plaf/metal.lo \
|
||||
javax/swing/plaf/multi.lo javax/swing/table.lo \
|
||||
javax/swing/text.lo javax/swing/text/html.lo \
|
||||
javax/swing/text/html/parser.lo javax/swing/text/rtf.lo \
|
||||
javax/swing/tree.lo javax/swing/undo.lo javax/transaction.lo \
|
||||
javax/crypto/spec.lo javax/management.lo javax/naming.lo \
|
||||
javax/naming/directory.lo javax/naming/event.lo \
|
||||
javax/naming/ldap.lo javax/naming/spi.lo javax/net.lo \
|
||||
javax/net/ssl.lo javax/print.lo javax/print/attribute.lo \
|
||||
javax/print/attribute/standard.lo javax/print/event.lo \
|
||||
javax/security/auth.lo javax/security/auth/callback.lo \
|
||||
javax/security/auth/login.lo javax/security/auth/spi.lo \
|
||||
javax/security/auth/x500.lo javax/security/cert.lo \
|
||||
javax/security/sasl.lo javax/sound/midi.lo \
|
||||
javax/sound/midi/spi.lo javax/sound/sampled.lo \
|
||||
javax/sound/sampled/spi.lo javax/sql.lo javax/swing.lo \
|
||||
javax/swing/border.lo javax/swing/colorchooser.lo \
|
||||
javax/swing/event.lo javax/swing/filechooser.lo \
|
||||
javax/swing/plaf.lo javax/swing/plaf/basic.lo \
|
||||
javax/swing/plaf/metal.lo javax/swing/plaf/multi.lo \
|
||||
javax/swing/table.lo javax/swing/text.lo \
|
||||
javax/swing/text/html.lo javax/swing/text/html/parser.lo \
|
||||
javax/swing/text/rtf.lo javax/swing/tree.lo \
|
||||
javax/swing/undo.lo javax/transaction.lo \
|
||||
javax/transaction/xa.lo org/ietf/jgss.lo
|
||||
am__DEPENDENCIES_3 = gnu-CORBA.lo gnu-java-beans.lo gnu-javax-rmi.lo \
|
||||
gnu-javax-sound-midi.lo gnu-xml.lo javax-imageio.lo \
|
||||
|
@ -582,6 +583,7 @@ build_os = @build_os@
|
|||
build_subdir = @build_subdir@
|
||||
build_vendor = @build_vendor@
|
||||
datadir = @datadir@
|
||||
dbexecdir = @dbexecdir@
|
||||
exec_prefix = @exec_prefix@
|
||||
extra_ldflags_libjava = @extra_ldflags_libjava@
|
||||
gxx_include_dir = @gxx_include_dir@
|
||||
|
@ -622,7 +624,6 @@ target_vendor = @target_vendor@
|
|||
toolexecdir = @toolexecdir@
|
||||
toolexeclibdir = @toolexeclibdir@
|
||||
toolexecmainlibdir = @toolexecmainlibdir@
|
||||
dbexecdir = @dbexecdir@
|
||||
AUTOMAKE_OPTIONS = foreign subdir-objects
|
||||
ACLOCAL_AMFLAGS = -I . -I .. -I ../config
|
||||
|
||||
|
@ -697,6 +698,7 @@ JC1FLAGS = @LIBGCJ_JAVAFLAGS@ $(GCJFLAGS)
|
|||
AM_CPPFLAGS = -I$(top_srcdir) \
|
||||
-Iinclude -I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/classpath/include \
|
||||
-Iclasspath/include \
|
||||
-I$(top_srcdir)/classpath/native/fdlibm \
|
||||
$(GCINCS) $(THREADINCS) $(INCLTDL) \
|
||||
$(GCC_UNWIND_INCLUDE) $(ZINCS) $(LIBFFIINCS)
|
||||
|
@ -1395,7 +1397,37 @@ classpath/gnu/java/beans/editors/NativeFloatEditor.java \
|
|||
classpath/gnu/java/beans/editors/NativeIntEditor.java \
|
||||
classpath/gnu/java/beans/editors/NativeLongEditor.java \
|
||||
classpath/gnu/java/beans/editors/NativeShortEditor.java \
|
||||
classpath/gnu/java/beans/editors/StringEditor.java
|
||||
classpath/gnu/java/beans/editors/StringEditor.java \
|
||||
classpath/gnu/java/beans/encoder/ArrayPersistenceDelegate.java \
|
||||
classpath/gnu/java/beans/encoder/ClassPersistenceDelegate.java \
|
||||
classpath/gnu/java/beans/encoder/CollectionPersistenceDelegate.java \
|
||||
classpath/gnu/java/beans/encoder/Context.java \
|
||||
classpath/gnu/java/beans/encoder/GenericScannerState.java \
|
||||
classpath/gnu/java/beans/encoder/IgnoringScannerState.java \
|
||||
classpath/gnu/java/beans/encoder/MapPersistenceDelegate.java \
|
||||
classpath/gnu/java/beans/encoder/ObjectId.java \
|
||||
classpath/gnu/java/beans/encoder/PrimitivePersistenceDelegate.java \
|
||||
classpath/gnu/java/beans/encoder/ReportingScannerState.java \
|
||||
classpath/gnu/java/beans/encoder/Root.java \
|
||||
classpath/gnu/java/beans/encoder/ScanEngine.java \
|
||||
classpath/gnu/java/beans/encoder/ScannerState.java \
|
||||
classpath/gnu/java/beans/encoder/StAXWriter.java \
|
||||
classpath/gnu/java/beans/encoder/Writer.java \
|
||||
classpath/gnu/java/beans/encoder/elements/ArrayInstantiation.java \
|
||||
classpath/gnu/java/beans/encoder/elements/Array_Get.java \
|
||||
classpath/gnu/java/beans/encoder/elements/Array_Set.java \
|
||||
classpath/gnu/java/beans/encoder/elements/ClassResolution.java \
|
||||
classpath/gnu/java/beans/encoder/elements/Element.java \
|
||||
classpath/gnu/java/beans/encoder/elements/List_Get.java \
|
||||
classpath/gnu/java/beans/encoder/elements/List_Set.java \
|
||||
classpath/gnu/java/beans/encoder/elements/MethodInvocation.java \
|
||||
classpath/gnu/java/beans/encoder/elements/NullObject.java \
|
||||
classpath/gnu/java/beans/encoder/elements/ObjectInstantiation.java \
|
||||
classpath/gnu/java/beans/encoder/elements/ObjectReference.java \
|
||||
classpath/gnu/java/beans/encoder/elements/PrimitiveInstantiation.java \
|
||||
classpath/gnu/java/beans/encoder/elements/StaticFieldAccess.java \
|
||||
classpath/gnu/java/beans/encoder/elements/StaticMethodInvocation.java \
|
||||
classpath/gnu/java/beans/encoder/elements/StringReference.java
|
||||
|
||||
gnu_java_io_source_files = \
|
||||
classpath/gnu/java/io/ASN1ParsingException.java \
|
||||
|
@ -1885,7 +1917,8 @@ classpath/gnu/java/text/WordBreakIterator.java
|
|||
gnu_java_text_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_text_source_files)))
|
||||
gnu_java_util_source_files = \
|
||||
classpath/gnu/java/util/DoubleEnumeration.java \
|
||||
classpath/gnu/java/util/EmptyEnumeration.java
|
||||
classpath/gnu/java/util/EmptyEnumeration.java \
|
||||
classpath/gnu/java/util/WeakIdentityHashMap.java
|
||||
|
||||
gnu_java_util_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_java_util_source_files)))
|
||||
gnu_java_util_prefs_source_files = \
|
||||
|
@ -2005,7 +2038,6 @@ classpath/gnu/regexp/UncheckedRE.java
|
|||
|
||||
gnu_regexp_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(gnu_regexp_source_files)))
|
||||
gnu_xml_source_files = \
|
||||
classpath/gnu/xml/aelfred2/ContentHandler2.java \
|
||||
classpath/gnu/xml/aelfred2/JAXPFactory.java \
|
||||
classpath/gnu/xml/aelfred2/SAXDriver.java \
|
||||
classpath/gnu/xml/aelfred2/XmlParser.java \
|
||||
|
@ -2166,6 +2198,8 @@ classpath/gnu/xml/pipeline/WellFormednessFilter.java \
|
|||
classpath/gnu/xml/pipeline/XIncludeFilter.java \
|
||||
classpath/gnu/xml/pipeline/XsltFilter.java \
|
||||
classpath/gnu/xml/stream/AttributeImpl.java \
|
||||
classpath/gnu/xml/stream/BufferedReader.java \
|
||||
classpath/gnu/xml/stream/CRLFReader.java \
|
||||
classpath/gnu/xml/stream/CharactersImpl.java \
|
||||
classpath/gnu/xml/stream/CommentImpl.java \
|
||||
classpath/gnu/xml/stream/DTDImpl.java \
|
||||
|
@ -2180,9 +2214,13 @@ classpath/gnu/xml/stream/LocationImpl.java \
|
|||
classpath/gnu/xml/stream/NamespaceImpl.java \
|
||||
classpath/gnu/xml/stream/NotationDeclarationImpl.java \
|
||||
classpath/gnu/xml/stream/ProcessingInstructionImpl.java \
|
||||
classpath/gnu/xml/stream/SAXParser.java \
|
||||
classpath/gnu/xml/stream/SAXParserFactory.java \
|
||||
classpath/gnu/xml/stream/StartDocumentImpl.java \
|
||||
classpath/gnu/xml/stream/StartElementImpl.java \
|
||||
classpath/gnu/xml/stream/StartEntityImpl.java \
|
||||
classpath/gnu/xml/stream/UnicodeReader.java \
|
||||
classpath/gnu/xml/stream/XIncludeFilter.java \
|
||||
classpath/gnu/xml/stream/XMLEventAllocatorImpl.java \
|
||||
classpath/gnu/xml/stream/XMLEventFactoryImpl.java \
|
||||
classpath/gnu/xml/stream/XMLEventImpl.java \
|
||||
|
@ -2190,6 +2228,7 @@ classpath/gnu/xml/stream/XMLEventReaderImpl.java \
|
|||
classpath/gnu/xml/stream/XMLEventWriterImpl.java \
|
||||
classpath/gnu/xml/stream/XMLInputFactoryImpl.java \
|
||||
classpath/gnu/xml/stream/XMLOutputFactoryImpl.java \
|
||||
classpath/gnu/xml/stream/XMLParser.java \
|
||||
classpath/gnu/xml/stream/XMLStreamReaderImpl.java \
|
||||
classpath/gnu/xml/stream/XMLStreamWriterImpl.java \
|
||||
classpath/gnu/xml/transform/AbstractNumberNode.java \
|
||||
|
@ -2218,6 +2257,7 @@ classpath/gnu/xml/transform/Key.java \
|
|||
classpath/gnu/xml/transform/KeyFunction.java \
|
||||
classpath/gnu/xml/transform/LiteralNode.java \
|
||||
classpath/gnu/xml/transform/MessageNode.java \
|
||||
classpath/gnu/xml/transform/NamespaceProxy.java \
|
||||
classpath/gnu/xml/transform/NodeNumberNode.java \
|
||||
classpath/gnu/xml/transform/NumberNode.java \
|
||||
classpath/gnu/xml/transform/OtherwiseNode.java \
|
||||
|
@ -2226,6 +2266,7 @@ classpath/gnu/xml/transform/ProcessingInstructionNode.java \
|
|||
classpath/gnu/xml/transform/SAXSerializer.java \
|
||||
classpath/gnu/xml/transform/SortKey.java \
|
||||
classpath/gnu/xml/transform/StreamSerializer.java \
|
||||
classpath/gnu/xml/transform/StrippingInstruction.java \
|
||||
classpath/gnu/xml/transform/Stylesheet.java \
|
||||
classpath/gnu/xml/transform/SystemPropertyFunction.java \
|
||||
classpath/gnu/xml/transform/Template.java \
|
||||
|
@ -2686,17 +2727,21 @@ classpath/java/beans/BeanDescriptor.java \
|
|||
classpath/java/beans/BeanInfo.java \
|
||||
classpath/java/beans/Beans.java \
|
||||
classpath/java/beans/Customizer.java \
|
||||
classpath/java/beans/DefaultPersistenceDelegate.java \
|
||||
classpath/java/beans/DesignMode.java \
|
||||
classpath/java/beans/Encoder.java \
|
||||
classpath/java/beans/EventHandler.java \
|
||||
classpath/java/beans/EventSetDescriptor.java \
|
||||
classpath/java/beans/ExceptionListener.java \
|
||||
classpath/java/beans/Expression.java \
|
||||
classpath/java/beans/FeatureDescriptor.java \
|
||||
classpath/java/beans/IndexedPropertyChangeEvent.java \
|
||||
classpath/java/beans/IndexedPropertyDescriptor.java \
|
||||
classpath/java/beans/IntrospectionException.java \
|
||||
classpath/java/beans/Introspector.java \
|
||||
classpath/java/beans/MethodDescriptor.java \
|
||||
classpath/java/beans/ParameterDescriptor.java \
|
||||
classpath/java/beans/PersistenceDelegate.java \
|
||||
classpath/java/beans/PropertyChangeEvent.java \
|
||||
classpath/java/beans/PropertyChangeListener.java \
|
||||
classpath/java/beans/PropertyChangeListenerProxy.java \
|
||||
|
@ -2712,7 +2757,8 @@ classpath/java/beans/VetoableChangeListener.java \
|
|||
classpath/java/beans/VetoableChangeListenerProxy.java \
|
||||
classpath/java/beans/VetoableChangeSupport.java \
|
||||
classpath/java/beans/Visibility.java \
|
||||
classpath/java/beans/XMLDecoder.java
|
||||
classpath/java/beans/XMLDecoder.java \
|
||||
classpath/java/beans/XMLEncoder.java
|
||||
|
||||
java_beans_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(java_beans_source_files)))
|
||||
java_beans_beancontext_source_files = \
|
||||
|
@ -3091,9 +3137,9 @@ classpath/java/nio/charset/UnsupportedCharsetException.java
|
|||
|
||||
java_nio_charset_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(java_nio_charset_source_files)))
|
||||
java_nio_charset_spi_source_files = \
|
||||
classpath/java/nio/charset/spi/CharsetProvider.java
|
||||
java/nio/charset/spi/CharsetProvider.java
|
||||
|
||||
java_nio_charset_spi_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(java_nio_charset_spi_source_files)))
|
||||
java_nio_charset_spi_header_files = $(patsubst %.java,%.h,$(java_nio_charset_spi_source_files))
|
||||
java_rmi_source_files = \
|
||||
classpath/java/rmi/AccessException.java \
|
||||
classpath/java/rmi/AlreadyBoundException.java \
|
||||
|
@ -3235,7 +3281,7 @@ classpath/java/security/PublicKey.java \
|
|||
classpath/java/security/SecureClassLoader.java \
|
||||
classpath/java/security/SecureRandom.java \
|
||||
classpath/java/security/SecureRandomSpi.java \
|
||||
classpath/java/security/Security.java \
|
||||
java/security/Security.java \
|
||||
classpath/java/security/SecurityPermission.java \
|
||||
classpath/java/security/Signature.java \
|
||||
classpath/java/security/SignatureException.java \
|
||||
|
@ -3372,6 +3418,7 @@ classpath/java/text/Annotation.java \
|
|||
classpath/java/text/AttributedCharacterIterator.java \
|
||||
classpath/java/text/AttributedString.java \
|
||||
classpath/java/text/AttributedStringIterator.java \
|
||||
classpath/java/text/Bidi.java \
|
||||
classpath/java/text/BreakIterator.java \
|
||||
classpath/java/text/CharacterIterator.java \
|
||||
classpath/java/text/ChoiceFormat.java \
|
||||
|
@ -3647,6 +3694,10 @@ classpath/javax/imageio/stream/ImageOutputStreamImpl.java \
|
|||
classpath/javax/imageio/stream/MemoryCacheImageInputStream.java \
|
||||
classpath/javax/imageio/stream/MemoryCacheImageOutputStream.java
|
||||
|
||||
javax_management_source_files = \
|
||||
classpath/javax/management/Attribute.java
|
||||
|
||||
javax_management_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(javax_management_source_files)))
|
||||
javax_naming_source_files = \
|
||||
classpath/javax/naming/AuthenticationException.java \
|
||||
classpath/javax/naming/AuthenticationNotSupportedException.java \
|
||||
|
@ -3870,9 +3921,11 @@ classpath/javax/print/attribute/standard/JobState.java \
|
|||
classpath/javax/print/attribute/standard/JobStateReason.java \
|
||||
classpath/javax/print/attribute/standard/JobStateReasons.java \
|
||||
classpath/javax/print/attribute/standard/Media.java \
|
||||
classpath/javax/print/attribute/standard/MediaName.java \
|
||||
classpath/javax/print/attribute/standard/MediaPrintableArea.java \
|
||||
classpath/javax/print/attribute/standard/MediaSize.java \
|
||||
classpath/javax/print/attribute/standard/MediaSizeName.java \
|
||||
classpath/javax/print/attribute/standard/MediaTray.java \
|
||||
classpath/javax/print/attribute/standard/MultipleDocumentHandling.java \
|
||||
classpath/javax/print/attribute/standard/NumberOfDocuments.java \
|
||||
classpath/javax/print/attribute/standard/NumberOfInterveningJobs.java \
|
||||
|
@ -3956,10 +4009,15 @@ classpath/javax/security/auth/callback/UnsupportedCallbackException.java
|
|||
|
||||
javax_security_auth_callback_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(javax_security_auth_callback_source_files)))
|
||||
javax_security_auth_login_source_files = \
|
||||
classpath/javax/security/auth/login/AccountException.java \
|
||||
classpath/javax/security/auth/login/AccountExpiredException.java \
|
||||
classpath/javax/security/auth/login/AccountLockedException.java \
|
||||
classpath/javax/security/auth/login/AccountNotFoundException.java \
|
||||
classpath/javax/security/auth/login/AppConfigurationEntry.java \
|
||||
classpath/javax/security/auth/login/Configuration.java \
|
||||
classpath/javax/security/auth/login/CredentialException.java \
|
||||
classpath/javax/security/auth/login/CredentialExpiredException.java \
|
||||
classpath/javax/security/auth/login/CredentialNotFoundException.java \
|
||||
classpath/javax/security/auth/login/FailedLoginException.java \
|
||||
classpath/javax/security/auth/login/LoginContext.java \
|
||||
classpath/javax/security/auth/login/LoginException.java \
|
||||
|
@ -4348,6 +4406,7 @@ classpath/javax/swing/plaf/basic/BasicEditorPaneUI.java \
|
|||
classpath/javax/swing/plaf/basic/BasicFileChooserUI.java \
|
||||
classpath/javax/swing/plaf/basic/BasicFormattedTextFieldUI.java \
|
||||
classpath/javax/swing/plaf/basic/BasicGraphicsUtils.java \
|
||||
classpath/javax/swing/plaf/basic/BasicHTML.java \
|
||||
classpath/javax/swing/plaf/basic/BasicIconFactory.java \
|
||||
classpath/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java \
|
||||
classpath/javax/swing/plaf/basic/BasicInternalFrameUI.java \
|
||||
|
@ -4492,6 +4551,7 @@ classpath/javax/swing/text/DateFormatter.java \
|
|||
classpath/javax/swing/text/DefaultCaret.java \
|
||||
classpath/javax/swing/text/DefaultEditorKit.java \
|
||||
classpath/javax/swing/text/DefaultFormatter.java \
|
||||
classpath/javax/swing/text/DefaultFormatterFactory.java \
|
||||
classpath/javax/swing/text/DefaultHighlighter.java \
|
||||
classpath/javax/swing/text/DefaultStyledDocument.java \
|
||||
classpath/javax/swing/text/DefaultTextUI.java \
|
||||
|
@ -4512,8 +4572,10 @@ classpath/javax/swing/text/Keymap.java \
|
|||
classpath/javax/swing/text/LabelView.java \
|
||||
classpath/javax/swing/text/LayeredHighlighter.java \
|
||||
classpath/javax/swing/text/LayoutQueue.java \
|
||||
classpath/javax/swing/text/MaskFormatter.java \
|
||||
classpath/javax/swing/text/MutableAttributeSet.java \
|
||||
classpath/javax/swing/text/NavigationFilter.java \
|
||||
classpath/javax/swing/text/NumberFormatter.java \
|
||||
classpath/javax/swing/text/ParagraphView.java \
|
||||
classpath/javax/swing/text/PasswordView.java \
|
||||
classpath/javax/swing/text/PlainDocument.java \
|
||||
|
@ -4531,6 +4593,7 @@ classpath/javax/swing/text/TabExpander.java \
|
|||
classpath/javax/swing/text/TabSet.java \
|
||||
classpath/javax/swing/text/TabStop.java \
|
||||
classpath/javax/swing/text/TabableView.java \
|
||||
classpath/javax/swing/text/TableView.java \
|
||||
classpath/javax/swing/text/TextAction.java \
|
||||
classpath/javax/swing/text/Utilities.java \
|
||||
classpath/javax/swing/text/View.java \
|
||||
|
@ -4539,11 +4602,14 @@ classpath/javax/swing/text/WrappedPlainView.java
|
|||
|
||||
javax_swing_text_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(javax_swing_text_source_files)))
|
||||
javax_swing_text_html_source_files = \
|
||||
classpath/javax/swing/text/html/BlockView.java \
|
||||
classpath/javax/swing/text/html/CSS.java \
|
||||
classpath/javax/swing/text/html/CSSParser.java \
|
||||
classpath/javax/swing/text/html/HTML.java \
|
||||
classpath/javax/swing/text/html/HTMLDocument.java \
|
||||
classpath/javax/swing/text/html/HTMLEditorKit.java \
|
||||
classpath/javax/swing/text/html/HTMLFrameHyperlinkEvent.java
|
||||
classpath/javax/swing/text/html/HTMLFrameHyperlinkEvent.java \
|
||||
classpath/javax/swing/text/html/StyleSheet.java
|
||||
|
||||
javax_swing_text_html_header_files = $(patsubst classpath/%,%,$(patsubst %.java,%.h,$(javax_swing_text_html_source_files)))
|
||||
javax_swing_text_html_parser_source_files = \
|
||||
|
@ -5558,6 +5624,7 @@ all_packages_source_files = \
|
|||
javax/crypto.list \
|
||||
javax/crypto/interfaces.list \
|
||||
javax/crypto/spec.list \
|
||||
javax/management.list \
|
||||
javax/naming.list \
|
||||
javax/naming/directory.list \
|
||||
javax/naming/event.list \
|
||||
|
@ -5711,6 +5778,7 @@ ordinary_header_files = \
|
|||
$(javax_crypto_header_files) \
|
||||
$(javax_crypto_interfaces_header_files) \
|
||||
$(javax_crypto_spec_header_files) \
|
||||
$(javax_management_header_files) \
|
||||
$(javax_naming_header_files) \
|
||||
$(javax_naming_directory_header_files) \
|
||||
$(javax_naming_event_header_files) \
|
||||
|
@ -8705,6 +8773,16 @@ javax-imageio.lo: $(javax_imageio_source_files)
|
|||
$(LTGCJCOMPILE) -fjni -findirect-dispatch -c -o javax-imageio.lo @javax-imageio.list
|
||||
@rm -f javax-imageio.list
|
||||
|
||||
javax/management.list: $(javax_management_source_files)
|
||||
@$(mkinstalldirs) $(dir $@)
|
||||
@for file in $(javax_management_source_files); do \
|
||||
if test -f $(srcdir)/$$file; then \
|
||||
echo $(srcdir)/$$file; \
|
||||
else echo $$file; fi; \
|
||||
done > javax/management.list
|
||||
|
||||
-include javax/management.deps
|
||||
|
||||
javax/naming.list: $(javax_naming_source_files)
|
||||
@$(mkinstalldirs) $(dir $@)
|
||||
@for file in $(javax_naming_source_files); do \
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,2 @@
|
|||
<?xml version='1.0'?>
|
||||
<launchConfiguration type='org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType'><stringAttribute key='org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS' value='full,incremental,auto,'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE' value='${working_set:<?xml version="1.0" encoding="UTF-8"?> <launchConfigurationWorkingSet factoryID="org.eclipse.ui.internal.WorkingSetFactory" name="workingSet" editPageId="org.eclipse.ui.resourceWorkingSetPage"> <item factoryID="org.eclipse.ui.internal.model.ResourceFactory" path="/classpath/include/Makefile" type="1"/> </launchConfigurationWorkingSet>}'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_LOCATION' value='${system_path:make}'/><booleanAttribute key='org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED' value='true'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY' value='${build_project}'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS' value='-C ${build_project}/include CLASSDIR=install/share/classpath USER_CLASSLIB=../install/share/classpath all install'/><booleanAttribute key='org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND' value='false'/><booleanAttribute key='org.eclipse.debug.core.appendEnvironmentVariables' value='true'/></launchConfiguration>
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
|
||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="true"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <launchConfigurationWorkingSet factoryID="org.eclipse.ui.internal.WorkingSetFactory" name="workingSet"> <item factoryID="org.eclipse.ui.internal.model.ResourceFactory" path="/classpath/install/share/classpath" type="2"/> </launchConfigurationWorkingSet>}"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-cf glibj.zip META-INF java gnu org javax vm"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${build_project:install/share/classpath}"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${system_path:jar}"/>
|
||||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
|
||||
</launchConfiguration>
|
|
@ -1,2 +1,2 @@
|
|||
<?xml version='1.0'?>
|
||||
<launchConfiguration type='org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType'><stringAttribute key='org.eclipse.debug.core.ATTR_REFRESH_SCOPE' value='${working_set:<?xml version="1.0" encoding="UTF-8"?> <launchConfigurationWorkingSet factoryID="org.eclipse.ui.internal.WorkingSetFactory" name="working set" editPageId="org.eclipse.ui.resourceWorkingSetPage"> <item factoryID="org.eclipse.ui.internal.model.ResourceFactory" path="/classpath/native" type="2"/> </launchConfigurationWorkingSet>}'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS' value='full,incremental,'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE' value='${working_set:<?xml version="1.0" encoding="UTF-8"?> <launchConfigurationWorkingSet factoryID="org.eclipse.ui.internal.WorkingSetFactory" name="workingSet" editPageId="org.eclipse.ui.resourceWorkingSetPage"> <item factoryID="org.eclipse.ui.internal.model.ResourceFactory" path="/classpath/native" type="2"/> </launchConfigurationWorkingSet>}'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_LOCATION' value='${system_path:make}'/><booleanAttribute key='org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED' value='true'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY' value='${build_project}'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS' value='-C ${build_project}/native all install'/><booleanAttribute key='org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND' value='false'/><booleanAttribute key='org.eclipse.debug.core.appendEnvironmentVariables' value='true'/></launchConfiguration>
|
||||
<launchConfiguration type='org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType'><stringAttribute key='org.eclipse.debug.core.ATTR_REFRESH_SCOPE' value='${working_set:<?xml version="1.0" encoding="UTF-8"?> <launchConfigurationWorkingSet factoryID="org.eclipse.ui.internal.WorkingSetFactory" name="working set" editPageId="org.eclipse.ui.resourceWorkingSetPage"> <item factoryID="org.eclipse.ui.internal.model.ResourceFactory" path="/classpath/native" type="2"/> </launchConfigurationWorkingSet>}'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS' value='full,incremental,auto,'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE' value='${working_set:<?xml version="1.0" encoding="UTF-8"?> <launchConfigurationWorkingSet factoryID="org.eclipse.ui.internal.WorkingSetFactory" name="workingSet"> <item factoryID="org.eclipse.ui.internal.model.ResourceFactory" path="/classpath/native" type="2"/> </launchConfigurationWorkingSet>}'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_LOCATION' value='${system_path:make}'/><booleanAttribute key='org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED' value='true'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY' value='${build_project}'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS' value='-C ${build_project}/native all install'/><booleanAttribute key='org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND' value='false'/><booleanAttribute key='org.eclipse.debug.core.appendEnvironmentVariables' value='true'/></launchConfiguration>
|
|
@ -1,2 +1,2 @@
|
|||
<?xml version='1.0'?>
|
||||
<launchConfiguration type='org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType'><stringAttribute key='org.eclipse.debug.core.ATTR_REFRESH_SCOPE' value='${project}'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS' value='full,incremental,'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_LOCATION' value='${build_project}/configure'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY' value='${build_project}'/><booleanAttribute key='org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED' value='true'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS' value='--prefix=${build_project}/install'/><booleanAttribute key='org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND' value='false'/><booleanAttribute key='org.eclipse.debug.core.appendEnvironmentVariables' value='true'/></launchConfiguration>
|
||||
<launchConfiguration type='org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType'><stringAttribute key='org.eclipse.debug.core.ATTR_REFRESH_SCOPE' value='${project}'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS' value='full,incremental,auto,'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE' value='${working_set:<?xml version="1.0" encoding="UTF-8"?> <launchConfigurationWorkingSet factoryID="org.eclipse.ui.internal.WorkingSetFactory" name="workingSet" editPageId="org.eclipse.ui.resourceWorkingSetPage"> <item factoryID="org.eclipse.ui.internal.model.ResourceFactory" path="/classpath/Makefile.in" type="1"/> </launchConfigurationWorkingSet>}'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_LOCATION' value='${build_project}/configure'/><booleanAttribute key='org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED' value='true'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY' value='${build_project}'/><booleanAttribute key='org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED' value='true'/><stringAttribute key='org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS' value='--prefix=${build_project}/install --enable-regen-headers --enable-gtk-cairo'/><booleanAttribute key='org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND' value='false'/><booleanAttribute key='org.eclipse.debug.core.appendEnvironmentVariables' value='true'/></launchConfiguration>
|
|
@ -7,7 +7,7 @@
|
|||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<triggers>auto,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>LaunchConfigHandle</key>
|
||||
|
@ -17,7 +17,7 @@
|
|||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<triggers>auto,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>LaunchConfigHandle</key>
|
||||
|
@ -37,7 +37,17 @@
|
|||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<triggers>auto,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>LaunchConfigHandle</key>
|
||||
<value><project>/.externalToolBuilders/ClasspathHeaders.launch</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||
<triggers>auto,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>LaunchConfigHandle</key>
|
||||
|
@ -50,6 +60,16 @@
|
|||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||
<triggers>auto,full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>LaunchConfigHandle</key>
|
||||
<value><project>/.externalToolBuilders/ClasspathJar.launch</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
|
|
|
@ -8,15 +8,19 @@ Lillian Angel (langel@redhat.com)
|
|||
Anthony Balkissoon (abalkiss@redhat.com)
|
||||
Stuart Ballard (stuart.a.ballard@gmail.com)
|
||||
Mark Benvenuto (mcb54@columbia.edu)
|
||||
Gary Benson (gbenson@redhat.com)
|
||||
Geoff Berry (gcb@gnu.org)
|
||||
James E. Blair (corvus@gnu.org)
|
||||
Eric Blake (ebb9@email.byu.edu)
|
||||
Sascha Brawer (brawer@acm.org)
|
||||
Chris Burdess (dog@gnu.org)
|
||||
David Daney (ddaney@avtrex.com)
|
||||
Nic Ferrier (nferrier@tapsellferrier.co.uk)
|
||||
Paul Fisher (rao@gnu.org)
|
||||
David Gilbert (david.gilbert@object-refinery.com)
|
||||
Anthony Green (green@redhat.com)
|
||||
Jochen Hoenicke (Jochen.Hoenicke@Informatik.Uni-Oldenburg.de)
|
||||
Kazumitsu Ito (kaz@maczuka.gcd.org)
|
||||
Andrew John Hughes (gnu_andrew@member.fsf.org)
|
||||
Brian Jones (cbj@gnu.org)
|
||||
Roman Kennke (roman@kennke.org)
|
||||
|
@ -25,8 +29,10 @@ John Keiser (jkeiser@iname.com)
|
|||
John Leuner (jewel@debian.org)
|
||||
Warren Levy (warrenl@cygnus.com)
|
||||
Sven de Marothy (sven@physto.se)
|
||||
Casey Marshall (csm@gnu.org)
|
||||
Bryce McKinlay (bryce@waitaki.otago.ac.nz)
|
||||
Audrius Meskauskas (audriusa@Bioinformatics.org)
|
||||
Raif S. Naffah (raif@swiftdsl.com.au)
|
||||
Aaron M. Renn (arenn@urbanophile.com)
|
||||
Andrew Selkirk (aselkirk@sympatico.ca)
|
||||
Christian Thalinger (twisti@complang.tuwien.ac.at)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,3 +1,13 @@
|
|||
2006-01-16 Mark Wielaard <mark@klomp.org>
|
||||
|
||||
* native/fdlibm/namespace.h: Empty for gcj.
|
||||
|
||||
2006-01-14 Anthony Green <green@redhat.com>
|
||||
|
||||
* java/net/ServerSocket.java (accept): Remove bogus
|
||||
security check.
|
||||
(implAccept): Add FIXME comment.
|
||||
|
||||
2006-01-06 Tom Tromey <tromey@redhat.com>
|
||||
|
||||
PR libgcj/23499:
|
||||
|
|
|
@ -10,7 +10,7 @@ ACLOCAL_AMFLAGS = -I m4 -I ../.. -I ../../config
|
|||
native: lib
|
||||
|
||||
EXTRA_DIST = HACKING BUGS THANKYOU mauve-classpath LICENSE \
|
||||
ChangeLog-2003 ChangeLog-2004 \
|
||||
ChangeLog-2003 ChangeLog-2004 ChangeLog-2005 \
|
||||
ChangeLog.gnujaxp.1 ChangeLog.gnujaxp.2 ChangeLog.libxmlj \
|
||||
autogen.sh
|
||||
|
||||
|
|
|
@ -46,10 +46,11 @@ subdir = .
|
|||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/../../libtool.m4 \
|
||||
$(top_srcdir)/m4/acattribute.m4 $(top_srcdir)/m4/accross.m4 \
|
||||
$(top_srcdir)/m4/acinclude.m4 $(top_srcdir)/m4/iconv.m4 \
|
||||
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
|
||||
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/pkg.m4 \
|
||||
$(top_srcdir)/configure.ac
|
||||
$(top_srcdir)/m4/acinclude.m4 \
|
||||
$(top_srcdir)/m4/ax_create_stdint_h.m4 \
|
||||
$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \
|
||||
$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
|
||||
$(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
|
||||
|
@ -165,6 +166,7 @@ JAY = @JAY@
|
|||
JAY_SKELETON = @JAY_SKELETON@
|
||||
JIKES = @JIKES@
|
||||
JIKESENCODING = @JIKESENCODING@
|
||||
JIKESWARNINGS = @JIKESWARNINGS@
|
||||
KJC = @KJC@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBDEBUG = @LIBDEBUG@
|
||||
|
@ -275,7 +277,7 @@ SUBDIRS = lib doc external include native resource scripts $(EXAMPLESDIR)
|
|||
DIST_SUBDIRS = lib doc external include native resource scripts examples
|
||||
ACLOCAL_AMFLAGS = -I m4 -I ../.. -I ../../config
|
||||
EXTRA_DIST = HACKING BUGS THANKYOU mauve-classpath LICENSE \
|
||||
ChangeLog-2003 ChangeLog-2004 \
|
||||
ChangeLog-2003 ChangeLog-2004 ChangeLog-2005 \
|
||||
ChangeLog.gnujaxp.1 ChangeLog.gnujaxp.2 ChangeLog.libxmlj \
|
||||
autogen.sh
|
||||
|
||||
|
|
|
@ -1,10 +1,47 @@
|
|||
New in release 0.20
|
||||
New in release 0.20 (Jan 13, 2006)
|
||||
|
||||
* New StAX pull parser and SAX-over-StAX driver. Lots of DOM, SAX/StAX,
|
||||
XPath and XSLT improvements. Support for XInclude and XML Base added.
|
||||
Conformance is now regularly tested against various test-suites at
|
||||
http://builder.classpath.org/xml/ See also doc/README.jaxp.
|
||||
|
||||
* Full beans XMLEncoder implementation.
|
||||
|
||||
* javax.sound.sampled implementation.
|
||||
|
||||
* javax.print.attribute and javax.print.event implementated.
|
||||
|
||||
* Lots of new datatransfer, print swing and swing.text work and optimization.
|
||||
|
||||
* Additional 1.5 support. Including new (separate) generic branch release.
|
||||
|
||||
* SecurityManager cleanups and start of review of all Permission checks
|
||||
(includes adding lots of new checks to the Mauve test-suite).
|
||||
|
||||
* Buildable on cygwin.
|
||||
|
||||
* Fully buildable as "in-workspace" library-plus-vm inside (native) Eclipse
|
||||
see http://developer.classpath.org/mediation/ClasspathHackingWithEclipse
|
||||
|
||||
* Full example that shows a real world CORBA and Free Swing implementation.
|
||||
See examples/gnu/classpath/examples/CORBA/swing/README.html
|
||||
|
||||
* A list of bug fixes can be found at:
|
||||
http://gcc.gnu.org/bugzilla/buglist.cgi?product=classpath&target_milestone=0.20
|
||||
|
||||
Runtime interface changes:
|
||||
|
||||
* New method VMStackWalker.getClassLoader() was added to avoid an infinite
|
||||
loop between getCallingClassLoader() and Class.getClassLoader().
|
||||
|
||||
* The included fdlibm implementation has seen several cleanups to handle
|
||||
new architectures and namespacing issues (in particular for ppc, darwin
|
||||
and non-C99 compilers). Please double check any arithmetic test against
|
||||
new platforms/runtimes.
|
||||
|
||||
* The gnu.java.net.Plain[Datagram]Socket implementations have been
|
||||
turned into VM reference classes with JNI/Posix implementations.
|
||||
|
||||
New in release 0.19 (Nov 2, 2005)
|
||||
|
||||
* The Swing RepaintManager has been reworked for more efficient painting,
|
||||
|
|
|
@ -1090,6 +1090,7 @@ m4_include([../../libtool.m4])
|
|||
m4_include([m4/acattribute.m4])
|
||||
m4_include([m4/accross.m4])
|
||||
m4_include([m4/acinclude.m4])
|
||||
m4_include([m4/ax_create_stdint_h.m4])
|
||||
m4_include([m4/iconv.m4])
|
||||
m4_include([m4/lib-ld.m4])
|
||||
m4_include([m4/lib-link.m4])
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
|
||||
timestamp='2005-07-08'
|
||||
timestamp='2005-11-11'
|
||||
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
|
@ -779,7 +779,7 @@ EOF
|
|||
i*:PW*:*)
|
||||
echo ${UNAME_MACHINE}-pc-pw32
|
||||
exit ;;
|
||||
x86:Interix*:[34]*)
|
||||
x86:Interix*:[345]*)
|
||||
echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//'
|
||||
exit ;;
|
||||
[345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
|
||||
|
@ -794,7 +794,7 @@ EOF
|
|||
i*:UWIN*:*)
|
||||
echo ${UNAME_MACHINE}-pc-uwin
|
||||
exit ;;
|
||||
amd64:CYGWIN*:*:*)
|
||||
amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
|
||||
echo x86_64-unknown-cygwin
|
||||
exit ;;
|
||||
p*:CYGWIN*:*)
|
||||
|
@ -873,6 +873,9 @@ EOF
|
|||
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
|
||||
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
|
||||
;;
|
||||
or32:Linux:*:*)
|
||||
echo or32-unknown-linux-gnu
|
||||
exit ;;
|
||||
ppc:Linux:*:*)
|
||||
echo powerpc-unknown-linux-gnu
|
||||
exit ;;
|
||||
|
@ -1182,7 +1185,6 @@ EOF
|
|||
*:Darwin:*:*)
|
||||
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
|
||||
case $UNAME_PROCESSOR in
|
||||
*86) UNAME_PROCESSOR=i686 ;;
|
||||
unknown) UNAME_PROCESSOR=powerpc ;;
|
||||
esac
|
||||
echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
|
||||
timestamp='2005-07-08'
|
||||
timestamp='2005-12-06'
|
||||
|
||||
# This file is (in principle) common to ALL GNU software.
|
||||
# The presence of a machine in this file suggests that SOME GNU software
|
||||
|
@ -171,6 +171,10 @@ case $os in
|
|||
-hiux*)
|
||||
os=-hiuxwe2
|
||||
;;
|
||||
-sco6)
|
||||
os=-sco5v6
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco5)
|
||||
os=-sco3.2v5
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
|
@ -187,6 +191,10 @@ case $os in
|
|||
# Don't forget version if it is 3.2v4 or newer.
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco5v6*)
|
||||
# Don't forget version if it is 3.2v4 or newer.
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
;;
|
||||
-sco*)
|
||||
os=-sco3.2v2
|
||||
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
|
||||
|
@ -257,7 +265,7 @@ case $basic_machine in
|
|||
| mipsisa64sr71k | mipsisa64sr71kel \
|
||||
| mipstx39 | mipstx39el \
|
||||
| mn10200 | mn10300 \
|
||||
| ms1 \
|
||||
| mt \
|
||||
| msp430 \
|
||||
| ns16k | ns32k \
|
||||
| or32 \
|
||||
|
@ -287,6 +295,9 @@ case $basic_machine in
|
|||
m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
|
||||
;;
|
||||
|
||||
ms1)
|
||||
basic_machine=mt-unknown
|
||||
;;
|
||||
# We use `pc' rather than `unknown'
|
||||
# because (1) that's what they normally are, and
|
||||
# (2) the word "unknown" tends to confuse beginning users.
|
||||
|
@ -336,7 +347,7 @@ case $basic_machine in
|
|||
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
|
||||
| mipstx39-* | mipstx39el-* \
|
||||
| mmix-* \
|
||||
| ms1-* \
|
||||
| mt-* \
|
||||
| msp430-* \
|
||||
| none-* | np1-* | ns16k-* | ns32k-* \
|
||||
| orion-* \
|
||||
|
@ -696,6 +707,9 @@ case $basic_machine in
|
|||
basic_machine=i386-pc
|
||||
os=-msdos
|
||||
;;
|
||||
ms1-*)
|
||||
basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
|
||||
;;
|
||||
mvs)
|
||||
basic_machine=i370-ibm
|
||||
os=-mvs
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -6,7 +6,7 @@ dnl -----------------------------------------------------------
|
|||
dnl define([AC_CACHE_LOAD], )dnl
|
||||
dnl define([AC_CACHE_SAVE], )dnl
|
||||
|
||||
AC_INIT([GNU Classpath],[0.20-pre],[classpath@gnu.org],[classpath])
|
||||
AC_INIT([GNU Classpath],[0.20],[classpath@gnu.org],[classpath])
|
||||
AC_CONFIG_SRCDIR(java/lang/System.java)
|
||||
|
||||
AC_CANONICAL_TARGET
|
||||
|
@ -274,7 +274,8 @@ if test "x${COMPILE_JNI}" = xyes; then
|
|||
localtime_r \
|
||||
strerror_r \
|
||||
fcntl \
|
||||
mmap munmap mincore msync madvise getpagesize sysconf])
|
||||
mmap munmap mincore msync madvise getpagesize sysconf \
|
||||
isnan])
|
||||
|
||||
AC_HEADER_TIME
|
||||
AC_STRUCT_TM
|
||||
|
@ -370,7 +371,7 @@ if test "x${COMPILE_JNI}" = xyes; then
|
|||
|
||||
dnl Check for AWT related Qt4
|
||||
if test "x${COMPILE_QT_PEER}" = xyes; then
|
||||
PKG_CHECK_MODULES(QT, QtGui >= 4.0.1, HAVE_QT4="yes", HAVE_QT4="no")
|
||||
PKG_CHECK_MODULES(QT, QtCore QtGui >= 4.1.0, HAVE_QT4="yes", HAVE_QT4="no")
|
||||
if test "x$HAVE_QT4" = "xyes"; then
|
||||
dnl Check needed because in some cases the QtGui includedir
|
||||
dnl doesn't contain the subsystem dir.
|
||||
|
@ -560,6 +561,8 @@ AC_ARG_ENABLE([portable-native-sync],
|
|||
esac],
|
||||
[])
|
||||
|
||||
AX_CREATE_STDINT_H([include/config-int.h])
|
||||
|
||||
dnl -----------------------------------------------------------
|
||||
dnl output files
|
||||
dnl -----------------------------------------------------------
|
||||
|
|
|
@ -41,10 +41,11 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in texinfo.tex
|
|||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/../../libtool.m4 \
|
||||
$(top_srcdir)/m4/acattribute.m4 $(top_srcdir)/m4/accross.m4 \
|
||||
$(top_srcdir)/m4/acinclude.m4 $(top_srcdir)/m4/iconv.m4 \
|
||||
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
|
||||
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/pkg.m4 \
|
||||
$(top_srcdir)/configure.ac
|
||||
$(top_srcdir)/m4/acinclude.m4 \
|
||||
$(top_srcdir)/m4/ax_create_stdint_h.m4 \
|
||||
$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \
|
||||
$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
|
||||
$(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
|
@ -149,6 +150,7 @@ JAY = @JAY@
|
|||
JAY_SKELETON = @JAY_SKELETON@
|
||||
JIKES = @JIKES@
|
||||
JIKESENCODING = @JIKESENCODING@
|
||||
JIKESWARNINGS = @JIKESWARNINGS@
|
||||
KJC = @KJC@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBDEBUG = @LIBDEBUG@
|
||||
|
|
|
@ -17,7 +17,7 @@ PACKAGES
|
|||
. gnu.xml.xpath.* ... JAXP XPath implementation
|
||||
. gnu.xml.transform.* ... JAXP XSL transformer implementation
|
||||
. gnu.xml.pipeline.* ... SAX2 event pipeline support
|
||||
. gnu.xml.stream.* ... StAX pull parser implementation
|
||||
. gnu.xml.stream.* ... StAX pull parser and SAX-over-StAX driver
|
||||
. gnu.xml.util.* ... various XML utility classes
|
||||
. gnu.xml.libxmlj.dom.* ... libxmlj DOM Level 3 Core and XPath
|
||||
. gnu.xml.libxmlj.sax.* ... libxmlj SAX parser
|
||||
|
@ -139,6 +139,9 @@ To enable the various GNU JAXP factories, set the following system properties
|
|||
-Djavax.xml.stream.XMLInputFactory=gnu.xml.stream.XMLInputFactoryImpl
|
||||
-Djavax.xml.stream.XMLOutputFactory=gnu.xml.stream.XMLOutputFactoryImpl
|
||||
|
||||
GNU SAX-over-StAX:
|
||||
-Djavax.xml.parsers.SAXParserFactory=gnu.xml.stream.SAXParserFactory
|
||||
|
||||
libxmlj SAX:
|
||||
-Djavax.xml.parsers.SAXParserFactory=gnu.xml.libxmlj.sax.GnomeSAXParserFactory
|
||||
|
||||
|
|
|
@ -42,10 +42,11 @@ DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
|||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/../../libtool.m4 \
|
||||
$(top_srcdir)/m4/acattribute.m4 $(top_srcdir)/m4/accross.m4 \
|
||||
$(top_srcdir)/m4/acinclude.m4 $(top_srcdir)/m4/iconv.m4 \
|
||||
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
|
||||
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/pkg.m4 \
|
||||
$(top_srcdir)/configure.ac
|
||||
$(top_srcdir)/m4/acinclude.m4 \
|
||||
$(top_srcdir)/m4/ax_create_stdint_h.m4 \
|
||||
$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \
|
||||
$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
|
||||
$(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
|
@ -142,6 +143,7 @@ JAY = @JAY@
|
|||
JAY_SKELETON = @JAY_SKELETON@
|
||||
JIKES = @JIKES@
|
||||
JIKESENCODING = @JIKESENCODING@
|
||||
JIKESWARNINGS = @JIKESWARNINGS@
|
||||
KJC = @KJC@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBDEBUG = @LIBDEBUG@
|
||||
|
|
|
@ -83,6 +83,11 @@ Programming Standards
|
|||
|
||||
Working on the code, Working with others
|
||||
|
||||
* Branches::
|
||||
* Writing ChangeLogs::
|
||||
|
||||
Working with branches
|
||||
|
||||
* Writing ChangeLogs::
|
||||
|
||||
Programming Goals
|
||||
|
@ -493,7 +498,7 @@ The following lists how code is formatted (and some other code
|
|||
conventions):
|
||||
|
||||
|
||||
@itemize
|
||||
@itemize @bullet
|
||||
|
||||
@item
|
||||
Java source files in GNU Classpath are encoded using UTF-8. However,
|
||||
|
@ -689,7 +694,7 @@ fail to compile the offending source code.
|
|||
|
||||
Some things are the same as in the normal GNU Coding Standards:
|
||||
|
||||
@itemize
|
||||
@itemize @bullet
|
||||
|
||||
@item
|
||||
Unnecessary braces can be removed, one line after an if, for, while as
|
||||
|
@ -807,10 +812,70 @@ followed to be the most productive they can be (given the above
|
|||
constraints).
|
||||
|
||||
@menu
|
||||
* Branches::
|
||||
* Writing ChangeLogs::
|
||||
@end menu
|
||||
|
||||
@node Writing ChangeLogs, , Hacking Code, Hacking Code
|
||||
@node Branches, Writing ChangeLogs, Hacking Code, Hacking Code
|
||||
@comment node-name, next, previous, up
|
||||
@section Working with branches
|
||||
|
||||
Sometimes it is necessary to create branch of the source for doing new
|
||||
work that is disruptive to the other hackers, or that needs new
|
||||
language or libraries not yet (easily) available.
|
||||
|
||||
After discussing the need for a branch on the main mailinglist with
|
||||
the other hackers explaining the need of a branch and suggestion of
|
||||
the particular branch rules (what will be done on the branch, who will
|
||||
work on it, will there be different commit guidelines then for the
|
||||
mainline trunk and when is the branch estimated to be finished and
|
||||
merged back into the trunk) every GNU Classpath hacker with commit
|
||||
access should feel free to create a branch. There are however a couple
|
||||
of rules that every branch should follow:
|
||||
|
||||
@itemize @bullet
|
||||
|
||||
@item All branches ought to be documented in the developer wiki at
|
||||
@uref{http://developer.classpath.org/mediation/ClasspathBranches}, so
|
||||
we can know which are live, who owns them, and when they die.
|
||||
|
||||
@item Some rules can be changed on a branch. In particular the branch
|
||||
maintainer can change the review requirements, and the requirement of
|
||||
keeping things building, testing, etc, can also be lifted. (These
|
||||
should be documented along with the branch name and owner if they
|
||||
differ from the trunk.)
|
||||
|
||||
@item Requirements for patch email to classpath-patches and for paperwork
|
||||
@strong{cannot} be lifted. See @ref{Requirements}.
|
||||
|
||||
@item A branch should not be seen as ``private'' or
|
||||
``may be completely broken''. It should be as much as possible
|
||||
something that you work on with a team (and if there is no team - yet
|
||||
- then there is nothing as bad as having a completely broken build to
|
||||
get others to help out). There can of course be occasional breakage, but
|
||||
it should be planned and explained. And you can certainly have a rule
|
||||
like ``please ask me before committing to this branch''.
|
||||
|
||||
@item Merges from the trunk to a branch are at the discretion of the
|
||||
branch maintainer.
|
||||
|
||||
@item A merge from a branch to the trunk is treated like any other patch.
|
||||
In particular, it has to go through review, it must satisfy all the
|
||||
trunk requirements (build, regression test, documentation).
|
||||
|
||||
@item There may be additional timing requirements on merging a branch to
|
||||
the trunk depending on the release schedule, etc. For instance we may
|
||||
not want to do a branch merge just before a release.
|
||||
|
||||
@end itemize
|
||||
|
||||
If any of these rules are unclear please discuss on the list first.
|
||||
|
||||
@menu
|
||||
* Writing ChangeLogs::
|
||||
@end menu
|
||||
|
||||
@node Writing ChangeLogs, , Branches, Hacking Code
|
||||
@comment node-name, next, previous, up
|
||||
@section Documenting what changed when with ChangeLog entries
|
||||
|
||||
|
@ -828,7 +893,7 @@ A good ChangeLog entry guideline can be found in the Guile Manual at
|
|||
Here are some example to explain what should or shouldn't be in a
|
||||
ChangeLog entry (and the corresponding commit message):
|
||||
|
||||
@itemize
|
||||
@itemize @bullet
|
||||
|
||||
@item
|
||||
The first line of a ChangeLog entry should be:
|
||||
|
|
|
@ -226,6 +226,7 @@ become operable.
|
|||
* java.lang.VMRuntime::
|
||||
* java.lang.VMString::
|
||||
* java.lang.VMThread::
|
||||
* java.lang.VMInstrumentationImpl::
|
||||
@end menu
|
||||
|
||||
@node java.lang.VMClass, java.lang.VMObject ,java.lang,java.lang
|
||||
|
@ -607,7 +608,7 @@ A new mapping is created for each new string being @code{intern}ed.
|
|||
A VM may implement this differently by implementing this method,
|
||||
which is @code{static} and the only one in @code{VMString}.
|
||||
|
||||
@node java.lang.VMThread,, java.lang.VMString, java.lang
|
||||
@node java.lang.VMThread,java.lang.VMInstrumentationImpl, java.lang.VMString, java.lang
|
||||
@subsection @code{java.lang.VMThread}
|
||||
|
||||
@code{VMThread} provides the link between Java's threads and the platform
|
||||
|
@ -683,6 +684,45 @@ having returned true, and is thus deprecated as a result.
|
|||
@end itemize
|
||||
@end itemize
|
||||
|
||||
@node java.lang.VMInstrumentationImpl,, java.lang.VMThread, java.lang
|
||||
@subsection @code{java.lang.VMInstrumentationImpl}
|
||||
|
||||
The @code{java.lang.VMInstrumentationImpl} and
|
||||
@code{java.lang.InstrumentationImpl} provides an implementation of the
|
||||
@code{java.lang.instrument.Instrument} interface. This interface is for java
|
||||
1.5 and is only in the generics branch.
|
||||
A @code{InstrumentationImpl} object should be given to any agent
|
||||
given in the command line (see the @code{java.lang.instrument} package
|
||||
documentation). A VM has to implement the static native methods of the
|
||||
@code{VMInstrumentationImpl} class.
|
||||
|
||||
@itemize @bullet
|
||||
@item @code{isRedefineClassesSupported()} -- Returns true if the JVM supports
|
||||
class redefinition.
|
||||
@item @code{redefineClasses()} -- Gives a set of classes with new bytecodes.
|
||||
The VM must redefine the classes by reading the new bytecodes.
|
||||
@item @code{getAllLoadedClass()} -- Returns an array of all loaded classes.
|
||||
@item @code{getInitiatedClass()} -- Returns an array of all classes loaded
|
||||
by a specific class loader.
|
||||
@item @code{getObjectSize()} -- Gives the size of an object.
|
||||
@end itemize
|
||||
|
||||
When agents are defined, the VM has to call transformers of the
|
||||
@code{InstrumentImpl} object each time a class is loaded, eg a call to
|
||||
@code{VMClassLoader.defineClass}. The @code{InstrumentationImpl} class defines
|
||||
a method that has to be called before reading a class file in the VM.
|
||||
|
||||
@itemize @bullet
|
||||
@item @code{callTransformers} -- Calls each transformer registered to
|
||||
the @code{InstrumentationImpl} object and returns a new bytecode file.
|
||||
@end itemize
|
||||
|
||||
No default implementation is provided in gnu classpath for the
|
||||
@code{VMInstrumentationImpl} methods. A default implementation will perhaps
|
||||
be written, but it might break the @code{ClassLoader/VMClassLoader} interface
|
||||
for calling the @code{InstrumentationImpl.callTransformers} when a class byte
|
||||
code is defined with @code{ClassLoader.defineClass}.
|
||||
|
||||
@node gnu.classpath, java.util, java.lang, Classpath Hooks
|
||||
@section @code{gnu.classpath}
|
||||
|
||||
|
|
|
@ -9,11 +9,7 @@
|
|||
<boxitem>
|
||||
<strong>Upcoming Events:</strong><br>
|
||||
<ul>
|
||||
<li>[1-5 Aug 2005] <a href="http://conferences.oreillynet.com/os2005/">OSCON</a>, Portland, Oregon - USA
|
||||
<ul>
|
||||
<li><a href="http://conferences.oreillynet.com/cs/os2005/view/e_sess/6730">The State of Free JVMs</a>
|
||||
Tom Tromey</li>
|
||||
</ul>
|
||||
<li>[25+26 Feb. 2006] FOSDEM'06 in Brussels, Belgium. [<createlink name="GNU Classpath and friends" url="events/fosdem06.html">]</li>
|
||||
</ul>
|
||||
</boxitem>
|
||||
|
||||
|
@ -21,6 +17,13 @@ Tom Tromey</li>
|
|||
<strong>Past Events:</strong><br>
|
||||
<ul>
|
||||
|
||||
<li>
|
||||
[1-5 Aug 2005] <a href="http://conferences.oreillynet.com/os2005/">OSCON</a>, Portland, Oregon - USA
|
||||
<ul>
|
||||
<li><a href="http://conferences.oreillynet.com/cs/os2005/view/e_sess/6730">The State of Free JVMs</a>
|
||||
Tom Tromey</li>
|
||||
</ul>
|
||||
|
||||
<li>
|
||||
[29-31 May 2005] <a href="http://2005.guadec.org/">Guadec</a>, Stuttgart - Germany
|
||||
<ul>
|
||||
|
|
|
@ -0,0 +1,191 @@
|
|||
#!wml --include=..
|
||||
|
||||
#include "include/layout.wml"
|
||||
|
||||
<set-var last-modified-author="mjw">
|
||||
<subject "GNU Classpath and friends @ Fosdem 2006">
|
||||
|
||||
<box>
|
||||
<boxitem>
|
||||
<h2>GNU Classpath and friends meeting during Fosdem 2006</h2>
|
||||
|
||||
<i>Fosdem, Saturday/Sunday 25/26 February 2006, Brussels, Belgium</i>
|
||||
<p>
|
||||
The various free software library, runtimes, compiler and tool
|
||||
projects around GNU Classpath will meet in Brussel to discuss what has
|
||||
happened in the last year in the Free Software community and what the
|
||||
next year will bring us during Fosdem.
|
||||
<p>
|
||||
The 6th edition of FOSDEM (Free and Opensource Software Developers'
|
||||
European Meeting) will take place on February 25+26 2006 in Brussels
|
||||
(Belgium), at the Solbosch Campus of the ULB (Free University of
|
||||
Brussels). FOSDEM is a free and non-commercial event for the community
|
||||
and organized by the community.
|
||||
See <a href="http://www.fosdem.org/">http://www.fosdem.org/</a>.
|
||||
</boxitem>
|
||||
|
||||
<boxitem>
|
||||
<h3>Saturday from 13:00 to 17:00 - "End-User talks"</h3>
|
||||
|
||||
<p>
|
||||
Presentations that show what cool stuff can be done with the Free
|
||||
Stack right now.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Putting the 'Free' into JFreeChart</b>
|
||||
<i>Dave Gilbert, JFreeChart Project Leader</i>
|
||||
<p>
|
||||
A review of the efforts to make JFreeChart work with GNU
|
||||
Classpath-based runtimes, including a brief history, a demonstration
|
||||
of the current state (using the java bindings for Cairo), and an
|
||||
overview of the work that remains to be done.
|
||||
</p>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Using Eclipse for GNU Classpath development</b>
|
||||
<i>Tom Tromey</i>
|
||||
<p>
|
||||
Learn how to setup a fully working development environment based
|
||||
on GNU Classpath in Eclipse that can be used to bootstrap the full
|
||||
free toolchain (and can be used to run Eclipse itself) in just 10
|
||||
minutes.
|
||||
</p>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Eclipse RCP and GCJ/GIJ</b>
|
||||
<i>Wayne Beaton</i>
|
||||
<p>
|
||||
Eclipse Rich Client Platform (RCP) is a runtime platform for
|
||||
delivering your Java applications on multiple platforms. RCP is far
|
||||
more than just a windowing toolkit; it is rich client "middleware"
|
||||
that provides a comprehensive framework for building and deploying
|
||||
applications that are modular, extensible, and updatable. The kinds
|
||||
of applications you can build with Eclipse RCP are limited only by
|
||||
your imagination. During this talk, we will discuss how the Eclipse
|
||||
RCP can be used in conjunction with the Eclipse Eco-system and
|
||||
GCJ/GIJ to build high quality applications.
|
||||
</p>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
</boxitem>
|
||||
|
||||
<boxitem>
|
||||
<h3>Sunday from 09:00 to 13:00 - "Developer talks"</h3>
|
||||
|
||||
<p>
|
||||
Presentations of (core) libraries and runtimes that are in progress,
|
||||
made a lot of progress in the last year and are in active development.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Free Swing, past, present and future</b>
|
||||
<i>Roman Kennke</i>
|
||||
<p>
|
||||
An overview of that state of Free Swing one year ago, what has been
|
||||
done in the meantime, what still must be done and which applications
|
||||
work now.
|
||||
</p>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>The Free CORBA comes</b>
|
||||
<i>Dr Audrius Meskauskas</i>
|
||||
<p>
|
||||
If the Free world does not want to step back in the battle, we need
|
||||
a complete set of the Free tools for advanced communication over
|
||||
the network. For our CORBA implementation we needed:
|
||||
<p>
|
||||
<ol>
|
||||
<li> Free. No classes with restricted license.
|
||||
<li> Fully workable, interoperable and pass tests, recognized by
|
||||
the CORBA user community as serious (we needed to find a well
|
||||
known Free testing suite).
|
||||
<li> Properly commented, being ready for the long life in the Free
|
||||
world.
|
||||
<li> No pressure to use the outdated approaches.
|
||||
CORBA 3.0.3 and jdk 1.5.
|
||||
</ol>
|
||||
<p>
|
||||
To reach these goals, we have chosen for implementing a clean room
|
||||
implementation, using the published standard specifications only.
|
||||
During the recent year of the GNU Classpath development, this goal
|
||||
is in large degree achieved. The important directions of future
|
||||
development could be providing features that are outside the scope
|
||||
of the both CORBA standard and Sun API, but included in the near all
|
||||
proprietary implementations (SSH, HTTP and other bridges, get rid of
|
||||
rmic code generator for RMI/IIOP, fault tolerant behavior, reduced
|
||||
the footprint and others).
|
||||
</p>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>The JamVM runtime</b>
|
||||
<i>Robert Lougher</i>
|
||||
<p>
|
||||
An overview of the JamVM virtual machine, with comparisons to other
|
||||
GNU Classpath runtimes, and a section on the VM interface.
|
||||
</p>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>Integrating Vmgen-based interpreters</b>
|
||||
<i>Christian Thalinger</i>
|
||||
<p>
|
||||
Vmgen is a tool for writing efficient interpreters. The Cacao
|
||||
runtime recently added a Vmgen based interpreter in addition to
|
||||
the JIT engine.
|
||||
</p>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<boxitem>
|
||||
|
||||
<boxitem>
|
||||
<h3>Sunday from 14:00 to 17:30 - "The Future"</h3>
|
||||
|
||||
<p>
|
||||
Interactive technical hacker discussions on how to integrate
|
||||
the projects more and move forward in the next year.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<b>State of the world, beyond japi</b>
|
||||
<i>Mark Wielaard, GNU Classpath Maintainer</i>
|
||||
<p>
|
||||
After a short overview of the various free stacks, libraries,
|
||||
compilers, tools and runtimes this session is mostly open discussion
|
||||
about what work remains to be done and how to integrate the various
|
||||
efforts better. Ideas for work items welcome.
|
||||
</p>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
</boxitem>
|
||||
|
||||
<boxitem>
|
||||
<b>Additional Resources:</b>
|
||||
<ul>
|
||||
<li><createlink name="Free But Shackled - The Java Trap"
|
||||
url="http://www.gnu.org/philosophy/java-trap.html">
|
||||
(by Richard Stallman)
|
||||
</li>
|
||||
<li><createlink name="Escaping the Java Trap: A practical road map to the Free Software and Open Source alternatives"
|
||||
url="http://developer.classpath.org/support/">
|
||||
</li>
|
||||
</ul>
|
||||
<p>
|
||||
</boxitem>
|
||||
|
||||
<boxitem>
|
||||
<b>Official links:</b>
|
||||
<ul>
|
||||
<li><createlink name="FOSDEM Homepage"
|
||||
url="http://www.fosdem.org/">
|
||||
</li>
|
||||
</ul>
|
||||
</boxitem>
|
||||
</box>
|
|
@ -1,3 +1,8 @@
|
|||
<newsitem date="25/26 Feb 2006">
|
||||
<createlink name="GNU Classpath and friends meeting during Fosdem 2006"
|
||||
url="events/fosdem06.html">
|
||||
</newsitem>
|
||||
|
||||
<newsitem date="02 Nov 2005">
|
||||
<createlink name="GNU Classpath 0.19"
|
||||
url="announce/20051102.html">
|
||||
|
|
|
@ -53,25 +53,25 @@ install-data-local:
|
|||
for file in $(ALL_EXAMPLE_FILES); do \
|
||||
f=`echo $$file | cut -c$$srcdir_cnt-`; \
|
||||
fdir=`dirname $$f`; \
|
||||
if test ! -d $(DESTDIR)/$(pkgdatadir)/examples/$$fdir; then \
|
||||
echo "$(mkinstalldirs) $(DESTDIR)/$(pkgdatadir)/examples/$$fdir"; \
|
||||
$(mkinstalldirs) $(DESTDIR)/$(pkgdatadir)/examples/$$fdir; \
|
||||
if test ! -d $(DESTDIR)$(pkgdatadir)/examples/$$fdir; then \
|
||||
echo "$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/examples/$$fdir"; \
|
||||
$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/examples/$$fdir; \
|
||||
fi; \
|
||||
echo "$(INSTALL_DATA) $$file $(DESTDIR)/$(pkgdatadir)/examples/$$f"; \
|
||||
$(INSTALL_DATA) $$file $(DESTDIR)/$(pkgdatadir)/examples/$$f; \
|
||||
echo "$(INSTALL_DATA) $$file $(DESTDIR)$(pkgdatadir)/examples/$$f"; \
|
||||
$(INSTALL_DATA) $$file $(DESTDIR)$(pkgdatadir)/examples/$$f; \
|
||||
done
|
||||
echo "$(INSTALL_DATA) Makefile.jawt $(DESTDIR)/$(pkgdatadir)/examples/"
|
||||
$(INSTALL_DATA) Makefile.jawt $(DESTDIR)/$(pkgdatadir)/examples/
|
||||
echo "$(INSTALL_DATA) Makefile.jawt $(DESTDIR)$(pkgdatadir)/examples/"
|
||||
$(INSTALL_DATA) Makefile.jawt $(DESTDIR)$(pkgdatadir)/examples/
|
||||
|
||||
uninstall-local:
|
||||
srcdir_cnt=`echo $(srcdir) | wc -c`; \
|
||||
for file in $(ALL_EXAMPLE_FILES); do \
|
||||
f=`echo $$file | cut -c$$srcdir_cnt-`; \
|
||||
echo "rm -f $(DESTDIR)/$(pkgdatadir)/examples/$$f"; \
|
||||
rm -f $(DESTDIR)/$(pkgdatadir)/examples/$$f; \
|
||||
echo "rm -f $(DESTDIR)$(pkgdatadir)/examples/$$f"; \
|
||||
rm -f $(DESTDIR)$(pkgdatadir)/examples/$$f; \
|
||||
done
|
||||
echo "rm -f $(DESTDIR)/$(pkgdatadir)/examples/Makefile.jawt"
|
||||
rm -f $(DESTDIR)/$(pkgdatadir)/examples/Makefile.jawt
|
||||
echo "rm -f $(DESTDIR)$(pkgdatadir)/examples/Makefile.jawt"
|
||||
rm -f $(DESTDIR)$(pkgdatadir)/examples/Makefile.jawt
|
||||
|
||||
# Make sure everything is included in the distribution.
|
||||
EXTRA_DIST = README Makefile.jawt.in
|
||||
|
|
|
@ -43,10 +43,11 @@ DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
|
|||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/../../libtool.m4 \
|
||||
$(top_srcdir)/m4/acattribute.m4 $(top_srcdir)/m4/accross.m4 \
|
||||
$(top_srcdir)/m4/acinclude.m4 $(top_srcdir)/m4/iconv.m4 \
|
||||
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
|
||||
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/pkg.m4 \
|
||||
$(top_srcdir)/configure.ac
|
||||
$(top_srcdir)/m4/acinclude.m4 \
|
||||
$(top_srcdir)/m4/ax_create_stdint_h.m4 \
|
||||
$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \
|
||||
$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
|
||||
$(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
|
@ -151,6 +152,7 @@ JAY = @JAY@
|
|||
JAY_SKELETON = @JAY_SKELETON@
|
||||
JIKES = @JIKES@
|
||||
JIKESENCODING = @JIKESENCODING@
|
||||
JIKESWARNINGS = @JIKESWARNINGS@
|
||||
KJC = @KJC@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBDEBUG = @LIBDEBUG@
|
||||
|
@ -491,25 +493,25 @@ install-data-local:
|
|||
for file in $(ALL_EXAMPLE_FILES); do \
|
||||
f=`echo $$file | cut -c$$srcdir_cnt-`; \
|
||||
fdir=`dirname $$f`; \
|
||||
if test ! -d $(DESTDIR)/$(pkgdatadir)/examples/$$fdir; then \
|
||||
echo "$(mkinstalldirs) $(DESTDIR)/$(pkgdatadir)/examples/$$fdir"; \
|
||||
$(mkinstalldirs) $(DESTDIR)/$(pkgdatadir)/examples/$$fdir; \
|
||||
if test ! -d $(DESTDIR)$(pkgdatadir)/examples/$$fdir; then \
|
||||
echo "$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/examples/$$fdir"; \
|
||||
$(mkinstalldirs) $(DESTDIR)$(pkgdatadir)/examples/$$fdir; \
|
||||
fi; \
|
||||
echo "$(INSTALL_DATA) $$file $(DESTDIR)/$(pkgdatadir)/examples/$$f"; \
|
||||
$(INSTALL_DATA) $$file $(DESTDIR)/$(pkgdatadir)/examples/$$f; \
|
||||
echo "$(INSTALL_DATA) $$file $(DESTDIR)$(pkgdatadir)/examples/$$f"; \
|
||||
$(INSTALL_DATA) $$file $(DESTDIR)$(pkgdatadir)/examples/$$f; \
|
||||
done
|
||||
echo "$(INSTALL_DATA) Makefile.jawt $(DESTDIR)/$(pkgdatadir)/examples/"
|
||||
$(INSTALL_DATA) Makefile.jawt $(DESTDIR)/$(pkgdatadir)/examples/
|
||||
echo "$(INSTALL_DATA) Makefile.jawt $(DESTDIR)$(pkgdatadir)/examples/"
|
||||
$(INSTALL_DATA) Makefile.jawt $(DESTDIR)$(pkgdatadir)/examples/
|
||||
|
||||
uninstall-local:
|
||||
srcdir_cnt=`echo $(srcdir) | wc -c`; \
|
||||
for file in $(ALL_EXAMPLE_FILES); do \
|
||||
f=`echo $$file | cut -c$$srcdir_cnt-`; \
|
||||
echo "rm -f $(DESTDIR)/$(pkgdatadir)/examples/$$f"; \
|
||||
rm -f $(DESTDIR)/$(pkgdatadir)/examples/$$f; \
|
||||
echo "rm -f $(DESTDIR)$(pkgdatadir)/examples/$$f"; \
|
||||
rm -f $(DESTDIR)$(pkgdatadir)/examples/$$f; \
|
||||
done
|
||||
echo "rm -f $(DESTDIR)/$(pkgdatadir)/examples/Makefile.jawt"
|
||||
rm -f $(DESTDIR)/$(pkgdatadir)/examples/Makefile.jawt
|
||||
echo "rm -f $(DESTDIR)$(pkgdatadir)/examples/Makefile.jawt"
|
||||
rm -f $(DESTDIR)$(pkgdatadir)/examples/Makefile.jawt
|
||||
dist-hook:
|
||||
srcdir_cnt=`echo $(srcdir) | wc -c`; \
|
||||
for file in $(ALL_EXAMPLE_FILES); do \
|
||||
|
|
|
@ -41,10 +41,11 @@ DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
|||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/../../libtool.m4 \
|
||||
$(top_srcdir)/m4/acattribute.m4 $(top_srcdir)/m4/accross.m4 \
|
||||
$(top_srcdir)/m4/acinclude.m4 $(top_srcdir)/m4/iconv.m4 \
|
||||
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
|
||||
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/pkg.m4 \
|
||||
$(top_srcdir)/configure.ac
|
||||
$(top_srcdir)/m4/acinclude.m4 \
|
||||
$(top_srcdir)/m4/ax_create_stdint_h.m4 \
|
||||
$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \
|
||||
$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
|
||||
$(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
|
@ -149,6 +150,7 @@ JAY = @JAY@
|
|||
JAY_SKELETON = @JAY_SKELETON@
|
||||
JIKES = @JIKES@
|
||||
JIKESENCODING = @JIKESENCODING@
|
||||
JIKESWARNINGS = @JIKESWARNINGS@
|
||||
KJC = @KJC@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBDEBUG = @LIBDEBUG@
|
||||
|
|
|
@ -41,10 +41,11 @@ DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
|||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/../../libtool.m4 \
|
||||
$(top_srcdir)/m4/acattribute.m4 $(top_srcdir)/m4/accross.m4 \
|
||||
$(top_srcdir)/m4/acinclude.m4 $(top_srcdir)/m4/iconv.m4 \
|
||||
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
|
||||
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/pkg.m4 \
|
||||
$(top_srcdir)/configure.ac
|
||||
$(top_srcdir)/m4/acinclude.m4 \
|
||||
$(top_srcdir)/m4/ax_create_stdint_h.m4 \
|
||||
$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \
|
||||
$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
|
||||
$(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
|
@ -140,6 +141,7 @@ JAY = @JAY@
|
|||
JAY_SKELETON = @JAY_SKELETON@
|
||||
JIKES = @JIKES@
|
||||
JIKESENCODING = @JIKESENCODING@
|
||||
JIKESWARNINGS = @JIKESWARNINGS@
|
||||
KJC = @KJC@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBDEBUG = @LIBDEBUG@
|
||||
|
|
|
@ -41,10 +41,11 @@ DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
|||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/../../libtool.m4 \
|
||||
$(top_srcdir)/m4/acattribute.m4 $(top_srcdir)/m4/accross.m4 \
|
||||
$(top_srcdir)/m4/acinclude.m4 $(top_srcdir)/m4/iconv.m4 \
|
||||
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
|
||||
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/pkg.m4 \
|
||||
$(top_srcdir)/configure.ac
|
||||
$(top_srcdir)/m4/acinclude.m4 \
|
||||
$(top_srcdir)/m4/ax_create_stdint_h.m4 \
|
||||
$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \
|
||||
$(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
|
||||
$(top_srcdir)/m4/pkg.m4 $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
|
@ -140,6 +141,7 @@ JAY = @JAY@
|
|||
JAY_SKELETON = @JAY_SKELETON@
|
||||
JIKES = @JIKES@
|
||||
JIKESENCODING = @JIKESENCODING@
|
||||
JIKESWARNINGS = @JIKESWARNINGS@
|
||||
KJC = @KJC@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBDEBUG = @LIBDEBUG@
|
||||
|
|
|
@ -40,6 +40,8 @@ package gnu.CORBA.Poa;
|
|||
|
||||
import gnu.CORBA.ByteArrayComparator;
|
||||
|
||||
import org.omg.CORBA.portable.Delegate;
|
||||
import org.omg.CORBA.portable.ObjectImpl;
|
||||
import org.omg.PortableServer.Servant;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
@ -66,7 +68,7 @@ public class AOM
|
|||
/**
|
||||
* Create an initialised instance.
|
||||
*/
|
||||
Obj(org.omg.CORBA.Object _object, byte[] _key, Servant _servant, gnuPOA _poa)
|
||||
Obj(gnuServantObject _object, byte[] _key, Servant _servant, gnuPOA _poa)
|
||||
{
|
||||
object = _object;
|
||||
key = _key;
|
||||
|
@ -77,7 +79,7 @@ public class AOM
|
|||
/**
|
||||
* The object.
|
||||
*/
|
||||
public final org.omg.CORBA.Object object;
|
||||
public final gnuServantObject object;
|
||||
|
||||
/**
|
||||
* The servant, serving the given object.
|
||||
|
@ -158,14 +160,13 @@ public class AOM
|
|||
Map objects = new TreeMap(new ByteArrayComparator());
|
||||
|
||||
/**
|
||||
* Get the record of the stored object. If the object is mapped
|
||||
* several times under the different keys, one of the mappings
|
||||
* is used.
|
||||
*
|
||||
* Get the record of the stored object. If the object is mapped several times
|
||||
* under the different keys, one of the mappings is used.
|
||||
*
|
||||
* @param object the stored object
|
||||
*
|
||||
* @return the record about the stored object, null if
|
||||
* this object is not stored here.
|
||||
*
|
||||
* @return the record about the stored object, null if this object is not
|
||||
* stored here.
|
||||
*/
|
||||
public Obj findObject(org.omg.CORBA.Object stored_object)
|
||||
{
|
||||
|
@ -173,9 +174,33 @@ public class AOM
|
|||
return null;
|
||||
|
||||
Map.Entry item;
|
||||
Iterator iter = objects.entrySet().iterator();
|
||||
Iterator iter;
|
||||
Obj ref;
|
||||
|
||||
if (stored_object instanceof ObjectImpl)
|
||||
{
|
||||
// If the delegate is available, search by delegate.
|
||||
Delegate d = ((ObjectImpl) stored_object)._get_delegate();
|
||||
Delegate d2;
|
||||
|
||||
if (d != null)
|
||||
{
|
||||
iter = objects.entrySet().iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
item = (Map.Entry) iter.next();
|
||||
ref = (Obj) item.getValue();
|
||||
d2 = ref.object._get_delegate();
|
||||
|
||||
if (d == d2 || (d2 != null && d2.equals(d)))
|
||||
return ref;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// For other objects (or if not possible to get the delegate),
|
||||
// search by .equals
|
||||
iter = objects.entrySet().iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
item = (Map.Entry) iter.next();
|
||||
|
@ -187,12 +212,11 @@ public class AOM
|
|||
}
|
||||
|
||||
/**
|
||||
* Find the reference info for the given servant.
|
||||
* If the servant is mapped to several objects, this
|
||||
* returns the first found occurence.
|
||||
*
|
||||
* Find the reference info for the given servant. If the servant is mapped to
|
||||
* several objects, this returns the first found occurence.
|
||||
*
|
||||
* @param servant a servant to find.
|
||||
*
|
||||
*
|
||||
* @return the servant/object/POA binding or null if no such found.
|
||||
*/
|
||||
public Obj findServant(Servant servant)
|
||||
|
@ -257,7 +281,7 @@ public class AOM
|
|||
*
|
||||
* @return the newly created object record.
|
||||
*/
|
||||
public Obj add(org.omg.CORBA.Object object, Servant servant, gnuPOA poa)
|
||||
public Obj add(gnuServantObject object, Servant servant, gnuPOA poa)
|
||||
{
|
||||
return add(generateObjectKey(object), object, servant, poa);
|
||||
}
|
||||
|
@ -270,7 +294,7 @@ public class AOM
|
|||
* @param servant a servant, serving the given object.
|
||||
* @param poa the POA, where the object is connected.
|
||||
*/
|
||||
public Obj add(byte[] key, org.omg.CORBA.Object object, Servant servant,
|
||||
public Obj add(byte[] key, gnuServantObject object, Servant servant,
|
||||
gnuPOA poa
|
||||
)
|
||||
{
|
||||
|
|
|
@ -1052,12 +1052,12 @@ public class gnuPOA
|
|||
|
||||
/**
|
||||
* Returns the servant that is serving this object.
|
||||
*
|
||||
* @return if the RETAIN policy applies and the object is in the Active
|
||||
* Object Map, the method returns the servant, associated with this object.
|
||||
*
|
||||
* @return if the RETAIN policy applies and the object is in the Active Object
|
||||
* Map, the method returns the servant, associated with this object.
|
||||
* Otherwise, if the USE_DEFAULT_SERVANT policy applies, the method returns
|
||||
* the default servant (if one was set).
|
||||
*
|
||||
*
|
||||
* @throws ObjectNotActive if none of the conditions above are satisfied.
|
||||
* @throws WrongAdapter if the object reference was not created with this POA.
|
||||
* @throws WrongPolicy. This method requires either RETAIN or
|
||||
|
@ -1065,14 +1065,26 @@ public class gnuPOA
|
|||
* apply to this POA.
|
||||
*/
|
||||
public Servant reference_to_servant(org.omg.CORBA.Object the_Object)
|
||||
throws ObjectNotActive, WrongPolicy,
|
||||
WrongAdapter
|
||||
throws ObjectNotActive, WrongPolicy, WrongAdapter
|
||||
{
|
||||
if (applies(ServantRetentionPolicyValue.RETAIN))
|
||||
{
|
||||
AOM.Obj ref = aom.findObject(the_Object);
|
||||
if (ref == null)
|
||||
throw new WrongAdapter();
|
||||
{
|
||||
String object;
|
||||
if (the_Object == null)
|
||||
object = "null passed";
|
||||
else if (the_Object instanceof gnuServantObject)
|
||||
{
|
||||
gnuServantObject gs = (gnuServantObject) the_Object;
|
||||
object = "Wrong owner POA " + gs.poa.the_name();
|
||||
}
|
||||
else
|
||||
object = "Unknown " + the_Object.getClass().getName();
|
||||
|
||||
throw new WrongAdapter(object + " for '" + the_name() + "'");
|
||||
}
|
||||
else if (ref.isDeactiveted() || ref.servant == null)
|
||||
{
|
||||
if (default_servant != null)
|
||||
|
@ -1092,32 +1104,30 @@ public class gnuPOA
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the id of the object, served by the given servant
|
||||
* (assuming that the servant serves only one object).
|
||||
* The id is found in one of the following ways.
|
||||
* <ul>
|
||||
* <li>If the POA has both the RETAIN and the UNIQUE_ID policy and
|
||||
* the specified servant is active, the method return the Object Id associated
|
||||
* with that servant.
|
||||
* </li><li>
|
||||
* If the POA has both the RETAIN and the IMPLICIT_ACTIVATION policy and
|
||||
* either the POA has the MULTIPLE_ID policy or the specified servant is
|
||||
* inactive, the method activates the servant using a POA-generated Object Id
|
||||
* and the Interface Id associated with the servant, and returns that
|
||||
* Object Id.
|
||||
* </li>
|
||||
* <li>If the POA has the USE_DEFAULT_SERVANT policy, the servant specified
|
||||
* is the default servant, and the method is being invoked in the context of
|
||||
* executing a request on the default servant, the method returns the
|
||||
* ObjectId associated with the current invocation.
|
||||
* </li>
|
||||
* </ul>
|
||||
* @throws ServantNotActive in all cases, not listed in the list above.
|
||||
* @throws WrongPolicy The method requres USE_DEFAULT_SERVANT policy or
|
||||
* a combination of the RETAIN policy and either the UNIQUE_ID or
|
||||
* IMPLICIT_ACTIVATION policies and throws the WrongPolicy if these conditions
|
||||
* are not satisfied.
|
||||
*/
|
||||
* Returns the id of the object, served by the given servant (assuming that
|
||||
* the servant serves only one object). The id is found in one of the
|
||||
* following ways.
|
||||
* <ul>
|
||||
* <li>If the POA has both the RETAIN and the UNIQUE_ID policy and the
|
||||
* specified servant is active, the method return the Object Id associated
|
||||
* with that servant. </li>
|
||||
* <li> If the POA has both the RETAIN and the IMPLICIT_ACTIVATION policy and
|
||||
* either the POA has the MULTIPLE_ID policy or the specified servant is
|
||||
* inactive, the method activates the servant using a POA-generated Object Id
|
||||
* and the Interface Id associated with the servant, and returns that Object
|
||||
* Id. </li>
|
||||
* <li>If the POA has the USE_DEFAULT_SERVANT policy, the servant specified
|
||||
* is the default servant, and the method is being invoked in the context of
|
||||
* executing a request on the default servant, the method returns the ObjectId
|
||||
* associated with the current invocation. </li>
|
||||
* </ul>
|
||||
*
|
||||
* @throws ServantNotActive in all cases, not listed in the list above.
|
||||
* @throws WrongPolicy The method requres USE_DEFAULT_SERVANT policy or a
|
||||
* combination of the RETAIN policy and either the UNIQUE_ID or
|
||||
* IMPLICIT_ACTIVATION policies and throws the WrongPolicy if these conditions
|
||||
* are not satisfied.
|
||||
*/
|
||||
public byte[] servant_to_id(Servant the_Servant)
|
||||
throws ServantNotActive, WrongPolicy
|
||||
{
|
||||
|
|
|
@ -42,6 +42,7 @@ package gnu.classpath.jdwp;
|
|||
import gnu.classpath.jdwp.event.Event;
|
||||
import gnu.classpath.jdwp.event.EventManager;
|
||||
import gnu.classpath.jdwp.event.EventRequest;
|
||||
import gnu.classpath.jdwp.exception.JdwpException;
|
||||
import gnu.classpath.jdwp.id.ThreadId;
|
||||
import gnu.classpath.jdwp.processor.PacketProcessor;
|
||||
import gnu.classpath.jdwp.transport.ITransport;
|
||||
|
@ -206,7 +207,20 @@ public class Jdwp
|
|||
EventManager em = EventManager.getDefault ();
|
||||
EventRequest request = em.getEventRequest (event);
|
||||
if (request != null)
|
||||
sendEvent (request, event);
|
||||
{
|
||||
try
|
||||
{
|
||||
System.out.println ("Jdwp.notify: sending event " + event);
|
||||
sendEvent (request, event);
|
||||
jdwp._enforceSuspendPolicy (request.getSuspendPolicy ());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
/* Really not much we can do. For now, just print out
|
||||
a warning to the user. */
|
||||
System.out.println ("Jdwp.notify: caught exception: " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -217,32 +231,25 @@ public class Jdwp
|
|||
*
|
||||
* @param request the debugger request for the event
|
||||
* @param event the event to send
|
||||
* @throws IOException if a communications failure occurs
|
||||
*/
|
||||
public static void sendEvent (EventRequest request, Event event)
|
||||
throws IOException
|
||||
{
|
||||
Jdwp jdwp = getDefault ();
|
||||
if (jdwp != null)
|
||||
{
|
||||
try
|
||||
// !! May need to implement send queue?
|
||||
synchronized (jdwp._connection)
|
||||
{
|
||||
// !! May need to implement send queue?
|
||||
synchronized (jdwp._connection)
|
||||
{
|
||||
jdwp._connection.sendEvent (request, event);
|
||||
}
|
||||
|
||||
// Follow suspend policy
|
||||
jdwp._enforceSuspendPolicy (request.getSuspendPolicy ());
|
||||
}
|
||||
catch (IOException ie)
|
||||
{
|
||||
System.out.println ("Jdwp.notify: caught exception: " + ie);
|
||||
jdwp._connection.sendEvent (request, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to enforce suspend policies on event notification
|
||||
private void _enforceSuspendPolicy (byte suspendPolicy)
|
||||
throws JdwpException
|
||||
{
|
||||
switch (suspendPolicy)
|
||||
{
|
||||
|
|
|
@ -41,6 +41,7 @@ package gnu.classpath.jdwp.event;
|
|||
|
||||
import gnu.classpath.jdwp.VMVirtualMachine;
|
||||
import gnu.classpath.jdwp.exception.InvalidEventTypeException;
|
||||
import gnu.classpath.jdwp.exception.JdwpException;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Hashtable;
|
||||
|
@ -133,7 +134,7 @@ public class EventManager
|
|||
EventRequest.EVENT_VM_DEATH,
|
||||
EventRequest.SUSPEND_NONE));
|
||||
}
|
||||
catch (InvalidEventTypeException e)
|
||||
catch (JdwpException e)
|
||||
{
|
||||
// This can't happen
|
||||
}
|
||||
|
@ -187,9 +188,10 @@ public class EventManager
|
|||
*
|
||||
* @param request the request to monitor
|
||||
* @throws InvalidEventTypeException for invalid event kind
|
||||
* @throws JdwpException for other errors involving request
|
||||
*/
|
||||
public void requestEvent (EventRequest request)
|
||||
throws InvalidEventTypeException
|
||||
throws JdwpException
|
||||
{
|
||||
// Add request to request list
|
||||
Hashtable requests;
|
||||
|
@ -212,8 +214,10 @@ public class EventManager
|
|||
* @param kind the event kind
|
||||
* @param id the ID of the request to delete
|
||||
* @throws IllegalArgumentException for invalid event kind
|
||||
* @throws JdwpException for other errors deleting request
|
||||
*/
|
||||
public void deleteRequest (byte kind, int id)
|
||||
throws JdwpException
|
||||
{
|
||||
Hashtable requests;
|
||||
requests = (Hashtable) _requests.get (new Byte (kind));
|
||||
|
@ -237,8 +241,10 @@ public class EventManager
|
|||
*
|
||||
* @param kind the event kind
|
||||
* @throws IllegalArgumentException for invalid event kind
|
||||
* @throws JdwpException for error clearing events
|
||||
*/
|
||||
public void clearRequests (byte kind)
|
||||
throws JdwpException
|
||||
{
|
||||
Hashtable requests = (Hashtable) _requests.get (new Byte (kind));
|
||||
if (requests == null)
|
||||
|
|
|
@ -40,6 +40,8 @@ package gnu.java.awt.image;
|
|||
import java.awt.image.ImageConsumer;
|
||||
import java.awt.image.ImageProducer;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInput;
|
||||
import java.io.EOFException;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -55,6 +57,7 @@ public abstract class ImageDecoder implements ImageProducer
|
|||
int offset;
|
||||
int length;
|
||||
InputStream input;
|
||||
DataInput datainput;
|
||||
|
||||
static
|
||||
{
|
||||
|
@ -79,6 +82,11 @@ public abstract class ImageDecoder implements ImageProducer
|
|||
this.input = is;
|
||||
}
|
||||
|
||||
public ImageDecoder (DataInput datainput)
|
||||
{
|
||||
this.datainput = datainput;
|
||||
}
|
||||
|
||||
public ImageDecoder (byte[] imagedata, int imageoffset, int imagelength)
|
||||
{
|
||||
data = imagedata;
|
||||
|
@ -119,6 +127,8 @@ public abstract class ImageDecoder implements ImageProducer
|
|||
{
|
||||
if (url != null)
|
||||
input = url.openStream();
|
||||
else if (datainput != null)
|
||||
input = new DataInputStreamWrapper(datainput);
|
||||
else
|
||||
{
|
||||
if (filename != null)
|
||||
|
@ -153,4 +163,26 @@ public abstract class ImageDecoder implements ImageProducer
|
|||
}
|
||||
|
||||
public abstract void produce (Vector v, InputStream is) throws IOException;
|
||||
|
||||
private static class DataInputStreamWrapper extends InputStream
|
||||
{
|
||||
private final DataInput datainput;
|
||||
|
||||
DataInputStreamWrapper(DataInput datainput)
|
||||
{
|
||||
this.datainput = datainput;
|
||||
}
|
||||
|
||||
public int read() throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
return datainput.readByte() & 0xFF;
|
||||
}
|
||||
catch (EOFException eofe)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,6 @@ import java.awt.Graphics;
|
|||
import java.awt.Image;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Shape;
|
||||
import java.awt.SystemColor;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.text.AttributedCharacterIterator;
|
||||
|
||||
|
@ -81,18 +80,23 @@ public class GdkGraphics extends Graphics
|
|||
native void initStateUnlocked (GtkComponentPeer component);
|
||||
native void initState (int width, int height);
|
||||
native void initFromImage (GtkImage image);
|
||||
native void copyState (GdkGraphics g);
|
||||
native void nativeCopyState (GdkGraphics g);
|
||||
|
||||
/**
|
||||
* A cached instance that is used by {@link #create} in order to avoid
|
||||
* massive allocation of graphics contexts.
|
||||
*/
|
||||
GdkGraphics cached = null;
|
||||
|
||||
/**
|
||||
* A link to the parent context. This is used in {@link #dispose} to put
|
||||
* this graphics context into the cache.
|
||||
*/
|
||||
GdkGraphics parent = null;
|
||||
|
||||
GdkGraphics (GdkGraphics g)
|
||||
{
|
||||
color = g.color;
|
||||
xorColor = g.xorColor;
|
||||
font = g.font;
|
||||
if (font == null)
|
||||
font = new Font ("Dialog", Font.PLAIN, 12);
|
||||
clip = new Rectangle (g.clip);
|
||||
component = g.component;
|
||||
|
||||
parent = g;
|
||||
copyState (g);
|
||||
}
|
||||
|
||||
|
@ -162,12 +166,54 @@ public class GdkGraphics extends Graphics
|
|||
public native void copyArea(int x, int y, int width, int height,
|
||||
int dx, int dy);
|
||||
|
||||
public Graphics create ()
|
||||
/**
|
||||
* Creates a copy of this GdkGraphics instance. This implementation can
|
||||
* reuse a cached instance to avoid massive instantiation of Graphics objects
|
||||
* during painting.
|
||||
*
|
||||
* @return a copy of this graphics context
|
||||
*/
|
||||
public Graphics create()
|
||||
{
|
||||
return new GdkGraphics (this);
|
||||
GdkGraphics copy = cached;
|
||||
if (copy == null)
|
||||
copy = new GdkGraphics(this);
|
||||
else
|
||||
{
|
||||
copy.copyState(this);
|
||||
cached = null;
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
public native void dispose();
|
||||
public native void nativeDispose();
|
||||
|
||||
/**
|
||||
* Disposes this graphics object. This puts this graphics context into the
|
||||
* cache of its parent graphics if there is one.
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
if (parent != null)
|
||||
{
|
||||
parent.cached = this;
|
||||
parent = null;
|
||||
}
|
||||
else
|
||||
nativeDispose();
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called when this object gets finalized by the garbage collector.
|
||||
* In addition to {@link Graphics#finalize()} this calls nativeDispose() to
|
||||
* make sure the native resources are freed before the graphics context is
|
||||
* thrown away.
|
||||
*/
|
||||
public void finalize()
|
||||
{
|
||||
super.finalize();
|
||||
nativeDispose();
|
||||
}
|
||||
|
||||
public boolean drawImage (Image img, int x, int y,
|
||||
Color bgcolor, ImageObserver observer)
|
||||
|
@ -248,9 +294,8 @@ public class GdkGraphics extends Graphics
|
|||
public void drawString (String str, int x, int y)
|
||||
{
|
||||
drawString(getFontPeer(), str, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void drawString (AttributedCharacterIterator ci, int x, int y)
|
||||
{
|
||||
throw new Error ("not implemented");
|
||||
|
@ -419,4 +464,23 @@ public class GdkGraphics extends Graphics
|
|||
|
||||
translateNative (x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies over the state of another GdkGraphics to this instance. This is
|
||||
* used by the {@link #GdkGraphics(GdkGraphics)} constructor and the
|
||||
* {@link #create()} method.
|
||||
*
|
||||
* @param g the GdkGraphics object to copy the state from
|
||||
*/
|
||||
private void copyState(GdkGraphics g)
|
||||
{
|
||||
color = g.color;
|
||||
xorColor = g.xorColor;
|
||||
font = g.font;
|
||||
if (font == null)
|
||||
font = new Font ("Dialog", Font.PLAIN, 12);
|
||||
clip = new Rectangle (g.clip);
|
||||
component = g.component;
|
||||
nativeCopyState(g);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,11 +180,14 @@ public class GdkGraphics2D extends Graphics2D
|
|||
else
|
||||
fg = new Color(g.fg.getRGB());
|
||||
|
||||
if (g.bg.getAlpha() != -1)
|
||||
bg = new Color(g.bg.getRed(), g.bg.getGreen(), g.bg.getBlue(),
|
||||
g.bg.getAlpha());
|
||||
else
|
||||
bg = new Color(g.bg.getRGB());
|
||||
if (g.bg != null)
|
||||
{
|
||||
if (g.bg.getAlpha() != -1)
|
||||
bg = new Color(g.bg.getRed(), g.bg.getGreen(), g.bg.getBlue(),
|
||||
g.bg.getAlpha());
|
||||
else
|
||||
bg = new Color(g.bg.getRGB());
|
||||
}
|
||||
|
||||
if (g.clip == null)
|
||||
clip = null;
|
||||
|
@ -1088,6 +1091,8 @@ public class GdkGraphics2D extends Graphics2D
|
|||
|
||||
public void setBackground(Color c)
|
||||
{
|
||||
if (c == null)
|
||||
c = Color.WHITE;
|
||||
bg = c;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ import java.awt.image.ImageConsumer;
|
|||
import java.awt.image.ImageProducer;
|
||||
import java.awt.image.Raster;
|
||||
import java.awt.image.RenderedImage;
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -102,6 +103,11 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder
|
|||
0x00ff0000,
|
||||
0x0000ff00,
|
||||
0x000000ff);
|
||||
public GdkPixbufDecoder (DataInput datainput)
|
||||
{
|
||||
super (datainput);
|
||||
}
|
||||
|
||||
public GdkPixbufDecoder (InputStream in)
|
||||
{
|
||||
super (in);
|
||||
|
@ -630,7 +636,14 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder
|
|||
boolean ignoreMetadata)
|
||||
{
|
||||
super.setInput(input, seekForwardOnly, ignoreMetadata);
|
||||
dec = new GdkPixbufDecoder((InputStream) getInput());
|
||||
Object get = getInput();
|
||||
if (get instanceof InputStream)
|
||||
dec = new GdkPixbufDecoder((InputStream) get);
|
||||
else if (get instanceof DataInput)
|
||||
dec = new GdkPixbufDecoder((DataInput) get);
|
||||
else
|
||||
throw new IllegalArgumentException("input object not supported: "
|
||||
+ get);
|
||||
}
|
||||
|
||||
public BufferedImage read(int imageIndex, ImageReadParam param)
|
||||
|
|
|
@ -0,0 +1,153 @@
|
|||
/* ArrayPersistenceDelegate.java - A PersistenceDelegate that handles arrays.
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder;
|
||||
|
||||
import java.beans.Encoder;
|
||||
import java.beans.Expression;
|
||||
import java.beans.PersistenceDelegate;
|
||||
import java.beans.Statement;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class ArrayPersistenceDelegate extends PersistenceDelegate
|
||||
{
|
||||
private static final HashMap NULL_VALUES = new HashMap();
|
||||
|
||||
static
|
||||
{
|
||||
NULL_VALUES.put(Boolean.TYPE, Boolean.FALSE);
|
||||
NULL_VALUES.put(Byte.TYPE, Byte.valueOf((byte) 0));
|
||||
NULL_VALUES.put(Short.TYPE, Short.valueOf((short) 0));
|
||||
NULL_VALUES.put(Integer.TYPE, Integer.valueOf(0));
|
||||
NULL_VALUES.put(Long.TYPE, Long.valueOf(0));
|
||||
NULL_VALUES.put(Float.TYPE, Float.valueOf(0.0f));
|
||||
NULL_VALUES.put(Double.TYPE, Double.valueOf(0.0));
|
||||
}
|
||||
|
||||
protected Expression instantiate(Object oldInstance, Encoder out)
|
||||
{
|
||||
Class type = oldInstance.getClass().getComponentType();
|
||||
|
||||
// oldInstance is expected to be an array, then
|
||||
// getClass().getComponentType() should lead
|
||||
// to its component type.
|
||||
assert (type != null);
|
||||
|
||||
// Not handling primitive types in a special way here
|
||||
// causes that Class.forName("int") is built as an Expression
|
||||
// later which would cause an exception if executed. A special
|
||||
// handling to avoid the execution for primitive types can be
|
||||
// java.beans.Encoder.writeExpression() .
|
||||
return new Expression(
|
||||
oldInstance,
|
||||
Array.class,
|
||||
"newInstance",
|
||||
new Object[] {
|
||||
type,
|
||||
new Integer(Array.getLength(oldInstance)) });
|
||||
}
|
||||
|
||||
protected void initialize(Class type, Object oldInstance, Object newInstance,
|
||||
Encoder out)
|
||||
{
|
||||
int length = Array.getLength(oldInstance);
|
||||
|
||||
// Compares the array value against a prototypical
|
||||
// null value of the array's component type in order to skip
|
||||
// writing the default values of an array.
|
||||
|
||||
// Note: I have no idea why the persistence delegate for arrays writes
|
||||
// an Expression that reads the value and then writes a Statement that sets
|
||||
// the value. However it turned out that object arrays work better with the
|
||||
// get-Expression and primitive array work fine with the set-Statement.
|
||||
|
||||
type = type.getComponentType();
|
||||
if (type.isPrimitive())
|
||||
{
|
||||
Object nullValue = NULL_VALUES.get(type);
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
Object oldValue = Array.get(oldInstance, i);
|
||||
|
||||
if (!oldValue.equals(nullValue))
|
||||
{
|
||||
out.writeExpression(new Expression(Array.class, "get",
|
||||
new Object[] { oldInstance,
|
||||
Integer.valueOf(i),
|
||||
}));
|
||||
|
||||
out.writeStatement(new Statement(Array.class, "set",
|
||||
new Object[] {
|
||||
oldInstance,
|
||||
Integer.valueOf(i),
|
||||
oldValue
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
Object oldValue = Array.get(oldInstance, i);
|
||||
|
||||
if (oldValue != null)
|
||||
{
|
||||
out.writeExpression(new Expression(Array.class, "get",
|
||||
new Object[] { oldInstance,
|
||||
Integer.valueOf(i),
|
||||
}));
|
||||
|
||||
out.writeStatement(new Statement(Array.class, "set",
|
||||
new Object[] {
|
||||
oldInstance,
|
||||
Integer.valueOf(i),
|
||||
oldValue
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/* ClassPersistenceDelegate.java - A PersistenceDelegate for the Class type.
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.java.beans.encoder;
|
||||
|
||||
import java.beans.Encoder;
|
||||
import java.beans.Expression;
|
||||
import java.beans.PersistenceDelegate;
|
||||
|
||||
/** <p>The <code>ClassPersistenceDelegate</code> creates
|
||||
* <code>Expression</code> instances which denote class resolutions.</p>
|
||||
*
|
||||
* <p>The class resolution is always the last step when serializing a tree
|
||||
* of objects. Due to the recursive nature of the algorithm we need a way
|
||||
* to end the recursion. This is achieved by the implementation of this
|
||||
* {@link instantiate} method. Arbitrary classes are described with a call
|
||||
* to <code>Class.forName</code>. However for the <code>Class</code> class
|
||||
* we call <code>getClass()</code> on a <code>String.class</code> instance.
|
||||
* This in turn lead to the resolution of the String class which is always
|
||||
* encoded as <code>"".getClass()</code>. Finally the <code>Encoder</code>
|
||||
* treats strings in a special way so that the recursion ends here.
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*/
|
||||
public class ClassPersistenceDelegate extends PersistenceDelegate
|
||||
{
|
||||
|
||||
protected Expression instantiate(Object oldInstance, Encoder out)
|
||||
{
|
||||
Class oldClass = (Class) oldInstance;
|
||||
|
||||
// Due to the special handling of String instances in the Encoder
|
||||
// this Expression does not lead to further class resolutions.
|
||||
if (oldClass == String.class)
|
||||
return new Expression(oldClass, "", "getClass", null);
|
||||
|
||||
// This Expression will lead to the class resolution of String.class.
|
||||
if (oldClass == Class.class)
|
||||
return new Expression(oldClass, String.class, "getClass", null);
|
||||
|
||||
// This Expression will lead to the class resolution of Class.class.
|
||||
return new Expression(oldClass, Class.class, "forName",
|
||||
new Object[] { oldClass.getName() });
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
/* CollectionPersistenceDelegate.java - A PersistenceDelegate for Collection subclasses.
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.beans.Encoder;
|
||||
import java.beans.Expression;
|
||||
import java.beans.PersistenceDelegate;
|
||||
import java.beans.Statement;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/** <p>A <code>PersistenceDelegate</code> implementation that calls
|
||||
* the no-argument constructor to create the Collection instance and
|
||||
* uses an iterator to add all the objects it reaches through it.</p>
|
||||
*
|
||||
* <p>It is used for <code>Set</code> and <code>List</code>
|
||||
* implementations.</p>
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*/
|
||||
public class CollectionPersistenceDelegate extends PersistenceDelegate
|
||||
{
|
||||
|
||||
protected Expression instantiate(Object oldInstance, Encoder out)
|
||||
{
|
||||
return new Expression(
|
||||
oldInstance,
|
||||
oldInstance.getClass(),
|
||||
"new",
|
||||
null);
|
||||
}
|
||||
|
||||
protected void initialize(Class type, Object oldInstance, Object newInstance,
|
||||
Encoder out)
|
||||
{
|
||||
Iterator ite = ((Collection) oldInstance).iterator();
|
||||
|
||||
while (ite.hasNext())
|
||||
{
|
||||
out.writeStatement(new Statement(oldInstance, "add",
|
||||
new Object[] { ite.next() }));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
/* Context.java -- Provides calling context information to ScannerStates.
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder;
|
||||
|
||||
/** A <code>Contect</code> object describes the current state
|
||||
* and the call number while processing the original object
|
||||
* tree in the {@link ScanEngine}.
|
||||
*
|
||||
* <p>The class allows to distinguish the different calling states
|
||||
* and is neccessary for the child element skipping feature of
|
||||
* the {@link GenericScannerState}.</p>
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*
|
||||
*/
|
||||
public class Context
|
||||
{
|
||||
private String state;
|
||||
|
||||
private int call;
|
||||
|
||||
Context(String newState, int newCall)
|
||||
{
|
||||
state = newState;
|
||||
call = newCall;
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
int hc = 7;
|
||||
hc = 31 * hc + state.hashCode();
|
||||
hc = 31 * hc + call;
|
||||
|
||||
return hc;
|
||||
}
|
||||
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (!(o instanceof Context))
|
||||
return false;
|
||||
|
||||
Context that = (Context) o;
|
||||
|
||||
return state.equals(that.state)
|
||||
&& call == that.call;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "Context [state=" + state + ", call=" + call + "]";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,257 @@
|
|||
/* GenericScannerState.java
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import gnu.java.beans.encoder.elements.ArrayInstantiation;
|
||||
import gnu.java.beans.encoder.elements.Array_Get;
|
||||
import gnu.java.beans.encoder.elements.Array_Set;
|
||||
import gnu.java.beans.encoder.elements.ClassResolution;
|
||||
import gnu.java.beans.encoder.elements.Element;
|
||||
import gnu.java.beans.encoder.elements.List_Get;
|
||||
import gnu.java.beans.encoder.elements.List_Set;
|
||||
import gnu.java.beans.encoder.elements.MethodInvocation;
|
||||
import gnu.java.beans.encoder.elements.NullObject;
|
||||
import gnu.java.beans.encoder.elements.ObjectInstantiation;
|
||||
import gnu.java.beans.encoder.elements.ObjectReference;
|
||||
import gnu.java.beans.encoder.elements.PrimitiveInstantiation;
|
||||
import gnu.java.beans.encoder.elements.StaticFieldAccess;
|
||||
import gnu.java.beans.encoder.elements.StaticMethodInvocation;
|
||||
import gnu.java.beans.encoder.elements.StringReference;
|
||||
|
||||
/**
|
||||
* This class is a {@link ScannerState} implementation that creates
|
||||
* suitable {@link gnu.java.beans.encoder.elements.Element} instances
|
||||
* for each transition variant.
|
||||
*
|
||||
* <p>Furthermore it can optionally skip a certain number of child
|
||||
* elements. The algorithm can cope with the fact that one
|
||||
* <code>GenericScannerState</code> instance may be called at
|
||||
* different levels of recursions.</p>
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*/
|
||||
class GenericScannerState extends ScannerState
|
||||
{
|
||||
private int skipElements, initialSkipElements;
|
||||
|
||||
final Root root;
|
||||
|
||||
HashMap skipValues;
|
||||
|
||||
GenericScannerState(Root newRoot)
|
||||
{
|
||||
root = newRoot;
|
||||
}
|
||||
|
||||
GenericScannerState(Root root, int skipElements)
|
||||
{
|
||||
this(root);
|
||||
this.skipElements = initialSkipElements = skipElements;
|
||||
|
||||
if (skipElements > 0)
|
||||
skipValues = new HashMap();
|
||||
}
|
||||
|
||||
protected void enterImpl(Context ctx)
|
||||
{
|
||||
if (skipValues != null)
|
||||
{
|
||||
Integer skip = (Integer) skipValues.get(ctx);
|
||||
|
||||
if (skip == null)
|
||||
{
|
||||
skip = Integer.valueOf(initialSkipElements);
|
||||
skipValues.put(ctx, skip);
|
||||
}
|
||||
|
||||
skipElements = skip.intValue();
|
||||
}
|
||||
}
|
||||
|
||||
void methodInvocation(String methodName)
|
||||
{
|
||||
if (skipValues != null && skipElements > 0)
|
||||
return;
|
||||
|
||||
root.addChild(new MethodInvocation(methodName));
|
||||
}
|
||||
|
||||
void staticMethodInvocation(String className, String methodName)
|
||||
{
|
||||
if (skipValues != null && skipElements > 0)
|
||||
return;
|
||||
|
||||
root.addChild(new StaticMethodInvocation(className, methodName));
|
||||
}
|
||||
|
||||
void staticFieldAccess(String className, String fieldName)
|
||||
{
|
||||
if (skipValues != null && skipElements > 0)
|
||||
return;
|
||||
|
||||
root.addChild(new StaticFieldAccess(className, fieldName));
|
||||
}
|
||||
|
||||
void classResolution(String className)
|
||||
{
|
||||
if (skipValues != null && skipElements > 0)
|
||||
return;
|
||||
|
||||
root.addChild(new ClassResolution(className));
|
||||
}
|
||||
|
||||
void objectInstantiation(String className, ObjectId objectId)
|
||||
{
|
||||
if (skipValues != null && skipElements > 0)
|
||||
return;
|
||||
|
||||
Element elem = new ObjectInstantiation(className);
|
||||
elem.initId(objectId);
|
||||
|
||||
root.addChild(elem);
|
||||
}
|
||||
|
||||
void primitiveInstantiation(String primitiveName, String valueAsString)
|
||||
{
|
||||
if (skipValues != null && skipElements > 0)
|
||||
return;
|
||||
|
||||
root.addChild(new PrimitiveInstantiation(primitiveName, valueAsString));
|
||||
}
|
||||
|
||||
void objectArrayInstantiation(String arrayClassName, String lengthAsString,
|
||||
ObjectId objectId)
|
||||
{
|
||||
if (skipValues != null && skipElements > 0)
|
||||
return;
|
||||
|
||||
Element elem = new ArrayInstantiation(arrayClassName, lengthAsString);
|
||||
elem.initId(objectId);
|
||||
|
||||
root.addChild(elem);
|
||||
}
|
||||
|
||||
void primitiveArrayInstantiation(String arrayClassName, String lengthAsString,
|
||||
ObjectId objectId)
|
||||
{
|
||||
objectArrayInstantiation(arrayClassName, lengthAsString, objectId);
|
||||
}
|
||||
|
||||
void arraySet(String indexAsString)
|
||||
{
|
||||
if (skipValues != null && skipElements > 0)
|
||||
return;
|
||||
|
||||
root.addChild(new Array_Set(indexAsString));
|
||||
}
|
||||
|
||||
void arrayGet(String indexAsString)
|
||||
{
|
||||
if (skipValues != null && skipElements > 0)
|
||||
return;
|
||||
|
||||
root.addChild(new Array_Get(indexAsString));
|
||||
}
|
||||
|
||||
void listGet()
|
||||
{
|
||||
if (skipValues != null && skipElements > 0)
|
||||
return;
|
||||
|
||||
root.addChild(new List_Get());
|
||||
}
|
||||
|
||||
void listSet()
|
||||
{
|
||||
if (skipValues != null && skipElements > 0)
|
||||
return;
|
||||
|
||||
root.addChild(new List_Set());
|
||||
}
|
||||
|
||||
void nullObject()
|
||||
{
|
||||
if (skipValues != null && skipElements > 0)
|
||||
return;
|
||||
|
||||
root.addChild(new NullObject());
|
||||
}
|
||||
|
||||
void stringReference(String string)
|
||||
{
|
||||
if (skipValues != null && skipElements > 0)
|
||||
return;
|
||||
|
||||
root.addChild(new StringReference(string));
|
||||
}
|
||||
|
||||
void objectReference(ObjectId id)
|
||||
{
|
||||
if (skipValues != null && skipElements > 0)
|
||||
return;
|
||||
|
||||
root.addChild(new ObjectReference(id));
|
||||
}
|
||||
|
||||
void end()
|
||||
{
|
||||
if (skipValues != null)
|
||||
{
|
||||
if (skipElements > 0)
|
||||
skipElements--;
|
||||
else
|
||||
{
|
||||
// Finishes the Element we are constructing.
|
||||
root.end();
|
||||
}
|
||||
skipValues.put(context(), Integer.valueOf(skipElements));
|
||||
}
|
||||
else
|
||||
root.end();
|
||||
|
||||
}
|
||||
|
||||
void enter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,133 @@
|
|||
/* IgnoringScannerState.java -- A ScannerState that does nothing.
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder;
|
||||
|
||||
/** A special {@link ScannerState} implementation that ignores all child
|
||||
* elements.
|
||||
*
|
||||
* <p>Consider the call hierarchy:
|
||||
* <code>
|
||||
* methodInvocation
|
||||
* objectInstantiation
|
||||
* classResolution*
|
||||
* objectInstantiation
|
||||
* classResolution
|
||||
* </code>
|
||||
* </p>
|
||||
*
|
||||
* <p>When the ignoring state is active one can filter the elements of
|
||||
* one level. One has to set up the state machine that a transition
|
||||
* via "class resolution" from a state that was reached via "object
|
||||
* instantation" reaches an <code>IgnoringScannerState</code>.</p>
|
||||
*
|
||||
* <p>Setting the default successor of a <code>IgnoringScannerState</code>
|
||||
* to itself causes all elements of the call hierarchy to be skipped
|
||||
* until another state is reached by going back.</p>
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*
|
||||
*/
|
||||
class IgnoringScannerState extends ScannerState
|
||||
{
|
||||
|
||||
void methodInvocation(String methodName)
|
||||
{
|
||||
}
|
||||
|
||||
void staticMethodInvocation(String className, String methodName)
|
||||
{
|
||||
}
|
||||
|
||||
void staticFieldAccess(String className, String fieldName)
|
||||
{
|
||||
}
|
||||
|
||||
void classResolution(String className)
|
||||
{
|
||||
}
|
||||
|
||||
void objectInstantiation(String className, ObjectId objectId)
|
||||
{
|
||||
}
|
||||
|
||||
void primitiveInstantiation(String primitiveName, String valueAsString)
|
||||
{
|
||||
}
|
||||
|
||||
void objectArrayInstantiation(String arrayClassName, String lengthAsString, ObjectId objectId)
|
||||
{
|
||||
}
|
||||
|
||||
void primitiveArrayInstantiation(String arrayClassName, String lengthAsString, ObjectId objectId)
|
||||
{
|
||||
}
|
||||
|
||||
void arraySet(String indexAsString)
|
||||
{
|
||||
}
|
||||
|
||||
void arrayGet(String indexAsString)
|
||||
{
|
||||
}
|
||||
|
||||
void listGet()
|
||||
{
|
||||
}
|
||||
|
||||
void listSet()
|
||||
{
|
||||
}
|
||||
|
||||
void nullObject()
|
||||
{
|
||||
}
|
||||
|
||||
void stringReference(String string)
|
||||
{
|
||||
}
|
||||
|
||||
void objectReference(ObjectId id)
|
||||
{
|
||||
}
|
||||
|
||||
void end()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
/* MapPersistenceDelegate.java -- A PersistenceDelegate for Map subclasses.
|
||||
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder;
|
||||
|
||||
import java.util.Map;
|
||||
import java.beans.Encoder;
|
||||
import java.beans.Expression;
|
||||
import java.beans.PersistenceDelegate;
|
||||
import java.beans.Statement;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*/
|
||||
public class MapPersistenceDelegate extends PersistenceDelegate
|
||||
{
|
||||
|
||||
protected Expression instantiate(Object oldInstance, Encoder out)
|
||||
{
|
||||
return new Expression(
|
||||
oldInstance,
|
||||
oldInstance.getClass(),
|
||||
"new",
|
||||
null);
|
||||
}
|
||||
|
||||
protected void initialize(Class type, Object oldInstance, Object newInstance,
|
||||
Encoder out)
|
||||
{
|
||||
Map map = (Map) oldInstance;
|
||||
Iterator ite = map.keySet().iterator();
|
||||
|
||||
while (ite.hasNext())
|
||||
{
|
||||
Object key = ite.next();
|
||||
out.writeStatement(new Statement(oldInstance, "put",
|
||||
new Object[] { key, map.get(key) }));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
/* ObjectId.java -- Simple object identification mechanism for XML encoding.
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* ObjectId provides an object identification mechanism which gives each object
|
||||
* a name in the form <code><class><Nameindex></code>.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* Each id can be in an unused state which means that only one instance of the
|
||||
* object is in use and a special id is not needed. Certain {@link
|
||||
* gnu.java.beans.encoder.elements.Element} subclasses use this feature to find
|
||||
* out whether they write the "id" attribute or not.
|
||||
* </p>
|
||||
* <p>
|
||||
* An <code>ObjectId</code> instance is typically given to multiple objects.
|
||||
* The second user should then invoke the {@link #init} method to generate the
|
||||
* identification string and bring the id in the 'used' state.
|
||||
* </p>
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*/
|
||||
public class ObjectId
|
||||
{
|
||||
/**
|
||||
* Stores the index an object of a specific type should be given.
|
||||
*/
|
||||
private static HashMap nameIndices = new HashMap();
|
||||
|
||||
private String id;
|
||||
|
||||
private Class klass;
|
||||
|
||||
ObjectId(Class klass)
|
||||
{
|
||||
this.klass = klass;
|
||||
}
|
||||
|
||||
public boolean isUnused()
|
||||
{
|
||||
return id == null;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return (id != null) ? id : "<unused id>";
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Generates a simple Id by concatenating a class name with a self-increasing
|
||||
* number.
|
||||
* </p>
|
||||
*/
|
||||
public void init()
|
||||
{
|
||||
assert (klass != null);
|
||||
|
||||
if (id != null)
|
||||
return;
|
||||
|
||||
Integer count = (Integer) nameIndices.get(klass);
|
||||
if (count == null)
|
||||
{
|
||||
count = Integer.valueOf(0);
|
||||
}
|
||||
|
||||
if (klass.isArray())
|
||||
{
|
||||
Class ct = klass.getComponentType();
|
||||
if (ct == Boolean.TYPE)
|
||||
id = "booleanArray" + count.intValue();
|
||||
else if (ct == Byte.TYPE)
|
||||
id = "byteArray" + count.intValue();
|
||||
else if (ct == Short.TYPE)
|
||||
id = "shortArray" + count.intValue();
|
||||
else if (ct == Integer.TYPE)
|
||||
id = "intArray" + count.intValue();
|
||||
else if (ct == Long.TYPE)
|
||||
id = "longArray" + count.intValue();
|
||||
else if (ct == Float.TYPE)
|
||||
id = "floatArray" + count.intValue();
|
||||
else if (ct == Double.TYPE)
|
||||
id = "doubleArray" + count.intValue();
|
||||
}
|
||||
else
|
||||
id = klass.getName() + count.intValue();
|
||||
|
||||
nameIndices.put(klass, Integer.valueOf(count.intValue() + 1));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/* PrimitivePersistenceDelegate.java
|
||||
-- A PersistenceDelegate for primitive data types.
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.java.beans.encoder;
|
||||
|
||||
import java.beans.Encoder;
|
||||
import java.beans.Expression;
|
||||
import java.beans.PersistenceDelegate;
|
||||
|
||||
/**
|
||||
* A shared PersistenceDelegate implementation for all primitive types.
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*/
|
||||
public class PrimitivePersistenceDelegate extends PersistenceDelegate
|
||||
{
|
||||
|
||||
protected Expression instantiate(Object oldInstance, Encoder out)
|
||||
{
|
||||
// The implementation relies on the fact that every primitive
|
||||
// wrapper class has a constructor accepting a String argument.
|
||||
// By using these constructors creating a primitive instance
|
||||
// depends on the String class only.
|
||||
return new Expression(oldInstance, oldInstance.getClass(), "new",
|
||||
new Object[] { oldInstance.toString() });
|
||||
}
|
||||
|
||||
protected void initialize(Class type, Object oldInstance, Object newInstance, Encoder out)
|
||||
{
|
||||
// This is a hack to make serializing primitive arrays work correctly.
|
||||
// Instead of modifying an existing primitive instance to make it equal
|
||||
// with another instance (which is not possible because primitives are
|
||||
// immutable) we create a new instance. This is against the specification
|
||||
// of the initialize method but make things work fine.
|
||||
out.writeExpression(new Expression(oldInstance, oldInstance.getClass(), "new",
|
||||
new Object[] { oldInstance.toString() }));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
/* ReportingScannerState.java -- A state for debugging purposes.
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder;
|
||||
|
||||
/**
|
||||
* A <code>ScannerState</code> implementation that prints useful details
|
||||
* about its arguments. Use it when the XML encoding does not work correctly
|
||||
* and you want to find out how things relate to each other.
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*/
|
||||
class ReportingScannerState extends ScannerState
|
||||
{
|
||||
|
||||
void methodInvocation(String methodName)
|
||||
{
|
||||
System.out.println("methodInvocation: " + methodName + "()");
|
||||
}
|
||||
|
||||
void staticMethodInvocation(String className, String methodName)
|
||||
{
|
||||
System.out.println("staticMethodInvocation: " + className + "." + methodName + "()");
|
||||
}
|
||||
|
||||
void staticFieldAccess(String className, String fieldName)
|
||||
{
|
||||
System.out.println("staticFieldAccess: " + className + "." + fieldName);
|
||||
}
|
||||
|
||||
void classResolution(String className)
|
||||
{
|
||||
System.out.println("classResolution: " + className);
|
||||
}
|
||||
|
||||
void objectInstantiation(String className, ObjectId objectId)
|
||||
{
|
||||
System.out.println("objectInstantiation: " + className);
|
||||
}
|
||||
|
||||
void primitiveInstantiation(String primitiveName, String valueAsString)
|
||||
{
|
||||
System.out.println("primitiveInstantiation: (" + primitiveName + ") " + valueAsString);
|
||||
}
|
||||
|
||||
void objectArrayInstantiation(String arrayClassName, String lengthAsString, ObjectId objectId)
|
||||
{
|
||||
System.out.println("objectArrayInstantiation: new " + arrayClassName + "[" + lengthAsString + "]");
|
||||
}
|
||||
|
||||
void primitiveArrayInstantiation(String arrayClassName, String lengthAsString, ObjectId objectId)
|
||||
{
|
||||
System.out.println("primitiveArrayInstantiation: new " + arrayClassName + "[" + lengthAsString + "]");
|
||||
}
|
||||
|
||||
void arraySet(String indexAsString)
|
||||
{
|
||||
System.out.println("arraySet: " + indexAsString);
|
||||
}
|
||||
|
||||
void arrayGet(String indexAsString)
|
||||
{
|
||||
System.out.println("arrayGet: " + indexAsString);
|
||||
}
|
||||
|
||||
void listGet()
|
||||
{
|
||||
System.out.println("listGet");
|
||||
}
|
||||
|
||||
void listSet()
|
||||
{
|
||||
System.out.println("listSet");
|
||||
}
|
||||
|
||||
void nullObject()
|
||||
{
|
||||
System.out.println("nullObject");
|
||||
}
|
||||
|
||||
void stringReference(String string)
|
||||
{
|
||||
System.out.println("stringReference: " + string);
|
||||
}
|
||||
|
||||
void objectReference(ObjectId id)
|
||||
{
|
||||
System.out.println("objectReference: " + id);
|
||||
}
|
||||
|
||||
void end()
|
||||
{
|
||||
System.out.println("-close");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,198 @@
|
|||
/* Root.java -- The root of an object tree.
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder;
|
||||
|
||||
import java.beans.XMLEncoder;
|
||||
import java.util.Iterator;
|
||||
import java.util.Stack;
|
||||
|
||||
import gnu.java.beans.encoder.elements.Element;
|
||||
|
||||
/** <p><code>Root</code> provides a simple interface to a tree of
|
||||
* objects.</p>
|
||||
*
|
||||
* <p>Using an instance of this class a logical representation of
|
||||
* the real object tree that is serialized can be built. When the
|
||||
* actual data should be written as XML <code>Root</code> and
|
||||
* {@link gnu.java.beans.encoder.elements.Element} class can provide
|
||||
* context information which is used to write the best fitting
|
||||
* XML representation.</p>
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*/
|
||||
public class Root
|
||||
{
|
||||
private Stack parents = new Stack();
|
||||
|
||||
private Element rootElement, current;
|
||||
|
||||
private boolean started;
|
||||
|
||||
public Root()
|
||||
{
|
||||
rootElement = current = new RootElement();
|
||||
}
|
||||
|
||||
/** <p>Adds another child element to the tree.</p>
|
||||
*
|
||||
* <p>The new element automatically becomes the current
|
||||
* element.</p>
|
||||
*
|
||||
* @param elem The new child element.
|
||||
*/
|
||||
public void addChild(Element elem)
|
||||
{
|
||||
current.addChild(elem);
|
||||
|
||||
parents.push(current);
|
||||
current = elem;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Marks that the end of the current element
|
||||
* is reached and that no more childs are added to
|
||||
* it.</p>
|
||||
*
|
||||
* <p>The behavior is to return to the nearest parent
|
||||
* element.</p>
|
||||
*/
|
||||
public void end()
|
||||
{
|
||||
current = (Element) parents.pop();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Goes back to the nearest parent element but
|
||||
* deletes the just created child.</p>
|
||||
*
|
||||
* <p>This is used if something went wrong while
|
||||
* processing the child element's {@link java.beans.Expression}
|
||||
* or {@link java.beans.Statement}.</p>
|
||||
*
|
||||
*/
|
||||
public void deleteLast()
|
||||
{
|
||||
current = (Element) parents.pop();
|
||||
|
||||
current.removeLast();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Traverses the elements in the object tree
|
||||
* and creates their XML representation in the output
|
||||
* stream of the given {@link Writer}.</p>
|
||||
*
|
||||
* <p>Finally the <code>Writer</code> is flushed.</p>
|
||||
*
|
||||
* @param writer The Writer instance that generates the XML representation.
|
||||
*/
|
||||
public void traverse(Writer writer)
|
||||
{
|
||||
if (!started)
|
||||
{
|
||||
writer.writePreamble();
|
||||
rootElement.writeStart(writer);
|
||||
}
|
||||
started = true;
|
||||
|
||||
traverse(writer, rootElement.iterator());
|
||||
|
||||
rootElement.clear();
|
||||
|
||||
writer.flush();
|
||||
}
|
||||
|
||||
/** Writes the closing element and closes the {@link Writer}
|
||||
*
|
||||
* @param writer The Writer instance that generates the XML representation.
|
||||
*/
|
||||
public void close(Writer writer)
|
||||
{
|
||||
rootElement.writeEnd(writer);
|
||||
writer.close();
|
||||
}
|
||||
|
||||
/** Recursively traverses the object tree.
|
||||
*
|
||||
* @param writer The Writer instance that generates the XML representation.
|
||||
* @param ite An Iterator returning Element instances.
|
||||
*/
|
||||
private void traverse(Writer writer, Iterator ite)
|
||||
{
|
||||
while (ite.hasNext())
|
||||
{
|
||||
Element e = (Element) ite.next();
|
||||
e.writeStart(writer);
|
||||
|
||||
traverse(writer, e.iterator());
|
||||
|
||||
e.writeEnd(writer);
|
||||
|
||||
e.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/** <p>A special Element implementation that represents the
|
||||
* encoder's context.</p>
|
||||
*
|
||||
* <p>This element is written only once per Writer.</p>
|
||||
*
|
||||
* <p>It is assumed that this element is never empty to simplify
|
||||
* the implementation.</p>
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org);
|
||||
*
|
||||
*/
|
||||
static class RootElement extends Element
|
||||
{
|
||||
public void writeStart(Writer writer)
|
||||
{
|
||||
writer.write("java", new String[] { "version", "class" },
|
||||
new String[] { System.getProperty("java.version"),
|
||||
XMLEncoder.class.getName() }, false);
|
||||
}
|
||||
|
||||
public void writeEnd(Writer writer)
|
||||
{
|
||||
writer.writeEnd(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,860 @@
|
|||
/* ScanEngine.java
|
||||
-- Scans the input and generates an object tree that can be written as XML.
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder;
|
||||
|
||||
import java.beans.Expression;
|
||||
import java.beans.Statement;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.HashMap;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
/** <p>The <code>ScanEngine</code> is the main class of the backend of the
|
||||
* XML persistence algorithm. It scans {@link java.beans.Expression} and
|
||||
* {@link java.beans.Statement} instances and some raw objects via the
|
||||
* {@link #writeObject} method and feeds it to a state machine. The
|
||||
* state machine then constructs and object tree which is finally
|
||||
* written as XML by a {@link Writer} implementation.</p>
|
||||
*
|
||||
* <p>How does it work?</p>
|
||||
* <p>The <code>ScanEngine</code> sits below the {@link java.beans.XMLEncoder}
|
||||
* class and is called by it exclusively. The <code>XMLEncoder</code> sends
|
||||
* interpretive data by invoking {@link #writeExpression}, {@link #writeStatement}
|
||||
* and {@link #writeObject}. The invocations of <code>writeExpression</code> and
|
||||
* <code>writeStatement</code> are usually nested into each other and provide
|
||||
* more information then necessary to generate the XML representation.
|
||||
* Furthermore the meaning of certain <code>Expressions</code> differs
|
||||
* depending on the enclosing elements or the inner elements have to be
|
||||
* simply discarded.</p>
|
||||
*
|
||||
* <p>To cope with this state dependant nature the <code>ScanEngine</code>
|
||||
* contains a state machine which is programmed statically (no adjustments are
|
||||
* needed, all <code>ScanEngine</code> engines use the same setup). The
|
||||
* <code>ScanEngine</code>'s job is to decode the <code>Expression</code>s,
|
||||
* <code>Statement</code>s and certain objects (namely <code>String</code>,
|
||||
* <code>null</code> objects and instances which are repeatedly provided to
|
||||
* the encoder) into 13 low-level (event) methods, which denote the meaning of the
|
||||
* argument. For example an <code>Expression</code> can be an array
|
||||
* instantiation which provokes a call to {@link arrayInstantiation} or
|
||||
* it can be a class resolution leading to a call to {@link #classResolution}.
|
||||
* For the state machione the 13 methods are the distinct way to transit
|
||||
* from one state to another. Whenever the <code>ScanEngine</code> calls
|
||||
* one of the event methods the current's state successor for that event
|
||||
* is fetched from the state machine configuration, the successpr becomes
|
||||
* the current state and then the event method is called in the new current
|
||||
* state. The last step allows the state instance to do something meaningful
|
||||
* to the object tree.</p>
|
||||
*
|
||||
* <p>The state machine knows the concept of returning to the previous
|
||||
* state. This is done using a stack of states which is popped every
|
||||
* time a call to <code>writeStatement</code>, <code>writeExpression</code>
|
||||
* in the <code>XMLEncoder</code> ends by calling the {@link #end} method.
|
||||
* Note that due to the inheritance relationship of <code>Encoder</code>
|
||||
* and <code>XMLEncoder</code> it is impossible for the
|
||||
* <code>ScanEngine</code> itself to decide when an expression or statement
|
||||
* ended. This can only be done in case of {@link #writeObject} calls because
|
||||
* they are not nested.</p>
|
||||
*
|
||||
* <p>When the XML persistence mechanism reaches an object twice (and more)
|
||||
* it should generate an XML element using the "idref" attribute and add
|
||||
* an "id" attribute to its first instantiation. This complicates things a bit
|
||||
* because the first instantiation will always be part of the object tree
|
||||
* as some {@link gnu.java.beans.encoder.elements.Element} subclass instance when the
|
||||
* second and further objects accesses are written. Therefore the {@link ObjectId}
|
||||
* class was introduced which is shared between all the object tree elements
|
||||
* and has the notion of an "unused" state meaning that no identification
|
||||
* is needed. The relationship between an object and its <code>ObjectId</code>
|
||||
* instance is stored in the <code>ScanEngine</code> and gets cleared whenever
|
||||
* the {@link #flush} method is called. This method also writes the currently
|
||||
* built object tree and generates the XML representation.</p>
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*/
|
||||
public class ScanEngine
|
||||
{
|
||||
|
||||
/** Change this to true to let the ScanEngine print state transition
|
||||
* information.
|
||||
*/
|
||||
boolean DEBUG = false;
|
||||
|
||||
/**
|
||||
* Stores the scanner engine states as values and their names as keys.
|
||||
*/
|
||||
HashMap states = new HashMap();
|
||||
|
||||
/**
|
||||
* Stores former scanner state and makes it possible to come back to them.
|
||||
*/
|
||||
Stack parents = new Stack();
|
||||
|
||||
/**
|
||||
* The currently active scanner state.
|
||||
*/
|
||||
ScannerState current;
|
||||
|
||||
/**
|
||||
* The root of an object tree that is later written to XML.
|
||||
*/
|
||||
Root root;
|
||||
|
||||
/**
|
||||
* The Writer used to generate the XML output.
|
||||
*/
|
||||
Writer writer;
|
||||
|
||||
/** Stores the relationship between objects and their {@link ObjectId} instance.
|
||||
*/
|
||||
IdentityHashMap objects = new IdentityHashMap();
|
||||
|
||||
public ScanEngine(OutputStream os)
|
||||
{
|
||||
// TODO: Provide another Writer implementation (e.g. one that does not use
|
||||
// the XML APIs at all).
|
||||
writer = new StAXWriter(os);
|
||||
root = new Root();
|
||||
|
||||
final ScannerState start = current = new GenericScannerState(root);;
|
||||
ScannerState conf;
|
||||
|
||||
// Use the ReportingScannerState to debug serialization issues.
|
||||
register(ScannerState.DEFAULT_STATE_NAME, new IgnoringScannerState());
|
||||
|
||||
register("start", start);
|
||||
|
||||
// Special dead-end state where all transitions are ignored.
|
||||
register("ignoreAll", new IgnoringScannerState())
|
||||
.setDefaultSuccessor("ignoreAll");
|
||||
|
||||
// Object reference, string reference, null object
|
||||
start.putSuccessor(ScannerState.TRANSITION_OBJECT_REFERENCE, "simple");
|
||||
start.putSuccessor(ScannerState.TRANSITION_STRING_REFERENCE, "simple");
|
||||
start.putSuccessor(ScannerState.TRANSITION_NULL_OBJECT, "simple");
|
||||
register("simple", new GenericScannerState(root))
|
||||
.setDefaultSuccessor("ignoreAll");
|
||||
|
||||
// Class resolution.
|
||||
start.putSuccessor(ScannerState.TRANSITION_CLASS_RESOLUTION, "classRes0");
|
||||
register("classRes0",
|
||||
new GenericScannerState(root)).setDefaultSuccessor("ignoreAll");
|
||||
|
||||
// Object instantiation.
|
||||
start.putSuccessor(ScannerState.TRANSITION_OBJECT_INSTANTIATION,
|
||||
"newObj0");
|
||||
conf = register("newObj0", new GenericScannerState(root));
|
||||
conf.setDefaultSuccessor("ignoreAll");
|
||||
|
||||
// Simply use the start state to encode method invocations inside of
|
||||
// objects.
|
||||
conf.putSuccessor(ScannerState.TRANSITION_METHOD_INVOCATION, "start");
|
||||
|
||||
// Primitive instantiations.
|
||||
start.putSuccessor(ScannerState.TRANSITION_PRIMITIVE_INSTANTIATION,
|
||||
"newPrimitive0");
|
||||
register("newPrimitive0",
|
||||
new GenericScannerState(root)).setDefaultSuccessor("ignoreAll");
|
||||
|
||||
// Object arrays use the ARRAY_GET transition to create setting the
|
||||
// array values.
|
||||
start.putSuccessor(ScannerState.TRANSITION_OBJECT_ARRAY_INSTANTIATION,
|
||||
"newObjectArray");
|
||||
conf = register("newObjectArray", new GenericScannerState(root));
|
||||
conf.putSuccessor(ScannerState.TRANSITION_ARRAY_GET, "newOArrayGet");
|
||||
conf.putSuccessor(ScannerState.TRANSITION_ARRAY_SET, "ignoreAll");
|
||||
conf.putSuccessor(ScannerState.TRANSITION_CLASS_RESOLUTION, "ignoreAll");
|
||||
conf.putSuccessor(ScannerState.TRANSITION_PRIMITIVE_INSTANTIATION,
|
||||
"ignoreAll");
|
||||
|
||||
// Get here when a value is set in the array.
|
||||
register("newOArrayGet",
|
||||
conf = new GenericScannerState(root));
|
||||
|
||||
conf.putSuccessor(ScannerState.TRANSITION_PRIMITIVE_INSTANTIATION,
|
||||
"newOArrayGet_ignoreFirstInteger");
|
||||
|
||||
// "newArrayGet_ignoreFirstInteger" is set up mostly identical like the "start"
|
||||
// state. Otherwise things would not behave the same when done inside
|
||||
// arrays.
|
||||
conf.putSuccessor(ScannerState.TRANSITION_OBJECT_REFERENCE, "simple");
|
||||
conf.putSuccessor(ScannerState.TRANSITION_STRING_REFERENCE, "simple");
|
||||
conf.putSuccessor(ScannerState.TRANSITION_NULL_OBJECT, "simple");
|
||||
conf.putSuccessor(ScannerState.TRANSITION_CLASS_RESOLUTION, "classRes0");
|
||||
conf.putSuccessor(ScannerState.TRANSITION_OBJECT_INSTANTIATION, "newObj0");
|
||||
conf.putSuccessor(ScannerState.TRANSITION_PRIMITIVE_ARRAY_INSTANTIATION,
|
||||
"newPrimitiveArray");
|
||||
conf.putSuccessor(ScannerState.TRANSITION_OBJECT_ARRAY_INSTANTIATION,
|
||||
"newObjectArray");
|
||||
|
||||
conf = register("newOArrayGet_ignoreFirstInteger",
|
||||
new GenericScannerState(root, 1));
|
||||
|
||||
// In non-int primitive arrays class resolutions can happen
|
||||
// but they should be ignored.
|
||||
conf.putSuccessor(ScannerState.TRANSITION_CLASS_RESOLUTION, "ignoreAll");
|
||||
|
||||
// Spurious object and string references occur when setting array
|
||||
// elements. This suppresses them.
|
||||
conf.putSuccessor(ScannerState.TRANSITION_PRIMITIVE_INSTANTIATION,
|
||||
"ignoreAll");
|
||||
conf.putSuccessor(ScannerState.TRANSITION_OBJECT_REFERENCE, "ignoreAll");
|
||||
conf.putSuccessor(ScannerState.TRANSITION_STRING_REFERENCE, "ignoreAll");
|
||||
|
||||
conf.setDefaultSuccessor("start");
|
||||
|
||||
// Primitive arrays use the ARRAY_SET transition to create setting the
|
||||
// array values. This turned out to be the only working solution.
|
||||
// When primitive arrays were handled by ARRAY_GET the values in boolean
|
||||
// arrays were always skipped.
|
||||
start.putSuccessor(ScannerState.TRANSITION_PRIMITIVE_ARRAY_INSTANTIATION,
|
||||
"newPrimitiveArray");
|
||||
conf = register("newPrimitiveArray", new GenericScannerState(root));
|
||||
conf.putSuccessor(ScannerState.TRANSITION_ARRAY_GET, "ignoreAll");
|
||||
conf.putSuccessor(ScannerState.TRANSITION_ARRAY_SET, "newPArraySet");
|
||||
conf.putSuccessor(ScannerState.TRANSITION_CLASS_RESOLUTION, "ignoreAll");
|
||||
conf.putSuccessor(ScannerState.TRANSITION_PRIMITIVE_INSTANTIATION,
|
||||
"ignoreAll");
|
||||
|
||||
conf = register("newPArraySet", new GenericScannerState(root));
|
||||
conf.putSuccessor(ScannerState.TRANSITION_PRIMITIVE_INSTANTIATION,
|
||||
"newPArraySet_ignoreFirstInteger");
|
||||
|
||||
// Primitive arrays ignore all kinds of non-primitive object information.
|
||||
conf.putSuccessor(ScannerState.TRANSITION_OBJECT_REFERENCE,
|
||||
"ignoreAll");
|
||||
conf.putSuccessor(ScannerState.TRANSITION_STRING_REFERENCE, "ignoreAll");
|
||||
conf.putSuccessor(ScannerState.TRANSITION_NULL_OBJECT, "ignoreAll");
|
||||
conf.putSuccessor(ScannerState.TRANSITION_CLASS_RESOLUTION, "ingoreAll");
|
||||
conf.putSuccessor(ScannerState.TRANSITION_OBJECT_INSTANTIATION, "ignoreAll");
|
||||
conf.putSuccessor(ScannerState.TRANSITION_PRIMITIVE_ARRAY_INSTANTIATION,
|
||||
"ignoreAll");
|
||||
conf.putSuccessor(ScannerState.TRANSITION_OBJECT_ARRAY_INSTANTIATION,
|
||||
"ignoreAll");
|
||||
|
||||
conf = register("newPArraySet_ignoreFirstInteger",
|
||||
new GenericScannerState(root, 1));
|
||||
|
||||
// In non-int primitive arrays class resolutions can happen
|
||||
// but they should be ignored.
|
||||
conf.putSuccessor(ScannerState.TRANSITION_CLASS_RESOLUTION, "ignoreAll");
|
||||
|
||||
// Spurious object and string references occur when setting array
|
||||
// elements. This suppresses them.
|
||||
conf.putSuccessor(ScannerState.TRANSITION_PRIMITIVE_INSTANTIATION,
|
||||
"ignoreAll");
|
||||
conf.putSuccessor(ScannerState.TRANSITION_OBJECT_REFERENCE, "ignoreAll");
|
||||
conf.putSuccessor(ScannerState.TRANSITION_STRING_REFERENCE, "ignoreAll");
|
||||
conf.setDefaultSuccessor("start");
|
||||
|
||||
}
|
||||
|
||||
/** Registers a <code>ScannerState</code> under a certain name.
|
||||
*
|
||||
* @param name Name of the state
|
||||
* @param state The <code>ScannerState</code> instance.
|
||||
* @return The second argument.
|
||||
*/
|
||||
private ScannerState register(String name, ScannerState state)
|
||||
{
|
||||
state.init(name);
|
||||
|
||||
states.put(name, state);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
/** Generates or returns an id for the given object which can be activated
|
||||
* later if the object is suitable.
|
||||
*
|
||||
* <p>Objects are unsuitable if they are an instance of a primitive wrapper
|
||||
* or String.</p>
|
||||
*
|
||||
* @param value The object to retrieve an id for.
|
||||
* @return The id for the object or <code>null</code>.
|
||||
*/
|
||||
private ObjectId retrieveId(Object value)
|
||||
{
|
||||
Class valueClass = value.getClass();
|
||||
ObjectId id = null;
|
||||
|
||||
// Although multiple accesses to Class objects are not handled
|
||||
// through ids we generate one for them, too. This allows us to detect
|
||||
// second time references to such objects in the writeObject method
|
||||
// and handle them in a special way.
|
||||
if (valueClass != String.class
|
||||
&& valueClass.getSuperclass() != Number.class
|
||||
&& valueClass != Boolean.class)
|
||||
{
|
||||
if ((id = (ObjectId) objects.get(value)) == null)
|
||||
{
|
||||
id = new ObjectId(valueClass);
|
||||
objects.put(value, id);
|
||||
}
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
/** Scans the argument and calls one of event methods. See
|
||||
* the introduction of this class for details.
|
||||
*
|
||||
* @param expr The expression to serialize.
|
||||
*/
|
||||
public void writeExpression(Expression expr)
|
||||
{
|
||||
String methodName = expr.getMethodName();
|
||||
Object[] args = expr.getArguments();
|
||||
Object target = expr.getTarget();
|
||||
Object value = null;
|
||||
|
||||
try
|
||||
{
|
||||
value = expr.getValue();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw (InternalError)
|
||||
new InternalError(
|
||||
"The Expression's value should be available at this point.")
|
||||
.initCause(e);
|
||||
}
|
||||
|
||||
// TODO: What if the value is null?
|
||||
ObjectId id;
|
||||
Class valueClass = value.getClass();
|
||||
|
||||
if (target == Array.class)
|
||||
{
|
||||
if (methodName.equals("newInstance"))
|
||||
{
|
||||
id = retrieveId(value);
|
||||
|
||||
Class ct = (Class) args[0];
|
||||
|
||||
if (ct.isPrimitive() || ct == Boolean.class || ct == Byte.class
|
||||
|| ct == Short.class || ct == Integer.class || ct == Long.class
|
||||
|| ct == Float.class || ct == Double.class)
|
||||
primitiveArrayInstantiation(ct.getName(),
|
||||
args[1].toString(),
|
||||
id);
|
||||
else
|
||||
objectArrayInstantiation(ct.getName(),
|
||||
args[1].toString(),
|
||||
id);
|
||||
|
||||
return;
|
||||
}
|
||||
else if (methodName.equals("get"))
|
||||
{
|
||||
arrayGet(args[1].toString());
|
||||
|
||||
// The encoder does not call the ScanEngine
|
||||
// when an object is serialized that we already know.
|
||||
// We test for this situation and insert the object reference
|
||||
// manually.
|
||||
// Since there is already a workaround for the Class class
|
||||
// in writeObject we have to except it from this behavior.
|
||||
id = (ObjectId) objects.get(value);
|
||||
if (id != null && valueClass != Class.class)
|
||||
{
|
||||
objectReference(id);
|
||||
end();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else if (methodName.equals("set"))
|
||||
{
|
||||
arraySet(args[1].toString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
id = retrieveId(value);
|
||||
|
||||
if (target instanceof Class)
|
||||
{
|
||||
if (methodName.equals("new"))
|
||||
{
|
||||
Class targetClass = (Class) target;
|
||||
|
||||
// All primitive types have short-hand forms for their
|
||||
// constructors.
|
||||
if (valueClass == Boolean.class)
|
||||
primitiveInstantiation("boolean", args[0].toString());
|
||||
else if (valueClass == Byte.class)
|
||||
primitiveInstantiation("byte", args[0].toString());
|
||||
else if (valueClass == Short.class)
|
||||
primitiveInstantiation("short", args[0].toString());
|
||||
else if (valueClass == Integer.class)
|
||||
primitiveInstantiation("int", args[0].toString());
|
||||
else if (valueClass == Long.class)
|
||||
primitiveInstantiation("long", args[0].toString());
|
||||
else if (valueClass == Float.class)
|
||||
primitiveInstantiation("float", args[0].toString());
|
||||
else if (valueClass == Double.class)
|
||||
primitiveInstantiation("double", args[0].toString());
|
||||
else
|
||||
objectInstantiation(targetClass.getName(), id);
|
||||
|
||||
return;
|
||||
}
|
||||
else if (value instanceof Class)
|
||||
{
|
||||
String className = ((Class) value).getName();
|
||||
|
||||
// At this point we know that some *static* method will be called.
|
||||
|
||||
if (methodName.equals("forName"))
|
||||
{
|
||||
// However "Class.forName" represents class resolution and has a
|
||||
// special syntax.
|
||||
classResolution(className);
|
||||
return;
|
||||
}
|
||||
else if (methodName.equals("getField"))
|
||||
{
|
||||
// The same goes for "Class.getField".
|
||||
// Note: The name of the wanted field is given in
|
||||
// the argument array.
|
||||
staticFieldAccess(className, args[0].toString());
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If nothing fits it is just a static method
|
||||
// invocation which we decode as such.
|
||||
staticMethodInvocation(className, methodName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (target instanceof List)
|
||||
{
|
||||
// Special behavior for indexed get and set method for list-style
|
||||
// classes.
|
||||
// The arguments are in the args array but we need them as subelements.
|
||||
if (methodName.equals("get"))
|
||||
{
|
||||
listGet();
|
||||
return;
|
||||
}
|
||||
else if (methodName.equals("set"))
|
||||
{
|
||||
listSet();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If nothing else could be used then this is a normal
|
||||
// method invocation.
|
||||
methodInvocation(methodName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends the current state and returns to the last one.
|
||||
*/
|
||||
public void end()
|
||||
{
|
||||
current.end();
|
||||
|
||||
if (DEBUG) System.err.print("back from " + current.getName());
|
||||
|
||||
ScannerState oldCurrent = current;
|
||||
current = (ScannerState) parents.pop();
|
||||
|
||||
if (DEBUG) System.err.println(" to " + current.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns to the last state and deletes the last element in the object tree.
|
||||
*/
|
||||
public void revoke()
|
||||
{
|
||||
ScannerState oldCurrent = current;
|
||||
current = (ScannerState) parents.pop();
|
||||
|
||||
root.deleteLast();
|
||||
}
|
||||
|
||||
/** Scans the argument and calls one of event methods. See
|
||||
* the introduction of this class for details.
|
||||
*
|
||||
* @param stmt The statement to serialize.
|
||||
*/
|
||||
public void writeStatement(Statement stmt)
|
||||
{
|
||||
// This is a simplified version of writeExpression. Everything
|
||||
// that would not create something that is embedded in a <void> tag
|
||||
// is left out (instantiation, getters, ...).
|
||||
// TODO: Is this the right thing to do?
|
||||
|
||||
String methodName = stmt.getMethodName();
|
||||
Object target = stmt.getTarget();
|
||||
Object[] args = stmt.getArguments();
|
||||
|
||||
if (target == Array.class && methodName.equals("set"))
|
||||
{
|
||||
arraySet(args[1].toString());
|
||||
return;
|
||||
}
|
||||
|
||||
if (target instanceof List)
|
||||
{
|
||||
if (methodName.equals("set"))
|
||||
{
|
||||
listSet();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If nothing else could be used then this is a normal
|
||||
// method invocation.
|
||||
methodInvocation(methodName);
|
||||
}
|
||||
|
||||
/** Scans the argument and calls one of event methods. See
|
||||
* the introduction of this class for details.
|
||||
*
|
||||
* @param o The object to serialize.
|
||||
*/
|
||||
public boolean writeObject(Object o)
|
||||
{
|
||||
ObjectId id = null;
|
||||
|
||||
if (o == null)
|
||||
{
|
||||
// Handle null objects which have a special syntax.
|
||||
nullObject();
|
||||
end();
|
||||
}
|
||||
else if (o.getClass() == String.class)
|
||||
{
|
||||
// Handle strings which are treated extremely special
|
||||
// in the encoder (they are never converted into a
|
||||
// Expression).
|
||||
stringReference((String) o);
|
||||
end();
|
||||
}
|
||||
else if ((id = (ObjectId) objects.get(o)) != null)
|
||||
{
|
||||
// Multiple references to a Class object do not generate
|
||||
// an object reference but we use the id to detect that
|
||||
// situation.
|
||||
if (o.getClass() == Class.class)
|
||||
{
|
||||
classResolution(((Class) o).getName());
|
||||
end();
|
||||
return false;
|
||||
}
|
||||
|
||||
// If our object has a corresponding ObjectId instance
|
||||
// then generate an objectReference. This will
|
||||
// initialize the id (= brings it in the "used" state)
|
||||
// when this is the first referal.
|
||||
objectReference(id);
|
||||
end();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the currently constructed object tree out as
|
||||
* XML and clears the object to {@link ObjectId} relations.
|
||||
*/
|
||||
public void flush()
|
||||
{
|
||||
// Make all references unreachable. That means we have to generate
|
||||
// new object ids.
|
||||
objects.clear();
|
||||
|
||||
root.traverse(writer);
|
||||
}
|
||||
|
||||
/** Writes the final bits if the object tree and closes the stream
|
||||
* afterwards.
|
||||
*/
|
||||
public void close()
|
||||
{
|
||||
flush();
|
||||
root.close(writer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does a transition from one state to another using the given event.
|
||||
*
|
||||
* <p>This involves saving the current state, retrieving it's
|
||||
* successor and setting it as the current state.</p>
|
||||
*
|
||||
* @param transition One of {@link ScannerStates]'s transition constants.
|
||||
*/
|
||||
private void transition(int transition)
|
||||
{
|
||||
parents.push(current);
|
||||
|
||||
String stateName = current.getSuccessor(transition);
|
||||
|
||||
if (DEBUG)
|
||||
{
|
||||
System.err.println("from state: " + current.getName() + "\n\troute: "
|
||||
+ ScannerState.transitionNames[transition]
|
||||
+ "\n\t\tto state: "
|
||||
+ stateName);
|
||||
}
|
||||
|
||||
ScannerState newState = (ScannerState) states.get(stateName);
|
||||
|
||||
newState.enter(new Context(current.getName(), current.getCalls()));
|
||||
|
||||
assert (newState != null) : "State '" + stateName + "' was not defined.";
|
||||
|
||||
current = newState;
|
||||
}
|
||||
|
||||
/** Event method that denotes a (non-static) method invocation.
|
||||
*
|
||||
* <p>More details about this method can be found in this
|
||||
* class' introduction.</p>
|
||||
*
|
||||
* @param methodName The name of the method which is called.
|
||||
*/
|
||||
void methodInvocation(String methodName)
|
||||
{
|
||||
transition(ScannerState.TRANSITION_METHOD_INVOCATION);
|
||||
|
||||
current.methodInvocation(methodName);
|
||||
}
|
||||
|
||||
/** Event method that denotes a static method invocation.
|
||||
*
|
||||
* <p>More details about this method can be found in this
|
||||
* class' introduction.</p>
|
||||
*
|
||||
* @param methodName The name of the method which is called.
|
||||
* @param className The name of the class in which the method is called.
|
||||
*/
|
||||
void staticMethodInvocation(String className, String methodName)
|
||||
{
|
||||
transition(ScannerState.TRANSITION_STATIC_METHOD_INVOCATION);
|
||||
|
||||
current.staticMethodInvocation(className, methodName);
|
||||
}
|
||||
|
||||
/** Event method that denotes the retrieval of a static field's value.
|
||||
*
|
||||
* <p>More details about this method can be found in this
|
||||
* class' introduction.</p>
|
||||
*
|
||||
* @param fieldName The name of the field whose value is retrieved.
|
||||
* @param className The name of the class in which the method is called.
|
||||
*/
|
||||
void staticFieldAccess(String className, String fieldName)
|
||||
{
|
||||
transition(ScannerState.TRANSITION_STATIC_FIELD_ACCESS);
|
||||
|
||||
current.staticFieldAccess(className, fieldName);
|
||||
}
|
||||
|
||||
/** Event method that denotes the resolution of a class.
|
||||
*
|
||||
* <p>More details about this method can be found in this
|
||||
* class' introduction.</p>
|
||||
*
|
||||
* @param className The name of the class in which the method is called.
|
||||
*/
|
||||
void classResolution(String className)
|
||||
{
|
||||
transition(ScannerState.TRANSITION_CLASS_RESOLUTION);
|
||||
|
||||
current.classResolution(className);
|
||||
}
|
||||
|
||||
/** Event method that denotes the instantiation of an object.
|
||||
*
|
||||
* <p>More details about this method can be found in this
|
||||
* class' introduction.</p>
|
||||
*
|
||||
* @param className The name of the class in which the method is called.
|
||||
* @param objectId An ObjectId instance which can be activated later.
|
||||
*/
|
||||
void objectInstantiation(String className, ObjectId objectId)
|
||||
{
|
||||
transition(ScannerState.TRANSITION_OBJECT_INSTANTIATION);
|
||||
|
||||
current.objectInstantiation(className, objectId);
|
||||
}
|
||||
|
||||
/** Event method that denotes the instantiation of a primitive.
|
||||
*
|
||||
* <p>More details about this method can be found in this
|
||||
* class' introduction.</p>
|
||||
*
|
||||
* @param primitiveName One of "boolean, "byte", "short", "int", "long"
|
||||
* , "float" or "double"
|
||||
* @param valueAsString The value of the primitive as a String.
|
||||
*/
|
||||
void primitiveInstantiation(String primitiveName, String valueAsString)
|
||||
{
|
||||
transition(ScannerState.TRANSITION_PRIMITIVE_INSTANTIATION);
|
||||
|
||||
current.primitiveInstantiation(primitiveName, valueAsString);
|
||||
}
|
||||
|
||||
/** Event method that denotes the instantiation of an object array.
|
||||
*
|
||||
* <p>More details about this method can be found in this
|
||||
* class' introduction.</p>
|
||||
*
|
||||
* @param arrayClassName The array's class name.
|
||||
* @param objectId An ObjectId instance which can be activated later.
|
||||
* @param lengthAsString The array's length as String.
|
||||
*/
|
||||
void objectArrayInstantiation(String arrayClassName, String lengthAsString,
|
||||
ObjectId objectId)
|
||||
{
|
||||
transition(ScannerState.TRANSITION_OBJECT_ARRAY_INSTANTIATION);
|
||||
|
||||
current.objectArrayInstantiation(arrayClassName, lengthAsString, objectId);
|
||||
}
|
||||
|
||||
/** Event method that denotes the instantiation of a primitive array.
|
||||
*
|
||||
* <p>More details about this method can be found in this
|
||||
* class' introduction.</p>
|
||||
*
|
||||
* @param arrayClassName The array's class name.
|
||||
* @param objectId An ObjectId instance which can be activated later.
|
||||
* @param lengthAsString The array's length as String.
|
||||
*/
|
||||
void primitiveArrayInstantiation(String arrayClassName, String lengthAsString,
|
||||
ObjectId objectId)
|
||||
{
|
||||
transition(ScannerState.TRANSITION_PRIMITIVE_ARRAY_INSTANTIATION);
|
||||
|
||||
current.objectArrayInstantiation(arrayClassName, lengthAsString, objectId);
|
||||
}
|
||||
|
||||
/** Event method that denotes the setting of a value in an array.
|
||||
*
|
||||
* <p>More details about this method can be found in this
|
||||
* class' introduction.</p>
|
||||
*
|
||||
* @param indexAsString The index to as a String.
|
||||
*/
|
||||
void arraySet(String indexAsString)
|
||||
{
|
||||
transition(ScannerState.TRANSITION_ARRAY_SET);
|
||||
|
||||
current.arraySet(indexAsString);
|
||||
}
|
||||
|
||||
/** Event method that denotes the retrieval of a value in an array.
|
||||
*
|
||||
* <p>More details about this method can be found in this
|
||||
* class' introduction.</p>
|
||||
*
|
||||
* @param indexAsString The index to as a String.
|
||||
*/
|
||||
void arrayGet(String indexAsString)
|
||||
{
|
||||
transition(ScannerState.TRANSITION_ARRAY_GET);
|
||||
|
||||
current.arrayGet(indexAsString);
|
||||
}
|
||||
|
||||
/** Event method that denotes the setting of a value in a list.
|
||||
*
|
||||
* <p>More details about this method can be found in this
|
||||
* class' introduction.</p>
|
||||
*/
|
||||
void listSet()
|
||||
{
|
||||
transition(ScannerState.TRANSITION_LIST_SET);
|
||||
|
||||
current.listSet();
|
||||
}
|
||||
|
||||
/** Event method that denotes the retrieval of a value in a list.
|
||||
*
|
||||
* <p>More details about this method can be found in this
|
||||
* class' introduction.</p>
|
||||
*/
|
||||
void listGet()
|
||||
{
|
||||
transition(ScannerState.TRANSITION_LIST_GET);
|
||||
|
||||
current.listGet();
|
||||
}
|
||||
|
||||
/** Event method that denotes the null value.
|
||||
*/
|
||||
void nullObject()
|
||||
{
|
||||
transition(ScannerState.TRANSITION_NULL_OBJECT);
|
||||
|
||||
current.nullObject();
|
||||
}
|
||||
|
||||
/** Event method that denotes a string.
|
||||
*
|
||||
* @param string The string that should be written.
|
||||
*/
|
||||
void stringReference(String string)
|
||||
{
|
||||
transition(ScannerState.TRANSITION_STRING_REFERENCE);
|
||||
|
||||
current.stringReference(string);
|
||||
}
|
||||
|
||||
/** Event method that denotes a reference to an existing object.
|
||||
*
|
||||
* @param id The ObjectId to be used.
|
||||
*/
|
||||
void objectReference(ObjectId id)
|
||||
{
|
||||
transition(ScannerState.TRANSITION_OBJECT_REFERENCE);
|
||||
|
||||
current.objectReference(id);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,236 @@
|
|||
/* ScannerState.java
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/** <p>Provides the infrastructure for the state machine and the transition
|
||||
* mechanism.</p>
|
||||
*
|
||||
* <p>Each states knows a set of successor. There can be one successor for
|
||||
* every transition variant. Furthermore a state knows about a default
|
||||
* successor which is taken when there is no special setup for a
|
||||
* transition.</p>
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*
|
||||
*/
|
||||
public abstract class ScannerState
|
||||
{
|
||||
|
||||
static final int TRANSITION_METHOD_INVOCATION = 0;
|
||||
|
||||
static final int TRANSITION_STATIC_METHOD_INVOCATION = 1;
|
||||
|
||||
static final int TRANSITION_STATIC_FIELD_ACCESS = 2;
|
||||
|
||||
static final int TRANSITION_CLASS_RESOLUTION = 3;
|
||||
|
||||
static final int TRANSITION_OBJECT_INSTANTIATION = 4;
|
||||
|
||||
static final int TRANSITION_PRIMITIVE_INSTANTIATION = 5;
|
||||
|
||||
static final int TRANSITION_OBJECT_ARRAY_INSTANTIATION = 6;
|
||||
|
||||
static final int TRANSITION_PRIMITIVE_ARRAY_INSTANTIATION = 7;
|
||||
|
||||
static final int TRANSITION_ARRAY_SET = 8;
|
||||
|
||||
static final int TRANSITION_ARRAY_GET = 9;
|
||||
|
||||
static final int TRANSITION_LIST_SET = 10;
|
||||
|
||||
static final int TRANSITION_LIST_GET = 11;
|
||||
|
||||
static final int TRANSITION_NULL_OBJECT = 12;
|
||||
|
||||
static final int TRANSITION_STRING_REFERENCE = 13;
|
||||
|
||||
static final int TRANSITION_OBJECT_REFERENCE = 14;
|
||||
|
||||
static final int TRANSITION_FIRST = 0;
|
||||
|
||||
static final int TRANSITION_LAST = 14;
|
||||
|
||||
static final String DEFAULT_STATE_NAME = "default";
|
||||
|
||||
String defaultSuccessor = DEFAULT_STATE_NAME;
|
||||
|
||||
static String[] transitionNames = { "METHOD_INVOCATION", "STATIC_METHOD_INVOCATION",
|
||||
"STATIC_FIELD_ACCESS", "CLASS_RESOLUTION",
|
||||
"OBJECT_INSTANTIATION",
|
||||
"PRIMITIVE_INSTANTIATION", "OBJECT_ARRAY_INSTANTIATION",
|
||||
"PRIMITIVE_ARRAY_INSTANTIATION",
|
||||
"ARRAY_SET", "ARRAY_GET", "LIST_SET", "LIST_GET",
|
||||
"NULL_OBJECT", "STRING_REFERENCE", "OBJECT_REFERENCE" };
|
||||
|
||||
/**
|
||||
* Stores the transition setup as the relation
|
||||
* transition->successor's state name.
|
||||
*/
|
||||
HashMap transitions = new HashMap();
|
||||
|
||||
int calls;
|
||||
|
||||
Context context;
|
||||
|
||||
String name;
|
||||
|
||||
final void init(String newName)
|
||||
{
|
||||
assert (name == null);
|
||||
|
||||
name = newName;
|
||||
}
|
||||
|
||||
final String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
final void enter(Context ctx)
|
||||
{
|
||||
calls++;
|
||||
context = ctx;
|
||||
|
||||
enterImpl(ctx);
|
||||
}
|
||||
|
||||
protected void enterImpl(Context ctx)
|
||||
{
|
||||
}
|
||||
|
||||
final Context context()
|
||||
{
|
||||
return context;
|
||||
}
|
||||
|
||||
final int getCalls()
|
||||
{
|
||||
return calls;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Stores a successor's state name for a certain transition.</p>
|
||||
*
|
||||
* <p>This method is only used at the configuration time of the state
|
||||
* machine.</p>
|
||||
*
|
||||
* @param transition One of the transition constants.
|
||||
* @param stateName The state name of the successor.
|
||||
*/
|
||||
final void putSuccessor(int transition, String stateName)
|
||||
{
|
||||
assert (transition >= TRANSITION_FIRST && transition <= TRANSITION_LAST) :
|
||||
"Transition identifier '" + transition + "' is unknown.";
|
||||
|
||||
transitions.put(new Integer(transition), stateName);
|
||||
}
|
||||
|
||||
/** <p>Retrieves a the state name of a successor for the given transition
|
||||
* constant.</p>
|
||||
*
|
||||
* <p>Returns the default successor's state name if no special setup was
|
||||
* prepared.</p>
|
||||
*
|
||||
* @param transition One of the transition constants.
|
||||
* @return The state name of the successor.
|
||||
*/
|
||||
final String getSuccessor(int transition)
|
||||
{
|
||||
String state = (String) transitions.get(new Integer(transition));
|
||||
|
||||
return (state == null) ? defaultSuccessor : state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name for the default successor state.
|
||||
*
|
||||
* @param newDefaultSuccessor The default successor's state name.
|
||||
*/
|
||||
final void setDefaultSuccessor(String newDefaultSuccessor)
|
||||
{
|
||||
defaultSuccessor = newDefaultSuccessor;
|
||||
}
|
||||
|
||||
abstract void methodInvocation(String methodName);
|
||||
|
||||
abstract void staticMethodInvocation(String className, String methodName);
|
||||
|
||||
abstract void staticFieldAccess(String className, String fieldName);
|
||||
|
||||
abstract void classResolution(String className);
|
||||
|
||||
abstract void objectInstantiation(String className, ObjectId objectId);
|
||||
|
||||
abstract void primitiveInstantiation(String primitiveName,
|
||||
String valueAsString);
|
||||
|
||||
abstract void objectArrayInstantiation(String arrayClassName, String lengthAsString, ObjectId objectId);
|
||||
|
||||
abstract void primitiveArrayInstantiation(String arrayClassName, String lengthAsString, ObjectId objectId);
|
||||
|
||||
abstract void arraySet(String indexAsString);
|
||||
|
||||
abstract void arrayGet(String indexAsString);
|
||||
|
||||
abstract void listGet();
|
||||
|
||||
abstract void listSet();
|
||||
|
||||
abstract void nullObject();
|
||||
|
||||
abstract void stringReference(String string);
|
||||
|
||||
abstract void objectReference(ObjectId id);
|
||||
|
||||
/**
|
||||
* <p>A special event that does not provoke a direct transition.</p>
|
||||
*
|
||||
* <p>Instead the transition is done by the <code>ScanEngine</code>: It goes
|
||||
* back to the previous state and just uses this method to inform the state
|
||||
* about this happening.</p>
|
||||
*/
|
||||
abstract void end();
|
||||
|
||||
void enter()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,233 @@
|
|||
/* StAXWriter.java
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder;
|
||||
|
||||
import java.io.OutputStream;
|
||||
|
||||
import javax.xml.stream.XMLOutputFactory;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
|
||||
/** A {@link Writer} implementation based on the StAX API.
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*
|
||||
*/
|
||||
public class StAXWriter implements Writer
|
||||
{
|
||||
XMLStreamWriter writer;
|
||||
|
||||
int indent = 0;
|
||||
|
||||
public StAXWriter(OutputStream os)
|
||||
{
|
||||
try
|
||||
{
|
||||
XMLOutputFactory factory = XMLOutputFactory.newInstance();
|
||||
writer = factory.createXMLStreamWriter(os);
|
||||
}
|
||||
catch (XMLStreamException se)
|
||||
{
|
||||
throw (InternalError)
|
||||
new InternalError(
|
||||
"Could not instantiate a streaming XML writer.")
|
||||
.initCause(se);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void flush()
|
||||
{
|
||||
if (writer != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
writer.flush();
|
||||
}
|
||||
catch (XMLStreamException xse)
|
||||
{
|
||||
// TODO: find out
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void close()
|
||||
{
|
||||
if (writer != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
writer.close();
|
||||
}
|
||||
catch (XMLStreamException xse)
|
||||
{
|
||||
// TODO: find out
|
||||
}
|
||||
writer = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void writePreamble()
|
||||
{
|
||||
try
|
||||
{
|
||||
writer.writeStartDocument("UTF-8", "1.0");
|
||||
}
|
||||
catch (XMLStreamException xmlse)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void writeEnd(boolean wasEmpty)
|
||||
{
|
||||
try
|
||||
{
|
||||
indent -= 2;
|
||||
|
||||
if (wasEmpty)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < indent; i++)
|
||||
writer.writeCharacters(" ");
|
||||
|
||||
writer.writeEndElement();
|
||||
|
||||
writer.writeCharacters("\n");
|
||||
}
|
||||
catch (XMLStreamException xmlse)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void writeEndNoChildren()
|
||||
{
|
||||
try
|
||||
{
|
||||
writer.writeEndElement();
|
||||
writer.writeCharacters("\n");
|
||||
}
|
||||
catch (XMLStreamException xmlse)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void write(String tagName, boolean empty)
|
||||
{
|
||||
write(tagName, null, null, null, empty);
|
||||
}
|
||||
|
||||
public void write(String tagName, String value)
|
||||
{
|
||||
write(tagName, value, null, null, value == null);
|
||||
}
|
||||
|
||||
public void writeNoChildren(String tagName, String value)
|
||||
{
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < indent; i++)
|
||||
writer.writeCharacters(" ");
|
||||
|
||||
writer.writeStartElement(tagName);
|
||||
|
||||
writer.writeCharacters(value);
|
||||
}
|
||||
catch (XMLStreamException xmlse)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void write(String tagName, String attributeName,
|
||||
String attributeValue, boolean empty)
|
||||
{
|
||||
write(tagName, null, new String[] { attributeName },
|
||||
new String[] { attributeValue }, empty);
|
||||
}
|
||||
|
||||
public void write(String tagName, String value, String[] attributeNames,
|
||||
String[] attributeValues, boolean empty)
|
||||
{
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < indent; i++)
|
||||
|
||||
writer.writeCharacters(" ");
|
||||
|
||||
if (empty)
|
||||
writer.writeEmptyElement(tagName);
|
||||
else
|
||||
writer.writeStartElement(tagName);
|
||||
|
||||
if (attributeNames != null)
|
||||
for (int i = 0; i < attributeNames.length; i++)
|
||||
writer.writeAttribute(attributeNames[i], attributeValues[i]);
|
||||
|
||||
writer.writeCharacters("\n");
|
||||
|
||||
indent += 2;
|
||||
|
||||
if (value != null)
|
||||
{
|
||||
for (int i = 0; i < indent; i++)
|
||||
writer.writeCharacters(" ");
|
||||
|
||||
writer.writeCharacters(value);
|
||||
|
||||
writer.writeCharacters("\n");
|
||||
}
|
||||
}
|
||||
catch (XMLStreamException xmlse)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void write(String tagName, String[] attributeNames,
|
||||
String[] attributeValues, boolean empty)
|
||||
{
|
||||
write(tagName, null, attributeNames, attributeValues, empty);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,174 @@
|
|||
/* Writer.java -- Writing interface for XML persistence.
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder;
|
||||
|
||||
/** A <code>Writer</code> represents a simplified interface to an XML
|
||||
* writer that is used for the XML persistence mechanism.
|
||||
*
|
||||
* <p>Its sole purpose is to allow multiple backends which may remove
|
||||
* the need to have certain APIs in the classpath. Eg. it is possible
|
||||
* to write a stripped down XML Writer that does not rely on SAX, StAX
|
||||
* or DOM APIs.</p>
|
||||
*
|
||||
* <p>The caller may assume that every action is done immediately. However
|
||||
* it is possible that the underlying implementation uses buffering streams.
|
||||
* To make sure the data is written call the {@link flush} method.</p>
|
||||
*
|
||||
* <p>The <code>Writer</code> implementation should care about the formatting
|
||||
* of the XML stream making it possible to generate three types of formats using
|
||||
* a special method invocation chain.</p>
|
||||
*
|
||||
* <p>Write
|
||||
* <code>
|
||||
* <element/>
|
||||
* </code>
|
||||
* by issuing <code>write("element", true)</code> (or any of the other
|
||||
* write-variants that allows specifying the <code>isEmpty</code> argument)
|
||||
* and <code>writeEnd(true)</code>.</p>
|
||||
*
|
||||
* <p>Write
|
||||
* <code>
|
||||
* <element>body</element>
|
||||
* </code>
|
||||
* by issuing <code>writeNoChildren("element", "body")</code> and <code>writeNoChildrenEnd()</code>.</p>
|
||||
*
|
||||
* <p>
|
||||
* Write
|
||||
* <code>
|
||||
* <element>
|
||||
* <child1/>
|
||||
* <child2/>
|
||||
* ...
|
||||
* <element/>
|
||||
* </code>
|
||||
* by issuing <code>write("element", false)</code> (or any of the other
|
||||
* write-variants that allows specifying the <code>isEmpty</code> argument)
|
||||
* and <code>writeEnd(false)</code>.</p>
|
||||
*
|
||||
* <p>Note: It is important that the values of <code>isEmpty</code> and
|
||||
* <code>wasEmpty</code> match. Otherwise strange things might happen to
|
||||
* the layout.</p>
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*
|
||||
*/
|
||||
public interface Writer
|
||||
{
|
||||
// TODO: This interface's design is not the best. Feel free to
|
||||
// improve it as you like.
|
||||
|
||||
/** Writes the XML preamble. */
|
||||
void writePreamble();
|
||||
|
||||
/** Writes the end of an XML tag.
|
||||
*
|
||||
* <p>If your tag has not generated any body text or child
|
||||
* elements provide <code>true</code> as the argument to generate
|
||||
* more space efficient variant of the tag.>/p>
|
||||
*
|
||||
* @param wasEmpty Whether the tag was empty or not.
|
||||
*/
|
||||
void writeEnd(boolean wasEmpty);
|
||||
|
||||
/** Writes an XML tag without any attributes.
|
||||
*
|
||||
* @param tagName The name of the tag to write.
|
||||
* @param empty Whether the element has child elements.
|
||||
*/
|
||||
void write(String tagName, boolean empty);
|
||||
|
||||
/** Writes an XML tag with one attribute name and value.
|
||||
*
|
||||
* @param tagName The name of the tag to write.
|
||||
* @param attributeName The name of attribute.
|
||||
* @param attributeValue The attribute's value.
|
||||
* @param empty Whether the element has child elements.
|
||||
*/
|
||||
void write(String tagName, String attributeName, String attributeValue, boolean empty);
|
||||
|
||||
/** Writes an XML tag with multiple attributes and a body text.
|
||||
*
|
||||
* @param tagName The name of the tag to write.
|
||||
* @param value The element's body content.
|
||||
* @param attributeNames A set of attribute names.
|
||||
* @param attributeValues A set of attribute values.
|
||||
* @param empty Whether the element has child elements.
|
||||
*/
|
||||
void write(String tagName, String value, String[] attributeNames,
|
||||
String[] attributeValues, boolean empty);
|
||||
|
||||
/** Writes an XML tag with multiple attributes without a body text.
|
||||
*
|
||||
* @param tagName The name of the tag to write.
|
||||
* @param attributeNames A set of attribute names.
|
||||
* @param attributeValues A set of attribute values.
|
||||
* @param empty Whether the element has child elements.
|
||||
*/
|
||||
void write(String tagName, String[] attributeNames, String[] attributeValues, boolean empty);
|
||||
|
||||
/** Writes an XML tag with no attributes but with a body text
|
||||
* that may have child elements.
|
||||
*
|
||||
* @param tagName The name of the tag to write.
|
||||
* @param value The element's body content.
|
||||
*/
|
||||
void write(String tagName, String value);
|
||||
|
||||
/** Writes an XML tag with no attributes but with a body text
|
||||
* that does not have child elements.
|
||||
*
|
||||
* @param tagName The name of the tag to write.
|
||||
* @param value The element's body content.
|
||||
*/
|
||||
void writeNoChildren(String tagName, String value);
|
||||
|
||||
/** Writes the end of an XML tag that has no child elements.
|
||||
*
|
||||
* <p>Must be used in combination with {@link writeNoChildren} only.</p>
|
||||
*/
|
||||
void writeEndNoChildren();
|
||||
|
||||
/** Forces the implementation to write some data.
|
||||
*/
|
||||
void flush();
|
||||
|
||||
/** Closes the writer.
|
||||
*/
|
||||
void close();
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
/* ArrayInstantiation.java
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder.elements;
|
||||
|
||||
import gnu.java.beans.encoder.ObjectId;
|
||||
import gnu.java.beans.encoder.Writer;
|
||||
|
||||
/** Generates an XML element denoting the instantiation of an array.
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*
|
||||
*/
|
||||
public class ArrayInstantiation extends Element
|
||||
{
|
||||
final String className;
|
||||
|
||||
final String lengthAsString;
|
||||
|
||||
public ArrayInstantiation(String newClassName, String newLengthAsString)
|
||||
{
|
||||
className = newClassName;
|
||||
lengthAsString = newLengthAsString;
|
||||
}
|
||||
|
||||
public void writeStart(Writer writer)
|
||||
{
|
||||
ObjectId objectId = getId();
|
||||
if (objectId.isUnused())
|
||||
writer.write("array", new String[] { "class", "length" },
|
||||
new String[] { className, lengthAsString }, isEmpty());
|
||||
else
|
||||
writer.write("array", new String[] { "id", "class", "length" },
|
||||
new String[] { objectId.toString(), className,
|
||||
lengthAsString }, isEmpty());
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/* Array_Get.java
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder.elements;
|
||||
|
||||
import gnu.java.beans.encoder.Writer;
|
||||
|
||||
/**
|
||||
* Generates an XML element denoting the retrieval of an array value.
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*/
|
||||
public class Array_Get extends Element
|
||||
{
|
||||
final String indexAsString;
|
||||
|
||||
public Array_Get(String newIndexAsString)
|
||||
{
|
||||
indexAsString = newIndexAsString;
|
||||
}
|
||||
|
||||
public void writeStart(Writer writer)
|
||||
{
|
||||
writer.write("void", "index", indexAsString, isEmpty());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
/* Array_Set.java -- FIXME: briefly describe file purpose
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder.elements;
|
||||
|
||||
import gnu.java.beans.encoder.Writer;
|
||||
|
||||
public class Array_Set extends Element
|
||||
{
|
||||
final String indexAsString;
|
||||
|
||||
public Array_Set(String newIndexAsString)
|
||||
{
|
||||
indexAsString = newIndexAsString;
|
||||
}
|
||||
|
||||
public void writeStart(Writer writer)
|
||||
{
|
||||
writer.write("void", "index", indexAsString, isEmpty());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/* ClassResolution.java
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder.elements;
|
||||
|
||||
import gnu.java.beans.encoder.Writer;
|
||||
|
||||
/** Generates an XML element denoting the resolution of a class.
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*
|
||||
*/
|
||||
public class ClassResolution extends Element
|
||||
{
|
||||
final String className;
|
||||
|
||||
public ClassResolution(String newClassName)
|
||||
{
|
||||
className = newClassName;
|
||||
}
|
||||
|
||||
public void writeStart(Writer writer)
|
||||
{
|
||||
writer.writeNoChildren("class", className);
|
||||
}
|
||||
|
||||
public void writeEnd(Writer writer)
|
||||
{
|
||||
writer.writeEndNoChildren();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,157 @@
|
|||
/* Element.java -- Base class for object tree elements.
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder.elements;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import gnu.java.beans.encoder.ObjectId;
|
||||
import gnu.java.beans.encoder.Writer;
|
||||
|
||||
/** <code>Element</code> is the base class for the object tree elements.
|
||||
*
|
||||
* <p>It provides the neccessary infrastructure every element subclass
|
||||
* needs in order to interact with the {@link gnu.java.beans.encoder.Root}
|
||||
* class.</p>
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*/
|
||||
public abstract class Element
|
||||
{
|
||||
/**
|
||||
* Stores the child elements.
|
||||
*/
|
||||
private LinkedList children = new LinkedList();
|
||||
|
||||
/**
|
||||
* An optional ObjectId instance which is needed for certain subclasses
|
||||
* only.
|
||||
*/
|
||||
private ObjectId objectId;
|
||||
|
||||
/** Sets an {@link gnu.java.beans.encoder.ObjectId} instance in this
|
||||
* <code>Element</code>.
|
||||
*
|
||||
* <p>This can only be done once.</p>
|
||||
*
|
||||
* @param objectId An ObjectId instance.
|
||||
*/
|
||||
public final void initId(ObjectId objectId)
|
||||
{
|
||||
assert (this.objectId == null);
|
||||
assert (objectId != null);
|
||||
|
||||
this.objectId = objectId;
|
||||
}
|
||||
|
||||
/** Adds a child element to this <code>Element</code>.
|
||||
*
|
||||
* @param elem The new child.
|
||||
*/
|
||||
public final void addChild(Element elem)
|
||||
{
|
||||
children.add(elem);
|
||||
}
|
||||
|
||||
/** Removes the child element added last.
|
||||
*/
|
||||
public final void removeLast()
|
||||
{
|
||||
children.removeLast();
|
||||
}
|
||||
|
||||
/** Provides access to the child elements via an iterator.
|
||||
*
|
||||
* @return An iterator for the child elements.
|
||||
*/
|
||||
public final Iterator iterator(){
|
||||
return children.iterator();
|
||||
}
|
||||
|
||||
/** Clears all the stored child elements.
|
||||
*
|
||||
*/
|
||||
public final void clear()
|
||||
{
|
||||
children.clear();
|
||||
}
|
||||
|
||||
/** Returns whether this element contains child elements.
|
||||
*
|
||||
* <p>This method is useful to decide which formatting variant
|
||||
* for the XML element can be chosen.</p>
|
||||
*
|
||||
* @return Whether the element has child elements.
|
||||
*/
|
||||
public final boolean isEmpty()
|
||||
{
|
||||
return children.isEmpty();
|
||||
}
|
||||
|
||||
/** Retrieves the element's {@link gnu.java.beans.encoder.ObjectId} instance
|
||||
* if it has one.
|
||||
*
|
||||
* @return The ObjectId instance or <code>null</code>.
|
||||
*/
|
||||
public final ObjectId getId()
|
||||
{
|
||||
return objectId;
|
||||
}
|
||||
|
||||
/** Writes the opening XML tag.
|
||||
*
|
||||
* @param writer The writer to be used for XML writing.
|
||||
*/
|
||||
public abstract void writeStart(Writer writer);
|
||||
|
||||
/** Writes the closing XML tag.
|
||||
*
|
||||
* <p>By default this does <code>writer.writeEnd(children.isEmpty())</code>.
|
||||
* Override if neccessary, for example when using the
|
||||
* {@link gnu.java.beans.encoder.Writer#writeNoChildren}</code> method
|
||||
* variants.
|
||||
*
|
||||
* @param writer The writer to be used for XML writing.
|
||||
*/
|
||||
public void writeEnd(Writer writer)
|
||||
{
|
||||
writer.writeEnd(children.isEmpty());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/* javaio.h - Declaration for common java.io native functions
|
||||
Copyright (C) 1998, 2004 Free Software Foundation, Inc.
|
||||
/* List_Get.java
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -7,7 +7,7 @@ GNU Classpath is free software; you can redistribute it and/or modify
|
|||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
|
@ -36,23 +36,21 @@ obligated to do so. If you do not wish to do so, delete this
|
|||
exception statement from your version. */
|
||||
|
||||
|
||||
#ifndef JAVAIO_H_INCLUDED
|
||||
#define JAVAIO_H_INCLUDED
|
||||
package gnu.java.beans.encoder.elements;
|
||||
|
||||
#include <stddef.h>
|
||||
import gnu.java.beans.encoder.Writer;
|
||||
|
||||
/*
|
||||
* Function Prototypes
|
||||
/** Generates an XML element denoting the retrieval of a list's element.
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*
|
||||
*/
|
||||
public class List_Get extends Element
|
||||
{
|
||||
|
||||
extern jlong _javaio_get_file_length(JNIEnv *, jint);
|
||||
extern jlong _javaio_skip_bytes(JNIEnv *, jint, jlong);
|
||||
extern jint _javaio_open(JNIEnv *, jstring, int);
|
||||
extern jint _javaio_open_read(JNIEnv *, jstring);
|
||||
extern jint _javaio_open_readwrite(JNIEnv *, jstring);
|
||||
extern void _javaio_close(JNIEnv *, jint fd);
|
||||
extern jint _javaio_read(JNIEnv *, jint, jarray, jint, jint);
|
||||
extern jint _javaio_write(JNIEnv *, jint, jarray, jint, jint);
|
||||
|
||||
#endif /* JAVAIO_H_INCLUDED */
|
||||
|
||||
public void writeStart(Writer writer)
|
||||
{
|
||||
writer.write("object", "get");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/* List_Set.java
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder.elements;
|
||||
|
||||
import gnu.java.beans.encoder.Writer;
|
||||
|
||||
/** Generates an XML element denoting the setting of a list's element.
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*
|
||||
*/
|
||||
public class List_Set extends Element
|
||||
{
|
||||
|
||||
public void writeStart(Writer writer)
|
||||
{
|
||||
writer.write("object", "set");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/* MethodCall.java
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder.elements;
|
||||
|
||||
import gnu.java.beans.encoder.Writer;
|
||||
|
||||
/** Generates an XML element denoting a non-static method call.
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*
|
||||
*/
|
||||
public class MethodInvocation extends Element
|
||||
{
|
||||
final String methodName;
|
||||
|
||||
public MethodInvocation(String newMethodName)
|
||||
{
|
||||
methodName = newMethodName;
|
||||
}
|
||||
|
||||
public void writeStart(Writer writer)
|
||||
{
|
||||
writer.write("void", "method", methodName, isEmpty());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
/* NullObject.java
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder.elements;
|
||||
|
||||
import gnu.java.beans.encoder.Writer;
|
||||
|
||||
/** Generates an XML element denoting the <code>null</code> value.
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*
|
||||
*/
|
||||
public class NullObject extends Element
|
||||
{
|
||||
|
||||
public void writeStart(Writer writer)
|
||||
{
|
||||
writer.write("null", true);
|
||||
}
|
||||
|
||||
public void writeEnd(Writer writer)
|
||||
{
|
||||
writer.writeEnd(true);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
/* ObjectInstantiation.java
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder.elements;
|
||||
|
||||
import gnu.java.beans.encoder.ObjectId;
|
||||
import gnu.java.beans.encoder.Writer;
|
||||
|
||||
/** Generates an XML element denoting the instantiation of an object.
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*
|
||||
*/
|
||||
public class ObjectInstantiation extends Element
|
||||
{
|
||||
final String className;
|
||||
|
||||
public ObjectInstantiation(String newClassName)
|
||||
{
|
||||
className = newClassName;
|
||||
}
|
||||
|
||||
public void writeStart(Writer writer)
|
||||
{
|
||||
ObjectId objectId = getId();
|
||||
if (objectId.isUnused())
|
||||
writer.write("object", "class", className, isEmpty());
|
||||
else
|
||||
writer.write("object", new String[] { "id", "class" },
|
||||
new String[] { objectId.toString(), className }, isEmpty());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
/* StringInstantiation.java
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder.elements;
|
||||
|
||||
import gnu.java.beans.encoder.ObjectId;
|
||||
import gnu.java.beans.encoder.Writer;
|
||||
|
||||
/** Generates an XML element denoting referencing an existing object.
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*
|
||||
*/
|
||||
public class ObjectReference extends Element
|
||||
{
|
||||
final ObjectId id;
|
||||
|
||||
public ObjectReference(ObjectId newId)
|
||||
{
|
||||
id = newId;
|
||||
|
||||
// Initializing the Id here is making sure it gets
|
||||
// actually used. This step modifies the Id instance
|
||||
// in other elements.
|
||||
id.init();
|
||||
}
|
||||
|
||||
public void writeStart(Writer writer)
|
||||
{
|
||||
writer.write("object", "idref", id.toString(), isEmpty());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/* PrimitiveInstantiation.java
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder.elements;
|
||||
|
||||
import gnu.java.beans.encoder.Writer;
|
||||
|
||||
/** Generates an XML element denoting a primitive data value.
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*
|
||||
*/
|
||||
public class PrimitiveInstantiation extends Element
|
||||
{
|
||||
final String primitiveName;
|
||||
|
||||
final String valueAsString;
|
||||
|
||||
public PrimitiveInstantiation(String newPrimitiveName, String newValueAsString)
|
||||
{
|
||||
primitiveName = newPrimitiveName;
|
||||
valueAsString = newValueAsString;
|
||||
}
|
||||
|
||||
public void writeStart(Writer writer)
|
||||
{
|
||||
writer.writeNoChildren(primitiveName, valueAsString);
|
||||
}
|
||||
|
||||
public void writeEnd(Writer writer)
|
||||
{
|
||||
writer.writeEndNoChildren();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/* StaticFieldAccess.java
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder.elements;
|
||||
|
||||
import gnu.java.beans.encoder.Writer;
|
||||
|
||||
/** Generates an XML element denoting a static method call.
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*
|
||||
*/
|
||||
public class StaticFieldAccess extends Element
|
||||
{
|
||||
final String className;
|
||||
|
||||
final String fieldName;
|
||||
|
||||
public StaticFieldAccess(String newClassName, String newFieldName)
|
||||
{
|
||||
className = newClassName;
|
||||
fieldName = newFieldName;
|
||||
}
|
||||
|
||||
public void writeStart(Writer writer)
|
||||
{
|
||||
writer.write("object", new String[] { "class", "field" },
|
||||
new String[] { className, fieldName }, isEmpty());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/* StaticMethodCall.java
|
||||
-- A class denoting an XML element which makes up a static method call.
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder.elements;
|
||||
|
||||
import gnu.java.beans.encoder.Writer;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Robert Schuster (robertschuster@fsfe.org)
|
||||
*
|
||||
*/
|
||||
public class StaticMethodInvocation extends Element
|
||||
{
|
||||
final String className;
|
||||
|
||||
final String methodName;
|
||||
|
||||
public StaticMethodInvocation(String newClassName, String newMethodName)
|
||||
{
|
||||
className = newClassName;
|
||||
methodName = newMethodName;
|
||||
}
|
||||
|
||||
public void writeStart(Writer writer)
|
||||
{
|
||||
writer.write("void", new String[] { "class", "method" },
|
||||
new String[] { className, methodName }, isEmpty());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/* StringInstantiation.java
|
||||
-- A class denoting an XML element which retrieves an array element.
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.beans.encoder.elements;
|
||||
|
||||
import gnu.java.beans.encoder.Writer;
|
||||
|
||||
public class StringReference extends Element
|
||||
{
|
||||
final String string;
|
||||
|
||||
public StringReference(String newString)
|
||||
{
|
||||
string = newString;
|
||||
}
|
||||
|
||||
public void writeStart(Writer writer)
|
||||
{
|
||||
writer.writeNoChildren("string", string);
|
||||
}
|
||||
|
||||
public void writeEnd(Writer writer)
|
||||
{
|
||||
writer.writeEndNoChildren();
|
||||
}
|
||||
|
||||
}
|
|
@ -128,7 +128,7 @@ public class CRLFInputStream
|
|||
in.reset();
|
||||
if (i != -1)
|
||||
{
|
||||
l = in.read(b, off, i + 1); // read to CR
|
||||
l = in.read(b, off, (i + 1) - off); // read to CR
|
||||
in.read(); // skip LF
|
||||
b[i] = LF; // fix CR as LF
|
||||
}
|
||||
|
|
|
@ -38,8 +38,6 @@ exception statement from your version. */
|
|||
|
||||
package gnu.java.net;
|
||||
|
||||
import gnu.classpath.Configuration;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.DatagramPacket;
|
||||
import java.net.DatagramSocketImpl;
|
||||
|
@ -64,20 +62,7 @@ import java.net.SocketException;
|
|||
*/
|
||||
public final class PlainDatagramSocketImpl extends DatagramSocketImpl
|
||||
{
|
||||
// Static initializer to load native library
|
||||
static
|
||||
{
|
||||
if (Configuration.INIT_LOAD_LIBRARY)
|
||||
{
|
||||
System.loadLibrary("javanet");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Option id for the IP_TTL (time to live) value.
|
||||
*/
|
||||
private static final int IP_TTL = 0x1E61; // 7777
|
||||
|
||||
|
||||
/**
|
||||
* This is the actual underlying file descriptor
|
||||
*/
|
||||
|
@ -98,6 +83,7 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
|
|||
*/
|
||||
public PlainDatagramSocketImpl()
|
||||
{
|
||||
// Nothing to do here.
|
||||
}
|
||||
|
||||
protected void finalize() throws Throwable
|
||||
|
@ -123,15 +109,48 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
|
|||
*
|
||||
* @exception SocketException If an error occurs
|
||||
*/
|
||||
protected synchronized native void bind(int port, InetAddress addr)
|
||||
throws SocketException;
|
||||
protected synchronized void bind(int port, InetAddress addr)
|
||||
throws SocketException
|
||||
{
|
||||
VMPlainDatagramSocketImpl.bind(this, port, addr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new datagram socket
|
||||
*
|
||||
* @exception SocketException If an error occurs
|
||||
*/
|
||||
protected synchronized native void create() throws SocketException;
|
||||
protected synchronized void create() throws SocketException
|
||||
{
|
||||
VMPlainDatagramSocketImpl.create(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects to the remote address and port specified as arguments.
|
||||
*
|
||||
* @param addr The remote address to connect to
|
||||
* @param port The remote port to connect to
|
||||
*
|
||||
* @exception SocketException If an error occurs
|
||||
*/
|
||||
protected void connect(InetAddress addr, int port) throws SocketException
|
||||
{
|
||||
VMPlainDatagramSocketImpl.connect(this, addr, port);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnects the socket.
|
||||
*
|
||||
* @since 1.4
|
||||
*/
|
||||
protected void disconnect()
|
||||
{
|
||||
synchronized (this)
|
||||
{
|
||||
if (native_fd != -1)
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Time to Live value for the socket
|
||||
|
@ -142,7 +161,7 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
|
|||
*/
|
||||
protected synchronized void setTimeToLive(int ttl) throws IOException
|
||||
{
|
||||
setOption(IP_TTL, new Integer(ttl));
|
||||
setOption(VMPlainDatagramSocketImpl.IP_TTL, new Integer(ttl));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -154,7 +173,7 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
|
|||
*/
|
||||
protected synchronized int getTimeToLive() throws IOException
|
||||
{
|
||||
Object obj = getOption(IP_TTL);
|
||||
Object obj = getOption(VMPlainDatagramSocketImpl.IP_TTL);
|
||||
|
||||
if (! (obj instanceof Integer))
|
||||
throw new IOException("Internal Error");
|
||||
|
@ -162,20 +181,6 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
|
|||
return ((Integer) obj).intValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a packet of data to a remote host
|
||||
*
|
||||
* @param addr The address to send to
|
||||
* @param port The port to send to
|
||||
* @param buf The buffer to send
|
||||
* @param offset The offset of the data in the buffer to send
|
||||
* @param len The length of the data to send
|
||||
*
|
||||
* @exception IOException If an error occurs
|
||||
*/
|
||||
private native void sendto (InetAddress addr, int port,
|
||||
byte[] buf, int offset, int len)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Sends a packet of data to a remote host
|
||||
|
@ -186,12 +191,13 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
|
|||
*/
|
||||
protected void send(DatagramPacket packet) throws IOException
|
||||
{
|
||||
synchronized(SEND_LOCK)
|
||||
if (native_fd != -1)
|
||||
{
|
||||
sendto(packet.getAddress(), packet.getPort(), packet.getData(),
|
||||
packet.getOffset(), packet.getLength());
|
||||
}
|
||||
|
||||
synchronized(SEND_LOCK)
|
||||
{
|
||||
VMPlainDatagramSocketImpl.send(this, packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -206,18 +212,10 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
|
|||
{
|
||||
synchronized(RECEIVE_LOCK)
|
||||
{
|
||||
receive0(packet);
|
||||
VMPlainDatagramSocketImpl.receive(this, packet);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Native call to receive a UDP packet from the network
|
||||
*
|
||||
* @param packet The packet to fill in with the data received
|
||||
*
|
||||
* @exception IOException IOException If an error occurs
|
||||
*/
|
||||
private native void receive0(DatagramPacket packet) throws IOException;
|
||||
|
||||
/**
|
||||
* Sets the value of an option on the socket
|
||||
|
@ -227,8 +225,11 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
|
|||
*
|
||||
* @exception SocketException If an error occurs
|
||||
*/
|
||||
public synchronized native void setOption(int option_id, Object val)
|
||||
throws SocketException;
|
||||
public synchronized void setOption(int option_id, Object val)
|
||||
throws SocketException
|
||||
{
|
||||
VMPlainDatagramSocketImpl.setOption(this, option_id, val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the value of an option on the socket
|
||||
|
@ -239,13 +240,19 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
|
|||
*
|
||||
* @exception SocketException If an error occurs
|
||||
*/
|
||||
public synchronized native Object getOption(int option_id)
|
||||
throws SocketException;
|
||||
public synchronized Object getOption(int option_id)
|
||||
throws SocketException
|
||||
{
|
||||
return VMPlainDatagramSocketImpl.getOption(this, option_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the socket
|
||||
*/
|
||||
protected synchronized native void close();
|
||||
protected synchronized void close()
|
||||
{
|
||||
VMPlainDatagramSocketImpl.close(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Time to Live value for the socket
|
||||
|
@ -282,7 +289,10 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
|
|||
*
|
||||
* @exception IOException If an error occurs
|
||||
*/
|
||||
protected synchronized native void join(InetAddress addr) throws IOException;
|
||||
protected synchronized void join(InetAddress addr) throws IOException
|
||||
{
|
||||
VMPlainDatagramSocketImpl.join(this,addr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Leaves a multicast group
|
||||
|
@ -291,7 +301,10 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
|
|||
*
|
||||
* @exception IOException If an error occurs
|
||||
*/
|
||||
protected synchronized native void leave(InetAddress addr) throws IOException;
|
||||
protected synchronized void leave(InetAddress addr) throws IOException
|
||||
{
|
||||
VMPlainDatagramSocketImpl.leave(this, addr);
|
||||
}
|
||||
|
||||
/**
|
||||
* What does this method really do?
|
||||
|
@ -308,14 +321,14 @@ public final class PlainDatagramSocketImpl extends DatagramSocketImpl
|
|||
}
|
||||
|
||||
public void joinGroup(SocketAddress address, NetworkInterface netIf)
|
||||
throws IOException
|
||||
{
|
||||
throw new InternalError
|
||||
("PlainDatagramSocketImpl::joinGroup is not implemented");
|
||||
VMPlainDatagramSocketImpl.joinGroup(this, address, netIf);
|
||||
}
|
||||
|
||||
public void leaveGroup(SocketAddress address, NetworkInterface netIf)
|
||||
throws IOException
|
||||
{
|
||||
throw new InternalError
|
||||
("PlainDatagramSocketImpl::leaveGroup is not implemented");
|
||||
VMPlainDatagramSocketImpl.leaveGroup(this, address, netIf);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,17 +39,13 @@ exception statement from your version. */
|
|||
|
||||
package gnu.java.net;
|
||||
|
||||
import gnu.classpath.Configuration;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.net.SocketException;
|
||||
import java.net.SocketImpl;
|
||||
import java.net.SocketOptions;
|
||||
|
||||
/**
|
||||
* Written using on-line Java Platform 1.2 API Specification, as well
|
||||
|
@ -69,14 +65,6 @@ import java.net.SocketOptions;
|
|||
*/
|
||||
public final class PlainSocketImpl extends SocketImpl
|
||||
{
|
||||
// Static initializer to load native library.
|
||||
static
|
||||
{
|
||||
if (Configuration.INIT_LOAD_LIBRARY)
|
||||
{
|
||||
System.loadLibrary("javanet");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The OS file handle representing the socket.
|
||||
|
@ -125,10 +113,11 @@ public final class PlainSocketImpl extends SocketImpl
|
|||
}
|
||||
|
||||
/**
|
||||
* Default do nothing constructor
|
||||
* Default do nothing constructor.
|
||||
*/
|
||||
public PlainSocketImpl()
|
||||
{
|
||||
// Nothing to do here.
|
||||
}
|
||||
|
||||
protected void finalize() throws Throwable
|
||||
|
@ -142,6 +131,7 @@ public final class PlainSocketImpl extends SocketImpl
|
|||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
// Nothing we can do about it.
|
||||
}
|
||||
}
|
||||
super.finalize();
|
||||
|
@ -158,121 +148,111 @@ public final class PlainSocketImpl extends SocketImpl
|
|||
* Integer. The option_id parameter is one of the defined constants in
|
||||
* this interface.
|
||||
*
|
||||
* @param option_id The identifier of the option
|
||||
* @param val The value to set the option to
|
||||
* @param optionId The identifier of the option
|
||||
* @param value The value to set the option to
|
||||
*
|
||||
* @exception SocketException If an error occurs
|
||||
* @throws SocketException if an error occurs
|
||||
*/
|
||||
public native void setOption(int optID, Object value) throws SocketException;
|
||||
public void setOption(int optionId, Object value) throws SocketException
|
||||
{
|
||||
VMPlainSocketImpl.setOption(this, optionId, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current setting of the specified option. The Object returned
|
||||
* will be an Integer for options that have integer values. The option_id
|
||||
* is one of the defined constants in this interface.
|
||||
*
|
||||
* @param option_id The option identifier
|
||||
* @param optionId the option identifier
|
||||
*
|
||||
* @return The current value of the option
|
||||
* @return the current value of the option
|
||||
*
|
||||
* @exception SocketException If an error occurs
|
||||
* @throws SocketException if an error occurs
|
||||
*/
|
||||
public native Object getOption(int optID) throws SocketException;
|
||||
public Object getOption(int optionId) throws SocketException
|
||||
{
|
||||
return VMPlainSocketImpl.getOption(this, optionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flushes the input stream and closes it. If you read from the input stream
|
||||
* after calling this method a <code>IOException</code> will be thrown.
|
||||
*
|
||||
* @throws IOException if an error occurs
|
||||
*/
|
||||
public native void shutdownInput() throws IOException;
|
||||
public void shutdownInput() throws IOException
|
||||
{
|
||||
VMPlainSocketImpl.shutdownInput(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flushes the output stream and closes it. If you write to the output stream
|
||||
* after calling this method a <code>IOException</code> will be thrown.
|
||||
*
|
||||
* @throws IOException if an error occurs
|
||||
*/
|
||||
public native void shutdownOutput() throws IOException;
|
||||
public void shutdownOutput() throws IOException
|
||||
{
|
||||
VMPlainSocketImpl.shutdownOutput(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new socket that is not bound to any local address/port and
|
||||
* is not connected to any remote address/port. This will be created as
|
||||
* a stream socket if the stream parameter is true, or a datagram socket
|
||||
* if the stream parameter is false.
|
||||
* is not connected to any remote address/port. The stream parameter will be
|
||||
* ignored since PlainSocketImpl always is a stream socket. Datagram sockets
|
||||
* are handled by PlainDatagramSocketImpl.
|
||||
*
|
||||
* @param stream true for a stream socket, false for a datagram socket
|
||||
* @param stream <code>true</code> for stream sockets, <code>false</code> for
|
||||
* datagram sockets
|
||||
*/
|
||||
protected synchronized native void create(boolean stream) throws IOException;
|
||||
protected synchronized void create(boolean stream) throws IOException
|
||||
{
|
||||
VMPlainSocketImpl.create(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects to the remote hostname and port specified as arguments.
|
||||
*
|
||||
* @param hostname The remote hostname to connect to
|
||||
* @param port The remote port to connect to
|
||||
* @param hostname the remote hostname to connect to
|
||||
* @param port the remote port to connect to
|
||||
*
|
||||
* @exception IOException If an error occurs
|
||||
* @throws IOException If an error occurs
|
||||
*/
|
||||
protected synchronized void connect(String host, int port) throws IOException
|
||||
protected synchronized void connect(String hostname, int port)
|
||||
throws IOException
|
||||
{
|
||||
connect(InetAddress.getByName(host), port);
|
||||
connect(InetAddress.getByName(hostname), port);
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects to the remote address and port specified as arguments.
|
||||
*
|
||||
* @param addr The remote address to connect to
|
||||
* @param port The remote port to connect to
|
||||
* @param addr the remote address to connect to
|
||||
* @param port the remote port to connect to
|
||||
*
|
||||
* @exception IOException If an error occurs
|
||||
* @throws IOException If an error occurs
|
||||
*/
|
||||
protected native void connect(InetAddress addr, int port) throws IOException;
|
||||
protected void connect(InetAddress addr, int port) throws IOException
|
||||
{
|
||||
VMPlainSocketImpl.connect(this, addr, port);
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects to the remote socket address with a specified timeout.
|
||||
*
|
||||
* @param timeout The timeout to use for this connect, 0 means infinite.
|
||||
* @param address the remote address to connect to
|
||||
* @param timeout the timeout to use for this connect, 0 means infinite.
|
||||
*
|
||||
* @exception IOException If an error occurs
|
||||
* @throws IOException If an error occurs
|
||||
*/
|
||||
protected synchronized void connect(SocketAddress address, int timeout) throws IOException
|
||||
protected synchronized void connect(SocketAddress address, int timeout)
|
||||
throws IOException
|
||||
{
|
||||
InetSocketAddress sockAddr = (InetSocketAddress) address;
|
||||
InetAddress addr = sockAddr.getAddress();
|
||||
|
||||
if (addr == null)
|
||||
throw new IllegalArgumentException("address is unresolved: " + sockAddr);
|
||||
|
||||
int port = sockAddr.getPort();
|
||||
|
||||
if (timeout < 0)
|
||||
throw new IllegalArgumentException("negative timeout");
|
||||
|
||||
Object oldTimeoutObj = null;
|
||||
|
||||
try
|
||||
{
|
||||
oldTimeoutObj = this.getOption (SocketOptions.SO_TIMEOUT);
|
||||
this.setOption (SocketOptions.SO_TIMEOUT, new Integer (timeout));
|
||||
connect (addr, port);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (oldTimeoutObj != null)
|
||||
this.setOption (SocketOptions.SO_TIMEOUT, oldTimeoutObj);
|
||||
}
|
||||
VMPlainSocketImpl.connect(this, address, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds to the specified port on the specified addr. Note that this addr
|
||||
* must represent a local IP address. **** How bind to INADDR_ANY? ****
|
||||
*
|
||||
* @param addr The address to bind to
|
||||
* @param port The port number to bind to
|
||||
* @param addr the address to bind to
|
||||
* @param port the port number to bind to
|
||||
*
|
||||
* @exception IOException If an error occurs
|
||||
* @throws IOException if an error occurs
|
||||
*/
|
||||
protected synchronized native void bind(InetAddress addr, int port)
|
||||
throws IOException;
|
||||
protected synchronized void bind(InetAddress addr, int port)
|
||||
throws IOException
|
||||
{
|
||||
VMPlainSocketImpl.bind(this, addr, port);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts listening for connections on a socket. The queuelen parameter
|
||||
|
@ -282,10 +262,13 @@ public final class PlainSocketImpl extends SocketImpl
|
|||
*
|
||||
* @param queuelen The length of the pending connection queue
|
||||
*
|
||||
* @exception IOException If an error occurs
|
||||
* @throws IOException If an error occurs
|
||||
*/
|
||||
protected synchronized native void listen(int queuelen)
|
||||
throws IOException;
|
||||
protected synchronized void listen(int queuelen)
|
||||
throws IOException
|
||||
{
|
||||
VMPlainSocketImpl.listen(this, queuelen);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts a new connection on this socket and returns in in the
|
||||
|
@ -293,33 +276,44 @@ public final class PlainSocketImpl extends SocketImpl
|
|||
*
|
||||
* @param impl The SocketImpl object to accept this connection.
|
||||
*/
|
||||
protected synchronized native void accept(SocketImpl impl)
|
||||
throws IOException;
|
||||
protected synchronized void accept(SocketImpl impl)
|
||||
throws IOException
|
||||
{
|
||||
VMPlainSocketImpl.accept(this, impl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of bytes that the caller can read from this socket
|
||||
* without blocking.
|
||||
*
|
||||
* @return The number of readable bytes before blocking
|
||||
* @return the number of readable bytes before blocking
|
||||
*
|
||||
* @exception IOException If an error occurs
|
||||
* @throws IOException if an error occurs
|
||||
*/
|
||||
protected native int available() throws IOException;
|
||||
protected int available() throws IOException
|
||||
{
|
||||
return VMPlainSocketImpl.available(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the socket. This will cause any InputStream or OutputStream
|
||||
* objects for this Socket to be closed as well.
|
||||
*
|
||||
* <p>
|
||||
* Note that if the SO_LINGER option is set on this socket, then the
|
||||
* operation could block.
|
||||
* </p>
|
||||
*
|
||||
* @exception IOException If an error occurs
|
||||
* @throws IOException if an error occurs
|
||||
*/
|
||||
protected native void close() throws IOException;
|
||||
protected void close() throws IOException
|
||||
{
|
||||
VMPlainSocketImpl.close(this);
|
||||
}
|
||||
|
||||
public void sendUrgentData(int data)
|
||||
{
|
||||
throw new InternalError ("PlainSocketImpl::sendUrgentData not implemented");
|
||||
VMPlainSocketImpl.sendUrgendData(this, data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -327,22 +321,53 @@ public final class PlainSocketImpl extends SocketImpl
|
|||
* the connection. Reads up to len bytes of data into the buffer
|
||||
* buf starting at offset bytes into the buffer.
|
||||
*
|
||||
* @return The actual number of bytes read or -1 if end of stream.
|
||||
* @return the actual number of bytes read or -1 if end of stream.
|
||||
*
|
||||
* @exception IOException If an error occurs
|
||||
* @throws IOException if an error occurs
|
||||
*/
|
||||
protected native int read(byte[] buf, int offset, int len)
|
||||
throws IOException;
|
||||
protected int read(byte[] buf, int offset, int len)
|
||||
throws IOException
|
||||
{
|
||||
return VMPlainSocketImpl.read(this, buf, offset, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method used by SocketInputStream for reading data from
|
||||
* the connection. Reads and returns one byte of data.
|
||||
*
|
||||
* @return the read byte
|
||||
*
|
||||
* @throws IOException if an error occurs
|
||||
*/
|
||||
protected int read()
|
||||
throws IOException
|
||||
{
|
||||
return VMPlainSocketImpl.read(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method used by SocketOuputStream for writing data to
|
||||
* the connection. Writes up to len bytes of data from the buffer
|
||||
* buf starting at offset bytes into the buffer.
|
||||
*
|
||||
* @exception IOException If an error occurs
|
||||
* @throws IOException If an error occurs
|
||||
*/
|
||||
protected native void write(byte[] buf, int offset, int len)
|
||||
throws IOException;
|
||||
protected void write(byte[] buf, int offset, int len)
|
||||
throws IOException
|
||||
{
|
||||
VMPlainSocketImpl.write(this, buf, offset, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method used by SocketOuputStream for writing data to
|
||||
* the connection. Writes up one byte to the socket.
|
||||
*
|
||||
* @throws IOException If an error occurs
|
||||
*/
|
||||
protected void write(int data) throws IOException
|
||||
{
|
||||
VMPlainSocketImpl.write(this, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an InputStream object for reading from this socket. This will
|
||||
|
@ -356,7 +381,7 @@ public final class PlainSocketImpl extends SocketImpl
|
|||
{
|
||||
if (in == null)
|
||||
in = new SocketInputStream();
|
||||
|
||||
|
||||
return in;
|
||||
}
|
||||
|
||||
|
@ -372,7 +397,7 @@ public final class PlainSocketImpl extends SocketImpl
|
|||
{
|
||||
if (out == null)
|
||||
out = new SocketOutputStream();
|
||||
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
|
@ -380,7 +405,7 @@ public final class PlainSocketImpl extends SocketImpl
|
|||
* This class contains an implementation of <code>InputStream</code> for
|
||||
* sockets. It in an internal only class used by <code>PlainSocketImpl</code>.
|
||||
*
|
||||
* @author Nic Ferrier (nferrier@tapsellferrier.co.uk)
|
||||
* @author Nic Ferrier <nferrier@tapsellferrier.co.uk>
|
||||
*/
|
||||
final class SocketInputStream
|
||||
extends InputStream
|
||||
|
@ -412,13 +437,7 @@ public final class PlainSocketImpl extends SocketImpl
|
|||
*/
|
||||
public int read() throws IOException
|
||||
{
|
||||
byte buf[] = new byte [1];
|
||||
int bytes_read = read(buf, 0, 1);
|
||||
|
||||
if (bytes_read == -1)
|
||||
return -1;
|
||||
|
||||
return buf[0] & 0xFF;
|
||||
return PlainSocketImpl.this.read();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -450,7 +469,7 @@ public final class PlainSocketImpl extends SocketImpl
|
|||
* <code>getOutputStream method</code>. It expects only to be used in that
|
||||
* context.
|
||||
*
|
||||
* @author Nic Ferrier (nferrier@tapsellferrier.co.uk)
|
||||
* @author Nic Ferrier <nferrier@tapsellferrier.co.uk>
|
||||
*/
|
||||
final class SocketOutputStream
|
||||
extends OutputStream
|
||||
|
@ -476,8 +495,7 @@ public final class PlainSocketImpl extends SocketImpl
|
|||
*/
|
||||
public void write(int b) throws IOException
|
||||
{
|
||||
byte buf[] = { (byte) b };
|
||||
write(buf, 0, 1);
|
||||
PlainSocketImpl.this.write(b);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* FileChannelImpl.java --
|
||||
Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -301,8 +301,10 @@ public final class FileChannelImpl extends FileChannel
|
|||
else if (mode == MapMode.READ_WRITE || mode == MapMode.PRIVATE)
|
||||
{
|
||||
nmode = mode == MapMode.READ_WRITE ? '+' : 'c';
|
||||
if ((this.mode & (READ|WRITE)) != (READ|WRITE))
|
||||
if ((this.mode & WRITE) != WRITE)
|
||||
throw new NonWritableChannelException();
|
||||
if ((this.mode & READ) != READ)
|
||||
throw new NonReadableChannelException();
|
||||
}
|
||||
else
|
||||
throw new IllegalArgumentException ("mode: " + mode);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Provider.java --
|
||||
Copyright (C) 2002, 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2002, 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -39,6 +39,8 @@ package gnu.java.nio.charset;
|
|||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.spi.CharsetProvider;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
@ -47,6 +49,11 @@ import java.util.Iterator;
|
|||
* Charset provider for the required charsets. Used by
|
||||
* {@link Charset#charsetForName} and * {@link Charset#availableCharsets}.
|
||||
*
|
||||
* Note: This class is a privileged class, because it can be instantiated without
|
||||
* requiring the RuntimePermission("charsetProvider"). There is a check in
|
||||
* java.nio.charset.spi.CharsetProvider to skip the security check if the provider
|
||||
* is an instance of this class.
|
||||
*
|
||||
* @author Jesse Rosenstock
|
||||
* @author Robert Schuster (thebohemian@gmx.net)
|
||||
* @see Charset
|
||||
|
@ -55,14 +62,6 @@ public final class Provider extends CharsetProvider
|
|||
{
|
||||
private static Provider singleton;
|
||||
|
||||
static
|
||||
{
|
||||
synchronized (Provider.class)
|
||||
{
|
||||
singleton = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Map from charset name to charset canonical name. The strings
|
||||
* are all lower-case to allow case-insensitive retrieval of
|
||||
|
@ -232,8 +231,16 @@ public final class Provider extends CharsetProvider
|
|||
|
||||
public static synchronized Provider provider ()
|
||||
{
|
||||
// The default provider is safe to instantiate.
|
||||
if (singleton == null)
|
||||
singleton = new Provider ();
|
||||
singleton = (Provider) AccessController.doPrivileged
|
||||
(new PrivilegedAction()
|
||||
{
|
||||
public Object run()
|
||||
{
|
||||
return new Provider();
|
||||
}
|
||||
});
|
||||
return singleton;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* IconvProvider.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -48,20 +48,17 @@ import java.util.Vector;
|
|||
/**
|
||||
* Charset provider wrapping iconv.
|
||||
*
|
||||
* Note: This class is a privileged class, because it can be instantiated without
|
||||
* requiring the RuntimePermission("charsetProvider"). There is a check in
|
||||
* java.nio.charset.spi.CharsetProvider to skip the security check if the provider
|
||||
* is an instance of this class.
|
||||
*
|
||||
* @author Sven de Marothy
|
||||
*/
|
||||
public final class IconvProvider extends CharsetProvider
|
||||
{
|
||||
private static IconvProvider singleton;
|
||||
|
||||
static
|
||||
{
|
||||
synchronized (IconvProvider.class)
|
||||
{
|
||||
singleton = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Declaring the construtor public may violate the use of singleton.
|
||||
// But it must be public so that an instance of this class can be
|
||||
// created by Class.newInstance(), which is the case when this provider is
|
||||
|
|
|
@ -47,6 +47,7 @@ import java.io.ObjectOutput;
|
|||
import java.io.ObjectOutputStream;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.rmi.ConnectException;
|
||||
import java.rmi.Remote;
|
||||
import java.rmi.RemoteException;
|
||||
import java.rmi.server.ObjID;
|
||||
|
@ -195,7 +196,7 @@ public RemoteCall newCall(RemoteObject obj, Operation[] op, int opnum, long hash
|
|||
conn = manager.getConnection();
|
||||
}
|
||||
catch (IOException e1) {
|
||||
throw new RemoteException("connection failed to host: " + manager.serverName, e1);
|
||||
throw new ConnectException("connection failed to host: " + manager.serverName, e1);
|
||||
}
|
||||
|
||||
//obj: useless?
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Engine -- generic getInstance method.
|
||||
Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
Copyright (C) 2003, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -130,7 +130,14 @@ public final class Engine
|
|||
Provider provider, Object[] initArgs)
|
||||
throws InvocationTargetException, NoSuchAlgorithmException
|
||||
{
|
||||
if (service == null || algorithm == null
|
||||
if (service != null)
|
||||
service = service.trim();
|
||||
|
||||
if (algorithm != null)
|
||||
algorithm = algorithm.trim();
|
||||
|
||||
if (service == null || service.length() == 0
|
||||
|| algorithm == null || algorithm.length() == 0
|
||||
|| provider == null || initArgs == null)
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
|
|
|
@ -0,0 +1,862 @@
|
|||
/* WeakIdentityHashMap -- an identity hashtable that keeps only weak references
|
||||
to its keys, allowing the virtual machine to reclaim them
|
||||
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
|
||||
package gnu.java.util;
|
||||
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.AbstractSet;
|
||||
import java.util.Collection;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A weak hash map has only weak references to the key. This means that it
|
||||
* allows the key to be garbage collected if it is not used otherwise. If
|
||||
* this happens, the entry will eventually disappear from the map,
|
||||
* asynchronously.
|
||||
*
|
||||
* <p>Other strange behaviors to be aware of: The size of this map may
|
||||
* spontaneously shrink (even if you use a synchronized map and synchronize
|
||||
* it); it behaves as if another thread removes entries from this table
|
||||
* without synchronization. The entry set returned by <code>entrySet</code>
|
||||
* has similar phenomenons: The size may spontaneously shrink, or an
|
||||
* entry, that was in the set before, suddenly disappears.
|
||||
*
|
||||
* <p>A weak hash map is not meant for caches; use a normal map, with
|
||||
* soft references as values instead, or try {@link LinkedHashMap}.
|
||||
*
|
||||
* <p>The weak hash map supports null values and null keys. The null key
|
||||
* is never deleted from the map (except explictly of course). The
|
||||
* performance of the methods are similar to that of a hash map.
|
||||
*
|
||||
* <p>The value objects are strongly referenced by this table. So if a
|
||||
* value object maintains a strong reference to the key (either direct
|
||||
* or indirect) the key will never be removed from this map. According
|
||||
* to Sun, this problem may be fixed in a future release. It is not
|
||||
* possible to do it with the jdk 1.2 reference model, though.
|
||||
*
|
||||
* @author Jochen Hoenicke
|
||||
* @author Eric Blake (ebb9@email.byu.edu)
|
||||
* @author Jeroen Frijters
|
||||
*
|
||||
* @see HashMap
|
||||
* @see WeakReference
|
||||
* @see WeakHashMap
|
||||
* @see IdentityHashMap
|
||||
* @see LinkedHashMap
|
||||
*/
|
||||
public class WeakIdentityHashMap extends AbstractMap implements Map
|
||||
{
|
||||
/**
|
||||
* The default capacity for an instance of HashMap.
|
||||
* Sun's documentation mildly suggests that this (11) is the correct
|
||||
* value.
|
||||
*/
|
||||
private static final int DEFAULT_CAPACITY = 11;
|
||||
|
||||
/**
|
||||
* The default load factor of a HashMap.
|
||||
*/
|
||||
private static final float DEFAULT_LOAD_FACTOR = 0.75F;
|
||||
|
||||
/**
|
||||
* This is used instead of the key value <i>null</i>. It is needed
|
||||
* to distinguish between an null key and a removed key.
|
||||
*/
|
||||
// Package visible for use by nested classes.
|
||||
static final Object NULL_KEY = new Object();
|
||||
|
||||
/**
|
||||
* The reference queue where our buckets (which are WeakReferences) are
|
||||
* registered to.
|
||||
*/
|
||||
private final ReferenceQueue queue;
|
||||
|
||||
/**
|
||||
* The number of entries in this hash map.
|
||||
*/
|
||||
// Package visible for use by nested classes.
|
||||
int size;
|
||||
|
||||
/**
|
||||
* The load factor of this WeakIdentityHashMap. This is the maximum ratio of
|
||||
* size versus number of buckets. If size grows the number of buckets
|
||||
* must grow, too.
|
||||
*/
|
||||
private float loadFactor;
|
||||
|
||||
/**
|
||||
* The rounded product of the capacity (i.e. number of buckets) and
|
||||
* the load factor. When the number of elements exceeds the
|
||||
* threshold, the HashMap calls <code>rehash()</code>.
|
||||
*/
|
||||
private int threshold;
|
||||
|
||||
/**
|
||||
* The number of structural modifications. This is used by
|
||||
* iterators, to see if they should fail. This doesn't count
|
||||
* the silent key removals, when a weak reference is cleared
|
||||
* by the garbage collection. Instead the iterators must make
|
||||
* sure to have strong references to the entries they rely on.
|
||||
*/
|
||||
// Package visible for use by nested classes.
|
||||
int modCount;
|
||||
|
||||
/**
|
||||
* The entry set. There is only one instance per hashmap, namely
|
||||
* theEntrySet. Note that the entry set may silently shrink, just
|
||||
* like the WeakIdentityHashMap.
|
||||
*/
|
||||
private final class WeakEntrySet extends AbstractSet
|
||||
{
|
||||
/**
|
||||
* Non-private constructor to reduce bytecode emitted.
|
||||
*/
|
||||
WeakEntrySet()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of this set.
|
||||
*
|
||||
* @return the set size
|
||||
*/
|
||||
public int size()
|
||||
{
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an iterator for all entries.
|
||||
*
|
||||
* @return an Entry iterator
|
||||
*/
|
||||
public Iterator iterator()
|
||||
{
|
||||
return new Iterator()
|
||||
{
|
||||
/**
|
||||
* The entry that was returned by the last
|
||||
* <code>next()</code> call. This is also the entry whose
|
||||
* bucket should be removed by the <code>remove</code> call. <br>
|
||||
*
|
||||
* It is null, if the <code>next</code> method wasn't
|
||||
* called yet, or if the entry was already removed. <br>
|
||||
*
|
||||
* Remembering this entry here will also prevent it from
|
||||
* being removed under us, since the entry strongly refers
|
||||
* to the key.
|
||||
*/
|
||||
WeakBucket.WeakEntry lastEntry;
|
||||
|
||||
/**
|
||||
* The entry that will be returned by the next
|
||||
* <code>next()</code> call. It is <code>null</code> if there
|
||||
* is no further entry. <br>
|
||||
*
|
||||
* Remembering this entry here will also prevent it from
|
||||
* being removed under us, since the entry strongly refers
|
||||
* to the key.
|
||||
*/
|
||||
WeakBucket.WeakEntry nextEntry = findNext(null);
|
||||
|
||||
/**
|
||||
* The known number of modification to the list, if it differs
|
||||
* from the real number, we throw an exception.
|
||||
*/
|
||||
int knownMod = modCount;
|
||||
|
||||
/**
|
||||
* Check the known number of modification to the number of
|
||||
* modifications of the table. If it differs from the real
|
||||
* number, we throw an exception.
|
||||
* @throws ConcurrentModificationException if the number
|
||||
* of modifications doesn't match.
|
||||
*/
|
||||
private void checkMod()
|
||||
{
|
||||
// This method will get inlined.
|
||||
cleanQueue();
|
||||
if (knownMod != modCount)
|
||||
throw new ConcurrentModificationException(knownMod + " != "
|
||||
+ modCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a strong reference to the next entry after
|
||||
* lastBucket.
|
||||
* @param lastEntry the previous bucket, or null if we should
|
||||
* get the first entry.
|
||||
* @return the next entry.
|
||||
*/
|
||||
private WeakBucket.WeakEntry findNext(WeakBucket.WeakEntry lastEntry)
|
||||
{
|
||||
int slot;
|
||||
WeakBucket nextBucket;
|
||||
if (lastEntry != null)
|
||||
{
|
||||
nextBucket = lastEntry.getBucket().next;
|
||||
slot = lastEntry.getBucket().slot;
|
||||
}
|
||||
else
|
||||
{
|
||||
nextBucket = buckets[0];
|
||||
slot = 0;
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
while (nextBucket != null)
|
||||
{
|
||||
WeakBucket.WeakEntry entry = nextBucket.getEntry();
|
||||
if (entry != null)
|
||||
// This is the next entry.
|
||||
return entry;
|
||||
|
||||
// Entry was cleared, try next.
|
||||
nextBucket = nextBucket.next;
|
||||
}
|
||||
|
||||
slot++;
|
||||
if (slot == buckets.length)
|
||||
// No more buckets, we are through.
|
||||
return null;
|
||||
|
||||
nextBucket = buckets[slot];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there are more entries.
|
||||
* @return true, iff there are more elements.
|
||||
* @throws ConcurrentModificationException if the hash map was
|
||||
* modified.
|
||||
*/
|
||||
public boolean hasNext()
|
||||
{
|
||||
checkMod();
|
||||
return nextEntry != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next entry.
|
||||
* @return the next entry.
|
||||
* @throws ConcurrentModificationException if the hash map was
|
||||
* modified.
|
||||
* @throws NoSuchElementException if there is no entry.
|
||||
*/
|
||||
public Object next()
|
||||
{
|
||||
checkMod();
|
||||
if (nextEntry == null)
|
||||
throw new NoSuchElementException();
|
||||
lastEntry = nextEntry;
|
||||
nextEntry = findNext(lastEntry);
|
||||
return lastEntry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the last returned entry from this set. This will
|
||||
* also remove the bucket of the underlying weak hash map.
|
||||
* @throws ConcurrentModificationException if the hash map was
|
||||
* modified.
|
||||
* @throws IllegalStateException if <code>next()</code> was
|
||||
* never called or the element was already removed.
|
||||
*/
|
||||
public void remove()
|
||||
{
|
||||
checkMod();
|
||||
if (lastEntry == null)
|
||||
throw new IllegalStateException();
|
||||
modCount++;
|
||||
internalRemove(lastEntry.getBucket());
|
||||
lastEntry = null;
|
||||
knownMod++;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A bucket is a weak reference to the key, that contains a strong
|
||||
* reference to the value, a pointer to the next bucket and its slot
|
||||
* number. <br>
|
||||
*
|
||||
* It would be cleaner to have a WeakReference as field, instead of
|
||||
* extending it, but if a weak reference gets cleared, we only get
|
||||
* the weak reference (by queue.poll) and wouldn't know where to
|
||||
* look for this reference in the hashtable, to remove that entry.
|
||||
*
|
||||
* @author Jochen Hoenicke
|
||||
*/
|
||||
private static class WeakBucket extends WeakReference
|
||||
{
|
||||
/**
|
||||
* The value of this entry. The key is stored in the weak
|
||||
* reference that we extend.
|
||||
*/
|
||||
Object value;
|
||||
|
||||
/**
|
||||
* The next bucket describing another entry that uses the same
|
||||
* slot.
|
||||
*/
|
||||
WeakBucket next;
|
||||
|
||||
/**
|
||||
* The slot of this entry. This should be
|
||||
* <code>Math.abs(key.hashCode() % buckets.length)</code>.
|
||||
*
|
||||
* But since the key may be silently removed we have to remember
|
||||
* the slot number.
|
||||
*
|
||||
* If this bucket was removed the slot is -1. This marker will
|
||||
* prevent the bucket from being removed twice.
|
||||
*/
|
||||
int slot;
|
||||
|
||||
/**
|
||||
* Creates a new bucket for the given key/value pair and the specified
|
||||
* slot.
|
||||
* @param key the key
|
||||
* @param queue the queue the weak reference belongs to
|
||||
* @param value the value
|
||||
* @param slot the slot. This must match the slot where this bucket
|
||||
* will be enqueued.
|
||||
*/
|
||||
public WeakBucket(Object key, ReferenceQueue queue, Object value,
|
||||
int slot)
|
||||
{
|
||||
super(key, queue);
|
||||
this.value = value;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
/**
|
||||
* This class gives the <code>Entry</code> representation of the
|
||||
* current bucket. It also keeps a strong reference to the
|
||||
* key; bad things may happen otherwise.
|
||||
*/
|
||||
class WeakEntry implements Map.Entry
|
||||
{
|
||||
/**
|
||||
* The strong ref to the key.
|
||||
*/
|
||||
Object key;
|
||||
|
||||
/**
|
||||
* Creates a new entry for the key.
|
||||
* @param key the key
|
||||
*/
|
||||
public WeakEntry(Object key)
|
||||
{
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the underlying bucket.
|
||||
* @return the owning bucket
|
||||
*/
|
||||
public WeakBucket getBucket()
|
||||
{
|
||||
return WeakBucket.this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key.
|
||||
* @return the key
|
||||
*/
|
||||
public Object getKey()
|
||||
{
|
||||
return key == NULL_KEY ? null : key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value.
|
||||
* @return the value
|
||||
*/
|
||||
public Object getValue()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* This changes the value. This change takes place in
|
||||
* the underlying hash map.
|
||||
* @param newVal the new value
|
||||
* @return the old value
|
||||
*/
|
||||
public Object setValue(Object newVal)
|
||||
{
|
||||
Object oldVal = value;
|
||||
value = newVal;
|
||||
return oldVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* The hashCode as specified in the Entry interface.
|
||||
* @return the hash code
|
||||
*/
|
||||
public int hashCode()
|
||||
{
|
||||
return System.identityHashCode(key)
|
||||
^ (value == null ? 0 : value.hashCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* The equals method as specified in the Entry interface.
|
||||
* @param o the object to compare to
|
||||
* @return true iff o represents the same key/value pair
|
||||
*/
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
if (o instanceof Map.Entry)
|
||||
{
|
||||
Map.Entry e = (Map.Entry) o;
|
||||
return getKey() == e.getKey()
|
||||
&& (value == null ? e.getValue() == null
|
||||
: value.equals(e.getValue()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return getKey() + "=" + value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This returns the entry stored in this bucket, or null, if the
|
||||
* bucket got cleared in the mean time.
|
||||
* @return the Entry for this bucket, if it exists
|
||||
*/
|
||||
WeakEntry getEntry()
|
||||
{
|
||||
final Object key = this.get();
|
||||
if (key == null)
|
||||
return null;
|
||||
return new WeakEntry(key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The entry set returned by <code>entrySet()</code>.
|
||||
*/
|
||||
private final WeakEntrySet theEntrySet;
|
||||
|
||||
/**
|
||||
* The hash buckets. These are linked lists. Package visible for use in
|
||||
* nested classes.
|
||||
*/
|
||||
WeakBucket[] buckets;
|
||||
|
||||
/**
|
||||
* Creates a new weak hash map with default load factor and default
|
||||
* capacity.
|
||||
*/
|
||||
public WeakIdentityHashMap()
|
||||
{
|
||||
this(DEFAULT_CAPACITY, DEFAULT_LOAD_FACTOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new weak hash map with default load factor and the given
|
||||
* capacity.
|
||||
* @param initialCapacity the initial capacity
|
||||
* @throws IllegalArgumentException if initialCapacity is negative
|
||||
*/
|
||||
public WeakIdentityHashMap(int initialCapacity)
|
||||
{
|
||||
this(initialCapacity, DEFAULT_LOAD_FACTOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new weak hash map with the given initial capacity and
|
||||
* load factor.
|
||||
* @param initialCapacity the initial capacity.
|
||||
* @param loadFactor the load factor (see class description of HashMap).
|
||||
* @throws IllegalArgumentException if initialCapacity is negative, or
|
||||
* loadFactor is non-positive
|
||||
*/
|
||||
public WeakIdentityHashMap(int initialCapacity, float loadFactor)
|
||||
{
|
||||
// Check loadFactor for NaN as well.
|
||||
if (initialCapacity < 0 || ! (loadFactor > 0))
|
||||
throw new IllegalArgumentException();
|
||||
if (initialCapacity == 0)
|
||||
initialCapacity = 1;
|
||||
this.loadFactor = loadFactor;
|
||||
threshold = (int) (initialCapacity * loadFactor);
|
||||
theEntrySet = new WeakEntrySet();
|
||||
queue = new ReferenceQueue();
|
||||
buckets = new WeakBucket[initialCapacity];
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new WeakIdentityHashMap with the same mappings as the given map.
|
||||
* The WeakIdentityHashMap has a default load factor of 0.75.
|
||||
*
|
||||
* @param m the map to copy
|
||||
* @throws NullPointerException if m is null
|
||||
* @since 1.3
|
||||
*/
|
||||
public WeakIdentityHashMap(Map m)
|
||||
{
|
||||
this(m.size(), DEFAULT_LOAD_FACTOR);
|
||||
putAll(m);
|
||||
}
|
||||
|
||||
/**
|
||||
* Simply hashes a non-null Object to its array index.
|
||||
* @param key the key to hash
|
||||
* @return its slot number
|
||||
*/
|
||||
private int hash(Object key)
|
||||
{
|
||||
return Math.abs(System.identityHashCode(key) % buckets.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans the reference queue. This will poll all references (which
|
||||
* are WeakBuckets) from the queue and remove them from this map.
|
||||
* This will not change modCount, even if it modifies the map. The
|
||||
* iterators have to make sure that nothing bad happens. <br>
|
||||
*
|
||||
* Currently the iterator maintains a strong reference to the key, so
|
||||
* that is no problem.
|
||||
*/
|
||||
// Package visible for use by nested classes.
|
||||
void cleanQueue()
|
||||
{
|
||||
Object bucket = queue.poll();
|
||||
while (bucket != null)
|
||||
{
|
||||
internalRemove((WeakBucket) bucket);
|
||||
bucket = queue.poll();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rehashes this hashtable. This will be called by the
|
||||
* <code>add()</code> method if the size grows beyond the threshold.
|
||||
* It will grow the bucket size at least by factor two and allocates
|
||||
* new buckets.
|
||||
*/
|
||||
private void rehash()
|
||||
{
|
||||
WeakBucket[] oldBuckets = buckets;
|
||||
int newsize = buckets.length * 2 + 1; // XXX should be prime.
|
||||
threshold = (int) (newsize * loadFactor);
|
||||
buckets = new WeakBucket[newsize];
|
||||
|
||||
// Now we have to insert the buckets again.
|
||||
for (int i = 0; i < oldBuckets.length; i++)
|
||||
{
|
||||
WeakBucket bucket = oldBuckets[i];
|
||||
WeakBucket nextBucket;
|
||||
while (bucket != null)
|
||||
{
|
||||
nextBucket = bucket.next;
|
||||
|
||||
Object key = bucket.get();
|
||||
if (key == null)
|
||||
{
|
||||
// This bucket should be removed; it is probably
|
||||
// already on the reference queue. We don't insert it
|
||||
// at all, and mark it as cleared.
|
||||
bucket.slot = -1;
|
||||
size--;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add this bucket to its new slot.
|
||||
int slot = hash(key);
|
||||
bucket.slot = slot;
|
||||
bucket.next = buckets[slot];
|
||||
buckets[slot] = bucket;
|
||||
}
|
||||
bucket = nextBucket;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the entry corresponding to key. Since it returns an Entry
|
||||
* it will also prevent the key from being removed under us.
|
||||
* @param key the key, may be null
|
||||
* @return The WeakBucket.WeakEntry or null, if the key wasn't found.
|
||||
*/
|
||||
private WeakBucket.WeakEntry internalGet(Object key)
|
||||
{
|
||||
if (key == null)
|
||||
key = NULL_KEY;
|
||||
int slot = hash(key);
|
||||
WeakBucket bucket = buckets[slot];
|
||||
while (bucket != null)
|
||||
{
|
||||
WeakBucket.WeakEntry entry = bucket.getEntry();
|
||||
if (entry != null && key == entry.key)
|
||||
return entry;
|
||||
|
||||
bucket = bucket.next;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new key/value pair to the hash map.
|
||||
* @param key the key. This mustn't exists in the map. It may be null.
|
||||
* @param value the value.
|
||||
*/
|
||||
private void internalAdd(Object key, Object value)
|
||||
{
|
||||
if (key == null)
|
||||
key = NULL_KEY;
|
||||
int slot = hash(key);
|
||||
WeakBucket bucket = new WeakBucket(key, queue, value, slot);
|
||||
bucket.next = buckets[slot];
|
||||
buckets[slot] = bucket;
|
||||
size++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a bucket from this hash map, if it wasn't removed before
|
||||
* (e.g. one time through rehashing and one time through reference queue).
|
||||
* Package visible for use in nested classes.
|
||||
*
|
||||
* @param bucket the bucket to remove.
|
||||
*/
|
||||
void internalRemove(WeakBucket bucket)
|
||||
{
|
||||
int slot = bucket.slot;
|
||||
if (slot == -1)
|
||||
// This bucket was already removed.
|
||||
return;
|
||||
|
||||
// Mark the bucket as removed. This is necessary, since the
|
||||
// bucket may be enqueued later by the garbage collection, and
|
||||
// internalRemove will be called a second time.
|
||||
bucket.slot = -1;
|
||||
|
||||
WeakBucket prev = null;
|
||||
WeakBucket next = buckets[slot];
|
||||
while (next != bucket)
|
||||
{
|
||||
if (next == null)
|
||||
throw new InternalError("WeakIdentityHashMap in inconsistent state");
|
||||
prev = next;
|
||||
next = prev.next;
|
||||
}
|
||||
if (prev == null)
|
||||
buckets[slot] = bucket.next;
|
||||
else
|
||||
prev.next = bucket.next;
|
||||
|
||||
size--;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of this hash map. Note that the size() may shrink
|
||||
* spontaneously, if the some of the keys were only weakly reachable.
|
||||
* @return the number of entries in this hash map.
|
||||
*/
|
||||
public int size()
|
||||
{
|
||||
cleanQueue();
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells if the map is empty. Note that the result may change
|
||||
* spontanously, if all of the keys were only weakly reachable.
|
||||
* @return true, iff the map is empty.
|
||||
*/
|
||||
public boolean isEmpty()
|
||||
{
|
||||
cleanQueue();
|
||||
return size == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells if the map contains the given key. Note that the result
|
||||
* may change spontanously, if the key was only weakly
|
||||
* reachable.
|
||||
* @param key the key to look for
|
||||
* @return true, iff the map contains an entry for the given key.
|
||||
*/
|
||||
public boolean containsKey(Object key)
|
||||
{
|
||||
cleanQueue();
|
||||
return internalGet(key) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the value the key is mapped to.
|
||||
* @return the value the key was mapped to. It returns null if
|
||||
* the key wasn't in this map, or if the mapped value was
|
||||
* explicitly set to null.
|
||||
*/
|
||||
public Object get(Object key)
|
||||
{
|
||||
cleanQueue();
|
||||
WeakBucket.WeakEntry entry = internalGet(key);
|
||||
return entry == null ? null : entry.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new key/value mapping to this map.
|
||||
* @param key the key, may be null
|
||||
* @param value the value, may be null
|
||||
* @return the value the key was mapped to previously. It returns
|
||||
* null if the key wasn't in this map, or if the mapped value
|
||||
* was explicitly set to null.
|
||||
*/
|
||||
public Object put(Object key, Object value)
|
||||
{
|
||||
cleanQueue();
|
||||
WeakBucket.WeakEntry entry = internalGet(key);
|
||||
if (entry != null)
|
||||
return entry.setValue(value);
|
||||
|
||||
modCount++;
|
||||
if (size >= threshold)
|
||||
rehash();
|
||||
|
||||
internalAdd(key, value);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the key and the corresponding value from this map.
|
||||
* @param key the key. This may be null.
|
||||
* @return the value the key was mapped to previously. It returns
|
||||
* null if the key wasn't in this map, or if the mapped value was
|
||||
* explicitly set to null.
|
||||
*/
|
||||
public Object remove(Object key)
|
||||
{
|
||||
cleanQueue();
|
||||
WeakBucket.WeakEntry entry = internalGet(key);
|
||||
if (entry == null)
|
||||
return null;
|
||||
|
||||
modCount++;
|
||||
internalRemove(entry.getBucket());
|
||||
return entry.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set representation of the entries in this map. This
|
||||
* set will not have strong references to the keys, so they can be
|
||||
* silently removed. The returned set has therefore the same
|
||||
* strange behaviour (shrinking size(), disappearing entries) as
|
||||
* this weak hash map.
|
||||
* @return a set representation of the entries.
|
||||
*/
|
||||
public Set entrySet()
|
||||
{
|
||||
cleanQueue();
|
||||
return theEntrySet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all entries from this map.
|
||||
*/
|
||||
public void clear()
|
||||
{
|
||||
super.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the map contains at least one key which points to
|
||||
* the specified object as a value. Note that the result
|
||||
* may change spontanously, if its key was only weakly reachable.
|
||||
* @param value the value to search for
|
||||
* @return true if it is found in the set.
|
||||
*/
|
||||
public boolean containsValue(Object value)
|
||||
{
|
||||
cleanQueue();
|
||||
return super.containsValue(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set representation of the keys in this map. This
|
||||
* set will not have strong references to the keys, so they can be
|
||||
* silently removed. The returned set has therefore the same
|
||||
* strange behaviour (shrinking size(), disappearing entries) as
|
||||
* this weak hash map.
|
||||
* @return a set representation of the keys.
|
||||
*/
|
||||
public Set keySet()
|
||||
{
|
||||
cleanQueue();
|
||||
return super.keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts all of the mappings from the given map into this one. If the
|
||||
* key already exists in this map, its value is replaced.
|
||||
* @param m the map to copy in
|
||||
*/
|
||||
public void putAll(Map m)
|
||||
{
|
||||
super.putAll(m);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a collection representation of the values in this map. This
|
||||
* collection will not have strong references to the keys, so mappings
|
||||
* can be silently removed. The returned collection has therefore the same
|
||||
* strange behaviour (shrinking size(), disappearing entries) as
|
||||
* this weak hash map.
|
||||
* @return a collection representation of the values.
|
||||
*/
|
||||
public Collection values()
|
||||
{
|
||||
cleanQueue();
|
||||
return super.values();
|
||||
}
|
||||
} // class WeakIdentityHashMap
|
|
@ -374,6 +374,9 @@ public class RE extends REToken {
|
|||
//
|
||||
// OPEN QUESTION:
|
||||
// what is proper interpretation of '{' at start of string?
|
||||
//
|
||||
// This method used to check "repeat.empty.token" to avoid such regexp
|
||||
// as "(a*){2,}", but now "repeat.empty.token" is allowed.
|
||||
|
||||
else if ((unit.ch == '{') && syntax.get(RESyntax.RE_INTERVALS) && (syntax.get(RESyntax.RE_NO_BK_BRACES) ^ (unit.bk || quot))) {
|
||||
int newIndex = getMinMax(pattern,index,minMax,syntax);
|
||||
|
@ -386,8 +389,6 @@ public class RE extends REToken {
|
|||
throw new REException(getLocalizedMessage("repeat.chained"),REException.REG_BADRPT,newIndex);
|
||||
if (currentToken instanceof RETokenWordBoundary || currentToken instanceof RETokenWordBoundary)
|
||||
throw new REException(getLocalizedMessage("repeat.assertion"),REException.REG_BADRPT,newIndex);
|
||||
if ((currentToken.getMinimumLength() == 0) && (minMax.second == Integer.MAX_VALUE))
|
||||
throw new REException(getLocalizedMessage("repeat.empty.token"),REException.REG_BADRPT,newIndex);
|
||||
index = newIndex;
|
||||
currentToken = setRepeated(currentToken,minMax.first,minMax.second,index);
|
||||
}
|
||||
|
@ -550,13 +551,50 @@ public class RE extends REToken {
|
|||
int nested = 0;
|
||||
|
||||
while ( ((nextIndex = getCharUnit(pattern,endIndex,unit,false)) > 0)
|
||||
&& !(nested == 0 && (unit.ch == ')') && (syntax.get(RESyntax.RE_NO_BK_PARENS) ^ (unit.bk || quot))) )
|
||||
&& !(nested == 0 && (unit.ch == ')') && (syntax.get(RESyntax.RE_NO_BK_PARENS) ^ (unit.bk || quot))) ) {
|
||||
if ((endIndex = nextIndex) >= pLength)
|
||||
throw new REException(getLocalizedMessage("subexpr.no.end"),REException.REG_ESUBREG,nextIndex);
|
||||
else if ((unit.ch == '[') && !(unit.bk || quot)) {
|
||||
// I hate to do something similar to the LIST OPERATOR matters
|
||||
// above, but ...
|
||||
int listIndex = nextIndex;
|
||||
if (listIndex < pLength && pattern[listIndex] == '^') listIndex++;
|
||||
if (listIndex < pLength && pattern[listIndex] == ']') listIndex++;
|
||||
int listEndIndex = -1;
|
||||
int listNest = 0;
|
||||
while (listIndex < pLength && listEndIndex < 0) {
|
||||
switch(pattern[listIndex++]) {
|
||||
case '\\':
|
||||
listIndex++;
|
||||
break;
|
||||
case '[':
|
||||
// Sun's API document says that regexp like "[a-d[m-p]]"
|
||||
// is legal. Even something like "[[[^]]]]" is accepted.
|
||||
listNest++;
|
||||
if (listIndex < pLength && pattern[listIndex] == '^') listIndex++;
|
||||
if (listIndex < pLength && pattern[listIndex] == ']') listIndex++;
|
||||
break;
|
||||
case ']':
|
||||
if (listNest == 0)
|
||||
listEndIndex = listIndex;
|
||||
listNest--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (listEndIndex >= 0) {
|
||||
nextIndex = listEndIndex;
|
||||
if ((endIndex = nextIndex) >= pLength)
|
||||
throw new REException(getLocalizedMessage("subexpr.no.end"),REException.REG_ESUBREG,nextIndex);
|
||||
else
|
||||
continue;
|
||||
}
|
||||
throw new REException(getLocalizedMessage("subexpr.no.end"),REException.REG_ESUBREG,nextIndex);
|
||||
}
|
||||
else if (unit.ch == '(' && (syntax.get(RESyntax.RE_NO_BK_PARENS) ^ (unit.bk || quot)))
|
||||
nested++;
|
||||
else if (unit.ch == ')' && (syntax.get(RESyntax.RE_NO_BK_PARENS) ^ (unit.bk || quot)))
|
||||
nested--;
|
||||
}
|
||||
|
||||
// endIndex is now position at a ')','\)'
|
||||
// nextIndex is end of string or position after ')' or '\)'
|
||||
|
@ -616,6 +654,9 @@ public class RE extends REToken {
|
|||
|
||||
// ZERO-OR-MORE REPEAT OPERATOR
|
||||
// *
|
||||
//
|
||||
// This method used to check "repeat.empty.token" to avoid such regexp
|
||||
// as "(a*)*", but now "repeat.empty.token" is allowed.
|
||||
|
||||
else if ((unit.ch == '*') && !(unit.bk || quot)) {
|
||||
if (currentToken == null)
|
||||
|
@ -624,14 +665,15 @@ public class RE extends REToken {
|
|||
throw new REException(getLocalizedMessage("repeat.chained"),REException.REG_BADRPT,index);
|
||||
if (currentToken instanceof RETokenWordBoundary || currentToken instanceof RETokenWordBoundary)
|
||||
throw new REException(getLocalizedMessage("repeat.assertion"),REException.REG_BADRPT,index);
|
||||
if (currentToken.getMinimumLength() == 0)
|
||||
throw new REException(getLocalizedMessage("repeat.empty.token"),REException.REG_BADRPT,index);
|
||||
currentToken = setRepeated(currentToken,0,Integer.MAX_VALUE,index);
|
||||
}
|
||||
|
||||
// ONE-OR-MORE REPEAT OPERATOR / POSSESSIVE MATCHING OPERATOR
|
||||
// + | \+ depending on RE_BK_PLUS_QM
|
||||
// not available if RE_LIMITED_OPS is set
|
||||
//
|
||||
// This method used to check "repeat.empty.token" to avoid such regexp
|
||||
// as "(a*)+", but now "repeat.empty.token" is allowed.
|
||||
|
||||
else if ((unit.ch == '+') && !syntax.get(RESyntax.RE_LIMITED_OPS) && (!syntax.get(RESyntax.RE_BK_PLUS_QM) ^ (unit.bk || quot))) {
|
||||
if (currentToken == null)
|
||||
|
@ -648,8 +690,6 @@ public class RE extends REToken {
|
|||
}
|
||||
else if (currentToken instanceof RETokenWordBoundary || currentToken instanceof RETokenWordBoundary)
|
||||
throw new REException(getLocalizedMessage("repeat.assertion"),REException.REG_BADRPT,index);
|
||||
else if (currentToken.getMinimumLength() == 0)
|
||||
throw new REException(getLocalizedMessage("repeat.empty.token"),REException.REG_BADRPT,index);
|
||||
else
|
||||
currentToken = setRepeated(currentToken,1,Integer.MAX_VALUE,index);
|
||||
}
|
||||
|
|
|
@ -108,6 +108,7 @@ final class RETokenRepeated extends REToken {
|
|||
REMatch doables;
|
||||
REMatch doablesLast;
|
||||
REMatch recurrent;
|
||||
int lastIndex = mymatch.index;
|
||||
|
||||
do {
|
||||
// Check for stingy match for each possibility.
|
||||
|
@ -151,6 +152,15 @@ final class RETokenRepeated extends REToken {
|
|||
++numRepeats;
|
||||
|
||||
positions.addElement(newMatch);
|
||||
|
||||
// doables.index == lastIndex means an empty string
|
||||
// was the longest that matched this token.
|
||||
// We break here, otherwise we will fall into an endless loop.
|
||||
if (doables.index == lastIndex) {
|
||||
if (numRepeats < min) numRepeats = min;
|
||||
break;
|
||||
}
|
||||
lastIndex = doables.index;
|
||||
} while (numRepeats < max);
|
||||
|
||||
// If there aren't enough repeats, then fail
|
||||
|
@ -165,7 +175,16 @@ final class RETokenRepeated extends REToken {
|
|||
REMatch allResultsLast = null;
|
||||
|
||||
REMatch results = null;
|
||||
while (--posIndex >= min) {
|
||||
int indexCount = posIndex - min;
|
||||
if (indexCount <= 0) {
|
||||
// This case occurs when we exited the previous do loop before
|
||||
// numRepeats >= min because an empty string matched the token.
|
||||
// In this case, an empty string can match as many times as
|
||||
// desired.
|
||||
indexCount = 1;
|
||||
}
|
||||
while (indexCount-- > 0) {
|
||||
--posIndex;
|
||||
newMatch = (REMatch) positions.elementAt(posIndex);
|
||||
results = matchRest(input, newMatch);
|
||||
if (results != null) {
|
||||
|
|
|
@ -655,21 +655,6 @@ final public class SAXDriver
|
|||
attributesList.clear();
|
||||
}
|
||||
|
||||
void xmlDecl(String version,
|
||||
String encoding,
|
||||
boolean standalone,
|
||||
String inputEncoding)
|
||||
throws SAXException
|
||||
{
|
||||
if (contentHandler instanceof ContentHandler2)
|
||||
{
|
||||
((ContentHandler2) contentHandler).xmlDecl(version,
|
||||
encoding,
|
||||
standalone,
|
||||
inputEncoding);
|
||||
}
|
||||
}
|
||||
|
||||
void skippedEntity(String name)
|
||||
throws SAXException
|
||||
{
|
||||
|
|
|
@ -841,9 +841,6 @@ final class XmlParser
|
|||
{
|
||||
inputEncoding = encodingName;
|
||||
}
|
||||
handler.xmlDecl(version, encodingName, docIsStandalone,
|
||||
inputEncoding);
|
||||
|
||||
return encodingName;
|
||||
}
|
||||
|
||||
|
|
|
@ -301,22 +301,6 @@ public class Consumer extends DomConsumer
|
|||
doc.setBuilding(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Required by DOM Level 3 to report document parameters
|
||||
*/
|
||||
public void xmlDecl(String version,
|
||||
String encoding,
|
||||
boolean standalone,
|
||||
String inputEncoding)
|
||||
throws SAXException
|
||||
{
|
||||
super.xmlDecl(version, encoding, standalone, inputEncoding);
|
||||
|
||||
DomDocument doc = (DomDocument) getDocument();
|
||||
doc.setXmlEncoding(encoding);
|
||||
doc.setInputEncoding(inputEncoding);
|
||||
}
|
||||
|
||||
public void endDocument ()
|
||||
throws SAXException
|
||||
{
|
||||
|
|
|
@ -1313,6 +1313,31 @@ public class DomDocument
|
|||
return config;
|
||||
}
|
||||
|
||||
public boolean isEqualNode(Node arg)
|
||||
{
|
||||
if (!super.isEqualNode(arg))
|
||||
return false;
|
||||
Document d = (Document) arg;
|
||||
String dversion = d.getXmlVersion();
|
||||
if (dversion == null || !dversion.equals(version))
|
||||
return false;
|
||||
boolean dstandalone = d.getXmlStandalone();
|
||||
if (dstandalone != standalone)
|
||||
return false;
|
||||
String dencoding = d.getXmlEncoding();
|
||||
if (dencoding == null || dencoding.equalsIgnoreCase("UTF-8"))
|
||||
{
|
||||
if (encoding != null && !encoding.equalsIgnoreCase("UTF-8"))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!dencoding.equals(encoding))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void normalizeDocument()
|
||||
{
|
||||
boolean save = building;
|
||||
|
|
|
@ -519,5 +519,38 @@ public class DomElement
|
|||
Attr attr = (Attr) attrs.getNamedItemNS(namespaceURI, localName);
|
||||
setIdAttributeNode(attr, isId);
|
||||
}
|
||||
|
||||
public boolean isEqualNode(Node arg)
|
||||
{
|
||||
if (!super.isEqualNode(arg))
|
||||
return false;
|
||||
getAttributes();
|
||||
NamedNodeMap argAttrs = arg.getAttributes();
|
||||
int len = argAttrs.getLength();
|
||||
if (argAttrs == null || (len != attributes.length))
|
||||
return false;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
Node argCtx = argAttrs.item(i);
|
||||
// Don't compare namespace nodes
|
||||
if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI
|
||||
.equals(argCtx.getNamespaceURI()))
|
||||
continue;
|
||||
// Find corresponding attribute node
|
||||
DomNode ctx = attributes.first;
|
||||
for (; ctx != null; ctx = ctx.next)
|
||||
{
|
||||
if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI
|
||||
.equals(ctx.getNamespaceURI()))
|
||||
continue;
|
||||
if (!ctx.isEqualNode(argCtx))
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
if (ctx == null)
|
||||
return false; // not found
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -319,7 +319,7 @@ public class DomNamedNodeMap
|
|||
if (ns)
|
||||
{
|
||||
String tln = ctx.getLocalName();
|
||||
if (tln.equals(name))
|
||||
if (name != null && name.equals(tln))
|
||||
{
|
||||
String tu = ctx.getNamespaceURI();
|
||||
if ((tu == null && uri == null) ||
|
||||
|
|
|
@ -38,6 +38,7 @@ exception statement from your version. */
|
|||
package gnu.xml.dom;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -149,7 +150,7 @@ public abstract class DomNode
|
|||
boolean readonly;
|
||||
|
||||
// event registrations
|
||||
private ListenerRecord[] listeners;
|
||||
private HashSet listeners;
|
||||
private int nListeners;
|
||||
|
||||
// DOM Level 3 userData dictionary.
|
||||
|
@ -167,19 +168,6 @@ public abstract class DomNode
|
|||
*/
|
||||
public void compact()
|
||||
{
|
||||
if (listeners != null && listeners.length != nListeners)
|
||||
{
|
||||
if (nListeners == 0)
|
||||
{
|
||||
listeners = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
ListenerRecord[] l = new ListenerRecord[nListeners];
|
||||
System.arraycopy(listeners, 0, l, 0, nListeners);
|
||||
listeners = l;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -201,6 +189,7 @@ public abstract class DomNode
|
|||
}
|
||||
}
|
||||
this.owner = owner;
|
||||
this.listeners = new HashSet();
|
||||
}
|
||||
|
||||
|
||||
|
@ -372,6 +361,16 @@ public abstract class DomNode
|
|||
return;
|
||||
}
|
||||
break;
|
||||
case DOCUMENT_TYPE_NODE:
|
||||
if (!owner.building)
|
||||
break;
|
||||
switch (childNodeType)
|
||||
{
|
||||
case COMMENT_NODE:
|
||||
case PROCESSING_INSTRUCTION_NODE:
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (owner.checkingWellformedness)
|
||||
{
|
||||
|
@ -960,12 +959,6 @@ public abstract class DomNode
|
|||
*/
|
||||
public void trimToSize()
|
||||
{
|
||||
if (listeners != null && listeners.length != nListeners)
|
||||
{
|
||||
ListenerRecord[] newKids = new ListenerRecord[length];
|
||||
System.arraycopy(listeners, 0, newKids, 0, nListeners);
|
||||
listeners = newKids;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1175,7 +1168,7 @@ public abstract class DomNode
|
|||
node.next = null;
|
||||
|
||||
node.readonly = false;
|
||||
node.listeners = null;
|
||||
node.listeners = new HashSet();
|
||||
node.nListeners = 0;
|
||||
return node;
|
||||
|
||||
|
@ -1264,16 +1257,17 @@ public abstract class DomNode
|
|||
elementName = name;
|
||||
matchAnyURI = "*".equals(uri);
|
||||
matchAnyName = "*".equals(name);
|
||||
|
||||
|
||||
DomNode.this.addEventListener("DOMNodeInserted", this, true);
|
||||
DomNode.this.addEventListener("DOMNodeRemoved", this, true);
|
||||
}
|
||||
|
||||
void detach()
|
||||
{
|
||||
current.detach();
|
||||
if (current != null)
|
||||
current.detach();
|
||||
current = null;
|
||||
|
||||
|
||||
DomNode.this.removeEventListener("DOMNodeInserted", this, true);
|
||||
DomNode.this.removeEventListener("DOMNodeRemoved", this, true);
|
||||
}
|
||||
|
@ -1336,6 +1330,8 @@ public abstract class DomNode
|
|||
return;
|
||||
}
|
||||
|
||||
if (current != null)
|
||||
current.detach();
|
||||
current = null;
|
||||
}
|
||||
|
||||
|
@ -1354,6 +1350,7 @@ public abstract class DomNode
|
|||
lastIndex--;
|
||||
}
|
||||
Node ret = current.previousNode ();
|
||||
current.detach();
|
||||
current = null;
|
||||
return ret;
|
||||
}
|
||||
|
@ -1361,9 +1358,11 @@ public abstract class DomNode
|
|||
// somewhere after last node
|
||||
while (++lastIndex != index)
|
||||
current.nextNode ();
|
||||
Node ret = current.nextNode ();
|
||||
current = null;
|
||||
return ret;
|
||||
|
||||
Node ret = current.nextNode ();
|
||||
current.detach();
|
||||
current = null;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int getLength()
|
||||
|
@ -1375,7 +1374,7 @@ public abstract class DomNode
|
|||
{
|
||||
retval++;
|
||||
}
|
||||
current = null;
|
||||
iter.detach();
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -1403,13 +1402,18 @@ public abstract class DomNode
|
|||
this.useCapture = useCapture;
|
||||
}
|
||||
|
||||
boolean equals(ListenerRecord rec)
|
||||
public boolean equals(Object o)
|
||||
{
|
||||
ListenerRecord rec = (ListenerRecord)o;
|
||||
return listener == rec.listener
|
||||
&& useCapture == rec.useCapture
|
||||
&& type == rec.type;
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return listener.hashCode() ^ type.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1464,30 +1468,12 @@ public abstract class DomNode
|
|||
EventListener listener,
|
||||
boolean useCapture)
|
||||
{
|
||||
if (listeners == null)
|
||||
{
|
||||
listeners = new ListenerRecord[1];
|
||||
}
|
||||
else if (nListeners == listeners.length)
|
||||
{
|
||||
ListenerRecord[] newListeners =
|
||||
new ListenerRecord[listeners.length + NKIDS_DELTA];
|
||||
System.arraycopy(listeners, 0, newListeners, 0, nListeners);
|
||||
listeners = newListeners;
|
||||
}
|
||||
|
||||
// prune duplicates
|
||||
ListenerRecord record;
|
||||
|
||||
record = new ListenerRecord(type, listener, useCapture);
|
||||
for (int i = 0; i < nListeners; i++)
|
||||
{
|
||||
if (record.equals(listeners[i]))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
listeners [nListeners++] = record;
|
||||
listeners.add(record);
|
||||
nListeners = listeners.size();
|
||||
}
|
||||
|
||||
// XXX this exception should be discarded from DOM
|
||||
|
@ -1672,11 +1658,14 @@ public abstract class DomNode
|
|||
ListenerRecord[] notificationSet)
|
||||
{
|
||||
int count = 0;
|
||||
Iterator iter;
|
||||
|
||||
iter = current.listeners.iterator();
|
||||
|
||||
// do any of this set of listeners get notified?
|
||||
for (int i = 0; i < current.nListeners; i++)
|
||||
while (iter.hasNext())
|
||||
{
|
||||
ListenerRecord rec = current.listeners[i];
|
||||
ListenerRecord rec = (ListenerRecord)iter.next();
|
||||
|
||||
if (rec.useCapture != capture)
|
||||
{
|
||||
|
@ -1697,6 +1686,7 @@ public abstract class DomNode
|
|||
}
|
||||
notificationSet[count++] = rec;
|
||||
}
|
||||
iter = null;
|
||||
|
||||
// Notify just those listeners
|
||||
e.currentNode = current;
|
||||
|
@ -1704,18 +1694,21 @@ public abstract class DomNode
|
|||
{
|
||||
try
|
||||
{
|
||||
iter = current.listeners.iterator();
|
||||
// Late in the DOM CR process (3rd or 4th CR?) the
|
||||
// removeEventListener spec became asymmetric with respect
|
||||
// to addEventListener ... effect is now immediate.
|
||||
for (int j = 0; j < current.nListeners; j++)
|
||||
while (iter.hasNext())
|
||||
{
|
||||
if (current.listeners[j].equals(notificationSet[i]))
|
||||
ListenerRecord rec = (ListenerRecord)iter.next();
|
||||
|
||||
if (rec.equals(notificationSet[i]))
|
||||
{
|
||||
notificationSet[i].listener.handleEvent(e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
iter = null;
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
|
@ -1733,36 +1726,8 @@ public abstract class DomNode
|
|||
EventListener listener,
|
||||
boolean useCapture)
|
||||
{
|
||||
for (int i = 0; i < nListeners; i++)
|
||||
{
|
||||
if (listeners[i].listener != listener)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (listeners[i].useCapture != useCapture)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!listeners[i].type.equals(type))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (nListeners == 1)
|
||||
{
|
||||
listeners = null;
|
||||
nListeners = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int j = i + 1; j < nListeners; j++)
|
||||
{
|
||||
listeners[i++] = listeners[j++];
|
||||
}
|
||||
listeners[--nListeners] = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
listeners.remove(new ListenerRecord(type, listener, useCapture));
|
||||
nListeners = listeners.size();
|
||||
// no exceptions reported
|
||||
}
|
||||
|
||||
|
@ -1779,10 +1744,15 @@ public abstract class DomNode
|
|||
readonly = false;
|
||||
for (DomNode ctx = first; ctx != null; ctx = ctx.next)
|
||||
{
|
||||
boolean saved2 = ctx.readonly;
|
||||
ctx.readonly = false;
|
||||
switch (ctx.nodeType)
|
||||
{
|
||||
case TEXT_NODE:
|
||||
while (ctx.next != null && ctx.next.nodeType == TEXT_NODE)
|
||||
case CDATA_SECTION_NODE:
|
||||
while (ctx.next != null &&
|
||||
(ctx.next.nodeType == TEXT_NODE ||
|
||||
ctx.next.nodeType == CDATA_SECTION_NODE))
|
||||
{
|
||||
Text text = (Text) ctx;
|
||||
text.appendData(ctx.next.getNodeValue());
|
||||
|
@ -1794,7 +1764,11 @@ public abstract class DomNode
|
|||
int len = attrs.getLength();
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
attrs.item(i).normalize();
|
||||
DomNode attr = (DomNode) attrs.item(i);
|
||||
boolean saved3 = attr.readonly;
|
||||
attr.readonly = false;
|
||||
attr.normalize();
|
||||
attr.readonly = saved3;
|
||||
}
|
||||
// Fall through
|
||||
case DOCUMENT_NODE:
|
||||
|
@ -1804,6 +1778,7 @@ public abstract class DomNode
|
|||
ctx.normalize();
|
||||
break;
|
||||
}
|
||||
ctx.readonly = saved2;
|
||||
}
|
||||
readonly = saved;
|
||||
}
|
||||
|
@ -2017,39 +1992,56 @@ public abstract class DomNode
|
|||
public boolean isEqualNode(Node arg)
|
||||
{
|
||||
if (this == arg)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
if (arg == null)
|
||||
return false;
|
||||
if (nodeType != arg.getNodeType())
|
||||
return false;
|
||||
switch (nodeType)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (nodeType != arg.getNodeType() ||
|
||||
!equal(getNodeName(), arg.getNodeName()) ||
|
||||
!equal(getLocalName(), arg.getLocalName()) ||
|
||||
!equal(getNamespaceURI(), arg.getNamespaceURI()) ||
|
||||
!equal(getPrefix(), arg.getPrefix()) ||
|
||||
!equal(getNodeValue(), arg.getNodeValue()))
|
||||
{
|
||||
return false;
|
||||
case ELEMENT_NODE:
|
||||
case ATTRIBUTE_NODE:
|
||||
if (!equal(getLocalName(), arg.getLocalName()) ||
|
||||
!equal(getNamespaceURI(), arg.getNamespaceURI()))
|
||||
return false;
|
||||
break;
|
||||
case PROCESSING_INSTRUCTION_NODE:
|
||||
if (!equal(getNodeName(), arg.getNodeName()) ||
|
||||
!equal(getNodeValue(), arg.getNodeValue()))
|
||||
return false;
|
||||
break;
|
||||
case COMMENT_NODE:
|
||||
case TEXT_NODE:
|
||||
case CDATA_SECTION_NODE:
|
||||
if (!equal(getNodeValue(), arg.getNodeValue()))
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
// Children
|
||||
Node argCtx = arg.getFirstChild();
|
||||
getFirstChild(); // because of DomAttr lazy children
|
||||
for (DomNode ctx = first; ctx != null; ctx = ctx.next)
|
||||
DomNode ctx = first;
|
||||
for (; ctx != null && argCtx != null; ctx = ctx.next)
|
||||
{
|
||||
if (!ctx.isEqualNode(argCtx))
|
||||
if (nodeType == DOCUMENT_NODE)
|
||||
{
|
||||
return false;
|
||||
// Ignore whitespace outside document element
|
||||
while (ctx != null && ctx.nodeType == TEXT_NODE)
|
||||
ctx = ctx.next;
|
||||
while (argCtx != null && ctx.getNodeType() == TEXT_NODE)
|
||||
argCtx = argCtx.getNextSibling();
|
||||
if (ctx == null && argCtx != null)
|
||||
return false;
|
||||
else if (argCtx == null && ctx != null)
|
||||
return false;
|
||||
}
|
||||
if (!ctx.isEqualNode(argCtx))
|
||||
return false;
|
||||
argCtx = argCtx.getNextSibling();
|
||||
}
|
||||
if (argCtx != null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (ctx != null || argCtx != null)
|
||||
return false;
|
||||
|
||||
// TODO Attr NamedNodeMap
|
||||
// TODO DocumentType
|
||||
return true;
|
||||
}
|
||||
|
@ -2185,5 +2177,14 @@ public abstract class DomNode
|
|||
}
|
||||
}
|
||||
|
||||
public void list(java.io.PrintStream out, int indent)
|
||||
{
|
||||
for (int i = 0; i < indent; i++)
|
||||
out.print(" ");
|
||||
out.println(toString());
|
||||
for (DomNode ctx = first; ctx != null; ctx = ctx.next)
|
||||
ctx.list(out, indent + 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -260,6 +260,7 @@ public class DomLSParser
|
|||
eventSink.coalescing = coalescing;
|
||||
// get and configure reader
|
||||
XMLReader reader = getXMLReader();
|
||||
eventSink.reader = reader;
|
||||
try
|
||||
{
|
||||
reader.setContentHandler(eventSink);
|
||||
|
|
|
@ -37,6 +37,7 @@ exception statement from your version. */
|
|||
|
||||
package gnu.xml.dom.ls;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
@ -45,20 +46,26 @@ import org.w3c.dom.Attr;
|
|||
import org.w3c.dom.DocumentType;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Entity;
|
||||
import org.w3c.dom.EntityReference;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.Text;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.DTDHandler;
|
||||
import org.xml.sax.Locator;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXNotRecognizedException;
|
||||
import org.xml.sax.SAXNotSupportedException;
|
||||
import org.xml.sax.XMLReader;
|
||||
import org.xml.sax.ext.Attributes2;
|
||||
import org.xml.sax.ext.DeclHandler;
|
||||
import org.xml.sax.ext.LexicalHandler;
|
||||
import gnu.xml.aelfred2.ContentHandler2;
|
||||
import org.xml.sax.ext.Locator2;
|
||||
import gnu.xml.dom.DomAttr;
|
||||
import gnu.xml.dom.DomDocument;
|
||||
import gnu.xml.dom.DomDoctype;
|
||||
import gnu.xml.dom.DomNode;
|
||||
|
||||
/**
|
||||
* A SAX content and lexical handler used to construct a DOM document.
|
||||
|
@ -66,17 +73,28 @@ import gnu.xml.dom.DomDoctype;
|
|||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class SAXEventSink
|
||||
implements ContentHandler2, LexicalHandler, DTDHandler, DeclHandler
|
||||
implements ContentHandler, LexicalHandler, DTDHandler, DeclHandler
|
||||
{
|
||||
|
||||
private static final String XMLNS_URI = XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
|
||||
private static final String XMLNS_PREFIX = XMLConstants.XMLNS_ATTRIBUTE;
|
||||
private static final HashSet PREDEFINED_ENTITIES = new HashSet();
|
||||
static
|
||||
{
|
||||
PREDEFINED_ENTITIES.add("amp");
|
||||
PREDEFINED_ENTITIES.add("lt");
|
||||
PREDEFINED_ENTITIES.add("gt");
|
||||
PREDEFINED_ENTITIES.add("quot");
|
||||
PREDEFINED_ENTITIES.add("apos");
|
||||
}
|
||||
|
||||
boolean namespaceAware;
|
||||
boolean ignoreWhitespace;
|
||||
boolean expandEntityReferences;
|
||||
boolean ignoreComments;
|
||||
boolean coalescing;
|
||||
|
||||
XMLReader reader; // reference back to the parser to get features
|
||||
|
||||
DomDocument doc; // document being constructed
|
||||
Node ctx; // current context (parent node)
|
||||
|
@ -110,20 +128,42 @@ class SAXEventSink
|
|||
doc.setStrictErrorChecking(false);
|
||||
doc.setBuilding(true);
|
||||
ctx = doc;
|
||||
}
|
||||
|
||||
public void xmlDecl(String version, String encoding, boolean standalone,
|
||||
String inputEncoding)
|
||||
throws SAXException
|
||||
{
|
||||
if (interrupted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
doc.setXmlVersion(version);
|
||||
doc.setXmlEncoding(encoding);
|
||||
final String FEATURES = "http://xml.org/sax/features/";
|
||||
final String PROPERTIES = "http://xml.org/sax/properties/";
|
||||
final String GNU_PROPERTIES = "http://gnu.org/sax/properties/";
|
||||
|
||||
boolean standalone = reader.getFeature(FEATURES + "is-standalone");
|
||||
doc.setXmlStandalone(standalone);
|
||||
doc.setInputEncoding(inputEncoding);
|
||||
try
|
||||
{
|
||||
String version = (String) reader.getProperty(PROPERTIES +
|
||||
"document-xml-version");
|
||||
doc.setXmlVersion(version);
|
||||
}
|
||||
catch (SAXNotRecognizedException e)
|
||||
{
|
||||
}
|
||||
catch (SAXNotSupportedException e)
|
||||
{
|
||||
}
|
||||
if (locator != null && locator instanceof Locator2)
|
||||
{
|
||||
String encoding = ((Locator2) locator).getEncoding();
|
||||
doc.setInputEncoding(encoding);
|
||||
}
|
||||
try
|
||||
{
|
||||
String encoding = (String) reader.getProperty(GNU_PROPERTIES +
|
||||
"document-xml-encoding");
|
||||
doc.setXmlEncoding(encoding);
|
||||
}
|
||||
catch (SAXNotRecognizedException e)
|
||||
{
|
||||
}
|
||||
catch (SAXNotSupportedException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void endDocument()
|
||||
|
@ -265,7 +305,7 @@ class SAXEventSink
|
|||
public void characters(char[] c, int off, int len)
|
||||
throws SAXException
|
||||
{
|
||||
if (interrupted)
|
||||
if (interrupted || len < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -301,11 +341,8 @@ class SAXEventSink
|
|||
{
|
||||
return;
|
||||
}
|
||||
if (!inDTD)
|
||||
{
|
||||
Node pi = createProcessingInstruction(target, data);
|
||||
ctx.appendChild(pi);
|
||||
}
|
||||
Node pi = createProcessingInstruction(target, data);
|
||||
ctx.appendChild(pi);
|
||||
}
|
||||
|
||||
protected Node createProcessingInstruction(String target, String data)
|
||||
|
@ -354,6 +391,8 @@ class SAXEventSink
|
|||
public void startEntity(String name)
|
||||
throws SAXException
|
||||
{
|
||||
if (interrupted)
|
||||
return;
|
||||
DocumentType doctype = doc.getDoctype();
|
||||
if (doctype == null)
|
||||
{
|
||||
|
@ -361,19 +400,9 @@ class SAXEventSink
|
|||
"reference to entity in undeclared doctype");
|
||||
}
|
||||
if ("[dtd]".equals(name) || name.charAt(0) == '%')
|
||||
{
|
||||
// Ignore DTD and parameter entities
|
||||
ctx = doctype;
|
||||
return;
|
||||
}
|
||||
if ("lt".equals(name) ||
|
||||
"gt".equals(name) ||
|
||||
"amp".equals(name) ||
|
||||
"apos".equals(name) ||
|
||||
"quot".equals(name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
return;
|
||||
if (PREDEFINED_ENTITIES.contains(name))
|
||||
return;
|
||||
// Get entity
|
||||
NamedNodeMap entities = doctype.getEntities();
|
||||
Entity entity = (Entity) entities.getNamedItem(name);
|
||||
|
@ -382,59 +411,47 @@ class SAXEventSink
|
|||
throw new SAXException("SAX parser error: " +
|
||||
"reference to undeclared entity: " + name);
|
||||
}
|
||||
pushEntity(entity);
|
||||
EntityReference ref = doc.createEntityReference(name);
|
||||
// DomDocument populates with the entity replacement text, remove this
|
||||
Node child = ref.getFirstChild();
|
||||
while (child != null)
|
||||
{
|
||||
Node nextChild = child.getNextSibling();
|
||||
ref.removeChild(child);
|
||||
child = nextChild;
|
||||
}
|
||||
ctx.appendChild(ref);
|
||||
ctx = ref;
|
||||
}
|
||||
|
||||
public void endEntity(String name)
|
||||
throws SAXException
|
||||
{
|
||||
if (interrupted)
|
||||
return;
|
||||
if ("[dtd]".equals(name) || name.charAt(0) == '%')
|
||||
{
|
||||
// Ignore DTD and parameter entities
|
||||
return;
|
||||
}
|
||||
if ("lt".equals(name) ||
|
||||
"gt".equals(name) ||
|
||||
"amp".equals(name) ||
|
||||
"apos".equals(name) ||
|
||||
"quot".equals(name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Get entity
|
||||
Entity entity = popEntity();
|
||||
// TODO resolve external entities to ensure that entity has content
|
||||
return;
|
||||
if (PREDEFINED_ENTITIES.contains(name))
|
||||
return;
|
||||
// Get entity reference
|
||||
EntityReference ref = (EntityReference) ctx;
|
||||
if (!ref.getNodeName().equals(name))
|
||||
throw new SAXException("expecting end of "+ref.getNodeName()+" entity");
|
||||
ctx = ctx.getParentNode();
|
||||
if (ref instanceof DomNode)
|
||||
((DomNode) ref).makeReadonly();
|
||||
if (expandEntityReferences)
|
||||
{
|
||||
// Get entity content
|
||||
for (Node child = entity.getFirstChild(); child != null;
|
||||
child = child.getNextSibling())
|
||||
// Move entity content from reference node onto context
|
||||
Node child = ref.getFirstChild();
|
||||
while (child != null)
|
||||
{
|
||||
Node nextChild = child.getNextSibling();
|
||||
ctx.appendChild(child);
|
||||
child = nextChild;
|
||||
}
|
||||
ctx.removeChild(ref);
|
||||
}
|
||||
else
|
||||
{
|
||||
Node entityReference = doc.createEntityReference(name);
|
||||
ctx.appendChild(entityReference);
|
||||
}
|
||||
}
|
||||
|
||||
void pushEntity(Node entity)
|
||||
{
|
||||
if (entityCtx == null)
|
||||
{
|
||||
entityCtx = new LinkedList();
|
||||
}
|
||||
entityCtx.addLast(ctx);
|
||||
ctx = entity;
|
||||
}
|
||||
|
||||
Entity popEntity()
|
||||
{
|
||||
Entity ret = (Entity) ctx;
|
||||
ctx = (Node) entityCtx.removeLast();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void startCDATA()
|
||||
|
@ -456,11 +473,8 @@ class SAXEventSink
|
|||
{
|
||||
return;
|
||||
}
|
||||
if (!inDTD)
|
||||
{
|
||||
Node comment = createComment(c, off, len);
|
||||
ctx.appendChild(comment);
|
||||
}
|
||||
Node comment = createComment(c, off, len);
|
||||
ctx.appendChild(comment);
|
||||
}
|
||||
|
||||
protected Node createComment(char[] c, int off, int len)
|
||||
|
@ -477,6 +491,8 @@ class SAXEventSink
|
|||
{
|
||||
return;
|
||||
}
|
||||
if (!inDTD)
|
||||
throw new SAXException("notation decl outside DTD");
|
||||
DomDoctype doctype = (DomDoctype) ctx;
|
||||
doctype.declareNotation(name, publicId, systemId);
|
||||
}
|
||||
|
@ -489,6 +505,8 @@ class SAXEventSink
|
|||
{
|
||||
return;
|
||||
}
|
||||
if (!inDTD)
|
||||
throw new SAXException("unparsed entity decl outside DTD");
|
||||
DomDoctype doctype = (DomDoctype) ctx;
|
||||
Entity entity = doctype.declareEntity(name, publicId, systemId,
|
||||
notationName);
|
||||
|
@ -503,6 +521,8 @@ class SAXEventSink
|
|||
{
|
||||
return;
|
||||
}
|
||||
if (!inDTD)
|
||||
throw new SAXException("element decl outside DTD");
|
||||
// Ignore fake element declarations generated by ValidationConsumer.
|
||||
// If an element is not really declared in the DTD it will not be
|
||||
// declared in the document model.
|
||||
|
@ -522,6 +542,8 @@ class SAXEventSink
|
|||
{
|
||||
return;
|
||||
}
|
||||
if (!inDTD)
|
||||
throw new SAXException("attribute decl outside DTD");
|
||||
DomDoctype doctype = (DomDoctype) ctx;
|
||||
doctype.attributeDecl(eName, aName, type, mode, value);
|
||||
}
|
||||
|
@ -533,6 +555,8 @@ class SAXEventSink
|
|||
{
|
||||
return;
|
||||
}
|
||||
if (!inDTD)
|
||||
throw new SAXException("internal entity decl outside DTD");
|
||||
DomDoctype doctype = (DomDoctype) ctx;
|
||||
Entity entity = doctype.declareEntity(name, null, null, null);
|
||||
if (entity != null)
|
||||
|
@ -549,6 +573,8 @@ class SAXEventSink
|
|||
{
|
||||
return;
|
||||
}
|
||||
if (!inDTD)
|
||||
throw new SAXException("external entity decl outside DTD");
|
||||
DomDoctype doctype = (DomDoctype) ctx;
|
||||
Entity entity = doctype.declareEntity(name, publicId, systemId, null);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ exception statement from your version. */
|
|||
|
||||
package gnu.xml.pipeline;
|
||||
|
||||
import gnu.xml.aelfred2.ContentHandler2;
|
||||
import gnu.xml.util.DomParser;
|
||||
|
||||
import org.xml.sax.Attributes;
|
||||
|
@ -330,7 +329,7 @@ public class DomConsumer implements EventConsumer
|
|||
* accepted illegal input data). </p>
|
||||
*/
|
||||
public static class Handler
|
||||
implements ContentHandler2, LexicalHandler,
|
||||
implements ContentHandler, LexicalHandler,
|
||||
DTDHandler, DeclHandler
|
||||
{
|
||||
protected DomConsumer consumer;
|
||||
|
@ -430,20 +429,6 @@ public class DomConsumer implements EventConsumer
|
|||
top = document;
|
||||
}
|
||||
|
||||
// ContentHandler2
|
||||
public void xmlDecl(String version,
|
||||
String encoding,
|
||||
boolean standalone,
|
||||
String inputEncoding)
|
||||
throws SAXException
|
||||
{
|
||||
if (document != null)
|
||||
{
|
||||
document.setXmlVersion(version);
|
||||
document.setXmlStandalone(standalone);
|
||||
}
|
||||
}
|
||||
|
||||
// SAX1
|
||||
public void endDocument ()
|
||||
throws SAXException
|
||||
|
|
|
@ -44,8 +44,6 @@ import org.xml.sax.*;
|
|||
import org.xml.sax.ext.*;
|
||||
import org.xml.sax.helpers.XMLFilterImpl;
|
||||
|
||||
import gnu.xml.aelfred2.ContentHandler2;
|
||||
|
||||
/**
|
||||
* A customizable event consumer, used to assemble various kinds of filters
|
||||
* using SAX handlers and an optional second consumer. It can be constructed
|
||||
|
@ -138,7 +136,7 @@ import gnu.xml.aelfred2.ContentHandler2;
|
|||
* @author David Brownell
|
||||
*/
|
||||
public class EventFilter
|
||||
implements EventConsumer, ContentHandler2, DTDHandler,
|
||||
implements EventConsumer, ContentHandler, DTDHandler,
|
||||
LexicalHandler, DeclHandler
|
||||
{
|
||||
// SAX handlers
|
||||
|
@ -600,17 +598,6 @@ public class EventFilter
|
|||
docNext.startDocument ();
|
||||
}
|
||||
|
||||
public void xmlDecl(String version, String encoding, boolean standalone,
|
||||
String inputEncoding)
|
||||
throws SAXException
|
||||
{
|
||||
if (docNext != null && docNext instanceof ContentHandler2)
|
||||
{
|
||||
((ContentHandler2) docNext).xmlDecl(version, encoding, standalone,
|
||||
inputEncoding);
|
||||
}
|
||||
}
|
||||
|
||||
/** <b>SAX2:</b> passes this callback to the next consumer, if any */
|
||||
public void skippedEntity (String name) throws SAXException
|
||||
{
|
||||
|
|
|
@ -0,0 +1,198 @@
|
|||
/* BufferedReader.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.stream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
|
||||
/**
|
||||
* A mark-capable buffered reader.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class BufferedReader
|
||||
extends Reader
|
||||
{
|
||||
|
||||
static final int DEFAULT_BUFFER_SIZE = 4096;
|
||||
|
||||
final Reader in;
|
||||
char[] buf;
|
||||
int pos, count, markpos, marklimit, bufferSize;
|
||||
|
||||
BufferedReader(Reader in)
|
||||
{
|
||||
this(in, DEFAULT_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
BufferedReader(Reader in, int bufferSize)
|
||||
{
|
||||
if (bufferSize < 1)
|
||||
throw new IllegalArgumentException();
|
||||
this.in = in;
|
||||
this.bufferSize = bufferSize;
|
||||
buf = new char[bufferSize];
|
||||
pos = count = bufferSize;
|
||||
}
|
||||
|
||||
public void close()
|
||||
throws IOException
|
||||
{
|
||||
buf = null;
|
||||
pos = count = 0;
|
||||
markpos = -1;
|
||||
in.close();
|
||||
}
|
||||
|
||||
public void mark(int readlimit)
|
||||
throws IOException
|
||||
{
|
||||
marklimit = readlimit;
|
||||
markpos = pos;
|
||||
}
|
||||
|
||||
public boolean markSupported()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public int read()
|
||||
throws IOException
|
||||
{
|
||||
if (pos >= count && !refill())
|
||||
return -1;
|
||||
return (int) buf[pos++];
|
||||
}
|
||||
|
||||
public int read(char[] b)
|
||||
throws IOException
|
||||
{
|
||||
return read(b, 0, b.length);
|
||||
}
|
||||
|
||||
public int read(char[] b, int off, int len)
|
||||
throws IOException
|
||||
{
|
||||
if (off < 0 || len < 0 || b.length - off < len)
|
||||
throw new IndexOutOfBoundsException();
|
||||
|
||||
if (len == 0)
|
||||
return 0;
|
||||
|
||||
if (pos >= count && !refill())
|
||||
return -1;
|
||||
|
||||
int ret = Math.min(count - pos, len);
|
||||
System.arraycopy(buf, pos, b, off, ret);
|
||||
pos += ret;
|
||||
off += ret;
|
||||
len -= ret;
|
||||
|
||||
while (len > 0 && refill())
|
||||
{
|
||||
int remain = Math.min(count - pos, len);
|
||||
System.arraycopy(buf, pos, b, off, remain);
|
||||
pos += remain;
|
||||
off += remain;
|
||||
len -= remain;
|
||||
ret += remain;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void reset()
|
||||
throws IOException
|
||||
{
|
||||
if (markpos == -1)
|
||||
throw new IOException(buf == null ? "Stream closed." : "Invalid mark.");
|
||||
pos = markpos;
|
||||
}
|
||||
|
||||
public long skip(long n)
|
||||
throws IOException
|
||||
{
|
||||
if (buf == null)
|
||||
throw new IOException("Stream closed.");
|
||||
final long origN = n;
|
||||
while (n > 0L)
|
||||
{
|
||||
if (pos >= count && !refill())
|
||||
break;
|
||||
int numread = (int) Math.min((long) (count - pos), n);
|
||||
pos += numread;
|
||||
n -= numread;
|
||||
}
|
||||
return origN - n;
|
||||
}
|
||||
|
||||
private boolean refill()
|
||||
throws IOException
|
||||
{
|
||||
if (buf == null)
|
||||
throw new IOException("Stream closed.");
|
||||
|
||||
int markcount = count - markpos;
|
||||
if (markpos == -1 || markcount >= marklimit)
|
||||
{
|
||||
markpos = -1;
|
||||
pos = count = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
char[] newbuf = buf;
|
||||
if (markpos < bufferSize)
|
||||
{
|
||||
newbuf = new char[count - markpos + bufferSize];
|
||||
}
|
||||
System.arraycopy(buf, markpos, newbuf, 0, markcount);
|
||||
buf = newbuf;
|
||||
count = markcount;
|
||||
pos -= markpos;
|
||||
markpos = 0;
|
||||
}
|
||||
|
||||
int numread = in.read(buf, count, bufferSize);
|
||||
if (numread <= 0)
|
||||
return false;
|
||||
|
||||
count += numread;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,180 @@
|
|||
/* CRLFReader.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.stream;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
|
||||
/**
|
||||
* Filtered reader that normalizes CRLF pairs into LFs.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class CRLFReader
|
||||
extends Reader
|
||||
{
|
||||
|
||||
/**
|
||||
* The CR octet.
|
||||
*/
|
||||
public static final int CR = 13;
|
||||
|
||||
/**
|
||||
* The LF octet.
|
||||
*/
|
||||
public static final int LF = 10;
|
||||
|
||||
private boolean doReset;
|
||||
|
||||
protected Reader in;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
protected CRLFReader(Reader in)
|
||||
{
|
||||
if (!in.markSupported())
|
||||
in = new BufferedReader(in);
|
||||
this.in = in;
|
||||
}
|
||||
|
||||
public int read()
|
||||
throws IOException
|
||||
{
|
||||
int c = in.read();
|
||||
if (c == 13) // CR
|
||||
{
|
||||
in.mark(1);
|
||||
int d = in.read();
|
||||
if (d == 10) // LF
|
||||
c = d;
|
||||
else
|
||||
in.reset();
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
public int read(char[] b)
|
||||
throws IOException
|
||||
{
|
||||
return read(b, 0, b.length);
|
||||
}
|
||||
|
||||
public int read(char[] b, int off, int len)
|
||||
throws IOException
|
||||
{
|
||||
in.mark(len + 1);
|
||||
int l = in.read(b, off, len);
|
||||
if (l > 0)
|
||||
{
|
||||
int i = indexOfCRLF(b, off, l);
|
||||
if (doReset)
|
||||
{
|
||||
in.reset();
|
||||
if (i != -1)
|
||||
{
|
||||
l = in.read(b, off, (i + 1) - off); // read to CR
|
||||
in.read(); // skip LF
|
||||
b[i] = '\n'; // fix CR as LF
|
||||
}
|
||||
else
|
||||
l = in.read(b, off, len); // CR(s) but no LF
|
||||
}
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
public boolean markSupported()
|
||||
{
|
||||
return in.markSupported();
|
||||
}
|
||||
|
||||
public void mark(int limit)
|
||||
throws IOException
|
||||
{
|
||||
in.mark(limit);
|
||||
}
|
||||
|
||||
public void reset()
|
||||
throws IOException
|
||||
{
|
||||
in.reset();
|
||||
}
|
||||
|
||||
public long skip(long n)
|
||||
throws IOException
|
||||
{
|
||||
return in.skip(n);
|
||||
}
|
||||
|
||||
public void close()
|
||||
throws IOException
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
|
||||
private int indexOfCRLF(char[] b, int off, int len)
|
||||
throws IOException
|
||||
{
|
||||
doReset = false;
|
||||
int lm1 = len - 1;
|
||||
for (int i = off; i < len; i++)
|
||||
{
|
||||
if (b[i] == '\r') // CR
|
||||
{
|
||||
int d;
|
||||
if (i == lm1)
|
||||
{
|
||||
d = in.read();
|
||||
doReset = true;
|
||||
}
|
||||
else
|
||||
d = b[i + 1];
|
||||
if (d == '\n') // LF
|
||||
{
|
||||
doReset = true;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,966 @@
|
|||
/* SAXParser.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.stream;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.net.URL;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import javax.xml.XMLConstants;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.stream.Location;
|
||||
import javax.xml.stream.XMLEventReader;
|
||||
import javax.xml.stream.XMLReporter;
|
||||
import javax.xml.stream.XMLResolver;
|
||||
import javax.xml.stream.XMLStreamConstants;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.DTDHandler;
|
||||
import org.xml.sax.EntityResolver;
|
||||
import org.xml.sax.ErrorHandler;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.Parser;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXNotRecognizedException;
|
||||
import org.xml.sax.SAXNotSupportedException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
import org.xml.sax.XMLReader;
|
||||
import org.xml.sax.ext.Attributes2;
|
||||
import org.xml.sax.ext.DeclHandler;
|
||||
import org.xml.sax.ext.EntityResolver2;
|
||||
import org.xml.sax.ext.LexicalHandler;
|
||||
import org.xml.sax.ext.Locator2;
|
||||
|
||||
/**
|
||||
* JAXP SAX parser using an underlying StAX parser.
|
||||
* This parser supports the following additional SAX features and
|
||||
* properties:
|
||||
* <table>
|
||||
* <tr><th colspan='4'>Features</th></tr>
|
||||
* <tr><td>http://gnu.org/sax/features/xml-base</td>
|
||||
* <td colspan='2'>read/write</td>
|
||||
* <td>Indicates or sets whether XML Base processing is enabled</td></tr>
|
||||
* <tr><th colspan='4'>Properties</th></tr>
|
||||
* <tr><td>http://gnu.org/sax/properties/base-uri</td>
|
||||
* <td>read-only</td><td>String</td>
|
||||
* <td>Returns the base URI of the current event</td></tr>
|
||||
* <tr><td>http://gnu.org/sax/properties/document-xml-encoding</td>
|
||||
* <td>read-only</td><td>String</td>
|
||||
* <td>Returns the encoding specified in the XML declaration</td></tr>
|
||||
* </table>
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class SAXParser
|
||||
extends javax.xml.parsers.SAXParser
|
||||
implements XMLReader, Attributes2, Locator2, XMLReporter,
|
||||
XMLParser.XMLResolver2
|
||||
{
|
||||
|
||||
ContentHandler contentHandler;
|
||||
DeclHandler declHandler;
|
||||
DTDHandler dtdHandler;
|
||||
EntityResolver entityResolver;
|
||||
ErrorHandler errorHandler;
|
||||
LexicalHandler lexicalHandler;
|
||||
|
||||
boolean validating = false;
|
||||
boolean namespaceAware = true;
|
||||
boolean xIncludeAware = false;
|
||||
boolean stringInterning = true;
|
||||
boolean coalescing = true;
|
||||
boolean replaceERefs = true;
|
||||
boolean externalEntities = true;
|
||||
boolean supportDTD = true;
|
||||
boolean baseAware = true;
|
||||
|
||||
XMLParser parser;
|
||||
XMLStreamReader reader;
|
||||
String encoding;
|
||||
String xmlVersion;
|
||||
boolean xmlStandalone;
|
||||
String xmlEncoding;
|
||||
String baseURI;
|
||||
|
||||
public SAXParser()
|
||||
{
|
||||
}
|
||||
|
||||
SAXParser(boolean validating, boolean namespaceAware, boolean xIncludeAware)
|
||||
{
|
||||
this.validating = validating;
|
||||
this.namespaceAware = namespaceAware;
|
||||
this.xIncludeAware = xIncludeAware;
|
||||
}
|
||||
|
||||
// -- SAXParser --
|
||||
|
||||
public Parser getParser()
|
||||
throws SAXException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public XMLReader getXMLReader()
|
||||
throws SAXException
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isNamespaceAware()
|
||||
{
|
||||
return namespaceAware;
|
||||
}
|
||||
|
||||
public boolean isValidating()
|
||||
{
|
||||
return validating;
|
||||
}
|
||||
|
||||
public void setProperty(String name, Object value)
|
||||
throws SAXNotRecognizedException, SAXNotSupportedException
|
||||
{
|
||||
if (parser != null)
|
||||
throw new IllegalStateException("parsing in progress");
|
||||
final String FEATURES = "http://xml.org/sax/features/";
|
||||
final String PROPERTIES = "http://xml.org/sax/properties/";
|
||||
final String GNU_FEATURES = "http://gnu.org/sax/features/";
|
||||
if ((FEATURES + "namespaces").equals(name))
|
||||
namespaceAware = Boolean.TRUE.equals(value);
|
||||
else if ((FEATURES + "namespace-prefixes").equals(name))
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
else if ((FEATURES + "string-interning").equals(name))
|
||||
stringInterning = Boolean.TRUE.equals(value);
|
||||
else if ((FEATURES + "use-attributes2").equals(name))
|
||||
{
|
||||
// NOOP
|
||||
}
|
||||
else if ((FEATURES + "validation").equals(name))
|
||||
validating = Boolean.TRUE.equals(value);
|
||||
else if ((FEATURES + "external-general-entities").equals(name))
|
||||
externalEntities = Boolean.TRUE.equals(value);
|
||||
else if ((FEATURES + "external-parameter-entities").equals(name))
|
||||
externalEntities = Boolean.TRUE.equals(value);
|
||||
else if ((PROPERTIES + "declaration-handler").equals(name))
|
||||
declHandler = (DeclHandler) value;
|
||||
else if ((PROPERTIES + "lexical-handler").equals(name))
|
||||
lexicalHandler = (LexicalHandler) value;
|
||||
else if ((GNU_FEATURES + "xml-base").equals(name))
|
||||
baseAware = Boolean.TRUE.equals(value);
|
||||
else
|
||||
throw new SAXNotSupportedException(name);
|
||||
}
|
||||
|
||||
public Object getProperty(String name)
|
||||
throws SAXNotRecognizedException, SAXNotSupportedException
|
||||
{
|
||||
final String FEATURES = "http://xml.org/sax/features/";
|
||||
final String PROPERTIES = "http://xml.org/sax/properties/";
|
||||
final String GNU_FEATURES = "http://gnu.org/sax/features/";
|
||||
final String GNU_PROPERTIES = "http://gnu.org/sax/properties/";
|
||||
if ((GNU_FEATURES + "base-uri").equals(name))
|
||||
return baseURI;
|
||||
if ((FEATURES + "is-standalone").equals(name))
|
||||
return xmlStandalone ? Boolean.TRUE : Boolean.FALSE;
|
||||
if ((FEATURES + "namespaces").equals(name))
|
||||
return namespaceAware ? Boolean.TRUE : Boolean.FALSE;
|
||||
if ((FEATURES + "namespace-prefixes").equals(name))
|
||||
return Boolean.TRUE;
|
||||
if ((FEATURES + "string-interning").equals(name))
|
||||
return stringInterning ? Boolean.TRUE : Boolean.FALSE;
|
||||
if ((FEATURES + "use-attributes2").equals(name))
|
||||
return Boolean.TRUE;
|
||||
if ((FEATURES + "use-locator2").equals(name))
|
||||
return Boolean.TRUE;
|
||||
if ((FEATURES + "use-entity-resolver2").equals(name))
|
||||
return Boolean.FALSE;
|
||||
if ((FEATURES + "validation").equals(name))
|
||||
return validating ? Boolean.TRUE : Boolean.FALSE;
|
||||
if ((FEATURES + "external-general-entities").equals(name))
|
||||
return externalEntities ? Boolean.TRUE : Boolean.FALSE;
|
||||
if ((FEATURES + "external-parameter-entities").equals(name))
|
||||
return externalEntities ? Boolean.TRUE : Boolean.FALSE;
|
||||
if ((FEATURES + "xml-1.1").equals(name))
|
||||
return Boolean.TRUE;
|
||||
if ((PROPERTIES + "declaration-handler").equals(name))
|
||||
return declHandler;
|
||||
if ((PROPERTIES + "document-xml-version").equals(name))
|
||||
return xmlVersion;
|
||||
if ((PROPERTIES + "lexical-handler").equals(name))
|
||||
return lexicalHandler;
|
||||
if ((GNU_FEATURES + "xml-base").equals(name))
|
||||
return baseAware ? Boolean.TRUE : Boolean.FALSE;
|
||||
if ((GNU_PROPERTIES + "document-xml-encoding").equals(name))
|
||||
return xmlEncoding;
|
||||
throw new SAXNotSupportedException(name);
|
||||
}
|
||||
|
||||
public boolean isXIncludeAware()
|
||||
{
|
||||
return xIncludeAware;
|
||||
}
|
||||
|
||||
public void reset()
|
||||
{
|
||||
parser = null;
|
||||
encoding = null;
|
||||
xmlVersion = null;
|
||||
xmlStandalone = false;
|
||||
}
|
||||
|
||||
// -- XMLReader --
|
||||
|
||||
public boolean getFeature(String name)
|
||||
throws SAXNotRecognizedException, SAXNotSupportedException
|
||||
{
|
||||
Object ret = getProperty(name);
|
||||
if (ret instanceof Boolean)
|
||||
return ((Boolean) ret).booleanValue();
|
||||
throw new SAXNotSupportedException(name);
|
||||
}
|
||||
|
||||
public void setFeature(String name, boolean value)
|
||||
throws SAXNotRecognizedException, SAXNotSupportedException
|
||||
{
|
||||
setProperty(name, value ? Boolean.TRUE : Boolean.FALSE);
|
||||
}
|
||||
|
||||
public void setEntityResolver(EntityResolver resolver)
|
||||
{
|
||||
entityResolver = resolver;
|
||||
}
|
||||
|
||||
public EntityResolver getEntityResolver()
|
||||
{
|
||||
return entityResolver;
|
||||
}
|
||||
|
||||
public void setDTDHandler(DTDHandler handler)
|
||||
{
|
||||
dtdHandler = handler;
|
||||
}
|
||||
|
||||
public DTDHandler getDTDHandler()
|
||||
{
|
||||
return dtdHandler;
|
||||
}
|
||||
|
||||
public void setContentHandler(ContentHandler handler)
|
||||
{
|
||||
contentHandler = handler;
|
||||
}
|
||||
|
||||
public ContentHandler getContentHandler()
|
||||
{
|
||||
return contentHandler;
|
||||
}
|
||||
|
||||
public void setErrorHandler(ErrorHandler handler)
|
||||
{
|
||||
errorHandler = handler;
|
||||
}
|
||||
|
||||
public ErrorHandler getErrorHandler()
|
||||
{
|
||||
return errorHandler;
|
||||
}
|
||||
|
||||
public synchronized void parse(InputSource input)
|
||||
throws IOException, SAXException
|
||||
{
|
||||
reset();
|
||||
String systemId = input.getSystemId();
|
||||
InputStream in = input.getByteStream();
|
||||
boolean opened = false;
|
||||
if (in != null)
|
||||
parser = new XMLParser(in, systemId,
|
||||
validating,
|
||||
namespaceAware,
|
||||
coalescing,
|
||||
replaceERefs,
|
||||
externalEntities,
|
||||
supportDTD,
|
||||
baseAware,
|
||||
stringInterning,
|
||||
this,
|
||||
this);
|
||||
else
|
||||
{
|
||||
Reader r = input.getCharacterStream();
|
||||
if (r != null)
|
||||
parser = new XMLParser(r, systemId,
|
||||
validating,
|
||||
namespaceAware,
|
||||
coalescing,
|
||||
replaceERefs,
|
||||
externalEntities,
|
||||
supportDTD,
|
||||
baseAware,
|
||||
stringInterning,
|
||||
this,
|
||||
this);
|
||||
}
|
||||
if (parser == null)
|
||||
{
|
||||
if (systemId == null)
|
||||
throw new SAXException("No stream or system ID specified");
|
||||
systemId = XMLParser.absolutize(null, systemId);
|
||||
in = new URL(systemId).openStream();
|
||||
opened = true;
|
||||
parser = new XMLParser(in, systemId,
|
||||
validating,
|
||||
namespaceAware,
|
||||
coalescing,
|
||||
replaceERefs,
|
||||
externalEntities,
|
||||
supportDTD,
|
||||
baseAware,
|
||||
stringInterning,
|
||||
this,
|
||||
this);
|
||||
}
|
||||
reader = parser;
|
||||
baseURI = systemId;
|
||||
|
||||
if (xIncludeAware)
|
||||
reader = new XIncludeFilter(parser, systemId, namespaceAware,
|
||||
validating, true);
|
||||
|
||||
if (contentHandler != null)
|
||||
contentHandler.setDocumentLocator(this);
|
||||
boolean startDocumentDone = false;
|
||||
try
|
||||
{
|
||||
while (parser.hasNext())
|
||||
{
|
||||
int event = parser.next();
|
||||
if (baseAware)
|
||||
baseURI = parser.getXMLBase();
|
||||
switch (event)
|
||||
{
|
||||
case XMLStreamConstants.CHARACTERS:
|
||||
if (contentHandler != null)
|
||||
{
|
||||
char[] b = reader.getTextCharacters();
|
||||
contentHandler.characters(b, 0, b.length);
|
||||
}
|
||||
break;
|
||||
case XMLStreamConstants.SPACE:
|
||||
if (contentHandler != null)
|
||||
{
|
||||
char[] b = reader.getTextCharacters();
|
||||
if (isIgnorableWhitespace(parser, b, false))
|
||||
contentHandler.ignorableWhitespace(b, 0, b.length);
|
||||
else
|
||||
contentHandler.characters(b, 0, b.length);
|
||||
}
|
||||
break;
|
||||
case XMLStreamConstants.CDATA:
|
||||
if (lexicalHandler != null)
|
||||
lexicalHandler.startCDATA();
|
||||
if (contentHandler != null)
|
||||
{
|
||||
char[] b = reader.getTextCharacters();
|
||||
if (isIgnorableWhitespace(parser, b, true))
|
||||
contentHandler.ignorableWhitespace(b, 0, b.length);
|
||||
else
|
||||
contentHandler.characters(b, 0, b.length);
|
||||
}
|
||||
if (lexicalHandler != null)
|
||||
lexicalHandler.endCDATA();
|
||||
break;
|
||||
case XMLStreamConstants.START_ELEMENT:
|
||||
if (contentHandler != null)
|
||||
{
|
||||
QName name = reader.getName();
|
||||
String uri = name.getNamespaceURI();
|
||||
String localName = name.getLocalPart();
|
||||
String prefix = name.getPrefix();
|
||||
String qName = localName;
|
||||
if (!"".equals(prefix))
|
||||
qName = prefix + ":" + localName;
|
||||
if (!namespaceAware)
|
||||
{
|
||||
uri = "";
|
||||
localName = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
int nc = reader.getNamespaceCount();
|
||||
for (int i = 0; i < nc; i++)
|
||||
{
|
||||
String nsuri = reader.getNamespaceURI(i);
|
||||
String nsprefix = reader.getNamespacePrefix(i);
|
||||
if ("xml".equals(nsprefix))
|
||||
continue;
|
||||
contentHandler.startPrefixMapping(nsprefix, nsuri);
|
||||
}
|
||||
}
|
||||
contentHandler.startElement(uri, localName, qName, this);
|
||||
}
|
||||
break;
|
||||
case XMLStreamConstants.END_ELEMENT:
|
||||
if (contentHandler != null)
|
||||
{
|
||||
QName name = reader.getName();
|
||||
String uri = name.getNamespaceURI();
|
||||
String localName = name.getLocalPart();
|
||||
String prefix = name.getPrefix();
|
||||
String qName = localName;
|
||||
if (!"".equals(prefix))
|
||||
qName = prefix + ":" + localName;
|
||||
if (!namespaceAware)
|
||||
{
|
||||
uri = "";
|
||||
localName = "";
|
||||
}
|
||||
contentHandler.endElement(uri, localName, qName);
|
||||
if (namespaceAware)
|
||||
{
|
||||
int nc = reader.getNamespaceCount();
|
||||
for (int i = 0; i < nc; i++)
|
||||
{
|
||||
String nsprefix = reader.getNamespacePrefix(i);
|
||||
if ("xml".equals(nsprefix))
|
||||
continue;
|
||||
contentHandler.endPrefixMapping(nsprefix);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case XMLStreamConstants.COMMENT:
|
||||
if (lexicalHandler != null)
|
||||
{
|
||||
char[] b = reader.getTextCharacters();
|
||||
lexicalHandler.comment(b, 0, b.length);
|
||||
}
|
||||
break;
|
||||
case XMLStreamConstants.PROCESSING_INSTRUCTION:
|
||||
if (contentHandler != null)
|
||||
{
|
||||
String target = reader.getPITarget();
|
||||
String data = reader.getPIData();
|
||||
if (data == null)
|
||||
data = "";
|
||||
contentHandler.processingInstruction(target, data);
|
||||
}
|
||||
break;
|
||||
case XMLStreamConstants.START_ENTITY:
|
||||
if (lexicalHandler != null)
|
||||
{
|
||||
String name = reader.getText();
|
||||
lexicalHandler.startEntity(name);
|
||||
}
|
||||
break;
|
||||
case XMLStreamConstants.END_ENTITY:
|
||||
if (lexicalHandler != null)
|
||||
{
|
||||
String name = reader.getText();
|
||||
lexicalHandler.endEntity(name);
|
||||
}
|
||||
break;
|
||||
case XMLStreamConstants.START_DOCUMENT:
|
||||
encoding = reader.getEncoding();
|
||||
xmlVersion = reader.getVersion();
|
||||
xmlStandalone = reader.isStandalone();
|
||||
xmlEncoding = reader.getCharacterEncodingScheme();
|
||||
if (contentHandler != null)
|
||||
contentHandler.startDocument();
|
||||
startDocumentDone = true;
|
||||
break;
|
||||
case XMLStreamConstants.END_DOCUMENT:
|
||||
if (contentHandler != null)
|
||||
contentHandler.endDocument();
|
||||
break;
|
||||
case XMLStreamConstants.DTD:
|
||||
XMLParser.Doctype doctype = parser.doctype;
|
||||
if (lexicalHandler != null)
|
||||
{
|
||||
String rootName = doctype.rootName;
|
||||
String publicId = doctype.publicId;
|
||||
String systemId2 = doctype.systemId;
|
||||
lexicalHandler.startDTD(rootName, publicId, systemId2);
|
||||
}
|
||||
for (Iterator i = doctype.entryIterator(); i.hasNext(); )
|
||||
{
|
||||
String entry = (String) i.next();
|
||||
char c = entry.charAt(0);
|
||||
String name = entry.substring(1);
|
||||
if ('E' == c)
|
||||
{
|
||||
// Element decl
|
||||
if (declHandler != null)
|
||||
{
|
||||
XMLParser.ContentModel model =
|
||||
doctype.getElementModel(name);
|
||||
declHandler.elementDecl(name, model.text);
|
||||
}
|
||||
}
|
||||
else if ('A' == c)
|
||||
{
|
||||
// Attlist decl
|
||||
if (declHandler != null)
|
||||
{
|
||||
for (Iterator j = doctype.attlistIterator(name);
|
||||
j.hasNext(); )
|
||||
{
|
||||
Map.Entry att = (Map.Entry) j.next();
|
||||
String aname = (String) att.getKey();
|
||||
XMLParser.AttributeDecl decl =
|
||||
(XMLParser.AttributeDecl) att.getValue();
|
||||
String type = decl.type;
|
||||
String value = decl.value;
|
||||
String mode = null;
|
||||
switch (decl.valueType)
|
||||
{
|
||||
case XMLParser.ATTRIBUTE_DEFAULT_FIXED:
|
||||
mode = "#FIXED";
|
||||
break;
|
||||
case XMLParser.ATTRIBUTE_DEFAULT_REQUIRED:
|
||||
mode = "#REQUIRED";
|
||||
break;
|
||||
case XMLParser.ATTRIBUTE_DEFAULT_IMPLIED:
|
||||
mode = "#IMPLIED";
|
||||
break;
|
||||
}
|
||||
declHandler.attributeDecl(name, aname,
|
||||
type, mode, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ('e' == c)
|
||||
{
|
||||
// Entity decl
|
||||
Object entity = doctype.getEntity(name);
|
||||
if (entity instanceof String)
|
||||
{
|
||||
if (declHandler != null)
|
||||
declHandler.internalEntityDecl(name,
|
||||
(String) entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
XMLParser.ExternalIds ids =
|
||||
(XMLParser.ExternalIds) entity;
|
||||
if (ids.notationName != null)
|
||||
{
|
||||
if (dtdHandler != null)
|
||||
{
|
||||
String pub = ids.publicId;
|
||||
String url = ids.systemId;
|
||||
String not = ids.notationName;
|
||||
dtdHandler.unparsedEntityDecl(name,
|
||||
pub,
|
||||
url,
|
||||
not);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (declHandler != null)
|
||||
{
|
||||
String pub = ids.publicId;
|
||||
String url = ids.systemId;
|
||||
declHandler.externalEntityDecl(name,
|
||||
pub,
|
||||
url);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ('n' == c)
|
||||
{
|
||||
// Notation decl
|
||||
if (dtdHandler != null)
|
||||
{
|
||||
XMLParser.ExternalIds ids =
|
||||
doctype.getNotation(name);
|
||||
String pub = ids.publicId;
|
||||
String url = ids.systemId;
|
||||
dtdHandler.notationDecl(name, pub, url);
|
||||
}
|
||||
}
|
||||
else if ('c' == c)
|
||||
{
|
||||
// Comment
|
||||
if (lexicalHandler != null)
|
||||
{
|
||||
String comment = doctype.getComment(name);
|
||||
char[] b = comment.toCharArray();
|
||||
lexicalHandler.comment(b, 0, b.length);
|
||||
}
|
||||
}
|
||||
else if ('p' == c)
|
||||
{
|
||||
// Processing instruction
|
||||
if (contentHandler != null)
|
||||
{
|
||||
String[] pi = doctype.getPI(name);
|
||||
String target = pi[0];
|
||||
String data = pi[1];
|
||||
if (data == null)
|
||||
data = "";
|
||||
contentHandler.processingInstruction(target, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (lexicalHandler != null)
|
||||
lexicalHandler.endDTD();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (XMLStreamException e)
|
||||
{
|
||||
if (!startDocumentDone && contentHandler != null)
|
||||
contentHandler.startDocument();
|
||||
SAXParseException e2 = new SAXParseException(e.getMessage(), this);
|
||||
e2.initCause(e);
|
||||
if (errorHandler != null)
|
||||
errorHandler.fatalError(e2);
|
||||
if (contentHandler != null)
|
||||
contentHandler.endDocument();
|
||||
throw e2;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (opened)
|
||||
in.close();
|
||||
reset();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the specified characters are ignorable whitespace.
|
||||
*/
|
||||
private boolean isIgnorableWhitespace(XMLParser reader, char[] b,
|
||||
boolean testCharacters)
|
||||
throws XMLStreamException
|
||||
{
|
||||
XMLParser.Doctype doctype = reader.doctype;
|
||||
if (doctype == null)
|
||||
return false;
|
||||
String currentElement = reader.getCurrentElement();
|
||||
// check for xml:space
|
||||
int ac = reader.getAttributeCount();
|
||||
for (int i = 0; i < ac; i++)
|
||||
{
|
||||
QName aname = reader.getAttributeQName(i);
|
||||
if ("space".equals(aname.getLocalPart()) &&
|
||||
XMLConstants.XML_NS_URI.equals(aname.getNamespaceURI()))
|
||||
{
|
||||
if ("preserve".equals(reader.getAttributeValue(i)))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
XMLParser.ContentModel model = doctype.getElementModel(currentElement);
|
||||
if (model == null || model.type != XMLParser.ContentModel.ELEMENT)
|
||||
return false;
|
||||
if (model.external && xmlStandalone)
|
||||
return false;
|
||||
boolean white = true;
|
||||
if (testCharacters)
|
||||
{
|
||||
for (int i = 0; i < b.length; i++)
|
||||
{
|
||||
if (b[i] != ' ' && b[i] != '\t' && b[i] != '\n' && b[i] != '\r')
|
||||
{
|
||||
white = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return white;
|
||||
}
|
||||
|
||||
public void parse(String systemId)
|
||||
throws IOException, SAXException
|
||||
{
|
||||
parse(new InputSource(systemId));
|
||||
}
|
||||
|
||||
// -- Attributes2 --
|
||||
|
||||
public int getIndex(String qName)
|
||||
{
|
||||
int len = reader.getAttributeCount();
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
QName q = reader.getAttributeQName(i);
|
||||
String localName = q.getLocalPart();
|
||||
String prefix = q.getPrefix();
|
||||
String qn = ("".equals(prefix)) ? localName : prefix + ":" + localName;
|
||||
if (qName.equals(qn))
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int getIndex(String uri, String localName)
|
||||
{
|
||||
int len = reader.getAttributeCount();
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
QName q = reader.getAttributeQName(i);
|
||||
String ln = q.getLocalPart();
|
||||
String u = q.getNamespaceURI();
|
||||
if (u == null && uri != null)
|
||||
continue;
|
||||
if (u != null && !u.equals(uri))
|
||||
continue;
|
||||
if (ln.equals(localName))
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int getLength()
|
||||
{
|
||||
return reader.getAttributeCount();
|
||||
}
|
||||
|
||||
public String getLocalName(int index)
|
||||
{
|
||||
return reader.getAttributeName(index);
|
||||
}
|
||||
|
||||
public String getQName(int index)
|
||||
{
|
||||
QName q = reader.getAttributeQName(index);
|
||||
String localName = q.getLocalPart();
|
||||
String prefix = q.getPrefix();
|
||||
return ("".equals(prefix)) ? localName : prefix + ":" + localName;
|
||||
}
|
||||
|
||||
public String getType(int index)
|
||||
{
|
||||
String ret = reader.getAttributeType(index);
|
||||
// SAX doesn't permit ENUMERATION?
|
||||
return ("ENUMERATION".equals(ret)) ? "NMTOKEN" : ret;
|
||||
}
|
||||
|
||||
public String getType(String qName)
|
||||
{
|
||||
int index = getIndex(qName);
|
||||
return (index == -1) ? null : getType(index);
|
||||
}
|
||||
|
||||
public String getType(String uri, String localName)
|
||||
{
|
||||
int index = getIndex(uri, localName);
|
||||
return (index == -1) ? null : getType(index);
|
||||
}
|
||||
|
||||
public String getURI(int index)
|
||||
{
|
||||
String ret = reader.getAttributeNamespace(index);
|
||||
return (ret == null) ? "" : ret;
|
||||
}
|
||||
|
||||
public String getValue(int index)
|
||||
{
|
||||
return reader.getAttributeValue(index);
|
||||
}
|
||||
|
||||
public String getValue(String qName)
|
||||
{
|
||||
int index = getIndex(qName);
|
||||
return (index == -1) ? null : getValue(index);
|
||||
}
|
||||
|
||||
public String getValue(String uri, String localName)
|
||||
{
|
||||
int index = getIndex(uri, localName);
|
||||
return (index == -1) ? null : getValue(index);
|
||||
}
|
||||
|
||||
public boolean isDeclared(int index)
|
||||
{
|
||||
return parser.isAttributeDeclared(index);
|
||||
}
|
||||
|
||||
public boolean isDeclared(String qName)
|
||||
{
|
||||
int index = getIndex(qName);
|
||||
return (index == -1) ? false : isDeclared(index);
|
||||
}
|
||||
|
||||
public boolean isDeclared(String uri, String localName)
|
||||
{
|
||||
int index = getIndex(uri, localName);
|
||||
return (index == -1) ? false : isDeclared(index);
|
||||
}
|
||||
|
||||
public boolean isSpecified(int index)
|
||||
{
|
||||
return reader.isAttributeSpecified(index);
|
||||
}
|
||||
|
||||
public boolean isSpecified(String qName)
|
||||
{
|
||||
int index = getIndex(qName);
|
||||
return (index == -1) ? false : isSpecified(index);
|
||||
}
|
||||
|
||||
public boolean isSpecified(String uri, String localName)
|
||||
{
|
||||
int index = getIndex(uri, localName);
|
||||
return (index == -1) ? false : isSpecified(index);
|
||||
}
|
||||
|
||||
// -- Locator2 --
|
||||
|
||||
public int getColumnNumber()
|
||||
{
|
||||
Location l = reader.getLocation();
|
||||
return l.getColumnNumber();
|
||||
}
|
||||
|
||||
public int getLineNumber()
|
||||
{
|
||||
Location l = reader.getLocation();
|
||||
return l.getLineNumber();
|
||||
}
|
||||
|
||||
public String getPublicId()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getSystemId()
|
||||
{
|
||||
Location l = reader.getLocation();
|
||||
return l.getLocationURI();
|
||||
}
|
||||
|
||||
public String getEncoding()
|
||||
{
|
||||
return encoding;
|
||||
}
|
||||
|
||||
public String getXMLVersion()
|
||||
{
|
||||
return xmlVersion;
|
||||
}
|
||||
|
||||
// -- XMLResolver --
|
||||
|
||||
public InputStream resolve(String uri)
|
||||
throws XMLStreamException
|
||||
{
|
||||
return resolve(null, uri);
|
||||
}
|
||||
|
||||
public InputStream resolve(String publicId, String systemId)
|
||||
throws XMLStreamException
|
||||
{
|
||||
if (entityResolver != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
InputSource input =
|
||||
entityResolver.resolveEntity(publicId, systemId);
|
||||
if (input != null)
|
||||
return input.getByteStream();
|
||||
}
|
||||
catch (SAXException e)
|
||||
{
|
||||
XMLStreamException e2 = new XMLStreamException(e.getMessage());
|
||||
e2.initCause(e);
|
||||
throw e2;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
XMLStreamException e2 = new XMLStreamException(e.getMessage());
|
||||
e2.initCause(e);
|
||||
throw e2;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public XMLEventReader resolveAsXMLEventReader(String uri)
|
||||
throws XMLStreamException
|
||||
{
|
||||
// unused
|
||||
return null;
|
||||
}
|
||||
|
||||
public XMLStreamReader resolveAsXMLStreamReader(String uri)
|
||||
throws XMLStreamException
|
||||
{
|
||||
// unused
|
||||
return null;
|
||||
}
|
||||
|
||||
// -- XMLReporter --
|
||||
|
||||
public void report(String message, String errorType,
|
||||
Object relatedInformation, Location location)
|
||||
throws XMLStreamException
|
||||
{
|
||||
if (errorHandler != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
errorHandler.warning(new SAXParseException(message, this));
|
||||
}
|
||||
catch (SAXException e)
|
||||
{
|
||||
XMLStreamException e2 = new XMLStreamException(e.getMessage());
|
||||
e2.initCause(e);
|
||||
throw e2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
throws Exception
|
||||
{
|
||||
SAXParser parser = new SAXParser();
|
||||
InputSource input = new InputSource(args[0]);
|
||||
parser.parse(input, new org.xml.sax.helpers.DefaultHandler());
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
/* SAXParserFactory.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.stream;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXNotRecognizedException;
|
||||
import org.xml.sax.SAXNotSupportedException;
|
||||
|
||||
/**
|
||||
* SAX parser factory providing a SAX compatibility layer on top of StAX.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
public class SAXParserFactory
|
||||
extends javax.xml.parsers.SAXParserFactory
|
||||
{
|
||||
|
||||
static final Set FEATURE_NAMES = new HashSet();
|
||||
static
|
||||
{
|
||||
FEATURE_NAMES.add("http://xml.org/sax/features/namespaces");
|
||||
FEATURE_NAMES.add("http://xml.org/sax/features/string-interning");
|
||||
FEATURE_NAMES.add("http://xml.org/sax/features/validation");
|
||||
}
|
||||
|
||||
Map features = new HashMap();
|
||||
|
||||
public javax.xml.parsers.SAXParser newSAXParser()
|
||||
throws ParserConfigurationException, SAXException
|
||||
{
|
||||
boolean validating = isValidating();
|
||||
boolean namespaceAware = isNamespaceAware();
|
||||
boolean xIncludeAware = isXIncludeAware();
|
||||
SAXParser ret = new SAXParser(validating, namespaceAware, xIncludeAware);
|
||||
for (Iterator i = features.entrySet().iterator(); i.hasNext(); )
|
||||
{
|
||||
Map.Entry entry = (Map.Entry) i.next();
|
||||
String name = (String) entry.getKey();
|
||||
Boolean value = (Boolean) entry.getValue();
|
||||
ret.setFeature(name, value.booleanValue());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void setFeature(String name, boolean value)
|
||||
throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException
|
||||
{
|
||||
if (!FEATURE_NAMES.contains(name))
|
||||
throw new SAXNotSupportedException(name);
|
||||
features.put(name, value ? Boolean.TRUE : Boolean.FALSE);
|
||||
}
|
||||
|
||||
public boolean getFeature(String name)
|
||||
throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException
|
||||
{
|
||||
if (!FEATURE_NAMES.contains(name))
|
||||
throw new SAXNotSupportedException(name);
|
||||
Boolean value = (Boolean) features.get(name);
|
||||
return (value == null) ? false : value.booleanValue();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,201 @@
|
|||
/* UnicodeReader.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.stream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
|
||||
/**
|
||||
* A reader that converts UTF-16 characters to Unicode code points.
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class UnicodeReader
|
||||
{
|
||||
|
||||
final Reader in;
|
||||
|
||||
UnicodeReader(Reader in)
|
||||
{
|
||||
this.in = in;
|
||||
}
|
||||
|
||||
public void mark(int limit)
|
||||
throws IOException
|
||||
{
|
||||
in.mark(limit * 2);
|
||||
}
|
||||
|
||||
public void reset()
|
||||
throws IOException
|
||||
{
|
||||
in.reset();
|
||||
}
|
||||
|
||||
public int read()
|
||||
throws IOException
|
||||
{
|
||||
int ret = in.read();
|
||||
if (ret == -1)
|
||||
return ret;
|
||||
if (ret >= 0xd800 && ret < 0xdc00)
|
||||
{
|
||||
// Unicode surrogate?
|
||||
int low = in.read();
|
||||
if (low >= 0xdc00 && low < 0xe000)
|
||||
ret = Character.toCodePoint((char) ret, (char) low);
|
||||
else
|
||||
throw new IOException("unpaired surrogate: U+" +
|
||||
Integer.toHexString(ret));
|
||||
}
|
||||
else if (ret >= 0xdc00 && ret < 0xe000)
|
||||
throw new IOException("unpaired surrogate: U+" +
|
||||
Integer.toHexString(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
public int read(int[] buf, int off, int len)
|
||||
throws IOException
|
||||
{
|
||||
if (len == 0)
|
||||
return 0;
|
||||
char[] b2 = new char[len];
|
||||
int ret = in.read(b2, 0, len);
|
||||
if (ret <= 0)
|
||||
return ret;
|
||||
int l = ret - 1;
|
||||
int i = 0, j = off;
|
||||
for (; i < l; i++)
|
||||
{
|
||||
char c = b2[i];
|
||||
if (c >= 0xd800 && c < 0xdc00)
|
||||
{
|
||||
// Unicode surrogate?
|
||||
char d = b2[i + 1];
|
||||
if (d >= 0xdc00 && d < 0xe000)
|
||||
{
|
||||
buf[j++] = Character.toCodePoint(c, d);
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
throw new IOException("unpaired surrogate: U+" +
|
||||
Integer.toHexString(c));
|
||||
}
|
||||
else if (c >= 0xdc00 && c < 0xe000)
|
||||
throw new IOException("unpaired surrogate: U+" +
|
||||
Integer.toHexString(c));
|
||||
buf[j++] = (int) c;
|
||||
}
|
||||
if (i == l)
|
||||
{
|
||||
// last char
|
||||
char c = b2[l];
|
||||
if (c >= 0xd800 && c < 0xdc00)
|
||||
{
|
||||
int low = in.read();
|
||||
if (low >= 0xdc00 && low < 0xe000)
|
||||
{
|
||||
buf[j++] = Character.toCodePoint(c, (char) low);
|
||||
return j;
|
||||
}
|
||||
else
|
||||
throw new IOException("unpaired surrogate: U+" +
|
||||
Integer.toHexString(c));
|
||||
}
|
||||
else if (c >= 0xdc00 && c < 0xe000)
|
||||
throw new IOException("unpaired surrogate: U+" +
|
||||
Integer.toHexString(c));
|
||||
buf[j++] = (int) c;
|
||||
}
|
||||
return j;
|
||||
}
|
||||
|
||||
public void close()
|
||||
throws IOException
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
|
||||
public static int[] toCodePointArray(String text)
|
||||
throws IOException
|
||||
{
|
||||
char[] b2 = text.toCharArray();
|
||||
int[] buf = new int[b2.length];
|
||||
if (b2.length > 0)
|
||||
{
|
||||
int l = b2.length - 1;
|
||||
int i = 0, j = 0;
|
||||
for (; i < l; i++)
|
||||
{
|
||||
char c = b2[i];
|
||||
if (c >= 0xd800 && c < 0xdc00)
|
||||
{
|
||||
// Unicode surrogate?
|
||||
char d = b2[i + 1];
|
||||
if (d >= 0xdc00 && d < 0xe000)
|
||||
{
|
||||
buf[j++] = Character.toCodePoint(c, d);
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
throw new IOException("unpaired surrogate: U+" +
|
||||
Integer.toHexString(c));
|
||||
}
|
||||
else if (c >= 0xdc00 && c < 0xe000)
|
||||
throw new IOException("unpaired surrogate: U+" +
|
||||
Integer.toHexString(c));
|
||||
buf[j++] = (int) c;
|
||||
}
|
||||
if (i == l)
|
||||
{
|
||||
// last char
|
||||
buf[j++] = (int) b2[l];
|
||||
if (j < buf.length)
|
||||
{
|
||||
int[] buf2 = new int[j];
|
||||
System.arraycopy(buf, 0, buf2, 0, j);
|
||||
buf = buf2;
|
||||
}
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,932 @@
|
|||
/* XIncludeFilter.java --
|
||||
Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
GNU Classpath is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU Classpath is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Classpath; see the file COPYING. If not, write to the
|
||||
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
|
||||
Linking this library statically or dynamically with other modules is
|
||||
making a combined work based on this library. Thus, the terms and
|
||||
conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
|
||||
As a special exception, the copyright holders of this library give you
|
||||
permission to link this library with independent modules to produce an
|
||||
executable, regardless of the license terms of these independent
|
||||
modules, and to copy and distribute the resulting executable under
|
||||
terms of your choice, provided that you also meet, for each linked
|
||||
independent module, the terms and conditions of the license of that
|
||||
module. An independent module is a module which is not derived from
|
||||
or based on this library. If you modify this library, you may extend
|
||||
this exception to your version of the library, but you are not
|
||||
obligated to do so. If you do not wish to do so, delete this
|
||||
exception statement from your version. */
|
||||
|
||||
package gnu.xml.stream;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.HashSet;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.StringTokenizer;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLStreamConstants;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.util.ReaderDelegate;
|
||||
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.DOMImplementation;
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.ProcessingInstruction;
|
||||
import org.w3c.dom.TypeInfo;
|
||||
import org.w3c.dom.traversal.DocumentTraversal;
|
||||
import org.w3c.dom.traversal.NodeFilter;
|
||||
import org.w3c.dom.traversal.TreeWalker;
|
||||
import org.w3c.dom.xpath.XPathEvaluator;
|
||||
import org.w3c.dom.xpath.XPathNSResolver;
|
||||
import org.w3c.dom.xpath.XPathResult;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* StAX filter for performing XInclude processing.
|
||||
*
|
||||
* @see http://www.w3.org/TR/xinclude/
|
||||
* @see http://www.w3.org/TR/xptr-framework/
|
||||
* @see http://www.w3.org/TR/xptr-element/
|
||||
*
|
||||
* @author <a href='mailto:dog@gnu.org'>Chris Burdess</a>
|
||||
*/
|
||||
class XIncludeFilter
|
||||
extends ReaderDelegate
|
||||
{
|
||||
|
||||
static final String XINCLUDE_NS_URI = "http://www.w3.org/2001/XInclude";
|
||||
static final int SHOW_FLAGS =
|
||||
NodeFilter.SHOW_CDATA_SECTION |
|
||||
NodeFilter.SHOW_COMMENT |
|
||||
NodeFilter.SHOW_ELEMENT |
|
||||
NodeFilter.SHOW_ENTITY_REFERENCE |
|
||||
NodeFilter.SHOW_PROCESSING_INSTRUCTION |
|
||||
NodeFilter.SHOW_TEXT;
|
||||
|
||||
final String systemId;
|
||||
final boolean namespaceAware;
|
||||
final boolean validating;
|
||||
final boolean expandERefs;
|
||||
String href;
|
||||
int event;
|
||||
boolean included;
|
||||
XPathResult result;
|
||||
int snapshotIndex;
|
||||
Node current;
|
||||
TreeWalker walker;
|
||||
HashSet seen = new HashSet();
|
||||
boolean backtracking;
|
||||
boolean lookahead;
|
||||
|
||||
Reader includedText;
|
||||
char[] buf;
|
||||
int len = -1;
|
||||
boolean inInclude, inFallback, seenFallback;
|
||||
|
||||
DocumentBuilder builder;
|
||||
|
||||
XIncludeFilter(XMLStreamReader reader, String systemId,
|
||||
boolean namespaceAware, boolean validating,
|
||||
boolean expandERefs)
|
||||
{
|
||||
super(reader);
|
||||
this.systemId = XMLParser.absolutize(null, systemId);
|
||||
this.namespaceAware = namespaceAware;
|
||||
this.validating = validating;
|
||||
this.expandERefs = expandERefs;
|
||||
}
|
||||
|
||||
public int getAttributeCount()
|
||||
{
|
||||
if (current != null)
|
||||
{
|
||||
NamedNodeMap attrs = current.getAttributes();
|
||||
return (attrs == null) ? 0 : attrs.getLength();
|
||||
}
|
||||
return super.getAttributeCount();
|
||||
}
|
||||
|
||||
public String getAttributeName(int index)
|
||||
{
|
||||
if (current != null)
|
||||
{
|
||||
NamedNodeMap attrs = current.getAttributes();
|
||||
if (attrs == null)
|
||||
return null;
|
||||
Node attr = attrs.item(index);
|
||||
return attr.getLocalName();
|
||||
}
|
||||
return super.getAttributeName(index);
|
||||
}
|
||||
|
||||
public String getAttributeNamespace(int index)
|
||||
{
|
||||
if (current != null)
|
||||
{
|
||||
NamedNodeMap attrs = current.getAttributes();
|
||||
if (attrs == null)
|
||||
return null;
|
||||
Node attr = attrs.item(index);
|
||||
return attr.getNamespaceURI();
|
||||
}
|
||||
return super.getAttributeNamespace(index);
|
||||
}
|
||||
|
||||
public String getAttributePrefix(int index)
|
||||
{
|
||||
if (current != null)
|
||||
{
|
||||
NamedNodeMap attrs = current.getAttributes();
|
||||
if (attrs == null)
|
||||
return null;
|
||||
Node attr = attrs.item(index);
|
||||
return attr.getPrefix();
|
||||
}
|
||||
return super.getAttributePrefix(index);
|
||||
}
|
||||
|
||||
public QName getAttributeQName(int index)
|
||||
{
|
||||
if (current != null)
|
||||
{
|
||||
NamedNodeMap attrs = current.getAttributes();
|
||||
if (attrs == null)
|
||||
return null;
|
||||
Node attr = attrs.item(index);
|
||||
String localName = attr.getLocalName();
|
||||
String uri = attr.getNamespaceURI();
|
||||
String prefix = attr.getPrefix();
|
||||
return new QName(uri, localName, prefix);
|
||||
}
|
||||
return super.getAttributeQName(index);
|
||||
}
|
||||
|
||||
public String getAttributeType(int index)
|
||||
{
|
||||
if (current != null)
|
||||
{
|
||||
NamedNodeMap attrs = current.getAttributes();
|
||||
if (attrs == null)
|
||||
return null;
|
||||
Attr attr = (Attr) attrs.item(index);
|
||||
TypeInfo ti = attr.getSchemaTypeInfo();
|
||||
return (ti == null) ? "CDATA" : ti.getTypeName();
|
||||
}
|
||||
return super.getAttributeType(index);
|
||||
}
|
||||
|
||||
public boolean isAttributeSpecified(int index)
|
||||
{
|
||||
if (current != null)
|
||||
{
|
||||
NamedNodeMap attrs = current.getAttributes();
|
||||
if (attrs == null)
|
||||
return false;
|
||||
Attr attr = (Attr) attrs.item(index);
|
||||
return attr.getSpecified();
|
||||
}
|
||||
return super.isAttributeSpecified(index);
|
||||
}
|
||||
|
||||
public String getAttributeValue(int index)
|
||||
{
|
||||
if (current != null)
|
||||
{
|
||||
NamedNodeMap attrs = current.getAttributes();
|
||||
if (attrs == null)
|
||||
return null;
|
||||
Node attr = attrs.item(index);
|
||||
return attr.getNodeValue();
|
||||
}
|
||||
return super.getAttributeValue(index);
|
||||
}
|
||||
|
||||
public String getAttributeValue(String uri, String localName)
|
||||
{
|
||||
if (current != null)
|
||||
{
|
||||
NamedNodeMap attrs = current.getAttributes();
|
||||
if (attrs == null)
|
||||
return null;
|
||||
Node attr = attrs.getNamedItemNS(uri, localName);
|
||||
return (attr == null) ? null : attr.getNodeValue();
|
||||
}
|
||||
return super.getAttributeValue(uri, localName);
|
||||
}
|
||||
|
||||
public String getElementText()
|
||||
throws XMLStreamException
|
||||
{
|
||||
if (current != null)
|
||||
return current.getTextContent();
|
||||
return super.getElementText();
|
||||
}
|
||||
|
||||
public int getEventType()
|
||||
{
|
||||
return event;
|
||||
}
|
||||
|
||||
public String getLocalName()
|
||||
{
|
||||
if (current != null)
|
||||
return current.getLocalName();
|
||||
return super.getLocalName();
|
||||
}
|
||||
|
||||
public QName getName()
|
||||
{
|
||||
if (current != null)
|
||||
{
|
||||
String localName = current.getLocalName();
|
||||
String uri = current.getNamespaceURI();
|
||||
String prefix = current.getPrefix();
|
||||
return new QName(uri, localName, prefix);
|
||||
}
|
||||
return super.getName();
|
||||
}
|
||||
|
||||
public String getNamespaceURI()
|
||||
{
|
||||
if (current != null)
|
||||
return current.getNamespaceURI();
|
||||
return super.getNamespaceURI();
|
||||
}
|
||||
|
||||
// TODO namespaces
|
||||
|
||||
public String getPIData()
|
||||
{
|
||||
if (current != null)
|
||||
return ((ProcessingInstruction) current).getData();
|
||||
return super.getPIData();
|
||||
}
|
||||
|
||||
public String getPITarget()
|
||||
{
|
||||
if (current != null)
|
||||
return ((ProcessingInstruction) current).getTarget();
|
||||
return super.getPITarget();
|
||||
}
|
||||
|
||||
public String getPrefix()
|
||||
{
|
||||
if (current != null)
|
||||
return current.getPrefix();
|
||||
return super.getPrefix();
|
||||
}
|
||||
|
||||
public String getText()
|
||||
{
|
||||
if (current != null)
|
||||
return current.getNodeValue();
|
||||
if (walker != null)
|
||||
{
|
||||
Node n = walker.getCurrentNode();
|
||||
if (n != null)
|
||||
return n.getTextContent();
|
||||
}
|
||||
if (buf != null)
|
||||
return new String(buf, 0, len);
|
||||
return super.getText();
|
||||
}
|
||||
|
||||
public char[] getTextCharacters()
|
||||
{
|
||||
if (current != null)
|
||||
{
|
||||
buf = current.getNodeValue().toCharArray();
|
||||
len = buf.length;
|
||||
}
|
||||
if (buf != null)
|
||||
return buf;
|
||||
return super.getTextCharacters();
|
||||
}
|
||||
|
||||
public int getTextCharacters(int sourceStart, char[] target,
|
||||
int targetStart, int length)
|
||||
throws XMLStreamException
|
||||
{
|
||||
if (current != null)
|
||||
{
|
||||
buf = current.getNodeValue().toCharArray();
|
||||
len = buf.length;
|
||||
}
|
||||
if (buf != null)
|
||||
{
|
||||
int max = Math.min(len - sourceStart, length);
|
||||
if (max > 0)
|
||||
System.arraycopy(buf, sourceStart, target, targetStart, max);
|
||||
return max;
|
||||
}
|
||||
return super.getTextCharacters(sourceStart, target, targetStart, length);
|
||||
}
|
||||
|
||||
public int getTextLength()
|
||||
{
|
||||
if (current != null)
|
||||
{
|
||||
buf = current.getNodeValue().toCharArray();
|
||||
len = buf.length;
|
||||
}
|
||||
if (buf != null)
|
||||
return len;
|
||||
return super.getTextLength();
|
||||
}
|
||||
|
||||
public int getTextStart()
|
||||
{
|
||||
if (current != null)
|
||||
{
|
||||
buf = current.getNodeValue().toCharArray();
|
||||
len = buf.length;
|
||||
}
|
||||
if (buf != null)
|
||||
return 0;
|
||||
return super.getTextStart();
|
||||
}
|
||||
|
||||
public boolean hasNext()
|
||||
throws XMLStreamException
|
||||
{
|
||||
if (!lookahead)
|
||||
{
|
||||
try
|
||||
{
|
||||
next();
|
||||
}
|
||||
catch (NoSuchElementException e)
|
||||
{
|
||||
event = -1;
|
||||
}
|
||||
lookahead = true;
|
||||
}
|
||||
return (event != -1);
|
||||
}
|
||||
|
||||
public int next()
|
||||
throws XMLStreamException
|
||||
{
|
||||
if (lookahead)
|
||||
{
|
||||
lookahead = false;
|
||||
return event;
|
||||
}
|
||||
buf = null;
|
||||
len = 0;
|
||||
if (walker != null)
|
||||
{
|
||||
Node c = walker.getCurrentNode();
|
||||
Node n = null;
|
||||
if (c.getNodeType() == Node.ELEMENT_NODE)
|
||||
{
|
||||
boolean isStartElement = !seen.contains(c);
|
||||
if (isStartElement)
|
||||
{
|
||||
seen.add(c);
|
||||
current = c;
|
||||
event = XMLStreamConstants.START_ELEMENT;
|
||||
return event;
|
||||
}
|
||||
else if (backtracking)
|
||||
{
|
||||
n = walker.nextSibling();
|
||||
if (n != null)
|
||||
backtracking = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
n = walker.firstChild();
|
||||
if (n == null)
|
||||
n = walker.nextSibling();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
n = walker.firstChild();
|
||||
if (n == null)
|
||||
n = walker.nextSibling();
|
||||
}
|
||||
if (n == null)
|
||||
{
|
||||
current = walker.parentNode();
|
||||
if (current != null && current.getNodeType() == Node.ELEMENT_NODE)
|
||||
{
|
||||
// end-element
|
||||
backtracking = true;
|
||||
event = XMLStreamConstants.END_ELEMENT;
|
||||
return event;
|
||||
}
|
||||
else
|
||||
{
|
||||
walker = null;
|
||||
current = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
current = n;
|
||||
switch (n.getNodeType())
|
||||
{
|
||||
case Node.ELEMENT_NODE:
|
||||
return next();
|
||||
case Node.TEXT_NODE:
|
||||
String text = n.getNodeValue();
|
||||
buf = text.toCharArray();
|
||||
len = buf.length;
|
||||
event = isSpace(buf, len) ?
|
||||
XMLStreamConstants.SPACE :
|
||||
XMLStreamConstants.CHARACTERS;
|
||||
return event;
|
||||
case Node.CDATA_SECTION_NODE:
|
||||
event = XMLStreamConstants.CDATA;
|
||||
return event;
|
||||
case Node.COMMENT_NODE:
|
||||
event = XMLStreamConstants.COMMENT;
|
||||
return event;
|
||||
case Node.PROCESSING_INSTRUCTION_NODE:
|
||||
event = XMLStreamConstants.PROCESSING_INSTRUCTION;
|
||||
return event;
|
||||
case Node.ENTITY_REFERENCE_NODE:
|
||||
event = XMLStreamConstants.ENTITY_REFERENCE;
|
||||
return event;
|
||||
default:
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (result != null)
|
||||
{
|
||||
switch (result.getResultType())
|
||||
{
|
||||
case XPathResult.BOOLEAN_TYPE:
|
||||
boolean bval = result.getBooleanValue();
|
||||
String btext = bval ? "true" : "false";
|
||||
buf = btext.toCharArray();
|
||||
len = buf.length;
|
||||
result = null;
|
||||
event = XMLStreamConstants.CHARACTERS;
|
||||
return event;
|
||||
case XPathResult.NUMBER_TYPE:
|
||||
double nval = result.getNumberValue();
|
||||
String ntext = new Double(nval).toString();
|
||||
buf = ntext.toCharArray();
|
||||
len = buf.length;
|
||||
result = null;
|
||||
event = XMLStreamConstants.CHARACTERS;
|
||||
return event;
|
||||
case XPathResult.STRING_TYPE:
|
||||
String stext = result.getStringValue();
|
||||
buf = stext.toCharArray();
|
||||
len = buf.length;
|
||||
result = null;
|
||||
event = isSpace(buf, len) ?
|
||||
XMLStreamConstants.SPACE :
|
||||
XMLStreamConstants.CHARACTERS;
|
||||
return event;
|
||||
case XPathResult.ANY_UNORDERED_NODE_TYPE:
|
||||
case XPathResult.FIRST_ORDERED_NODE_TYPE:
|
||||
Node n1 = result.getSingleNodeValue();
|
||||
Document d1 = getDocument(n1);
|
||||
walker = getDocumentTraversal(d1)
|
||||
.createTreeWalker(n1, SHOW_FLAGS, null, expandERefs);
|
||||
result = null;
|
||||
return next();
|
||||
case XPathResult.ORDERED_NODE_ITERATOR_TYPE:
|
||||
case XPathResult.UNORDERED_NODE_ITERATOR_TYPE:
|
||||
Node n2 = result.iterateNext();
|
||||
if (n2 == null)
|
||||
{
|
||||
result = null;
|
||||
return next();
|
||||
}
|
||||
Document d2 = getDocument(n2);
|
||||
walker = getDocumentTraversal(d2)
|
||||
.createTreeWalker(n2, SHOW_FLAGS, null, expandERefs);
|
||||
return next();
|
||||
case XPathResult.ORDERED_NODE_SNAPSHOT_TYPE:
|
||||
case XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE:
|
||||
Node n3 = result.snapshotItem(snapshotIndex++);
|
||||
if (n3 == null)
|
||||
{
|
||||
result = null;
|
||||
return next();
|
||||
}
|
||||
Document d3 = getDocument(n3);
|
||||
walker = getDocumentTraversal(d3)
|
||||
.createTreeWalker(n3, SHOW_FLAGS, null, expandERefs);
|
||||
return next();
|
||||
default:
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
if (includedText != null)
|
||||
{
|
||||
// fill buffer
|
||||
if (buf == null)
|
||||
buf = new char[2048];
|
||||
try
|
||||
{
|
||||
len = includedText.read(buf, 0, buf.length);
|
||||
if (len == -1)
|
||||
{
|
||||
includedText = null;
|
||||
buf = null;
|
||||
return next();
|
||||
}
|
||||
// chars or space?
|
||||
return (event = isSpace(buf, len) ?
|
||||
XMLStreamConstants.SPACE :
|
||||
XMLStreamConstants.CHARACTERS);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
XMLStreamException e2 = new XMLStreamException(e.getMessage());
|
||||
e2.initCause(e);
|
||||
throw e2;
|
||||
}
|
||||
}
|
||||
event = super.next();
|
||||
switch (event)
|
||||
{
|
||||
case XMLStreamConstants.START_ELEMENT:
|
||||
String uri = getNamespaceURI();
|
||||
if (XINCLUDE_NS_URI.equals(uri))
|
||||
{
|
||||
String localName = getLocalName();
|
||||
if ("include".equals(localName))
|
||||
{
|
||||
href = getAttributeValue(null, "href");
|
||||
String parse = getAttributeValue(null, "parse");
|
||||
String xpointer = getAttributeValue(null, "xpointer");
|
||||
String encoding = getAttributeValue(null, "encoding");
|
||||
String accept = getAttributeValue(null, "accept");
|
||||
String acceptLanguage = getAttributeValue(null,
|
||||
"accept-language");
|
||||
if (includeResource(href, parse, xpointer, encoding,
|
||||
accept, acceptLanguage))
|
||||
{
|
||||
// Skip to xi:include end-element event
|
||||
int depth = 0;
|
||||
while (depth >= 0)
|
||||
{
|
||||
event = super.next();
|
||||
switch (event)
|
||||
{
|
||||
case XMLStreamConstants.START_ELEMENT:
|
||||
depth++;
|
||||
break;
|
||||
case XMLStreamConstants.END_ELEMENT:
|
||||
depth--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
inInclude = true;
|
||||
}
|
||||
else if (inInclude && "fallback".equals(localName))
|
||||
{
|
||||
if (!seenFallback)
|
||||
inFallback = seenFallback = true;
|
||||
else
|
||||
throw new XMLStreamException("duplicate xi:fallback element");
|
||||
}
|
||||
else if (inInclude)
|
||||
{
|
||||
throw new XMLStreamException("illegal xi element '" +
|
||||
localName + "'");
|
||||
}
|
||||
return next();
|
||||
}
|
||||
break;
|
||||
case XMLStreamConstants.END_ELEMENT:
|
||||
String uri2 = getNamespaceURI();
|
||||
if (XINCLUDE_NS_URI.equals(uri2))
|
||||
{
|
||||
String localName = getLocalName();
|
||||
if ("include".equals(localName))
|
||||
{
|
||||
if (!seenFallback && included)
|
||||
{
|
||||
String msg = "Unable to read " + href +
|
||||
" and no xi:fallback element present";
|
||||
throw new XMLStreamException(msg);
|
||||
}
|
||||
included = false;
|
||||
href = null;
|
||||
inInclude = inFallback = seenFallback = false;
|
||||
}
|
||||
else if ("fallback".equals(localName))
|
||||
inFallback = false;
|
||||
return next();
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (inInclude && !inFallback)
|
||||
return next();
|
||||
return event;
|
||||
}
|
||||
|
||||
boolean isSpace(char[] text, int len)
|
||||
{
|
||||
boolean space = true;
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
char c = text[i];
|
||||
if (c != ' ' && c != '\t' && c != '\n' && c != '\r')
|
||||
{
|
||||
space = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return space;
|
||||
}
|
||||
|
||||
String getBaseURI()
|
||||
{
|
||||
String base = (String) getParent().getProperty("gnu.xml.stream.baseURI");
|
||||
return (base == null) ? systemId : base;
|
||||
}
|
||||
|
||||
boolean includeResource(String href, String parse, String xpointer,
|
||||
String encoding, String accept,
|
||||
String acceptLanguage)
|
||||
{
|
||||
included = false;
|
||||
try
|
||||
{
|
||||
if (xpointer != null)
|
||||
throw new XMLStreamException("xpointer attribute not yet supported");
|
||||
String base = getBaseURI();
|
||||
if (href == null || "".equals(href))
|
||||
href = base;
|
||||
else
|
||||
href = XMLParser.absolutize(base, href);
|
||||
if (parse == null || "xml".equals(parse))
|
||||
{
|
||||
seen.clear();
|
||||
result = null;
|
||||
snapshotIndex = 0;
|
||||
walker = null;
|
||||
current = null;
|
||||
backtracking = false;
|
||||
|
||||
URLConnection connection = getURLConnection(href, accept,
|
||||
acceptLanguage);
|
||||
InputStream in = connection.getInputStream();
|
||||
Document doc = getDocumentBuilder().parse(in, href);
|
||||
DocumentTraversal dt = getDocumentTraversal(doc);
|
||||
if (xpointer == null)
|
||||
{
|
||||
result = null;
|
||||
Node item = doc.getDocumentElement();
|
||||
walker = dt.createTreeWalker(item, SHOW_FLAGS, null,
|
||||
expandERefs);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = null;
|
||||
snapshotIndex = 0;
|
||||
walker = null;
|
||||
// shorthand or scheme-based?
|
||||
int lpi = xpointer.indexOf('(');
|
||||
int rpi = xpointer.indexOf(')', lpi);
|
||||
if (lpi != -1 && rpi != -1)
|
||||
{
|
||||
String scheme = xpointer.substring(0, lpi);
|
||||
if ("element".equals(scheme))
|
||||
{
|
||||
// element() scheme
|
||||
String elementSchemeData =
|
||||
xpointer.substring(lpi + 1, rpi);
|
||||
Node item = doc;
|
||||
int si = elementSchemeData.indexOf('/');
|
||||
if (si == -1)
|
||||
{
|
||||
if (elementSchemeData.length() > 0)
|
||||
item = doc.getElementById(elementSchemeData);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (si > 0)
|
||||
{
|
||||
String context =
|
||||
elementSchemeData.substring(0, si);
|
||||
item = doc.getElementById(context);
|
||||
elementSchemeData =
|
||||
elementSchemeData.substring(si + 1);
|
||||
}
|
||||
StringTokenizer st =
|
||||
new StringTokenizer(elementSchemeData, "/");
|
||||
while (st.hasMoreTokens() && item != null)
|
||||
{
|
||||
int n = Integer.parseInt(st.nextToken());
|
||||
Node ctx = item.getFirstChild();
|
||||
int count = 1;
|
||||
while (ctx != null && count++ < n)
|
||||
ctx = ctx.getNextSibling();
|
||||
item = ctx;
|
||||
}
|
||||
}
|
||||
walker = dt.createTreeWalker(item, SHOW_FLAGS, null,
|
||||
expandERefs);
|
||||
included = true;
|
||||
}
|
||||
else if ("xpointer".equals(scheme))
|
||||
{
|
||||
xpointer = xpointer.substring(lpi + 1, rpi);
|
||||
XPathEvaluator eval = getXPathEvaluator(doc);
|
||||
XPathNSResolver resolver = eval.createNSResolver(doc);
|
||||
result =
|
||||
(XPathResult) eval.evaluate(xpointer, doc,
|
||||
resolver,
|
||||
XPathResult.ANY_TYPE,
|
||||
null);
|
||||
// TODO xpointer() scheme functions
|
||||
included = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
String msg = "Unknown XPointer scheme: " + scheme;
|
||||
throw new XMLStreamException(msg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Node item = doc.getElementById(xpointer);
|
||||
walker = dt.createTreeWalker(item, SHOW_FLAGS, null,
|
||||
expandERefs);
|
||||
included = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ("text".equals(parse))
|
||||
{
|
||||
URLConnection connection = getURLConnection(href, accept,
|
||||
acceptLanguage);
|
||||
InputStream in = connection.getInputStream();
|
||||
if (encoding == null)
|
||||
{
|
||||
encoding = connection.getContentEncoding();
|
||||
if (encoding == null)
|
||||
{
|
||||
String contentType = connection.getContentType();
|
||||
if (contentType != null)
|
||||
encoding = getParameter(contentType, "charset");
|
||||
}
|
||||
}
|
||||
if (encoding == null)
|
||||
includedText = new InputStreamReader(in, "UTF-8");
|
||||
else
|
||||
includedText = new InputStreamReader(in, encoding);
|
||||
included = true;
|
||||
}
|
||||
else
|
||||
throw new XMLStreamException("value of 'parse' attribute must be "+
|
||||
"'xml' or 'text'");
|
||||
return true;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
catch (XMLStreamException e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
catch (SAXException e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
URLConnection getURLConnection(String href, String accept,
|
||||
String acceptLanguage)
|
||||
throws IOException
|
||||
{
|
||||
URL url = new URL(href);
|
||||
URLConnection connection = url.openConnection();
|
||||
if (connection instanceof HttpURLConnection)
|
||||
{
|
||||
HttpURLConnection http = (HttpURLConnection) connection;
|
||||
http.setInstanceFollowRedirects(true);
|
||||
if (accept != null)
|
||||
http.setRequestProperty("Accept", accept);
|
||||
if (acceptLanguage != null)
|
||||
http.setRequestProperty("Accept-Language", acceptLanguage);
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
|
||||
Document getDocument(Node node)
|
||||
{
|
||||
if (node.getNodeType() == Node.DOCUMENT_NODE)
|
||||
return (Document) node;
|
||||
return node.getOwnerDocument();
|
||||
}
|
||||
|
||||
DocumentBuilder getDocumentBuilder()
|
||||
throws XMLStreamException
|
||||
{
|
||||
if (builder == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
|
||||
f.setXIncludeAware(true);
|
||||
f.setNamespaceAware(namespaceAware);
|
||||
f.setValidating(validating);
|
||||
builder = f.newDocumentBuilder();
|
||||
}
|
||||
catch (ParserConfigurationException e)
|
||||
{
|
||||
XMLStreamException e2 = new XMLStreamException(e.getMessage());
|
||||
e2.initCause(e);
|
||||
throw e2;
|
||||
}
|
||||
}
|
||||
builder.reset();
|
||||
return builder;
|
||||
}
|
||||
|
||||
DocumentTraversal getDocumentTraversal(Document doc)
|
||||
throws XMLStreamException
|
||||
{
|
||||
DOMImplementation dom = doc.getImplementation();
|
||||
if (!dom.hasFeature("Traversal", "2.0"))
|
||||
throw new XMLStreamException("Traversal not supported");
|
||||
return (DocumentTraversal) doc;
|
||||
}
|
||||
|
||||
XPathEvaluator getXPathEvaluator(Document doc)
|
||||
throws XMLStreamException
|
||||
{
|
||||
DOMImplementation dom = doc.getImplementation();
|
||||
if (!dom.hasFeature("XPath", "3.0"))
|
||||
throw new XMLStreamException("XPath not supported");
|
||||
return (XPathEvaluator) doc;
|
||||
}
|
||||
|
||||
static String getParameter(String contentType, String name)
|
||||
{
|
||||
StringTokenizer st = new StringTokenizer(contentType, " ;");
|
||||
if (st.hasMoreTokens())
|
||||
st.nextToken();
|
||||
while (st.hasMoreTokens())
|
||||
{
|
||||
String token = st.nextToken();
|
||||
int ei = token.indexOf('=');
|
||||
if (ei != -1)
|
||||
{
|
||||
String key = token.substring(0, ei);
|
||||
if (key.equals(name))
|
||||
{
|
||||
String value = token.substring(ei + 1);
|
||||
int len = value.length();
|
||||
if (len > 1 &&
|
||||
value.charAt(0) == '"' &&
|
||||
value.charAt(len - 1) == '"')
|
||||
value = value.substring(1, len - 1);
|
||||
else if (len > 1 &&
|
||||
value.charAt(0) == '\'' &&
|
||||
value.charAt(len - 1) == '\'')
|
||||
value = value.substring(1, len - 1);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue