diff options
author | doko <doko@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-10-21 17:55:01 +0000 |
---|---|---|
committer | doko <doko@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-10-21 17:55:01 +0000 |
commit | 2bc043354c4edb1f5aad751285060fb722a63ea1 (patch) | |
tree | 6de8da5758622565799768e49cd0de6698ca3cb8 /libjava/classpath/java/util | |
parent | be9f921eb27de7f5f22e4755df15340ab8042a09 (diff) | |
download | gcc-2bc043354c4edb1f5aad751285060fb722a63ea1.tar.gz |
libjava/ChangeLog:
2008-10-21 Andrew John Hughes <gnu_andrew@member.fsf.org>
* sources.am, Makfile.in: Regenerate.
2008-10-17 Matthias Klose <doko@ubuntu.com>
* configure.ac: Fix bashisms.
* configure: Regenerate.
2008-10-15 Matthias Klose <doko@ubuntu.com>
* configure.ac: Disable build of gjdoc, if configured without
--with-antlr-jar or if no antlr.jar found.
* configure: Regenerate.
2008-10-09 Andrew John Hughes <gnu_andrew@member.fsf.org>
* classpath/configure.ac,
* classpath/m4/ac_prog_antlr.m4,
* classpath/m4/ac_prog_java.m4,
* classpath/tools/Makefile.am:
Ported --regen-gjdoc-parser patch and
cantlr support from GNU Classpath.
2008-10-06 Andrew Haley <aph@redhat.com>
* java/lang/Thread.java (Thread): Always create the ThreadLocalMap
when creating a thread.
(getThreadLocals) Don't lazily create the ThreadLocalMap.
2008-09-28 Andrew John Hughes <gnu_andrew@member.fsf.org>
* classpath/java/lang/ThreadLocalMap.java,
* java/lang/ThreadLocalMap$Entry.h,
* java/lang/ThreadLocalMap.h,
* lib/java/lang/ThreadLocalMap.class,
* lib/java/lang/ThreadLocalMap$Entry.class:
Add the new files for the ThreadLocal patch.
2008-09-28 Andrew John Hughes <gnu_andrew@member.fsf.org>
* classpath/ChangeLog,
* classpath/java/lang/InheritableThreadLocal.java,
* classpath/java/lang/Thread.java,
* classpath/java/lang/ThreadLocal.java:
Merge Daniel Frampton's ThreadLocal patch.
* gcj/javaprims.h: Updated.
* java/lang/Thread.h: Regenerated.
* java/lang/Thread.java:
Replace WeakIdentityHashMap with ThreadLocalMap.
(getThreadLocals()): Likewise.
* java/lang/ThreadLocal.h: Regenerated.
* java/lang/ThreadLocal.java:
(computeNextHash()): New method.
(ThreadLocal()): Initialise fastHash.
(internalGet()): Updated to match Classpath's get().
(internalSet(Object)): Likewise for set(Object).
(internalRemove()): Likewise for remove().
2008-09-25 Andrew John Hughes <gnu_andrew@member.fsf.org>
* classpath/configure,
* classpath/configure.ac:
Resynchronise with Classpath's configure.
* classpath/examples/Makefile.in:
Add equivalent support for building as in
tools/Makefile.in.
* classpath/java/nio/Buffer.java,
* classpath/java/nio/ByteBuffer.java,
* classpath/java/nio/ByteBufferImpl.java,
* classpath/java/nio/CharBuffer.java,
* classpath/java/nio/CharBufferImpl.java,
* classpath/java/nio/CharSequenceBuffer.java,
* classpath/java/nio/CharViewBufferImpl.java,
* classpath/java/nio/DirectByteBufferImpl.java,
* classpath/java/nio/DoubleBuffer.java,
* classpath/java/nio/DoubleBufferImpl.java,
* classpath/java/nio/DoubleViewBufferImpl.java,
* classpath/java/nio/FloatBuffer.java,
* classpath/java/nio/FloatBufferImpl.java,
* classpath/java/nio/FloatViewBufferImpl.java,
* classpath/java/nio/IntBuffer.java,
* classpath/java/nio/IntBufferImpl.java,
* classpath/java/nio/IntViewBufferImpl.java,
* classpath/java/nio/LongBuffer.java,
* classpath/java/nio/LongBufferImpl.java,
* classpath/java/nio/LongViewBufferImpl.java,
* classpath/java/nio/MappedByteBuffer.java,
* classpath/java/nio/MappedByteBufferImpl.java,
* classpath/java/nio/ShortBuffer.java,
* classpath/java/nio/ShortBufferImpl.java,
* classpath/java/nio/ShortViewBufferImpl.java:
Replace use of gnu.classpath.Pointer with gnu.gcj.RawData,
and fix some formatting issues.
* classpath/tools/gnu/classpath/tools/gjdoc/expr/JavaLexer.java,
* classpath/tools/gnu/classpath/tools/gjdoc/expr/JavaLexer.smap,
* classpath/tools/gnu/classpath/tools/gjdoc/expr/JavaRecognizer.java,
* classpath/tools/gnu/classpath/tools/gjdoc/expr/JavaRecognizer.smap,
* classpath/tools/gnu/classpath/tools/gjdoc/expr/JavaTokenTypes.java,
* classpath/tools/gnu/classpath/tools/gjdoc/expr/JavaTokenTypes.txt:
Regenerated (later version of antlr).
* java/nio/Buffer.h: Regenerated.
* java/nio/Buffer.java: Ported changes from Classpath.
* java/nio/ByteBuffer.h,
* java/nio/CharBuffer.h: Regenerated.
* java/nio/DirectByteBufferImpl.java: Ported changes from
Classpath.
* java/nio/DoubleBuffer.h,
* java/nio/FloatBuffer.h,
* java/nio/IntBuffer.h,
* java/nio/LongBuffer.h,
* java/nio/MappedByteBuffer.h,
* java/nio/MappedByteBufferImpl.h: Regenerated.
* java/nio/MappedByteBufferImpl.java: Ported changes from
Classpath.
* java/nio/ShortBuffer.h: Regenerated.
2008-09-24 Matthias Klose <doko@ubuntu.com>
* configure.ac: Search for antlr.jar, if not configured.
* configure: Regenerate.
2008-09-24 Matthias Klose <doko@ubuntu.com>
* Makefile.am: Build a gjdoc binary, if enabled.
* configure.ac: Add options --disable-gjdoc, --with-antlr-jar=file.
* Makefile.in, */Makefile.in, configure: Regenerate.
2008-09-22 Andrew Haley <aph@redhat.com>
* java/lang/String.java (toString(char[], int, int)): New method.
2008-09-14 Matthias Klose <doko@ubuntu.com>
Import GNU Classpath (libgcj-import-20080914).
* Regenerate class and header files.
* Regenerate auto* files.
* configure.ac: Don't pass --disable-gjdoc to classpath.
* sources.am: Regenerated.
* HACKING: Mention to build gjdoc in maintainer builds.
* gnu/classpath/Configuration.java: Update classpath version.
* gcj/javaprims.h: Update.
2008-09-08 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Makefile.am: Replace natStringBuffer.cc
and natStringBuilder.cc with natAbstractStringBuffer.cc.
* Makefile.in: Regenerated.
* java/lang/AbstractStringBuffer.java:
(append(int)): Made native.
(regionMatches(int,String)): Likewise.
* java/lang/StringBuffer.h: Regenerated.
* java/lang/StringBuffer.java: Remerged with GNU Classpath.
* java/lang/StringBuilder.h: Regenerated.
* java/lang/StringBuilder.java: Remerged with GNU Classpath.
* java/lang/natAbstractStringBuffer.cc: Provide common
native methods for StringBuffer and StringBuilder.
* java/lang/natStringBuffer.cc,
* java/lang/natStringBuilder.cc: Removed.
2008-09-04 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Makefile.in,
* classpath/configure: Regenerated.
* gnu/gcj/util/natDebug.cc,
* gnu/gcj/xlib/natColormap.cc,
* gnu/gcj/xlib/natDisplay.cc,
* gnu/gcj/xlib/natDrawable.cc,
* gnu/gcj/xlib/natFont.cc,
* gnu/gcj/xlib/natWMSizeHints.cc,
* gnu/gcj/xlib/natWindow.cc,
* gnu/gcj/xlib/natXImage.cc:
Add :: prefix to namespaces.
* java/io/CharArrayWriter.h,
* java/lang/StringBuffer.h:
Regenerated using patched gjavah.
* java/lang/natStringBuffer.cc:
Fix naming of append(jint).
* java/sql/Timestamp.h: Regenerated
using patched gjavah.
* jni.cc: Rename p to functions
to match change in GNU Classpath.
* scripts/makemake.tcl: Switch
gnu.java.math to BC compilation.
* sources.am: Regenerated.
2008-08-21 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Makefile.in: Updated location of Configuration.java.
* classpath/lib/gnu/java/locale/LocaleData.class: Regenerated.
2008-08-18 Andrew John Hughes <gnu_andrew@member.fsf.org>
* Makefile.in: Updated with new Java files.
* classpath/configure: Regenerated.
* classpath/tools/Makefile.am: Add missing
use of GJDOC_EX so --disable-gjdoc works.
* classpath/tools/Makefile.in: Regenerated.
2008-08-15 Matthias Klose <doko@ubuntu.com>
Import GNU Classpath (libgcj-import-20080811).
* Regenerate class and header files.
* Regenerate auto* files.
* configure.ac: Don't pass --with-fastjar to classpath, substitute new
dummy value in classpath/gnu/classpath/Configuration.java.in, pass
--disable-gjdoc to classpath.
* scripts/makemake.tcl:
* sources.am: Regenerated.
* java/lang/AbstractStringBuffer.java, gnu/java/lang/VMCPStringBuilder.java:
New, copied from classpath, use System instead of VMSystem.
* java/lang/StringBuffer.java: Merge from classpath.
* java/lang/ClassLoader.java: Merge from classpath.
* gcj/javaprims.h: Update class definitions,
remove _Jv_jobjectRefType, jobjectRefType definitions.
libjava/classpath/ChangeLog.gcj:
2008-10-21 Matthias Klose <doko@ubuntu.com>
* classpath/tools/gnu/classpath/tools/gjdoc/expr/Java*: Move from ...
* classpath/tools/generated/gnu/classpath/tools/gjdoc/expr/ ... here.
* Update .class files.
2008-10-21 Andrew John Hughes <gnu_andrew@member.fsf.org>
* tools/Makefile.am:
Always generate parser in the srcdir.
2008-10-21 Matthias Klose <doko@ubuntu.com>
* doc/Makefile.am (MAINTAINERCLEANFILES): Add gjdoc.1.
* doc/Makefile.in: Regenerate.
2008-10-20 Matthias Klose <doko@ubuntu.com>
* configure.ac: Don't check for working java, if not configured
with --enable-java-maintainer-mode.
* configure: Regenerate.
2008-10-19 Matthias Klose <doko@ubuntu.com>
* m4/ac_prog_java.m4: Revert previous change.
* m4/ac_prog_javac.m4: Apply it here.
* configure: Regenerate.
2008-10-19 Matthias Klose <doko@ubuntu.com>
* m4/ac_prog_javac.m4: Don't check for working javac, if not configured
with --enable-java-maintainer-mode.
* configure: Regenerate.
* Makefile.in, */Makefile.in: Regenerate.
2008-09-30 Matthias Klose <doko@ubuntu.com>
* m4/ac_prog_antlr.m4: Check for cantlr binary as well.
2008-09-29 Matthias Klose <doko@ubuntu.com>
* m4/ac_prog_antlr.m4: Check for antlr binary as well.
2008-09-28 Matthias Klose <doko@ubuntu.com>
* PR libgcj/37636. Revert:
2008-02-20 Matthias Klose <doko@ubuntu.com>
* tools/Makefile.am ($(TOOLS_ZIP)): Revert part of previous change,
Do copy resource files in JAVA_MAINTAINER_MODE only.
* tools/Makefile.in: Regenerate.
2008-09-14 Matthias Klose <doko@ubuntu.com>
* m4/ac_prog_javac_works.m4, m4/ac_prog_javac.m4, m4/acinclude.m4:
Revert local changes.
* m4/ac_prog_antlr.m4: Check for an runantlr binary.
* tools/Makefile.am, lib/Makefile.am: Revert local changes (JCOMPILER).
* tools/Makefile.am: Remove USE_JAVAC_FLAGS, pass ANTLR_JAR in
GLIBJ_CLASSPATH.
2008-09-14 Matthias Klose <doko@ubuntu.com>
Revert:
Daniel Frampton <zyridium at zyridium.net>
* AUTHORS: Added.
* java/lang/InheritableThreadLocal.java,
* java/lang/Thread.java,
* java/lang/ThreadLocal.java:
Modified to use java.lang.ThreadLocalMap.
* java/lang/ThreadLocalMap.java:
New cheaper ThreadLocal-specific WeakHashMap.
2008-08-15 Matthias Klose <doko@ubuntu.com>
* m4/acinclude.m4 (CLASSPATH_JAVAC_MEM_CHECK): Remove unknown
args for javac.
libjava/classpath/ChangeLog:
2008-10-20 Andrew John Hughes <gnu_andrew@member.fsf.org>
* m4/ac_prog_antlr.m4:
Remove redundant checks.
* tools/Makefile.am:
Use gjdoc_gendir when calling antlr.
2008-10-15 Andrew John Hughes <gnu_andrew@member.fsf.org>
* configure.ac:
Remove superfluous AC_PROG_JAVA call.
2008-10-06 Andrew John Hughes <gnu_andrew@member.fsf.org>
* m4/ac_prog_antlr:
Check for cantlr as well.
* tools/Makefile.am:
Only build GJDoc parser when both
CREATE_GJDOC and CREATE_GJDOC_PARSER
are on.
2008-10-02 Andrew John Hughes <gnu_andrew@member.fsf.org>
* configure.ac:
Add regen-gjdoc-parser option,
and separate antlr tests.
* m4/ac_prog_antlr.m4:
Turn single test into AC_LIB_ANTLR
and AC_PROG_ANTLR.
* m4/ac_prog_java.m4:
Quote tests.
* tools/Makefile.am:
Support CREATE_GJDOC_PARSER option.
2008-09-14 Andrew John Hughes <gnu_andrew@member.fsf.org>
* examples/Makefile.am:
Check lib directly as well as glibj.zip
for boot classes.
* m4/acinclude.m4:
Only require the class files to be built
to allow the tools and examples to be built,
not the installation of glibj.zip.
* tools/Makefile.am:
Check lib directly as well as glibj.zip
for boot classes.
2008-09-13 Andrew John Hughes <gnu_andrew@member.fsf.org>
* examples/Makefile.am,
* lib/Makefile.am:
Add GCJ rules.
* m4/ac_prog_javac.m4:
Check whether JAVAC is gcj.
* m4/ac_prog_javac_works.m4:
Add GCJ rules.
* m4/acinclude.m4:
Don't bother checking for -J
if using GCJ.
* tools/Makefile.am:
Add GCJ rules.
2007-08-23 Daniel Frampton <zyridium@zyridium.net>
* AUTHORS: Added.
* java/lang/InheritableThreadLocal.java,
* java/lang/Thread.java,
* java/lang/ThreadLocal.java:
Modified to use java.lang.ThreadLocalMap.
* java/lang/ThreadLocalMap.java:
New cheaper ThreadLocal-specific WeakHashMap.
2008-02-07 Ian Rogers <ian.rogers@manchester.ac.uk>
* java/util/zip/ZipEntry.java:
Use byte fields instead of integer fields,
store the time as well as the DOS time and
don't retain a global Calendar instance.
(setDOSTime(int)): Set KNOWN_DOSTIME instead
of KNOWN_TIME, and unset KNOWN_TIME.
(getDOSTime()): Compute DOS time from UNIX time
only when needed.
(clone()): Provide cloning via the ZipEntry constructor
where possible.
(setTime(long)): Don't compute DOS time at this point.
(getCalendar()): Removed.
2008-09-09 Andrew John Hughes <gnu_andrew@member.fsf.org>
* tools/gnu/classpath/tools/getopt/Parser.java:
(setHeader(String)): Make synchronized.
(setFooter(String)): Likewise.
* tools/gnu/classpath/tools/rmic/SourceGiopRmicCompiler.java,
(reset()): Make synchronized.
(name(Class)): Likewise.
2008-09-04 Robert Schuster <robertschuster@fsfe.org>
* gnu/java/nio/charset/ByteDecodeLoopHelper:
(arrayDecodeLoop): Added new break label, escape to that label.
* gnu/java/nio/charset/ByteEncodeLoopHelper:
(arrayDecodeLoop): Added new break label, escape to that label.
2008-09-04 Robert Schuster <robertschuster@fsfe.org>
* java/text/DecimalFormat.java:
(scanFix): Use 'i + 1' when looking at following character.
(scanNegativePattern): Dito.
2008-09-02 Andrew John Hughes <gnu_andrew@member.fsf.org>
* tools/gnu/classpath/tools/javah/ClassWrapper.java:
(makeVtable()): Populate methodNameMap.
(printMethods(CniPrintStream)): Always use pre-populated
methodNameMap for bridge targets.
2008-09-01 Mario Torre <neugens@aicas.com>
* gnu/java/awt/peer/x/XImage.java (XImageProducer): remove @Override
annotation to allow compilation on javac < 1.6 and ecj < 3.4.
2008-09-01 Mario Torre <neugens@aicas.com>
* gnu/java/awt/peer/x/XGraphicsDevice.java (getDisplay): fix to support
new Escher API.
* gnu/java/awt/peer/x/XImage.java (getSource): method implemented.
* gnu/java/awt/peer/x/XImage.java (XImageProducer): implement ImageProducer
for getSource.
2008-09-01 Andrew John Hughes <gnu_andrew@member.fsf.org>
* gnu/java/util/regex/BacktrackStack.java,
* gnu/java/util/regex/CharIndexed.java,
* gnu/java/util/regex/CharIndexedCharArray.java,
* gnu/java/util/regex/CharIndexedCharSequence.java,
* gnu/java/util/regex/CharIndexedInputStream.java,
* gnu/java/util/regex/CharIndexedString.java,
* gnu/java/util/regex/CharIndexedStringBuffer.java,
* gnu/java/util/regex/RE.java,
* gnu/java/util/regex/REException.java,
* gnu/java/util/regex/REFilterInputStream.java,
* gnu/java/util/regex/REMatch.java,
* gnu/java/util/regex/REMatchEnumeration.java,
* gnu/java/util/regex/RESyntax.java,
* gnu/java/util/regex/REToken.java,
* gnu/java/util/regex/RETokenAny.java,
* gnu/java/util/regex/RETokenBackRef.java,
* gnu/java/util/regex/RETokenChar.java,
* gnu/java/util/regex/RETokenEnd.java,
* gnu/java/util/regex/RETokenEndOfPreviousMatch.java,
* gnu/java/util/regex/RETokenEndSub.java,
* gnu/java/util/regex/RETokenIndependent.java,
* gnu/java/util/regex/RETokenLookAhead.java,
* gnu/java/util/regex/RETokenLookBehind.java,
* gnu/java/util/regex/RETokenNamedProperty.java,
* gnu/java/util/regex/RETokenOneOf.java,
* gnu/java/util/regex/RETokenPOSIX.java,
* gnu/java/util/regex/RETokenRange.java,
* gnu/java/util/regex/RETokenRepeated.java,
* gnu/java/util/regex/RETokenStart.java,
* gnu/java/util/regex/RETokenWordBoundary.java,
* gnu/java/util/regex/UncheckedRE.java:
Fix indentation.
2008-09-01 Andrew John Hughes <gnu_andrew@member.fsf.org>
* gnu/java/util/regex/RETokenStart.java:
(getMaximumLength()): Add Override annotation.
(matchThis(CharIndexed, REMatch)): Likewise.
(returnsFixedLengthMatches()): Renamed from
returnsFixedLengthmatches and added Override
annotation.
(findFixedLengthMatches(CharIndexed,REMatch,int)):
Add Override annotation.
(dump(CPStringBuilder)): Likewise.
* gnu/javax/print/ipp/IppRequest.java:
(RequestWriter.writeOperationAttributes(AttributeSet)):
Throw exception, don't just create and drop it.
* javax/management/MBeanServerPermission.java:
(MBeanServerPermissionCollection.add(Permission)): Compare
against individual Strings not the entire array, and
store the result of replace.
* javax/swing/text/html/StyleSheet.java:
(setBaseFontSize(size)): Store result of trim().
2008-09-01 Andrew John Hughes <gnu_andrew@member.fsf.org>
* javax/tools/FileObject.java:
(openReader(boolean)): Document new parameter.
2008-03-27 Michael Franz <mvfranz@gmail.com>
PR classpath/35690:
* javax/tools/FileObject.java:
(toUri()): Fix case from toURI.
(openReader(boolean)): Add missing boolean argument.
2008-08-26 Andrew John Hughes <gnu_andrew@member.fsf.org>
PR classpath/35487:
* gnu/javax/management/Server.java:
(beans): Change to ConcurrentHashMap.
(defaultDomain): Make final.
(outer): Likewise.
(LazyListenersHolder): Added to wrap
listeners, also now a ConcurrentHashMap,
providing lazy initialisation safely.
(sequenceNumber): Documented.
(getBean(ObjectName)): Remove redundant cast.
(addNotificationListener(ObjectName,NotificationListener,
NotificationFilter,Object)): Remove map initialisation
and use holder.
(getObjectInstance(ObjectName)): Remove redundant cast.
(registerMBean(Object,ObjectName)): Add bean atomically.
(removeNotificationListener(ObjectName,NotificationListener)):
Simplified.
(removeNotificationListener(ObjectName,NotificationListener,
NotificationFilter,Object)): Likewise.
(notify(ObjectName,String)): Documented.
2008-08-26 Andrew John Hughes <gnu_andrew@member.fsf.org>
* gnu/javax/management/Server.java:
Genericised.
2008-08-26 Andrew John Hughes <gnu_andrew@member.fsf.org>
* gnu/javax/management/Translator.java:
Genericised.
2008-08-26 Andrew John Hughes <gnu_andrew@member.fsf.org>
* javax/management/DefaultLoaderRepository.java,
* javax/management/JMX.java,
* javax/management/MBeanAttributeInfo.java,
* javax/management/MBeanConstructorInfo.java,
* javax/management/MBeanOperationInfo.java,
* javax/management/MBeanServerDelegate.java:
Fix warnings due to generics.
2008-08-25 Andrew John Hughes <gnu_andrew@member.fsf.org>
* javax/management/MBeanPermission.java,
* javax/management/MBeanServerDelegate.java,
* javax/management/MBeanServerFactory.java,
* javax/management/MBeanServerInvocationHandler.java,
* javax/management/MBeanServerPermission.java:
Fix warnings due to use of non-generic collections.
2008-08-25 Mario Torre <neugens@aicas.com>
* gnu/javax/rmi/CORBA/RmiUtilities.java (readValue): check if sender is
null to avoid NPE.
2008-08-22 Mario Torre <neugens@aicas.com>
* gnu/CORBA/OrbFunctional.java (set_parameters): Fix
NullPointerException checking when param is null.
2008-08-23 Andrew John Hughes <gnu_andrew@member.fsf.org>
* java/util/regex/Matcher.java:
(reset()): Reset append position so
we don't try and append to the end of
the old input.
2008-08-22 Andrew John Hughes <gnu_andrew@member.fsf.org>
PR classpath/32028:
* m4/acinclude.m4:
Also allow versions of GJDoc from 0.8* on, as
CVS is 0.8.0-pre.
2008-08-21 Andrew John Hughes <gnu_andrew@member.fsf.org>
PR classpath/32028:
* m4/acinclude.m4:
(CLASSPATH_WITH_GJDOC): Ensure version 0.7.9 is
being used.
2008-08-20 Andrew John Hughes <gnu_andrew@member.fsf.org>
* tools/Makefile.am:
Add taglets subdirectory to list of excluded
paths when GJDoc is not compiled.
2008-08-19 David P Grove <groved@us.ibm.com>
* scripts/check_jni_methods.sh.in:
Fix build issue on AIX by splitting generation
of method list.
2008-08-18 Andrew John Hughes <gnu_andrew@member.fsf.org>
* native/jni/gstreamer-peer/gst_native_pipeline.c:
(get_free_space(int)): Use #else not #elif when
there is no condition.
2008-08-17 Andrew John Hughes <gnu_andrew@member.fsf.org>
PR classpath/31895:
* java/text/DecimalFormat.java:
(setCurrency(Currency)): Update prefixes and
suffixes when currency changes.
* java/text/DecimalFormatSymbols.java:
(DecimalFormatSymbols(Locale)): Set locale earlier
so it can be used by setCurrency(Currency).
(setCurrency(Currency)): Set the symbol correctly using
the locale of the instance.
* java/util/Currency.java:
Throw error instead of just printing a message.
2008-08-17 Andrew John Hughes <gnu_andrew@member.fsf.org>
* javax/activation/ActivationDataFlavor.java:
Suppress warnings from public API.
(mimeType): Made final.
(representationClass): Added generic type and
made final.
(normalizeMimeTypeParameter(String,String)):
Use CPStringBuilder.
* javax/activation/CommandInfo.java:
(verb): Made final.
(className): Made final.
* javax/activation/DataHandler.java:
(dataSource): Made final.
* javax/activation/FileDataSource.java:
(file): Made final.
* javax/activation/MailcapCommandMap.java:
Use generics on collections and CPStringBuilder
instead of StringBuffer.
* javax/activation/MimeType.java:
(toString()): Use CPStringBuilder.
(getBaseType()): Likewise.
* javax/activation/MimeTypeParameterList.java:
Use generics on collections and CPStringBuilder
instead of StringBuffer.
* javax/activation/MimeTypeParseException.java:
(MimeTypeParseException(String,String)): Use
CPStringBuilder.
* javax/activation/MimetypesFileTypeMap.java:
Use generics on collections and CPStringBuilder
instead of StringBuffer.
* javax/activation/URLDataSource.java:
(url): Made final.
2008-08-17 Andrew John Hughes <gnu_andrew@member.fsf.org>
* gnu/javax/activation/viewers/ImageViewer.java,
* gnu/javax/activation/viewers/TextEditor.java,
* gnu/javax/activation/viewers/TextViewer.java,
* javax/activation/ActivationDataFlavor.java,
* javax/activation/CommandInfo.java,
* javax/activation/CommandMap.java,
* javax/activation/CommandObject.java,
* javax/activation/DataContentHandler.java,
* javax/activation/DataContentHandlerFactory.java,
* javax/activation/DataHandler.java,
* javax/activation/DataHandlerDataSource.java,
* javax/activation/DataSource.java,
* javax/activation/DataSourceDataContentHandler.java,
* javax/activation/FileDataSource.java,
* javax/activation/FileTypeMap.java,
* javax/activation/MailcapCommandMap.java,
* javax/activation/MimeType.java,
* javax/activation/MimeTypeParameterList.java,
* javax/activation/MimeTypeParseException.java,
* javax/activation/MimetypesFileTypeMap.java,
* javax/activation/ObjectDataContentHandler.java,
* javax/activation/URLDataSource.java,
* javax/activation/UnsupportedDataTypeException.java,
* javax/activation/package.html,
* resource/META-INF/mailcap.default,
* resource/META-INF/mimetypes.default:
Import GNU JAF CVS as of 17/08/2008.
2006-04-25 Archit Shah <ashah@redhat.com>
* javax/activation/MimeTypeParameterList.java:
Insert ';' separator before parameter list.
2005-06-29 Xavier Poinsard <xpoinsard@openpricer.com>
* javax/activation/ObjectDataContentHandler.java:
Fixed typo.
2005-05-28 Chris Burdess <dog@bluezoo.org>
* javax/activation/CommandMap.java,
* javax/activation/MailcapCommandMap.java:
Updated to JAF 1.1.
2004-06-09 Chris Burdess <dog@bluezoo.org>
* javax/activation/MailcapCommandMap.java:
Fixed bug whereby x-java prefix was not
attempted.
2008-08-17 Andrew John Hughes <gnu_andrew@member.fsf.org>
* AUTHORS: Added Laszlo.
2008-04-20 Andrew John Hughes <gnu_andrew@member.fsf.org>
PR classpath/30436:
* java/util/Scanner.java:
Fix package to be java.util and correct
indentation.
2007-07-25 Laszlo Andras Hernadi <e0327023@student.tuwien.ac.at>
PR classpath/30436:
* java/util/Scanner.java:
Initial implementation.
2008-08-17 Andrew John Hughes <gnu_andrew@member.fsf.org>
* java/util/regex/Matcher.java:
(toMatchResult()): Implemented.
2008-08-13 Joshua Sumali <jsumali@redhat.com>
* doc/Makefile.am (gjdoc.pod): Generate gjdoc pod from cp-tools.texinfo
instead of invoke.texi. Remove invoke.texi from EXTRA_DIST.
* doc/invoke.texi: Removed and merged into ...
* doc/cp-tools.texinfo: Here
2008-08-12 Robert Schuster <robertschuster@fsfe.org>
* native/jni/java-net/local.c
(local_bind): Removed fprintf call, fixed access outside
of array bounds.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@141271 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/java/util')
32 files changed, 2912 insertions, 204 deletions
diff --git a/libjava/classpath/java/util/AbstractCollection.java b/libjava/classpath/java/util/AbstractCollection.java index ef74342237a..a11654ebbaf 100644 --- a/libjava/classpath/java/util/AbstractCollection.java +++ b/libjava/classpath/java/util/AbstractCollection.java @@ -38,6 +38,8 @@ exception statement from your version. */ package java.util; +import gnu.java.lang.CPStringBuilder; + import java.lang.reflect.Array; /** @@ -434,7 +436,7 @@ public abstract class AbstractCollection<E> public String toString() { Iterator itr = iterator(); - StringBuffer r = new StringBuffer("["); + CPStringBuilder r = new CPStringBuilder("["); boolean hasNext = itr.hasNext(); while (hasNext) { diff --git a/libjava/classpath/java/util/AbstractMap.java b/libjava/classpath/java/util/AbstractMap.java index 02a30a294de..5d59db9a666 100644 --- a/libjava/classpath/java/util/AbstractMap.java +++ b/libjava/classpath/java/util/AbstractMap.java @@ -39,6 +39,8 @@ exception statement from your version. */ package java.util; +import gnu.java.lang.CPStringBuilder; + import java.io.Serializable; /** @@ -524,7 +526,7 @@ public abstract class AbstractMap<K, V> implements Map<K, V> public String toString() { Iterator<Map.Entry<K, V>> entries = entrySet().iterator(); - StringBuilder r = new StringBuilder("{"); + CPStringBuilder r = new CPStringBuilder("{"); for (int pos = size(); pos > 0; pos--) { Map.Entry<K, V> entry = entries.next(); diff --git a/libjava/classpath/java/util/ArrayList.java b/libjava/classpath/java/util/ArrayList.java index 0693049b53a..1fb25d80152 100644 --- a/libjava/classpath/java/util/ArrayList.java +++ b/libjava/classpath/java/util/ArrayList.java @@ -472,8 +472,7 @@ public class ArrayList<E> extends AbstractList<E> // use of a negative index will cause an ArrayIndexOutOfBoundsException, // a subclass of the required exception, with no effort on our part. if (index > size) - throw new IndexOutOfBoundsException("Index: " + index + ", Size: " - + size); + raiseBoundsError(index); } /** @@ -488,11 +487,25 @@ public class ArrayList<E> extends AbstractList<E> // use of a negative index will cause an ArrayIndexOutOfBoundsException, // a subclass of the required exception, with no effort on our part. if (index >= size) - throw new IndexOutOfBoundsException("Index: " + index + ", Size: " - + size); + raiseBoundsError(index); } /** + * Raise the ArrayIndexOfOutBoundsException. + * + * @param index the index of the access + * @throws IndexOutOfBoundsException unconditionally + */ + private void raiseBoundsError(int index) + { + // Implementaion note: put in a separate method to make the JITs job easier + // (separate common from uncommon code at method boundaries when trivial to + // do so). + throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size); + } + + + /** * Remove from this list all elements contained in the given collection. * This is not public, due to Sun's API, but this performs in linear * time while the default behavior of AbstractList would be quadratic. diff --git a/libjava/classpath/java/util/Arrays.java b/libjava/classpath/java/util/Arrays.java index e5f772778c2..d154eb1d1ba 100644 --- a/libjava/classpath/java/util/Arrays.java +++ b/libjava/classpath/java/util/Arrays.java @@ -39,6 +39,8 @@ exception statement from your version. */ package java.util; +import gnu.java.lang.CPStringBuilder; + import java.io.Serializable; import java.lang.reflect.Array; @@ -2935,7 +2937,7 @@ public class Arrays { if (v == null) return "null"; - StringBuilder b = new StringBuilder("["); + CPStringBuilder b = new CPStringBuilder("["); for (int i = 0; i < v.length; ++i) { if (i > 0) @@ -2957,7 +2959,7 @@ public class Arrays { if (v == null) return "null"; - StringBuilder b = new StringBuilder("["); + CPStringBuilder b = new CPStringBuilder("["); for (int i = 0; i < v.length; ++i) { if (i > 0) @@ -2979,7 +2981,7 @@ public class Arrays { if (v == null) return "null"; - StringBuilder b = new StringBuilder("["); + CPStringBuilder b = new CPStringBuilder("["); for (int i = 0; i < v.length; ++i) { if (i > 0) @@ -3001,7 +3003,7 @@ public class Arrays { if (v == null) return "null"; - StringBuilder b = new StringBuilder("["); + CPStringBuilder b = new CPStringBuilder("["); for (int i = 0; i < v.length; ++i) { if (i > 0) @@ -3023,7 +3025,7 @@ public class Arrays { if (v == null) return "null"; - StringBuilder b = new StringBuilder("["); + CPStringBuilder b = new CPStringBuilder("["); for (int i = 0; i < v.length; ++i) { if (i > 0) @@ -3045,7 +3047,7 @@ public class Arrays { if (v == null) return "null"; - StringBuilder b = new StringBuilder("["); + CPStringBuilder b = new CPStringBuilder("["); for (int i = 0; i < v.length; ++i) { if (i > 0) @@ -3067,7 +3069,7 @@ public class Arrays { if (v == null) return "null"; - StringBuilder b = new StringBuilder("["); + CPStringBuilder b = new CPStringBuilder("["); for (int i = 0; i < v.length; ++i) { if (i > 0) @@ -3089,7 +3091,7 @@ public class Arrays { if (v == null) return "null"; - StringBuilder b = new StringBuilder("["); + CPStringBuilder b = new CPStringBuilder("["); for (int i = 0; i < v.length; ++i) { if (i > 0) @@ -3111,7 +3113,7 @@ public class Arrays { if (v == null) return "null"; - StringBuilder b = new StringBuilder("["); + CPStringBuilder b = new CPStringBuilder("["); for (int i = 0; i < v.length; ++i) { if (i > 0) @@ -3122,7 +3124,7 @@ public class Arrays return b.toString(); } - private static void deepToString(Object[] v, StringBuilder b, HashSet seen) + private static void deepToString(Object[] v, CPStringBuilder b, HashSet seen) { b.append("["); for (int i = 0; i < v.length; ++i) @@ -3171,7 +3173,7 @@ public class Arrays if (v == null) return "null"; HashSet seen = new HashSet(); - StringBuilder b = new StringBuilder(); + CPStringBuilder b = new CPStringBuilder(); deepToString(v, b, seen); return b.toString(); } diff --git a/libjava/classpath/java/util/BitSet.java b/libjava/classpath/java/util/BitSet.java index e4f923b7f22..13bf8a13cff 100644 --- a/libjava/classpath/java/util/BitSet.java +++ b/libjava/classpath/java/util/BitSet.java @@ -36,6 +36,9 @@ obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ package java.util; + +import gnu.java.lang.CPStringBuilder; + import java.io.Serializable; /* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3 @@ -687,7 +690,7 @@ public class BitSet implements Cloneable, Serializable */ public String toString() { - StringBuffer r = new StringBuffer("{"); + CPStringBuilder r = new CPStringBuilder("{"); boolean first = true; for (int i = 0; i < bits.length; ++i) { diff --git a/libjava/classpath/java/util/Calendar.java b/libjava/classpath/java/util/Calendar.java index 712296b1a2a..0449e126db8 100644 --- a/libjava/classpath/java/util/Calendar.java +++ b/libjava/classpath/java/util/Calendar.java @@ -39,6 +39,8 @@ exception statement from your version. */ package java.util; +import gnu.java.lang.CPStringBuilder; + import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -485,6 +487,28 @@ public abstract class Calendar } /** + * The set of properties for obtaining the minimum number of days in + * the first week. + */ + private static transient final Properties properties; + + /** + * Reads in the properties. + */ + static + { + properties = new Properties(); + try + { + properties.load(Calendar.class.getResourceAsStream("weeks.properties")); + } + catch (IOException exception) + { + System.out.println("Failed to load weeks resource: " + exception); + } + } + + /** * Constructs a new Calendar with the default time zone and the default * locale. */ @@ -505,9 +529,13 @@ public abstract class Calendar lenient = true; String[] days = { "", "sun", "mon", "tue", "wed", "thu", "fri", "sat" }; - ResourceBundle rb = getBundle(locale); - String min = (String) rb.getObject("minNumberOfDaysInFirstWeek"); - String first = (String) rb.getObject("firstDayOfWeek"); + String country = locale.getCountry(); + String min = properties.getProperty("minDays." + country); + if (min == null) + min = properties.getProperty("minDays.DEFAULT"); + String first = properties.getProperty("firstDay." + country); + if (first == null) + first = properties.getProperty("firstDay.DEFAULT"); try { if (min != null) @@ -1328,7 +1356,7 @@ public abstract class Calendar */ public String toString() { - StringBuilder sb = new StringBuilder(getClass().getName()); + CPStringBuilder sb = new CPStringBuilder(getClass().getName()); sb.append('['); sb.append("time="); if (isTimeSet) diff --git a/libjava/classpath/java/util/Collections.java b/libjava/classpath/java/util/Collections.java index ae2010f1ce5..066c9d53893 100644 --- a/libjava/classpath/java/util/Collections.java +++ b/libjava/classpath/java/util/Collections.java @@ -39,6 +39,8 @@ exception statement from your version. */ package java.util; +import gnu.java.lang.CPStringBuilder; + import java.io.Serializable; /** @@ -1135,7 +1137,7 @@ public class Collections */ public String toString() { - StringBuffer r = new StringBuffer("{"); + CPStringBuilder r = new CPStringBuilder("{"); for (int i = n - 1; --i > 0; ) r.append(element).append(", "); r.append(element).append("}"); diff --git a/libjava/classpath/java/util/Currency.java b/libjava/classpath/java/util/Currency.java index b5da13c37f1..11235f14b35 100644 --- a/libjava/classpath/java/util/Currency.java +++ b/libjava/classpath/java/util/Currency.java @@ -139,7 +139,7 @@ public final class Currency } catch (IOException exception) { - System.out.println("Failed to load currency resource: " + exception); + throw new InternalError("Failed to load currency resource: " + exception); } } diff --git a/libjava/classpath/java/util/Date.java b/libjava/classpath/java/util/Date.java index 8646c19175e..5f83cd06cb3 100644 --- a/libjava/classpath/java/util/Date.java +++ b/libjava/classpath/java/util/Date.java @@ -37,6 +37,8 @@ exception statement from your version. */ package java.util; +import gnu.java.lang.CPStringBuilder; + import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -722,7 +724,7 @@ public class Date boolean localTimezone = true; // Trim out any nested stuff in parentheses now to make parsing easier. - StringBuilder buf = new StringBuilder(); + CPStringBuilder buf = new CPStringBuilder(); int parenNesting = 0; int len = string.length(); for (int i = 0; i < len; i++) diff --git a/libjava/classpath/java/util/Formatter.java b/libjava/classpath/java/util/Formatter.java index 82130782e0f..9217d93b6e9 100644 --- a/libjava/classpath/java/util/Formatter.java +++ b/libjava/classpath/java/util/Formatter.java @@ -38,6 +38,8 @@ exception statement from your version. */ package java.util; +import gnu.java.lang.CPStringBuilder; + import java.io.Closeable; import java.io.File; import java.io.FileNotFoundException; @@ -470,7 +472,7 @@ public final class Formatter * @param width the width of the numeric value. * @param isNegative true if the value is negative. */ - private void applyLocalization(StringBuilder builder, int flags, int width, + private void applyLocalization(CPStringBuilder builder, int flags, int width, boolean isNegative) { DecimalFormatSymbols dfsyms; @@ -741,9 +743,9 @@ public final class Formatter * @param conversion the conversion character. * @return the result. */ - private StringBuilder basicIntegralConversion(Object arg, int flags, - int width, int precision, - int radix, char conversion) + private CPStringBuilder basicIntegralConversion(Object arg, int flags, + int width, int precision, + int radix, char conversion) { assert radix == 8 || radix == 10 || radix == 16; noPrecision(precision); @@ -798,7 +800,7 @@ public final class Formatter else throw new IllegalFormatConversionException(conversion, arg.getClass()); - return new StringBuilder(result); + return new CPStringBuilder(result); } /** @@ -819,9 +821,9 @@ public final class Formatter { assert radix == 8 || radix == 16; - StringBuilder builder = basicIntegralConversion(arg, flags, width, - precision, radix, - conversion); + CPStringBuilder builder = basicIntegralConversion(arg, flags, width, + precision, radix, + conversion); int insertPoint = 0; // Insert the sign. @@ -897,9 +899,9 @@ public final class Formatter int precision, char conversion) throws IOException { - StringBuilder builder = basicIntegralConversion(arg, flags, width, - precision, 10, - conversion); + CPStringBuilder builder = basicIntegralConversion(arg, flags, width, + precision, 10, + conversion); boolean isNegative = false; if (builder.charAt(0) == '-') { @@ -920,7 +922,7 @@ public final class Formatter * @param conversion the formatting character to specify the type of data. * @param syms the date formatting symbols. */ - private void singleDateTimeConversion(StringBuilder builder, Calendar cal, + private void singleDateTimeConversion(CPStringBuilder builder, Calendar cal, char conversion, DateFormatSymbols syms) { @@ -1151,7 +1153,7 @@ public final class Formatter else syms = new DateFormatSymbols(fmtLocale); - StringBuilder result = new StringBuilder(); + CPStringBuilder result = new CPStringBuilder(); singleDateTimeConversion(result, cal, subConversion, syms); genericFormat(result.toString(), flags, width, precision); diff --git a/libjava/classpath/java/util/Hashtable.java b/libjava/classpath/java/util/Hashtable.java index 07bd9469318..0851de8249a 100644 --- a/libjava/classpath/java/util/Hashtable.java +++ b/libjava/classpath/java/util/Hashtable.java @@ -39,6 +39,8 @@ exception statement from your version. */ package java.util; +import gnu.java.lang.CPStringBuilder; + import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -579,7 +581,7 @@ public class Hashtable<K, V> extends Dictionary<K, V> // would repeatedly re-lock/release the monitor, we directly use the // unsynchronized EntryIterator instead. Iterator<Map.Entry<K, V>> entries = new EntryIterator(); - StringBuilder r = new StringBuilder("{"); + CPStringBuilder r = new CPStringBuilder("{"); for (int pos = size; pos > 0; pos--) { r.append(entries.next()); diff --git a/libjava/classpath/java/util/Locale.java b/libjava/classpath/java/util/Locale.java index cd372f24551..c28709f95d6 100644 --- a/libjava/classpath/java/util/Locale.java +++ b/libjava/classpath/java/util/Locale.java @@ -39,6 +39,9 @@ exception statement from your version. */ package java.util; import gnu.classpath.SystemProperties; + +import gnu.java.lang.CPStringBuilder; + import gnu.java.locale.LocaleHelper; import java.io.IOException; @@ -548,7 +551,7 @@ public final class Locale implements Serializable, Cloneable return ""; else if (country.length() == 0 && variant.length() == 0) return language; - StringBuffer result = new StringBuffer(language); + CPStringBuilder result = new CPStringBuilder(language); result.append('_').append(country); if (variant.length() != 0) result.append('_').append(variant); @@ -922,7 +925,7 @@ public final class Locale implements Serializable, Cloneable */ public String getDisplayName(Locale locale) { - StringBuffer result = new StringBuffer(); + CPStringBuilder result = new CPStringBuilder(); int count = 0; String[] delimiters = {"", " (", ","}; if (language.length() != 0) diff --git a/libjava/classpath/java/util/Properties.java b/libjava/classpath/java/util/Properties.java index e294fee7ea9..a57004b3415 100644 --- a/libjava/classpath/java/util/Properties.java +++ b/libjava/classpath/java/util/Properties.java @@ -38,6 +38,8 @@ exception statement from your version. */ package java.util; +import gnu.java.lang.CPStringBuilder; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; @@ -46,6 +48,7 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintStream; import java.io.PrintWriter; +import java.io.Reader; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamConstants; @@ -155,7 +158,7 @@ public class Properties extends Hashtable<Object, Object> } /** - * Reads a property list from an input stream. The stream should + * Reads a property list from a character stream. The stream should * have the following format: <br> * * An empty line or a line starting with <code>#</code> or @@ -187,15 +190,14 @@ weekdays: Sunday,Monday,Tuesday,Wednesday,\\ # The safest way to include a space at the end of a value: label = Name:\\u0020</pre> * - * @param inStream the input stream + * @param inReader the input {@link java.io.Reader}. * @throws IOException if an error occurred when reading the input * @throws NullPointerException if in is null + * @since 1.6 */ - public void load(InputStream inStream) throws IOException + public void load(Reader inReader) throws IOException { - // The spec says that the file must be encoded using ISO-8859-1. - BufferedReader reader = - new BufferedReader(new InputStreamReader(inStream, "ISO-8859-1")); + BufferedReader reader = new BufferedReader(inReader); String line; while ((line = reader.readLine()) != null) @@ -217,7 +219,7 @@ label = Name:\\u0020</pre> // Try to short-circuit when there is no escape char. int start = pos; boolean needsEscape = line.indexOf('\\', pos) != -1; - StringBuilder key = needsEscape ? new StringBuilder() : null; + CPStringBuilder key = needsEscape ? new CPStringBuilder() : null; while (pos < line.length() && ! Character.isWhitespace(c = line.charAt(pos++)) && c != '=' && c != ':') @@ -361,6 +363,24 @@ label = Name:\\u0020</pre> } /** + * Reads a property list from the supplied input stream. + * This method has the same functionality as {@link #load(Reader)} + * but the character encoding is assumed to be ISO-8859-1. + * Unicode characters not within the Latin1 set supplied by + * ISO-8859-1 should be escaped using '\\uXXXX' where XXXX + * is the UTF-16 code unit in hexadecimal. + * + * @param inStream the byte stream to read the property list from. + * @throws IOException if an I/O error occurs. + * @see #load(Reader) + * @since 1.2 + */ + public void load(InputStream inStream) throws IOException + { + load(new InputStreamReader(inStream, "ISO-8859-1")); + } + + /** * Calls <code>store(OutputStream out, String header)</code> and * ignores the IOException that may be thrown. * @@ -421,7 +441,7 @@ label = Name:\\u0020</pre> Iterator iter = entrySet ().iterator (); int i = size (); - StringBuilder s = new StringBuilder (); // Reuse the same buffer. + CPStringBuilder s = new CPStringBuilder (); // Reuse the same buffer. while (--i >= 0) { Map.Entry entry = (Map.Entry) iter.next (); @@ -564,7 +584,7 @@ label = Name:\\u0020</pre> * leading spaces must be escaped for the value * @see #store(OutputStream, String) */ - private void formatForOutput(String str, StringBuilder buffer, boolean key) + private void formatForOutput(String str, CPStringBuilder buffer, boolean key) { if (key) { @@ -745,7 +765,7 @@ label = Name:\\u0020</pre> Boolean.FALSE); XMLStreamReader reader = factory.createXMLStreamReader(in); String name, key = null; - StringBuffer buf = null; + CPStringBuilder buf = null; while (reader.hasNext()) { switch (reader.next()) @@ -760,7 +780,7 @@ label = Name:\\u0020</pre> String msg = "missing 'key' attribute"; throw new InvalidPropertiesFormatException(msg); } - buf = new StringBuffer(); + buf = new CPStringBuilder(); } else if (!"properties".equals(name) && !"comment".equals(name)) { diff --git a/libjava/classpath/java/util/PropertyResourceBundle.java b/libjava/classpath/java/util/PropertyResourceBundle.java index 53a1af5360b..b528f08ca85 100644 --- a/libjava/classpath/java/util/PropertyResourceBundle.java +++ b/libjava/classpath/java/util/PropertyResourceBundle.java @@ -40,6 +40,7 @@ package java.util; import java.io.IOException; import java.io.InputStream; +import java.io.Reader; /** * This class is a concrete <code>ResourceBundle</code> that gets it @@ -97,7 +98,8 @@ public class PropertyResourceBundle extends ResourceBundle private Properties properties; /** - * Creates a new property resource bundle. + * Creates a new property resource bundle. The property file must + * be encoded using ISO-8859-1. * * @param stream an input stream, where the resources are read from * @throws NullPointerException if stream is null @@ -110,6 +112,21 @@ public class PropertyResourceBundle extends ResourceBundle } /** + * Creates a new property resource bundle. The encoding of the property + * file is determined by the supplied {@link Reader} object. + * + * @param reader an input stream, where the resources are read from + * @throws NullPointerException if stream is null + * @throws IOException if reading the stream fails + * @since 1.6 + */ + public PropertyResourceBundle(Reader reader) throws IOException + { + properties = new Properties(); + properties.load(reader); + } + + /** * Called by <code>getObject</code> when a resource is needed. This * returns the resource given by the key. * diff --git a/libjava/classpath/java/util/ResourceBundle.java b/libjava/classpath/java/util/ResourceBundle.java index 9b82bc80152..21243403c5f 100644 --- a/libjava/classpath/java/util/ResourceBundle.java +++ b/libjava/classpath/java/util/ResourceBundle.java @@ -41,6 +41,8 @@ package java.util; import gnu.classpath.VMStackWalker; +import gnu.java.lang.CPStringBuilder; + import java.io.IOException; import java.io.InputStream; @@ -121,9 +123,10 @@ public abstract class ResourceBundle * * @see BundleKey */ - private static Map bundleCache = new LinkedHashMap(CACHE_SIZE + 1, 0.75F, true) + private static Map<BundleKey,Object> bundleCache = + new LinkedHashMap<BundleKey,Object>(CACHE_SIZE + 1, 0.75F, true) { - public boolean removeEldestEntry(Map.Entry entry) + public boolean removeEldestEntry(Map.Entry<BundleKey,Object> entry) { return size() > CACHE_SIZE; } @@ -294,14 +297,29 @@ public abstract class ResourceBundle && locale.equals(key.locale) && classLoader.equals(key.classLoader); } + + public String toString() + { + CPStringBuilder builder = new CPStringBuilder(getClass().getName()); + builder.append("[defaultLocale="); + builder.append(defaultLocale); + builder.append(",baseName="); + builder.append(baseName); + builder.append(",locale="); + builder.append(locale); + builder.append(",classLoader="); + builder.append(classLoader); + builder.append("]"); + return builder.toString(); + } } /** A cache lookup key. This avoids having to a new one for every * getBundle() call. */ - private static BundleKey lookupKey = new BundleKey(); + private static final BundleKey lookupKey = new BundleKey(); /** Singleton cache entry to represent previous failed lookups. */ - private static Object nullEntry = new Object(); + private static final Object nullEntry = new Object(); /** * Get the appropriate ResourceBundle for the given locale. The following @@ -452,7 +470,7 @@ public abstract class ResourceBundle ResourceBundle bundle = null; try { - Class rbClass; + Class<?> rbClass; if (classloader == null) rbClass = Class.forName(localizedName); else @@ -495,7 +513,7 @@ public abstract class ResourceBundle } /** - * Tries to load a the bundle for a given locale, also loads the backup + * Tries to load the bundle for a given locale, also loads the backup * locales with the same language. * * @param baseName the raw bundle name, without locale qualifiers @@ -515,9 +533,9 @@ public abstract class ResourceBundle int baseLen = baseName.length(); - // Build up a StringBuffer containing the complete bundle name, fully + // Build up a CPStringBuilder containing the complete bundle name, fully // qualified by locale. - StringBuffer sb = new StringBuffer(baseLen + variant.length() + 7); + CPStringBuilder sb = new CPStringBuilder(baseLen + variant.length() + 7); sb.append(baseName); @@ -568,4 +586,40 @@ public abstract class ResourceBundle return first; } + + /** + * Remove all resources from the cache that were loaded + * using the class loader of the calling class. + * + * @since 1.6 + */ + public static final void clearCache() + { + clearCache(VMStackWalker.getCallingClassLoader()); + } + + /** + * Remove all resources from the cache that were loaded + * using the specified class loader. + * + * @param loader the loader used for the bundles that will be removed. + * @throws NullPointerException if {@code loader} is {@code null}. + * @since 1.6 + */ + public static final void clearCache(ClassLoader loader) + { + if (loader == null) + throw new NullPointerException("The loader can not be null."); + synchronized (ResourceBundle.class) + { + Iterator<BundleKey> iter = bundleCache.keySet().iterator(); + while (iter.hasNext()) + { + BundleKey key = iter.next(); + if (key.classLoader == loader) + iter.remove(); + } + } + } + } diff --git a/libjava/classpath/java/util/Scanner.java b/libjava/classpath/java/util/Scanner.java new file mode 100644 index 00000000000..cc39f191de9 --- /dev/null +++ b/libjava/classpath/java/util/Scanner.java @@ -0,0 +1,2223 @@ +/* java.util.Scanner -- Parses primitive types and strings using regexps + Copyright (C) 2007 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 java.util; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; + +import java.math.BigDecimal; +import java.math.BigInteger; + +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.channels.ReadableByteChannel; + +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.text.NumberFormat; +import java.text.ParseException; + +import java.util.Iterator; +import java.util.Locale; +import java.util.regex.MatchResult; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author E0327023 Hernadi Laszlo + */ +public class Scanner + implements Iterator <String> +{ + private static final String NOT_LONG = "\" is not a long"; //$NON-NLS-1$ + + private static final String ERR_PREFIX = "\""; //$NON-NLS-1$ + + private static final String NOT_INT = "\" is not an integer"; //$NON-NLS-1$ + + private static final String NOT_DOUBLE = "\" is not a double"; //$NON-NLS-1$ + + private static final String NOT_BYTE = "\" is not a byte"; //$NON-NLS-1$ + + private static final String NOT_BOOLEAN = "\" is not a boolean"; //$NON-NLS-1$ + + private static final String IS_NOT = "\" is not "; //$NON-NLS-1$ + + private static final String DEFAULT_PATTERN_S = "\\p{javaWhitespace}+"; //$NON-NLS-1$ + + private static final Pattern DEFAULT_PATTERN = + Pattern.compile (DEFAULT_PATTERN_S); + + private static final String BIG_INTEGER = "BigInteger"; //$NON-NLS-1$ + + private final static String NEW_LINE = + System.getProperty ("line.separator"); + + private IOException lastIOException = null; + + /** + * An InputStream source if a Constructor with an InputStream source is called, otherwise it + * stays <source> null </source>. + */ + private InputStream bIS = null; + + /** + * Length of the input Buffer, which is the maximum bytes to be read at once. + */ + private final int MaxBufferLen = 1000000; + + /** + * Minimum buffer length. If there are less chars in the Buffer than this value reading from + * source is tried. + */ + private final int MIN_BUF_LEN = 100; + + /** + * Maximum number of processed chars in the Buffer. If exeeded, all processed chars from the + * beginning of the Buffer will be discarded to save space. The bytes left are copyed into a new + * Buffer. + */ + private final int MAX_PREFIX = 10000; + + /** + * The Buffer which is used by the Matcher to find given patterns. It is filled up when matcher + * hits end or <code> MIN_BUF_LEN </code> is reached. + */ + private String actBuffer = new String (); + + /** + * The current radix to use by the methods getNextXXX and hasNextXXX. + */ + private int currentRadix = 10; + + /** + * The current locale. + * + * @see #useLocale(Locale) + * @see #locale() + */ + private Locale actLocale = Locale.getDefault (); + + /** + * The current pattern for the matcher. + */ + private Pattern p = DEFAULT_PATTERN; + + /** + * The current position in the Buffer, at which the next match should start. + */ + private int actPos = 0; + + /** + * A global buffer to save new allocations by reading from source. + */ + private final byte[] tmpBuffer = new byte[this.MaxBufferLen]; + + /** + * The charsetName to use with the source. + */ + private String charsetName = null; + + /** + * The Matcher which is used. + */ + private Matcher myMatcher = this.p.matcher (this.actBuffer); + + /** + * The MatchResult is generated at each match, even if match() isn't called. + */ + private MatchResult actResult = null; + + /** + * A Readable source if a Constructor with a Readable source is called, otherwise it stays + * <source> null </source>. + */ + private Readable readableSource = null; + + /** + * A ReadableByteChannel source if a Constructor with a ReadableByteChannel source is called, + * otherwise it stays <source> null </source>. + */ + private ReadableByteChannel rbcSource = null; + + /** + * Indicates if the close() method was called. + */ + private boolean isClosed = false; + + /** + * For performance reasons the last Found is saved, if a hasNextXXX method was called. + */ + private String lastFound = null; + + private boolean lastFoundPresent = false; + + private int lastNextPos = 0; + + private int lastPatternHash = 0; + + private int last_RegionStart = 0; + + private int last_RegionEnd = 0; + + private boolean last_anchor = false; + + private boolean last_transparent = false; + + private MatchResult lastResult = null; + + /** + * To keep track of the current position in the stream for the toString method, each time + * processed chars are removed the amount is added to processedChars. + */ + private int procesedChars = 0; + + /** + * needInput is set <code> true </code> before a read method, and if there is no input it blocks + * and stays <code>true</code>. Right after a read it is set to <code>false</code>. + */ + private boolean needInput = false; + + private boolean skipped = false; + + /** + * <code> {@link #doSkipp} </code> indicates that the found pattern belongs to the result. If + * <code> {@link #doSkipp} </code> is false the match result ends at the beginning of the match. + * In both cases the current position is set after the pattern, if the found pattern has to be + * removed, a nextXXX method is called. + */ + private boolean doSkipp = false; + + /** + * Indicates if the last match was valid or not. + */ + private boolean matchValid = false; + + private NumberFormat actFormat = NumberFormat.getInstance (this.actLocale); + + private DecimalFormat df = (DecimalFormat) this.actFormat; + + /** + * Indicates if current Locale should be used at the input. + */ + private boolean useLocale = true; + + private DecimalFormatSymbols dfs = + new DecimalFormatSymbols (this.actLocale); + + /** + * Constructs a new Scanner with the given File as source. + * {@link #Scanner(InputStream, String)} is called with <code> null </code> as charsetName. + * + * @param source + * The File to use as source. + * @throws FileNotFoundException + * If the file is not found an Exception is thrown. + */ + public Scanner (final File source) throws FileNotFoundException // TESTED + { + this (source, null); + } + + /** + * Constructs a new Scanner with the given File as source. <br> + * {@link #Scanner(InputStream, String)} is called with the given charsetName. + * + * @param source + * The File to use as source. + * @param charsetName + * Current charset name of the file. If charsetName is null it behaves if it was not + * set. + * @throws FileNotFoundException + * If the file is not found an Exception is thrown. + */ + public Scanner (final File source, + final String charsetName) throws FileNotFoundException + { + this (new FileInputStream (source), charsetName); + } + + /** + * Constructs a new Scanner with the given inputStream. <br> + * {@link #Scanner(InputStream, String)} is called with <code> null </code> as charsetName. + * + * @param source + * The InputStream to use as source. + */ + public Scanner (final InputStream source) // TESTED + { + this (source, null); + } + + /** + * Constructs a new Scanner with the InputSream and a charsetName. Afterwards the Buffer is + * filled. + * + * @param source + * The InputStream to use as source. + * @param charsetName + * The charsetName to apply on the source's data. + */ + public Scanner (final InputStream source, final String charsetName) + { + this.bIS = (new BufferedInputStream (source)); + this.charsetName = charsetName; + myFillBuffer (); + } + + /** + * Constructs a new Scanner with a Readable input as source. + * + * @param source + * The Readable to use as source. + */ + public Scanner (final Readable source) + { + this.readableSource = source; + myFillBuffer (); + } + + /** + * Constructs a new Scanner with a ReadableByteChannel as + * source. Therfore the {@link #Scanner(ReadableByteChannel, + * String)} is called with <code> null </code> as charsetName. + * + * @param source + * The ReadableByteChannel to use as source. + */ + public Scanner (final ReadableByteChannel source) + { + this (source, null); + } + + /** + * Constructs a new Scanner with a ReadableByteChannel as source and + * a given charsetName, which is to be applied on it. <br> It also + * initiates the main Buffer. + * + * @param source + * The ReadableByteChannel to use as source. + * @param charsetName + * The charsetName to be applied on the source. + */ + public Scanner (final ReadableByteChannel source, final String charsetName) + { + this.charsetName = charsetName; + this.rbcSource = source; + myFillBuffer (); + } + + /** + * Constructs a new Scanner using the given String as input only. + * + * @param source + * The whole String to be used as source. + */ + public Scanner (final String source) // TESTED + { + this.actBuffer = new String (source); + this.myMatcher.reset (this.actBuffer); + } + + /** + * Closes this Scanner. If an {@link IOException} occurs it is + * catched and is available under {@link #ioException()}.<br> After + * the Scanner is closed, all searches will lead to a {@link + * IllegalStateException}. + */ + public void close () + { + try + { + if (this.bIS != null) + this.bIS.close (); + if (this.rbcSource != null) + this.rbcSource.close (); + this.isClosed = true; + } + catch (IOException ioe) + { + this.lastIOException = ioe; + } + } + + /** + * Returns the current delimiter. + * + * @return the current delimiter. + */ + public Pattern delimiter () // TESTED + { + return this.p; + } + + /** + * Tries to find the pattern in the current line. + * + * @param pattern The pattern which should be searched in the + * current line of the input. + * @throws NoSuchElementException + * If the pattern was not found. + * @return If the search was successful, the result or otherwise a + * {@link NoSuchElementException} is thrown. + */ + public String findInLine (final Pattern pattern) throws NoSuchElementException // TESTED + { + String tmpStr = myNextLine (false); + return myFindPInStr (pattern, tmpStr, 0); + } + + /** + * Compiles the given pattern into a {@link Pattern} and calls + * {@link #findInLine(Pattern)} with the compiled pattern and + * returns whatever it returns. + * + * @param pattern + * The pattern which should be matched in the input. + * @throws NoSuchElementException + * If the pattern was not found. + * @return The match in the current line. + */ + public String findInLine (final String pattern) // TESTED + { + return findInLine (Pattern.compile (pattern)); + } + + /** + * Trys to match the pattern within the given horizon. + * + * @param pattern + * Pattern to search. + * @param horizon + * @return The result of the match. + * @throws IllegalArgumentException + * if the horizon is negative. + * @throws IllegalStateException + * if the Scanner is closed. + */ + public String findWithinHorizon (final Pattern pattern, final int horizon) + throws IllegalArgumentException, IllegalStateException + { + if (horizon < 0) + { + throw new IllegalArgumentException (horizon + " is negative"); + } + + if (this.isClosed) + { + throw new IllegalStateException ("Scanner is closed"); + } + + // doSkipp is set true to get the matching patern together with the found String + this.doSkipp = true; + String rc = myFindPInStr (pattern, this.actBuffer, horizon); + + if (rc != null) + { + this.actPos += rc.length (); + } + + return rc; + } + + /** + * Compile the pattern and call {@link #findWithinHorizon(Pattern, + * int)}. + * + * @param pattern + * Pattern to search. + * @param horizon + * @return The result of the match. + * @throws IllegalArgumentException + * if the horizon is negative. + * @throws IllegalStateException + * if the Scanner is closed. + */ + public String findWithinHorizon (final String pattern, final int horizon) + throws IllegalArgumentException, IllegalStateException + { + return findWithinHorizon (Pattern.compile (pattern), horizon); + } + + /** + * Checks if there is any next String using the current + * delimiter. Therefore the string must not be <code> null </code> + * and the length must be greater then 0. If a {@link + * NoSuchElementException} is thrown by the search method, it is + * catched and false is returned. + * + * @return <code> true </code> if there is any result using the current delimiter. This wouldn't + * lead to a {@link NoSuchElementException}. + * @throws IllegalStateException + * if the Scanner is closed. + */ + public boolean hasNext () throws IllegalStateException // TESTED + { + String tmpStr = null; + + try + { + tmpStr = myCoreNext (false, this.p); + } + catch (NoSuchElementException nf) + { + } + + if (tmpStr == null || tmpStr.length () <= 0) + { + return false; + } + return true; + } + + /** + * Searches the pattern in the next subString before the next + * current delimiter. + * + * @param pattern + * The pattern to search for. + * @return <code> true </code> if the pattern is found before the current delimiter. + * @throws IllegalStateException + * if the Scanner is closed. + */ + public boolean hasNext (final Pattern pattern) throws IllegalStateException // TESTED + { + String tmpStr; + + tmpStr = myNext (pattern, false); + + if (tmpStr == null || tmpStr.length () <= 0) + { + return false; + } + return true; + } + + /** + * Compiles the pattern to a {@link Pattern} and calls {@link + * #hasNext(Pattern)}. + * + * @see #hasNext(Pattern) + * @param pattern + * The pattern as string to search for. + * @return <code> true </code> if the pattern is found before the current delimiter. + * @throws IllegalStateException + * if the Scanner is closed. + */ + public boolean hasNext (final String pattern) throws IllegalStateException // TESTED + { + return hasNext (Pattern.compile (pattern)); + } + + /** + * Checks if the string to the next delimiter can be interpreted as + * a BigDecimal number. <br> BigDecimal numbers are always tryed + * with radix 10. + * + * @see #nextBigDecimal() + * @return <code> true </code> if the next string is a BigDecimal number. + * @throws IllegalStateException + * if the Scanner is closed. + */ + public boolean hasNextBigDecimal () throws IllegalStateException // TESTED + { + try + { + myBigDecimal (false); + return true; + } + catch (InputMismatchException nfe) + { + return false; + } + } + + /** + * Checks if the string to the next delimiter can be interpreted as + * a BigInteger number. <br> Call {@link #hasNextBigInteger(int)} + * with the current radix. + * + * @see #nextBigInteger() + * @return <code> true </code> if the next string is a BigInteger number. + * @throws IllegalStateException + * if the Scanner is closed. + */ + public boolean hasNextBigInteger () throws IllegalStateException // TESTED + { + return hasNextBigInteger (this.currentRadix); + } + + /** + * Checks if the string to the next delimiter can be interpreted as + * a BigInteger number. <br> + * + * @param radix + * The radix to use for this check. The global radix of the Scanner will not be + * changed. + * @return <code> true </code> if the next string is a BigInteger number. + * @throws IllegalStateException + * if the Scanner is closed. + */ + public boolean hasNextBigInteger (final int radix) throws + IllegalStateException + { + try + { + myNextBigInteger (radix, false, BIG_INTEGER); + return true; + } + catch (InputMismatchException ime) + { + return false; + } + } + + /** + * Checks if the next string could be a boolean. The method handles + * the input not case sensitiv, so "true" and "TRUE" and even "tRuE" + * are <code> true </code>. + * + * @see #nextBoolean() + * @return Return <code> true </code> if the next string is a boolean. + * @throws IllegalStateException + * if the Scanner is closed. + */ + public boolean hasNextBoolean () throws IllegalStateException // TESTED + { + try + { + myNextBoolean (false); + return true; + } + catch (InputMismatchException ime) + { + return false; + } + } + + /** + * Checks if the string to the next delimiter can be interpreted as + * a byte number. <br> Calls {@link #hasNextByte(int)} with the + * current radix. + * + * @see #nextByte() + * @return <code> true </code> if the next string is a byte number. + * @throws IllegalStateException + * if the Scanner is closed. + */ + public boolean hasNextByte () throws IllegalStateException // TESTED + { + return hasNextByte (this.currentRadix); + } + + /** + * Checks if the string to the next delimiter can be interpreted as + * a byte number with the given radix. <br> To check, the private + * method {@link #myNextByte(int, boolean)} is called, and if no + * error occurs the next string could be a byte. + * + * @see #nextByte(int) + * @param radix The radix to use for this check. The global radix of + * the Scanner will not be changed. + * @return <code> true </code> if the next string is a byte number. + * @throws IllegalStateException + * if the Scanner is closed. + */ + public boolean hasNextByte (final int radix) throws IllegalStateException + { + try + { + myNextByte (radix, false); + return true; + } + catch (InputMismatchException ime) + { + return false; + } + } + + /** + * Checks if the string to the next delimiter can be interpreted as + * a double number. <br> To check, the private method {@link + * #myNextDouble(boolean)} is called, and if no error occurs the + * next string could be a double. + * + * @see #nextDouble() + * @return <code> true </code> if the next string is a double number. + * @throws IllegalStateException + * if the Scanner is closed. + */ + public boolean hasNextDouble () throws IllegalStateException // TESTED + { + try + { + myNextDouble (false); + return true; + } + catch (InputMismatchException ime) + { + return false; + } + } + + /** + * Checks if the string to the next delimiter can be interpreted as + * a double number. Because every float is a double this is + * checked.<br> To check, the private method {@link + * #myNextDouble(boolean)} is called, and if no error occurs the + * next string could be a double. + * + * @see #nextFloat() + * @return <code> true </code> if the next string is a double number. + * @throws IllegalStateException + * if the Scanner is closed. + */ + public boolean hasNextFloat () throws IllegalStateException // TESTED + { + try + { + myNextDouble (false); + // myNextFloat(false); + return true; + } + catch (InputMismatchException ime) + { + return false; + } + } + + /** + * Checks if the string to the next delimiter can be interpreted as + * an int number. <br> To check, the private method {@link + * #myNextInt(int, boolean)} is called, and if no error occurs the + * next string could be an int. + * + * @see #nextInt(int) + * @return <code> true </code> if the next string is an int number. + * @throws IllegalStateException + * if the Scanner is closed. + */ + public boolean hasNextInt () throws IllegalStateException // TESTED + { + return hasNextInt (this.currentRadix); + } + + /** + * Checks if the string to the next delimiter can be interpreted as + * an int number with the given radix. <br> To check, the private + * method {@link #myNextInt(int, boolean)} is called, and if no + * error occurs the next string could be an int. + * + * @see #nextInt(int) + * @param radix + * The radix to use for this check. The global radix of the Scanner will not be + * changed. + * @return <code> true </code> if the next string is an int number. + * @throws IllegalStateException + * if the Scanner is closed. + */ + public boolean hasNextInt (final int radix) throws IllegalStateException + { + try + { + myNextInt (radix, false); + return true; + } + catch (InputMismatchException ime) + { + return false; + } + } + + /** + * Checks if there is a current line, which ends at the next line + * break or the end of the input. + * + * @return <code> true </code> if there is a current line. + * @throws IllegalStateException + * if the Scanner is closed. + */ + public boolean hasNextLine () throws IllegalStateException // TESTED + { + return (myNextLine (false) != null); + } + + /** + * Checks if the string to the next delimiter can be interpreted as + * a long number. <br> To check, the private method {@link + * #myNextLong(int, boolean)} is called, and if no error occurs the + * next string could be a long. + * + * @see #nextLong() + * @return <code> true </code> if the next string is a long number. + * @throws IllegalStateException + * if the Scanner is closed. + */ + public boolean hasNextLong () throws IllegalStateException // TESTED + { + return hasNextLong (this.currentRadix); + } + + /** + * Checks if the string to the next delimiter can be interpreted as + * a long number with the given radix. <br> To check, the private + * method {@link #myNextLong(int, boolean)} is called, and if no + * error occurs the next string could be a long. + * + * @see #nextLong(int) + * @param radix + * The radix to use for this check. The global radix of the Scanner will not be + * changed. + * @return <code> true </code> if the next string is a long number. + * @throws IllegalStateException + * if the Scanner is closed. + */ + public boolean hasNextLong (final int radix) throws IllegalStateException + { + try + { + myNextLong (radix, false); + return true; + } + catch (InputMismatchException ime) + { + return false; + } + } + + /** + * Checks if the string to the next delimiter can be interpreted as + * a short number with the given radix. <br> To check, the private + * method {@link #myNextShort(int, boolean)} is called, and if no + * error occurs the next string could be a short. + * + * @see #nextShort(int) + * @return <code> true </code> if the next string is a short number. + * @throws IllegalStateException + * if the Scanner is closed. + */ + public boolean hasNextShort () throws IllegalStateException // TESTED + { + return hasNextShort (this.currentRadix); + } + + /** + * Checks if the string to the next delimiter can be interpreted as + * a short number. <br> To check, the private method {@link + * #myNextShort(int, boolean)} is called, and if no error occurs the + * next string could be a short. + * + * @see #nextShort(int) + * @param radix + * The radix to use for this check. The global radix of the Scanner will not be + * changed. + * @return <code> true </code> if the next string is a short number. + * @throws IllegalStateException + * if the Scanner is closed. + */ + public boolean hasNextShort (final int radix) throws IllegalStateException + { + try + { + myNextShort (radix, false); + return true; + } + catch (InputMismatchException ime) + { + return false; + } + } + + /** + * Returns the last {@link IOException} occured. + * + * @return Returns the last {@link IOException}. + */ + public IOException ioException () + { + return this.lastIOException; + } + + /** + * Returns the current value of {@link #useLocale}. This is used to + * tell the Scanner if it should use the Locale format or just + * handle numbers of the default format. + * + * @see #setUseLocale(boolean) + * @return the useLoclae. + */ + public boolean isUseLocale () // TESTED + { + return this.useLocale; + } + + /** + * Returns the current Locale. It is initialized with {@link + * Locale#getDefault()}. + * + * @see #useLocale(Locale) + * @return Returns the current Locale. + */ + public Locale locale () // TESTED + { + return this.actLocale; + } + + /** + * Returns the last MatchResult found. This is updated after every + * successfully search. + * + * @return Returns the last {@link MatchResult} found. + */ + public MatchResult match () // TESTED + { + return this.actResult; + } + + /** + * Uses the current delimiter to find the next string in the + * buffer. If a string is found the current position is set after + * the delimiter, otherwise a {@link NoSuchElementException} is + * thrown. A successful match sets the matchResult. + * + * @see #match() + * @return Returns the next string of the buffer. + * @throws NoSuchElementException + * If no element was found an exception is thrown. + * @throws IllegalStateException + * If the Scanner is closed. + */ + public String next () throws NoSuchElementException, IllegalStateException // TESTED + { + return myCoreNext (true, this.p); + } + + /** + * Tries to match the buffer with the given pattern. The current + * delimiter will not be changed. + * + * @param pattern + * The pattern to match. + * @return Returns the next string matching the pattern. + * @throws NoSuchElementException + * If no element was found an exception is thrown. + * @throws IllegalStateException + * If the Scanner is closed. + */ + public String next (final Pattern pattern) throws NoSuchElementException, IllegalStateException // TESTED + { + return myNext (pattern, true); + } + + /** + * Tries to match the buffer with the given pattern. The current + * delimiter will not be changed. Calls the {@link #next(Pattern)} + * with the compiled pattern. + * + * @see #next(Pattern) + * @param pattern + * The pattern to match. + * @return Returns the next string matching the pattern. + * @throws NoSuchElementException + * If no element was found an exception is thrown. + * @throws IllegalStateException + * If the Scanner is closed. + */ + public String next (final String pattern) throws NoSuchElementException, IllegalStateException // TESTED + { + return next (Pattern.compile (pattern)); + } + + /** + * Tries to interpret the next string as a BigDecimal value. + * + * @return Returns the BigDecimal value of the next string. + * @throws NoSuchElementException + * If no string is found or the string is not a BigDecimal. + * @throws IllegalStateException + * If the Scanner is closed. + */ + public BigDecimal nextBigDecimal () throws NoSuchElementException, IllegalStateException // TESTED + { + return myBigDecimal (true); + } + + /** + * Tries to interpret the next string as a BigInteger value. Call + * {@link #nextBigInteger(int)} with the current radix as parameter, + * and return the value. + * + * @see #nextBigInteger(int) + * @return Returns the BigInteger value of the next string. + * @throws NoSuchElementException + * If no string is found or the string is not a BigInteger. + * @throws IllegalStateException + * If the Scanner is closed. + */ + public BigInteger nextBigInteger () throws NoSuchElementException, IllegalStateException // TESTED + { + return nextBigInteger (this.currentRadix); + } + + /** + * Tries to interpret the next string as a BigInteger value with the + * given radix. + * + * @param radix + * The radix to be used for this BigInteger. The current radix of the Scanner is not + * changed. + * @return Returns the BigInteger value of the next string. + * @throws NoSuchElementException + * If no string is found or the string is not a BigInteger. + * @throws IllegalStateException + * If the Scanner is closed. + */ + public BigInteger nextBigInteger (final int radix) throws + NoSuchElementException, IllegalStateException + { + return myNextBigInteger (radix, true, BIG_INTEGER); + } + + /** + * Tries to interpret the next string to the delimiter as a boolean + * value, ignoring case. + * + * @return Returns the boolean value of the next matching string or throws an exception. + * @throws NoSuchElementException + * If no string is found or the string is not a boolean. + * @throws IllegalStateException + * If the Scanner is closed. + */ + public boolean nextBoolean () throws NoSuchElementException, IllegalStateException // TESTED + { + return myNextBoolean (true); + } + + /** + * Tries to interpret the next string as a byte value. Call {@link + * #nextByte(int)} with the current radix as parameter, and return + * the value. + * + * @see #nextByte(int) + * @return Returns the byte value of the next string. + * @throws NoSuchElementException + * If no string is found or the string is not a byte + * @throws IllegalStateException + * If the Scanner is closed. + */ + public byte nextByte () throws NoSuchElementException, IllegalStateException // TESTED + { + return nextByte (this.currentRadix); + } + + /** + * Tries to interpret the next string as a byte value with the given + * radix. + * + * @param radix + * The radix to be used for this byte. The current radix of the Scanner is not + * changed. + * @return Returns the byte value of the next string. + * @throws NoSuchElementException + * If no string is found or the string is not a byte. + * @throws IllegalStateException + * If the Scanner is closed. + */ + public byte nextByte (final int radix) throws NoSuchElementException, + IllegalStateException + { + return myNextByte (radix, true); + } + + /** + * Tries to interpret the next string as a double value. + * + * @return Returns the int value of the next string. + * @throws NoSuchElementException + * If no string is found or the string is not a double. + * @throws IllegalStateException + * If the Scanner is closed. + */ + public double nextDouble () throws NoSuchElementException, IllegalStateException // TESTED + { + return myNextDouble (true); + } + + /** + * Tries to interpret the next string as a double value, and then + * casts down to float. + * + * @return Returns the int value of the next string. + * @throws NoSuchElementException + * If no string is found or the string is not a double. + * @throws IllegalStateException + * If the Scanner is closed. + */ + public float nextFloat () throws NoSuchElementException, IllegalStateException // TESTED + { + return (float) myNextDouble (true); + // return myNextFloat(true); + } + + /** + * Tries to interpret the next string as an int value. Calls {@link + * #nextInt(int)} with the current radix as parameter, and return + * the value. + * + * @see #nextInt(int) + * @return Returns the int value of the next string. + * @throws NoSuchElementException + * If no string is found or the string is not an int. + * @throws IllegalStateException + * If the Scanner is closed. + */ + public int nextInt () throws NoSuchElementException, IllegalStateException // TESTED + { + return nextInt (this.currentRadix); + } + + /** + * Tries to interpret the next string as an int value with the given + * radix. + * + * @param radix + * The radix to be used for this int. The current radix of the Scanner is not changed + * @return Returns the int value of the next string. + * @throws NoSuchElementException + * If no string is found or the string is not an int. + * @throws IllegalStateException + * If the Scanner is closed. + */ + public int nextInt (final int radix) throws NoSuchElementException, + IllegalStateException + { + return myNextInt (radix, true); + } + + /** + * Tries to match the system line seperator, and returns the current + * line. + * + * @return Returns the current line. + * @throws NoSuchElementException + * If the current delimiter is not found. + * @throws IllegalStateException + * If the Scanner is closed. + */ + public String nextLine () throws NoSuchElementException, IllegalStateException // TESTED + { + return myNextLine (true); + } + + /** + * Tries to interpret the next string as a long value. Calls {@link + * #nextLong(int)} with the current radix as parameter, and return + * the value. + * + * @see #nextLong(int) + * @return Returns the long value of the next string. + * @throws NoSuchElementException + * If no string is found or the string is not a long. + * @throws IllegalStateException + * If the Scanner is closed. + */ + public long nextLong () throws NoSuchElementException, IllegalStateException // TESTED + { + return nextLong (this.currentRadix); + } + + /** + * Tries to interpret the next string as a long value with the given + * radix. + * + * @param radix + * The radix to be used for this long. The current radix of the Scanner is not + * changed + * @return Returns the long value of the next string. + * @throws NoSuchElementException + * If no string is found or the string is not a long. + * @throws IllegalStateException + * If the Scanner is closed. + */ + public long nextLong (final int radix) throws NoSuchElementException, + IllegalStateException + { + return myNextLong (radix, true); + } + + /** + * Tries to interpret the next string as a short value. Calls {@link + * #nextShort(int)} with the current radix as parameter, and return + * the value. + * + * @see #nextShort(int) + * @return Returns the short value of the next string. + * @throws NoSuchElementException + * If no string is found or the string is not a short. + */ + public short nextShort () throws NoSuchElementException // TESTED + { + return nextShort (this.currentRadix); + } + + /** + * Tries to interpret the next string as a short value with the + * given radix. + * + * @param radix + * The radix to be used for this short. The current radix of the Scanner is not + * changed. + * @return Returns the short value of the next string. + * @throws NoSuchElementException + * If no string is found or the string is not a short. + */ + public short nextShort (final int radix) throws NoSuchElementException + { + return myNextShort (radix, true); + } + + /** + * @return Returns the current radix. + */ + public int radix () + { + return this.currentRadix; + } + + /** + * The remove operation is not supported by this implementation of + * Iterator. + */ + public void remove () + { + } + + /** + * @param useLocale the useLocale to set. + */ + public void setUseLocale (final boolean useLocale) // TESTED + { + this.useLocale = useLocale; + } + + /** + * Skips the given pattern. Sets skipped <code>true</code>. + * + * @param pattern + * Pattern which should be skipped. + * @return <code>this</code> with the skipped buffer. + * @throws NoSuchElementException + * If the Pattern is not found. + */ + public Scanner skip (final Pattern pattern) throws NoSuchElementException + { + this.doSkipp = true; + int end; + boolean found; + Matcher matcher = pattern.matcher (this.actBuffer); + matcher.region (this.actPos - 1, this.actBuffer.length ()); + + found = matcher.find (); + found = myFillBuffer_loop (matcher, this.actPos - 1, found); + end = matcher.end (); + + this.actPos = end + 1; + + this.doSkipp = false; + this.skipped = true; + + actResult = null; + + if (!found) + { + throw new NoSuchElementException (); + } + return this; + } + + /** + * Skips a given pattern. Calls {@link #skip(Pattern)} with the + * compiled pattern. + * + * @see #skip(Pattern) + * @param pattern + * Pattern which should be skipped. + * @return <code>this</code> with the skipped buffer. + */ + public Scanner skip (final String pattern) + { + return skip (Pattern.compile (pattern)); + } + + /** + * Returns the string representation of this Scanner. + */ + @Override + public String toString () + { + String tmpStr2; + String rc = this.getClass ().getName (); + tmpStr2 = rc; + tmpStr2 = "[delimiters=" + this.p.pattern () + "]"; + rc += tmpStr2; + tmpStr2 = "[position=" + (this.procesedChars + this.actPos) + "]"; + rc += tmpStr2; + tmpStr2 = "[match valid=" + this.matchValid + "]"; + rc += tmpStr2; + tmpStr2 = "[need input=" + this.needInput + "]"; + rc += tmpStr2; + tmpStr2 = "[source closed=" + this.isClosed + "]"; + rc += tmpStr2; + tmpStr2 = "[skipped=" + this.skipped + "]"; + rc += tmpStr2; + tmpStr2 = "[group separator=\\" + this.dfs.getGroupingSeparator () + "]"; + rc += tmpStr2; + tmpStr2 = "[decimal separator=\\" + this.dfs.getDecimalSeparator () + "]"; + rc += tmpStr2; + tmpStr2 = + "[positive prefix=" + myConvert (this.df.getPositivePrefix ()) + "]"; + rc += tmpStr2; + tmpStr2 = + "[negative prefix=" + myConvert (this.df.getNegativePrefix ()) + "]"; + rc += tmpStr2; + tmpStr2 = + "[positive suffix=" + myConvert (this.df.getPositiveSuffix ()) + "]"; + rc += tmpStr2; + tmpStr2 = + "[negative suffix=" + myConvert (this.df.getNegativeSuffix ()) + "]"; + rc += tmpStr2; + tmpStr2 = "[NaN string=" + myConvert (this.dfs.getNaN ()) + "]"; + rc += tmpStr2; + tmpStr2 = "[infinity string=" + myConvert (this.dfs.getInfinity ()) + "]"; + rc += tmpStr2; + return rc; + } + + /** + * Sets the current pattern to the given parameter, and updates the + * {@link Matcher} with the new pattern. + * + * @param pattern + * The new pattern to use. + * @return Returns the Scanner (<code>this</code>) with the new pattern. + */ + public Scanner useDelimiter (final Pattern pattern) // TESTED + { + if (pattern != null) + { + this.p = pattern; + this.myMatcher = this.p.matcher (this.actBuffer); + } + return this; + } + + /** + * Sets the current pattern to the given parameter. Compiles the + * pattern and calls {@link #useDelimiter(Pattern)} + * + * @see #useDelimiter(Pattern) + * @param pattern + * The new pattern to use. + * @return Returns the Scanner (<code>this</code>) with the new pattern. + */ + public Scanner useDelimiter (final String pattern) // TESTED + { + return useDelimiter (Pattern.compile (pattern)); + } + + /** + * Sets the current Locale to the given parameter. Formats and + * Symbols are also set using the new Locale. + * + * @param locale The new Locale to use. If it is <code>null</code> + * nothing happens. + * @return Returns the Scanner (<code>this</code>) with the new Locale. + */ + public Scanner useLocale (final Locale locale) // TESTED + { + if (locale != null) + { + this.actLocale = locale; + this.actFormat = NumberFormat.getInstance (this.actLocale); + this.dfs = new DecimalFormatSymbols (this.actLocale); + this.df = (DecimalFormat) this.actFormat; + } + return this; + } + + /** + * Sets the current radix to the current value if the given radix is + * >= 2 and <= 36 otherwise an {@link IllegalArgumentException} is + * thrown. + * + * @param radix + * the new radix to use as default. + * @return <code> this </code> with the new radix value. + * @throws IllegalArgumentException + * When the given radix is out of bounds. + */ + public Scanner useRadix (final int radix) throws IllegalArgumentException + { + if (radix < 2 || radix > 36) + { + throw new IllegalArgumentException (); + } + this.currentRadix = radix; + return this; + } + + /** + * Checks if it is necessary to apply the current Locale on the + * String. If so the String is converted using the {@link + * NumberFormat#parse(String)} into a Number and then back to a + * default stringrepresentation of that Number. + * + * @see #setUseLocale(boolean) + * @param str + * String to convert into another string. + * @param radix Radix of the Number in the original string. It has + * to be 10 for anything to happen. + * @return Eighter the Stringrepresention of the number without the + * Locale or an unchanged string. + * @throws ParseException + * if {@link NumberFormat#parse(String)} fails to parse. + */ + private String myApplyLocale (final String str, + final int radix) throws ParseException + { + String rc; + + if (this.useLocale && radix == 10) + { + rc = this.actFormat.parse (str).toString (); + return rc; + } + + return str; + } + + /** + * If {@link #useLocale} is set and radix is 10 the string is tryed + * to be converted to string without Locale settings, because the + * "normal" convert from Local has only double precision and it is + * not enough for the about 50 digits of precision of the + * BigDecimal. So in the first step the string is seperated into the + * integer part which is converted to a long, and the fraction part + * is appended afterwards. Between the integer and the fraction part + * comes a ".". Finally the resulting string is returned. + * + * @see #setUseLocale(boolean) + * @param str String representation of a BigDecimal number. + * @return The default String representation (without Locale) of the + * BigInteger. + * @throws ParseException + * If the String has more than one decimal seperators a parse exception is thrown. + */ + private String myApplyLocaleBD (final String str) throws ParseException + { + if (!this.useLocale || this.currentRadix != 10) + { + return str; + } + + String negPrefix = this.df.getNegativePrefix (); + String negSuffix = this.df.getNegativeSuffix (); + String posPrefix = this.df.getPositivePrefix (); + String posSuffix = this.df.getPositiveSuffix (); + + char d = this.dfs.getDecimalSeparator (); + int begin1, begin2; + boolean isNegativ = false; + String parts = null; + + String tmpStr1 = ""; + + begin1 = str.indexOf (d); + begin2 = str.indexOf (d, begin1 + 1); + + if (begin2 > 0) + { + throw new ParseException ("more than one Decimal seperators", begin2); + } + + parts = str.substring (0, begin1); + + if ((negPrefix.length () > 0 + && str.substring (0, negPrefix.length ()).equals (negPrefix)) + || (negSuffix.length () > 0 + && str.substring (str.length () - + negSuffix.length ()).equals (negSuffix))) + { + parts += negSuffix; + isNegativ = true; + } + else + if ((posPrefix.length () > 0 + && str.substring (0, posPrefix.length ()).equals (posPrefix)) + || (posSuffix.length () > 0 + && str.substring (str.length () - + posSuffix.length ()).equals (posSuffix))) + { + parts += posSuffix; + } + + tmpStr1 = this.actFormat.parse (parts).toString (); + + if (isNegativ) + { + tmpStr1 += + "." + str.substring (str.indexOf (d) + 1, + str.length () - negSuffix.length ()); + } + else + { + tmpStr1 += + "." + str.substring (str.indexOf (d) + 1, + str.length () - posSuffix.length ()); + } + + return tmpStr1; + } + + /** + * Tries to interpret the next String as a BigDecimal. Therfore the + * next String is get with {@link #myCoreNext(boolean, Pattern)} and + * then {@link #myApplyLocaleBD(String)} is called to convert the + * String into a BigDecimal. + * + * @param delete + * Should the found string be deleted or not. + * @return Returns the BigDecimal value of the next string. + * @throws InputMismatchException + * If the string is not a BigDecimal + */ + private BigDecimal myBigDecimal (final boolean delete) throws + InputMismatchException + { + BigDecimal rc; + String tmp = myCoreNext (delete, this.p); + try + { + tmp = myApplyLocaleBD (tmp); + } + catch (ParseException e) + { + throw new InputMismatchException (ERR_PREFIX + tmp + IS_NOT + + "BigDecimal!!"); + } + rc = new BigDecimal (tmp); + + return rc; + } + + /** + * Applies suffix ("\E") and prefix ("\Q") if str.length != 0 Used + * by the toString method. + * + * @param str + * the string on which the suffix and prefix should be applied. + * @return The new new string with the suffix and prefix. + */ + private String myConvert (final String str) + { + if (str != null && str.length () > 0) + { + return "\\Q" + str + "\\E"; + } + return str; + } + + /** + * Searches the current Matcher for the current Pattern. If the end + * is reached during the search it tried to read again from the + * source. The search results are always saved in {@link #actResult} + * which is returned when match() is called. If doSkip is true the + * pattern is also taken. + * + * @param delete + * if true the aktPos is set. + * @param pattern + * pattern to search for. + * @return Returns the String which matches the pattern. + * @throws NoSuchElementException + * If the search has no result. + */ + private String myCoreNext (final boolean delete, final Pattern pattern) + throws NoSuchElementException + { + if (this.isClosed) + { + throw new IllegalStateException ("Scanner closed"); + } + if (shallUseLastFound (pattern != null ? pattern : this.p)) + { + if (this.last_RegionEnd != this.myMatcher.regionEnd ()) + { + System.out.println (this.last_RegionEnd + " != " + + this.myMatcher.regionEnd () + " (" + + (this.last_RegionEnd - + this.myMatcher.regionEnd ()) + ")"); + } + if (delete) + { + this.actPos = this.lastNextPos; + this.lastFoundPresent = false; + this.actResult = this.lastResult; + } + return this.lastFound; + } + + boolean found = false; + int left; + int endIndex; + + String tmp2 = null; + + if (this.actPos > this.MAX_PREFIX) + { + // skipp the processed chars so that the size of the buffer don't grow to much even with + // huge files + this.procesedChars += this.actPos; + this.actBuffer = this.actBuffer.substring (this.actPos); + this.actPos = 0; + this.myMatcher = pattern.matcher (this.actBuffer); + } + + left = this.actBuffer.length () - this.actPos; + if (left < this.MIN_BUF_LEN) + { + myFillBuffer (); + } + found = this.myMatcher.find (this.actPos); + + found = myFillBuffer_loop (this.myMatcher, this.actPos, found); + + this.needInput = false; + + if (found) + { + if (this.doSkipp) + { + endIndex = this.myMatcher.end (); + } + else + { + endIndex = this.myMatcher.start (); + } + tmp2 = this.actBuffer.substring (this.actPos, endIndex); + this.lastNextPos = this.myMatcher.end (); + /* + * if the delete flag is set, just set the current position after the end of the matched + * pattern. + */ + if (delete) + { + this.actPos = this.lastNextPos; + } + else + { + this.lastFound = tmp2; + this.lastFoundPresent = true; + this.lastPatternHash = pattern.hashCode (); + } + this.last_RegionStart = this.myMatcher.regionStart (); + this.last_RegionEnd = this.myMatcher.regionEnd (); + this.last_anchor = this.myMatcher.hasAnchoringBounds (); + this.last_transparent = this.myMatcher.hasTransparentBounds (); + } + else if (this.myMatcher.hitEnd ()) + // the end of input is matched + { + tmp2 = this.actBuffer.substring (this.actPos); + this.lastNextPos = this.actBuffer.length (); + if (delete) + { + this.actPos = this.lastNextPos; + } + else + { + this.lastFound = tmp2; + this.lastFoundPresent = true; + this.lastPatternHash = pattern.hashCode (); + } + this.last_RegionStart = this.myMatcher.regionStart (); + this.last_RegionEnd = this.myMatcher.regionEnd (); + this.last_anchor = this.myMatcher.hasAnchoringBounds (); + this.last_transparent = this.myMatcher.hasTransparentBounds (); + } + else + { + /* + * if no match found an Exception is throwed + */ + throw new NoSuchElementException (); + } + /* + * change the Result only when a nextXXX() method was called, not if a hasNextXXX() method + * is called + */ + if (delete) + { + this.actResult = this.myMatcher.toMatchResult (); + + this.matchValid = this.actResult != null; + } + else + { + this.lastResult = this.myMatcher.toMatchResult (); + } + + this.skipped = this.doSkipp; + this.doSkipp = false; + + return tmp2; + } + + /** + * Used to fill the String buffer from a source. Therfore the 3 + * possible sources are checked if they are not <code>null</code> + * and this not used, otherwise the read method is called on the + * source. If a charsetName is set and not <code>null</code> it is + * applied to convert to String. + */ + private void myFillBuffer () + { + int len; + String tmpStr; + CharBuffer cb = null; + ByteBuffer bb = null; + + if (this.bIS != null) + { + try + { + len = this.bIS.read (this.tmpBuffer); + if (len < 0) + { + return; + } + if (this.charsetName != null) + { + tmpStr = new String (this.tmpBuffer, 0, len, this.charsetName); + } + else + { + tmpStr = new String (this.tmpBuffer, 0, len); + } + this.actBuffer += tmpStr; + } + catch (IOException e) + { + this.lastIOException = e; + } + } + else if (this.readableSource != null) + { + try + { + cb = CharBuffer.allocate (1000); + this.needInput = true; + len = this.readableSource.read (cb); + if (len < 0) + { + return; + } + this.needInput = false; + tmpStr = new String (cb.array ()); + this.actBuffer += tmpStr; + } + catch (IOException e) + { + this.lastIOException = e; + } + } + else if (this.rbcSource != null) + { + try + { + bb = ByteBuffer.allocate (1000); + this.needInput = true; + len = this.rbcSource.read (bb); + this.needInput = false; + if (len < 0) + { + return; + } + if (this.charsetName != null) + { + tmpStr = new String (bb.array (), 0, len, this.charsetName); + } + else + { + tmpStr = new String (bb.array (), 0, len); + } + this.actBuffer += tmpStr; + } + catch (IOException e) + { + this.lastIOException = e; + } + } + + this.myMatcher.reset (this.actBuffer); + } + + /** + * A loop in which the {@link #myFillBuffer()} is called and checked + * if the pattern is found in the matcher and if the buffersize + * changes after the read. + * + * @param aktM + * The current Matcher. + * @param pos + * Position from which the matcher should start matching. + * @param found + * if already found. + * @return <code> true </code> if the matcher has found a match. + */ + private boolean myFillBuffer_loop (final Matcher aktM, final int pos, + boolean found) + { + int tmp; + + tmp = this.actBuffer.length (); + while (aktM.hitEnd () + && ((this.bIS != null) || (this.readableSource != null) + || (this.rbcSource != null))) + { + myFillBuffer (); + if (tmp == this.actBuffer.length ()) + { + break; + } + found = aktM.find (pos); + this.needInput = true; + } + return found; + } + + /** + * Used to find the given pattern in the given string before the + * given horizon. Therfore the current matcher is copied, and + * overwritten using the given pattern and the given Sting. <br> + * After the search the original values are restored, and skipped is + * set <code> true </code>. + * + * @param pattern + * Pattern which should be matched. + * @param str + * The String in which the pattern should be matched. + * @param horizon + * the horizon whithin the match should be, if 0 then it is ignored. + * @return Returns the String in the given String that matches the pattern. + */ + private String myFindPInStr (final Pattern pattern, final String str, + final int horizon) + { + String rc = null; + int curPos = this.actPos; + Matcher aktMatcher = this.myMatcher; + + this.myMatcher = pattern.matcher (str); + if (horizon > 0) + { + this.myMatcher.useAnchoringBounds (true); + this.myMatcher.useTransparentBounds (true); + this.myMatcher.region (this.actPos, this.actPos + horizon); + } + rc = myCoreNext (true, pattern); + this.myMatcher = aktMatcher; + + this.actPos = curPos; + this.skipped = true; + + return rc; + } + + /** + * Used by the {@link #hasNext(Pattern)} and {@link #next(Pattern)} + * methods. Therfore a substring is taken first to the current + * delimiter, afterwards the given pattern is searched in this + * subsring.<br> Finally the current Buffer and matcher (which have + * been temporarily changed) are set back.<br> <br> The {@link + * #skipped} is set <code> true </code>. + * + * @param pattern + * Pattern to find until the current delimiter. + * @param delete + * Is <code> true </code> if a next method is called.<br> + * Is <code> false </code> if a hasNext method is called. + * @return Returns the String which is returned by the public methods. + */ + private String myNext (final Pattern pattern, final boolean delete) + { + String tmpStr; + Matcher aktMatcher = this.myMatcher; + String result; + String currBuffer = this.actBuffer; + int currAktPos; + + tmpStr = myCoreNext (delete, this.p); + this.myMatcher = pattern.matcher (tmpStr); + this.actBuffer = tmpStr; + currAktPos = this.actPos; + this.actPos = 0; + result = myCoreNext (delete, pattern); + this.actPos = currAktPos; + + this.actBuffer = currBuffer; + this.myMatcher = aktMatcher; + this.skipped = true; + + return result; + } + + /** + * Calls the next() method internally to get the next String, and + * trys to apply a locale which is only applied if the radix is 10 + * and useLocale is <code> true </code>. Afterwards it is tried to + * call the Constructor of a {@link BigInteger} with the given + * radix. + * + * @param radix The radix to use. + * @param delete If the found String should be removed from input or + * not. + * @param name name of "BigInteger" in case of an Error. + * @return Returns the new BigInteger created if there is no Error. + * @throws InputMismatchException + * If there is a {@link ParseException} or a {@link NumberFormatException}. + */ + private BigInteger myNextBigInteger (final int radix, final boolean delete, + final String name) + { + BigInteger rc; + String tmp = myPrepareForNext (this.p, delete); + + try + { + tmp = myApplyLocale (tmp, radix); + rc = new BigInteger (tmp, radix); + return rc; + } + catch (NumberFormatException nfe) + { + } + catch (ParseException e) + { + } + throw new InputMismatchException (ERR_PREFIX + tmp + IS_NOT + name); + } + + /** + * Checks if the next String is either "true" or "false", otherwise + * an {@link InputMismatchException} is thrown. It ignores the case + * of the string so that "true" and "TRUE" and even "TrUe" are + * accepted. + * + * @param delete Should the found value be removed from the input or + * not. + * @return Returns the boolean value (if it is a boolean). + * @throws InputMismatchException + * If the next String is not a boolean. + */ + private boolean myNextBoolean (final boolean delete) throws + InputMismatchException + { + String tmp = myPrepareForNext (this.p, delete); + if (tmp.equalsIgnoreCase ("true")) + { + return true; + } + else if (tmp.equalsIgnoreCase ("false")) + { + return false; + } + else + { + throw new InputMismatchException (ERR_PREFIX + tmp + NOT_BOOLEAN); + } + } + + /** + * Calls the {@link #myPrepareForNext(Pattern, boolean)} which calls + * the {@link #myCoreNext(boolean, Pattern)} to return the next + * String matching the current delimier. Afterwards it is tryed to + * convert the String into a byte. Any Error will lead into a {@link + * InputMismatchException}. + * + * @param radix The radix to use. + * @param delete Should the found String be removed from the input. + * @return Returns the byte value of the String. + * @throws InputMismatchException if the next String is not a byte. + */ + private byte myNextByte (final int radix, + final boolean delete) throws InputMismatchException + { + byte rc; + String tmp = myPrepareForNext (this.p, delete); + + try + { + tmp = myApplyLocale (tmp, radix); + rc = Byte.parseByte (tmp, radix); + return rc; + } + catch (NumberFormatException nfe) + { + } + catch (ParseException e) + { + } + throw new InputMismatchException (ERR_PREFIX + tmp + NOT_BYTE); + } + + /** + * Tries to interpret the next String as a double value. To verify + * if the double value is correct, it is converted back to a String + * using the default Locale and this String is compared with the + * String from which the double was converted. If the two Strings + * don't match, an {@link InputMismatchException} is thrown.<br> + * <br> The radix used is always 10 even if the global radix is + * changed. + * + * @param delete Should the String be removed, if true it will be + * also removed if the String is not a double value. + * @return Returns the double value of the next String. + * @throws InputMismatchException if the next String is not a + * double. + */ + private double myNextDouble (final boolean delete) throws + InputMismatchException + { + double rc; + String tmp = myPrepareForNext (this.p, delete); + + try + { + tmp = myApplyLocale (tmp, 10); + rc = Double.parseDouble (tmp); + if (("" + rc).equals (tmp)) + { + return rc; + } + } + catch (ParseException e) + { + } + throw new InputMismatchException (ERR_PREFIX + tmp + NOT_DOUBLE); + } + + /** + * Tries to interpret the next String as an int value. Therfore + * {@link #myApplyLocale(String, int)} decides if the current Locale + * should be applied or not and then the result is parsed using + * {@link Integer#parseInt(String, int)}. Any Error will lead to an + * {@link InputMismatchException}. + * + * @param radix The radix to use. + * @param delete <code> true </code> if the String should be deleted + * from the input. + * @return Returns the int value of the String. + * @throws InputMismatchException if the next String is not an int. + */ + private int myNextInt (final int radix, + final boolean delete) throws InputMismatchException + { + int rc; + String tmp = myPrepareForNext (this.p, delete); + try + { + tmp = myApplyLocale (tmp, radix); + rc = Integer.parseInt (tmp, radix); + return rc; + } + catch (NumberFormatException nfe) + { + } + catch (ParseException e) + { + } + throw new InputMismatchException (ERR_PREFIX + tmp + NOT_INT); + } + + /** + * Finds the next line using the {@link #NEW_LINE} constant which is + * set to the system specific line seperator. + * + * @param delete Should the found line be deleted from the input. + * @return Returns the current line. + */ + private String myNextLine (final boolean delete) + { + String rc = null; + rc = myPrepareForNext (Pattern.compile (NEW_LINE), delete); + return rc; + } + + /** + * Tries to interpret the next String as a long value with the given + * radix. Therfore the {@link Long#parseLong(String, int)} is called + * and every Error will lead into a {@link InputMismatchException}. + * + * @param radix The radix to be used. + * @param delete Should the found String be deleted from the input. + * @return the long value of the next String. + * @throws InputMismatchException if the next String is not a long. + */ + private long myNextLong (final int radix, + final boolean delete) throws InputMismatchException + { + long rc; + String tmp = myPrepareForNext (this.p, delete); + + try + { + tmp = myApplyLocale (tmp, radix); + rc = Long.parseLong (tmp, radix); + return rc; + } + catch (NumberFormatException nfe) + { + } + catch (ParseException e) + { + } + throw new InputMismatchException (ERR_PREFIX + tmp + NOT_LONG); + } + + /** + * Tries to interpret the next String as a short value with the + * given radix. Therfore the {@link Short#parseShort(String, int)} + * is called and every Error will lead into a {@link + * InputMismatchException} . + * + * @param radix + * The radix to be used. + * @param delete + * Should the found String be deleted from the input. + * @return the long value of the next String. + * @throws InputMismatchException + * if the next String is not a short. + */ + private short myNextShort (final int radix, + final boolean delete) throws + InputMismatchException + { + short rc; + String tmp = myPrepareForNext (this.p, delete); + + try + { + tmp = myApplyLocale (tmp, radix); + rc = Short.parseShort (tmp, radix); + return rc; + } + catch (NumberFormatException nfe) + { + } + catch (ParseException e) + { + } + throw new InputMismatchException (ERR_PREFIX + tmp + + "\" is not a short"); + } + + /** + * Sets the current pattern to the given pattern and calls the + * {@link #myCoreNext(boolean, Pattern)}. Finally sets the pattern + * back to its old value. + * + * @param aktPattern Pattern to be used for the next match. + * @param delete Should the found String be deleted or not. + * @return Return the String returned from {@link + * #myCoreNext(boolean, Pattern)}. + */ + private String myPrepareForNext (final Pattern aktPattern, + final boolean delete) + { + + String rc; + Pattern oldPattern = this.p; + useDelimiter (aktPattern); + + rc = myCoreNext (delete, aktPattern); + + useDelimiter (oldPattern); + + return rc; + } + + /** + * Determinates if the last found can be used, so that after a + * hasNextXXX the nextXXX has not to search if nothing has + * changed.<br /> Used in {@link #myCoreNext(boolean, Pattern)}. + * + * @param aktP The pattern which should be checked. + * @return <code> true </code> if the searchresult is already ready. + */ + private boolean shallUseLastFound (final Pattern aktP) + { + if (this.lastFoundPresent && + this.lastPatternHash == aktP.hashCode () && + this.last_RegionStart == this.myMatcher.regionStart () && + this.last_anchor == this.myMatcher.hasAnchoringBounds () && + this.last_transparent == this.myMatcher.hasTransparentBounds ()) + { + if (this.last_RegionEnd != this.myMatcher.regionEnd ()) + { + int tmpVal = + this.myMatcher.regionEnd () - + this.last_RegionEnd - this.MAX_PREFIX; + if (tmpVal > 0 && tmpVal < 20) + { + this.last_RegionEnd = + this.myMatcher.regionEnd (); + return true; + } + } + else + return true; + } + return false; + } + +} diff --git a/libjava/classpath/java/util/Stack.java b/libjava/classpath/java/util/Stack.java index 404a146c272..1d8792882ef 100644 --- a/libjava/classpath/java/util/Stack.java +++ b/libjava/classpath/java/util/Stack.java @@ -102,13 +102,14 @@ public class Stack<T> extends Vector<T> * @return the Object popped from the stack * @throws EmptyStackException if the stack is empty */ + @SuppressWarnings("unchecked") public synchronized T pop() { if (elementCount == 0) throw new EmptyStackException(); modCount++; - T obj = elementData[--elementCount]; + T obj = (T) elementData[--elementCount]; // Set topmost element to null to assist the gc in cleanup. elementData[elementCount] = null; @@ -121,12 +122,13 @@ public class Stack<T> extends Vector<T> * @return the top Object on the stack * @throws EmptyStackException if the stack is empty */ + @SuppressWarnings("unchecked") public synchronized T peek() { if (elementCount == 0) throw new EmptyStackException(); - return elementData[elementCount - 1]; + return (T) elementData[elementCount - 1]; } /** diff --git a/libjava/classpath/java/util/TimeZone.java b/libjava/classpath/java/util/TimeZone.java index 5329e06c11f..681a6a24ad4 100644 --- a/libjava/classpath/java/util/TimeZone.java +++ b/libjava/classpath/java/util/TimeZone.java @@ -40,7 +40,9 @@ exception statement from your version. */ package java.util; import gnu.classpath.SystemProperties; +import gnu.java.lang.CPStringBuilder; import gnu.java.util.ZoneInfo; + import java.io.File; import java.security.AccessController; import java.security.PrivilegedAction; @@ -1404,7 +1406,7 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable { int offset = getRawOffset() + (dst ? getDSTSavings() : 0); - StringBuffer sb = new StringBuffer(9); + CPStringBuilder sb = new CPStringBuilder(9); sb.append("GMT"); offset = offset / (1000 * 60); @@ -1564,7 +1566,7 @@ public abstract class TimeZone implements java.io.Serializable, Cloneable } // Custom IDs have to be normalized - StringBuffer sb = new StringBuffer(9); + CPStringBuilder sb = new CPStringBuilder(9); sb.append("GMT"); sb.append(offset_direction >= 0 ? '+' : '-'); diff --git a/libjava/classpath/java/util/TreeMap.java b/libjava/classpath/java/util/TreeMap.java index f54cbc336ec..1068100d562 100644 --- a/libjava/classpath/java/util/TreeMap.java +++ b/libjava/classpath/java/util/TreeMap.java @@ -39,6 +39,8 @@ exception statement from your version. */ package java.util; +import gnu.java.lang.CPStringBuilder; + import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; @@ -2720,7 +2722,7 @@ public class TreeMap<K, V> extends AbstractMap<K, V> public String toString() { - StringBuilder r = new StringBuilder("{"); + CPStringBuilder r = new CPStringBuilder("{"); final Iterator<Entry<DK,DV>> it = entrySet().iterator(); while (it.hasNext()) { @@ -3158,7 +3160,7 @@ public class TreeMap<K, V> extends AbstractMap<K, V> public String toString() { - StringBuilder r = new StringBuilder("["); + CPStringBuilder r = new CPStringBuilder("["); final Iterator<D> it = iterator(); while (it.hasNext()) { diff --git a/libjava/classpath/java/util/Vector.java b/libjava/classpath/java/util/Vector.java index ea29ce09315..101a78ddac2 100644 --- a/libjava/classpath/java/util/Vector.java +++ b/libjava/classpath/java/util/Vector.java @@ -95,7 +95,7 @@ public class Vector<T> extends AbstractList<T> * in positions 0 through elementCount - 1, and all remaining slots are null. * @serial the elements */ - protected T[] elementData; + protected Object[] elementData; /** * The number of elements currently in the vector, also returned by @@ -133,7 +133,7 @@ public class Vector<T> extends AbstractList<T> public Vector(Collection<? extends T> c) { elementCount = c.size(); - elementData = c.toArray((T[]) new Object[elementCount]); + elementData = c.toArray(new Object[elementCount]); } /** @@ -149,7 +149,7 @@ public class Vector<T> extends AbstractList<T> { if (initialCapacity < 0) throw new IllegalArgumentException(); - elementData = (T[]) new Object[initialCapacity]; + elementData = new Object[initialCapacity]; this.capacityIncrement = capacityIncrement; } @@ -295,11 +295,12 @@ public class Vector<T> extends AbstractList<T> return i < elementCount; } + @SuppressWarnings("unchecked") public T nextElement() { if (i >= elementCount) throw new NoSuchElementException(); - return elementData[i++]; + return (T) elementData[i++]; } }; } @@ -385,10 +386,11 @@ public class Vector<T> extends AbstractList<T> * @throws ArrayIndexOutOfBoundsException index < 0 || index >= size() * @see #get(int) */ + @SuppressWarnings("unchecked") public synchronized T elementAt(int index) { checkBoundExclusive(index); - return elementData[index]; + return (T) elementData[index]; } /** @@ -397,12 +399,13 @@ public class Vector<T> extends AbstractList<T> * @return the first Object in the Vector * @throws NoSuchElementException the Vector is empty */ + @SuppressWarnings("unchecked") public synchronized T firstElement() { if (elementCount == 0) throw new NoSuchElementException(); - return elementData[0]; + return (T) elementData[0]; } /** @@ -411,12 +414,13 @@ public class Vector<T> extends AbstractList<T> * @return the last Object in the Vector * @throws NoSuchElementException the Vector is empty */ + @SuppressWarnings("unchecked") public synchronized T lastElement() { if (elementCount == 0) throw new NoSuchElementException(); - return elementData[elementCount - 1]; + return (T) elementData[elementCount - 1]; } /** @@ -604,10 +608,11 @@ public class Vector<T> extends AbstractList<T> * @throws ArrayIndexOutOfBoundsException index < 0 || index >= size() * @since 1.2 */ + @SuppressWarnings("unchecked") public synchronized T set(int index, T element) { checkBoundExclusive(index); - T temp = elementData[index]; + T temp = (T) elementData[index]; elementData[index] = element; return temp; } @@ -660,10 +665,11 @@ public class Vector<T> extends AbstractList<T> * @throws ArrayIndexOutOfBoundsException index < 0 || index >= size() * @since 1.2 */ + @SuppressWarnings("unchecked") public synchronized T remove(int index) { checkBoundExclusive(index); - T temp = elementData[index]; + T temp = (T) elementData[index]; modCount++; elementCount--; if (index < elementCount) @@ -903,7 +909,7 @@ public class Vector<T> extends AbstractList<T> // use of a negative index will cause an ArrayIndexOutOfBoundsException // with no effort on our part. if (index > elementCount) - throw new ArrayIndexOutOfBoundsException(index + " > " + elementCount); + raiseBoundsError(index, " > "); } /** @@ -918,10 +924,25 @@ public class Vector<T> extends AbstractList<T> // use of a negative index will cause an ArrayIndexOutOfBoundsException // with no effort on our part. if (index >= elementCount) - throw new ArrayIndexOutOfBoundsException(index + " >= " + elementCount); + raiseBoundsError(index, " >= "); } /** + * Raise the ArrayIndexOfOutBoundsException. + * + * @param index the index of the access + * @param operator the operator to include in the error message + * @throws IndexOutOfBoundsException unconditionally + */ + private void raiseBoundsError(int index, String operator) + { + // Implementaion note: put in a separate method to make the JITs job easier + // (separate common from uncommon code at method boundaries when trivial to + // do so). + throw new ArrayIndexOutOfBoundsException(index + operator + elementCount); + } + + /** * Serializes this object to the given stream. * * @param s the stream to write to diff --git a/libjava/classpath/java/util/logging/FileHandler.java b/libjava/classpath/java/util/logging/FileHandler.java index 357d51e14fc..deba5c2e55c 100644 --- a/libjava/classpath/java/util/logging/FileHandler.java +++ b/libjava/classpath/java/util/logging/FileHandler.java @@ -38,6 +38,8 @@ exception statement from your version. */ package java.util.logging; +import gnu.java.lang.CPStringBuilder; + import java.io.File; import java.io.FileOutputStream; import java.io.FilterOutputStream; @@ -478,7 +480,7 @@ public class FileHandler int uniqueNumber, int count) { - StringBuffer buf = new StringBuffer(pattern); + CPStringBuilder buf = new CPStringBuilder(pattern); String replaceWith; boolean foundGeneration = false; diff --git a/libjava/classpath/java/util/logging/Logger.java b/libjava/classpath/java/util/logging/Logger.java index f7157c17698..cddc02d1c9c 100644 --- a/libjava/classpath/java/util/logging/Logger.java +++ b/libjava/classpath/java/util/logging/Logger.java @@ -38,6 +38,8 @@ exception statement from your version. */ package java.util.logging; +import gnu.java.lang.CPStringBuilder; + import java.util.List; import java.util.MissingResourceException; import java.util.ResourceBundle; @@ -776,7 +778,7 @@ public class Logger { if (isLoggable(Level.FINER)) { - StringBuffer buf = new StringBuffer(80); + CPStringBuilder buf = new CPStringBuilder(80); buf.append("ENTRY"); for (int i = 0; i < params.length; i++) { diff --git a/libjava/classpath/java/util/logging/SimpleFormatter.java b/libjava/classpath/java/util/logging/SimpleFormatter.java index 2ebb1a1485f..da731f2b1de 100644 --- a/libjava/classpath/java/util/logging/SimpleFormatter.java +++ b/libjava/classpath/java/util/logging/SimpleFormatter.java @@ -39,6 +39,8 @@ exception statement from your version. */ package java.util.logging; +import gnu.java.lang.CPStringBuilder; + import java.io.PrintWriter; import java.io.StringWriter; import java.text.DateFormat; @@ -98,7 +100,7 @@ public class SimpleFormatter */ public String format(LogRecord record) { - StringBuffer buf = new StringBuffer(180); + CPStringBuilder buf = new CPStringBuilder(180); if (dateFormat == null) dateFormat = DateFormat.getDateTimeInstance(); diff --git a/libjava/classpath/java/util/logging/XMLFormatter.java b/libjava/classpath/java/util/logging/XMLFormatter.java index 8f5769be1b9..194fcd238ce 100644 --- a/libjava/classpath/java/util/logging/XMLFormatter.java +++ b/libjava/classpath/java/util/logging/XMLFormatter.java @@ -39,6 +39,8 @@ exception statement from your version. */ package java.util.logging; +import gnu.java.lang.CPStringBuilder; + import java.text.SimpleDateFormat; import java.util.Date; import java.util.ResourceBundle; @@ -86,10 +88,10 @@ public class XMLFormatter /** * Appends a line consisting of indentation, opening element tag, * element content, closing element tag and line separator to - * a StringBuffer, provided that the element content is + * a CPStringBuilder, provided that the element content is * actually existing. * - * @param buf the StringBuffer to which the line will be appended. + * @param buf the CPStringBuilder to which the line will be appended. * * @param indent the indentation level. * @@ -98,7 +100,7 @@ public class XMLFormatter * @param content the element content, or <code>null</code> to * have no output whatsoever appended to <code>buf</code>. */ - private static void appendTag(StringBuffer buf, int indent, + private static void appendTag(CPStringBuilder buf, int indent, String tag, String content) { int i; @@ -163,9 +165,9 @@ public class XMLFormatter /** * Appends a line consisting of indentation, opening element tag, * numeric element content, closing element tag and line separator - * to a StringBuffer. + * to a CPStringBuilder. * - * @param buf the StringBuffer to which the line will be appended. + * @param buf the CPStringBuilder to which the line will be appended. * * @param indent the indentation level. * @@ -173,7 +175,7 @@ public class XMLFormatter * * @param content the element content. */ - private static void appendTag(StringBuffer buf, int indent, + private static void appendTag(CPStringBuilder buf, int indent, String tag, long content) { appendTag(buf, indent, tag, Long.toString(content)); @@ -182,7 +184,7 @@ public class XMLFormatter public String format(LogRecord record) { - StringBuffer buf = new StringBuffer(400); + CPStringBuilder buf = new CPStringBuilder(400); Level level = record.getLevel(); long millis = record.getMillis(); Object[] params = record.getParameters(); @@ -314,10 +316,10 @@ public class XMLFormatter */ public String getHead(Handler h) { - StringBuffer buf; + CPStringBuilder buf; String encoding; - buf = new StringBuffer(80); + buf = new CPStringBuilder(80); buf.append("<?xml version=\"1.0\" encoding=\""); encoding = h.getEncoding(); diff --git a/libjava/classpath/java/util/prefs/AbstractPreferences.java b/libjava/classpath/java/util/prefs/AbstractPreferences.java index f3a62e6980d..9562e1bbf5b 100644 --- a/libjava/classpath/java/util/prefs/AbstractPreferences.java +++ b/libjava/classpath/java/util/prefs/AbstractPreferences.java @@ -38,7 +38,8 @@ exception statement from your version. */ package java.util.prefs; -import gnu.java.util.prefs.EventDispatcher; +import gnu.classpath.toolkit.DefaultDaemonThreadFactory; +import gnu.java.lang.CPStringBuilder; import gnu.java.util.prefs.NodeWriter; import java.io.ByteArrayOutputStream; @@ -49,6 +50,8 @@ import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.TreeSet; +import java.util.concurrent.Executor; +import java.util.concurrent.Executors; /** * Partial implementation of a Preference node. @@ -841,7 +844,7 @@ public abstract class AbstractPreferences extends Preferences { * Helper method for encoding an array of bytes as a Base64 String. */ private static String encode64(byte[] b) { - StringBuffer sb = new StringBuffer((b.length/3)*4); + CPStringBuilder sb = new CPStringBuilder((b.length/3)*4); int i = 0; int remaining = b.length; @@ -1236,17 +1239,18 @@ public abstract class AbstractPreferences extends Preferences { */ private void fire(final PreferenceChangeEvent event) { - Iterator it = preferenceListeners.iterator(); - while (it.hasNext()) + for (final PreferenceChangeListener listener : preferenceListeners) { - final PreferenceChangeListener l = (PreferenceChangeListener) it.next(); - EventDispatcher.dispatch(new Runnable() - { - public void run() - { - l.preferenceChange(event); - } - }); + Runnable dispatcher = new Runnable() { + public void run() + { + listener.preferenceChange(event); + } + }; + + Executor executor = + Executors.newSingleThreadExecutor(new DefaultDaemonThreadFactory()); + executor.execute(dispatcher); } } @@ -1258,20 +1262,21 @@ public abstract class AbstractPreferences extends Preferences { */ private void fire(final NodeChangeEvent event, final boolean added) { - Iterator it = nodeListeners.iterator(); - while (it.hasNext()) + for (final NodeChangeListener listener : nodeListeners) { - final NodeChangeListener l = (NodeChangeListener) it.next(); - EventDispatcher.dispatch(new Runnable() - { - public void run() - { - if (added) - l.childAdded(event); - else - l.childRemoved(event); - } - }); + Runnable dispatcher = new Runnable() { + public void run() + { + if (added) + listener.childAdded(event); + else + listener.childRemoved(event); + } + }; + + Executor executor = + Executors.newSingleThreadExecutor(new DefaultDaemonThreadFactory()); + executor.execute(dispatcher); } } diff --git a/libjava/classpath/java/util/regex/Matcher.java b/libjava/classpath/java/util/regex/Matcher.java index bf833673b0e..50cb065f287 100644 --- a/libjava/classpath/java/util/regex/Matcher.java +++ b/libjava/classpath/java/util/regex/Matcher.java @@ -38,6 +38,8 @@ exception statement from your version. */ package java.util.regex; +import gnu.java.lang.CPStringBuilder; + import gnu.java.util.regex.CharIndexed; import gnu.java.util.regex.RE; import gnu.java.util.regex.REMatch; @@ -59,11 +61,45 @@ public final class Matcher implements MatchResult private int appendPosition; private REMatch match; + /** + * The start of the region of the input on which to match. + */ + private int regionStart; + + /** + * The end of the region of the input on which to match. + */ + private int regionEnd; + + /** + * True if the match process should look beyond the + * region marked by regionStart to regionEnd when + * performing lookAhead, lookBehind and boundary + * matching. + */ + private boolean transparentBounds; + + /** + * The flags that affect the anchoring bounds. + * If {@link #hasAnchoringBounds()} is {@code true}, + * the match process will honour the + * anchoring bounds: ^, \A, \Z, \z and $. If + * {@link #hasAnchoringBounds()} is {@code false}, + * the anchors are ignored and appropriate flags, + * stored in this variable, are used to provide this + * behaviour. + */ + private int anchoringBounds; + Matcher(Pattern pattern, CharSequence input) { this.pattern = pattern; this.input = input; this.inputCharIndexed = RE.makeCharIndexed(input, 0); + regionStart = 0; + regionEnd = input.length(); + transparentBounds = false; + anchoringBounds = 0; } /** @@ -125,13 +161,17 @@ public final class Matcher implements MatchResult public boolean find () { boolean first = (match == null); - match = pattern.getRE().getMatch(inputCharIndexed, position); + if (transparentBounds || (regionStart == 0 && regionEnd == input.length())) + match = pattern.getRE().getMatch(inputCharIndexed, position, anchoringBounds); + else + match = pattern.getRE().getMatch(input.subSequence(regionStart, regionEnd), + position, anchoringBounds); if (match != null) { int endIndex = match.getEndIndex(); // Are we stuck at the same position? if (!first && endIndex == position) - { + { match = null; // Not at the end of the input yet? if (position < input.length() - 1) @@ -156,7 +196,11 @@ public final class Matcher implements MatchResult */ public boolean find (int start) { - match = pattern.getRE().getMatch(inputCharIndexed, start); + if (transparentBounds || (regionStart == 0 && regionEnd == input.length())) + match = pattern.getRE().getMatch(inputCharIndexed, start, anchoringBounds); + else + match = pattern.getRE().getMatch(input.subSequence(regionStart, regionEnd), + start, anchoringBounds); if (match != null) { position = match.getEndIndex(); @@ -218,7 +262,12 @@ public final class Matcher implements MatchResult public boolean lookingAt () { - match = pattern.getRE().getMatch(inputCharIndexed, 0, RE.REG_FIX_STARTING_POSITION, null); + if (transparentBounds || (regionStart == 0 && regionEnd == input.length())) + match = pattern.getRE().getMatch(inputCharIndexed, regionStart, + anchoringBounds|RE.REG_FIX_STARTING_POSITION|RE.REG_ANCHORINDEX); + else + match = pattern.getRE().getMatch(input.subSequence(regionStart, regionEnd), 0, + anchoringBounds|RE.REG_FIX_STARTING_POSITION); if (match != null) { if (match.getStartIndex() == 0) @@ -243,7 +292,12 @@ public final class Matcher implements MatchResult */ public boolean matches () { - match = pattern.getRE().getMatch(inputCharIndexed, 0, RE.REG_TRY_ENTIRE_MATCH|RE.REG_FIX_STARTING_POSITION, null); + if (transparentBounds || (regionStart == 0 && regionEnd == input.length())) + match = pattern.getRE().getMatch(inputCharIndexed, regionStart, + anchoringBounds|RE.REG_TRY_ENTIRE_MATCH|RE.REG_FIX_STARTING_POSITION|RE.REG_ANCHORINDEX); + else + match = pattern.getRE().getMatch(input.subSequence(regionStart, regionEnd), 0, + anchoringBounds|RE.REG_TRY_ENTIRE_MATCH|RE.REG_FIX_STARTING_POSITION); if (match != null) { if (match.getStartIndex() == 0) @@ -265,15 +319,40 @@ public final class Matcher implements MatchResult return pattern; } + /** + * Resets the internal state of the matcher, including + * resetting the region to its default state of encompassing + * the whole input. The state of {@link #hasTransparentBounds()} + * and {@link #hasAnchoringBounds()} are unaffected. + * + * @return a reference to this matcher. + * @see #regionStart() + * @see #regionEnd() + * @see #hasTransparentBounds() + * @see #hasAnchoringBounds() + */ public Matcher reset () { position = 0; match = null; + regionStart = 0; + regionEnd = input.length(); + appendPosition = 0; return this; } /** - * @param input The new input character sequence + * Resets the internal state of the matcher, including + * resetting the region to its default state of encompassing + * the whole input. The state of {@link #hasTransparentBounds()} + * and {@link #hasAnchoringBounds()} are unaffected. + * + * @param input The new input character sequence. + * @return a reference to this matcher. + * @see #regionStart() + * @see #regionEnd() + * @see #hasTransparentBounds() + * @see #hasAnchoringBounds() */ public Matcher reset (CharSequence input) { @@ -283,7 +362,7 @@ public final class Matcher implements MatchResult } /** - * @returns the index of a capturing group in this matcher's pattern + * @return the index of a capturing group in this matcher's pattern * * @exception IllegalStateException If no match has yet been attempted, * or if the previous match operation failed @@ -312,6 +391,7 @@ public final class Matcher implements MatchResult /** * @return True if and only if the matcher hit the end of input. + * @since 1.5 */ public boolean hitEnd() { @@ -323,10 +403,12 @@ public final class Matcher implements MatchResult */ public String toString() { - StringBuilder sb = new StringBuilder(); + CPStringBuilder sb = new CPStringBuilder(); sb.append(this.getClass().getName()) .append("[pattern=").append(pattern.pattern()) - .append(" region=").append("0").append(",").append(input.length()) + .append(" region=").append(regionStart).append(",").append(regionEnd) + .append(" anchoringBounds=").append(anchoringBounds == 0) + .append(" transparentBounds=").append(transparentBounds) .append(" lastmatch=").append(match == null ? "" : match.toString()) .append("]"); return sb.toString(); @@ -336,4 +418,193 @@ public final class Matcher implements MatchResult { if (match == null) throw new IllegalStateException(); } + + /** + * <p> + * Defines the region of the input on which to match. + * By default, the {@link Matcher} attempts to match + * the whole string (from 0 to the length of the input), + * but a region between {@code start} (inclusive) and + * {@code end} (exclusive) on which to match may instead + * be defined using this method. + * </p> + * <p> + * The behaviour of region matching is further affected + * by the use of transparent or opaque bounds (see + * {@link #useTransparentBounds(boolean)}) and whether or not + * anchors ({@code ^} and {@code $}) are in use + * (see {@link #useAnchoringBounds(boolean)}). With transparent + * bounds, the matcher is aware of input outside the bounds + * set by this method, whereas, with opaque bounds (the default) + * only the input within the bounds is used. The use of + * anchors are affected by this setting; with transparent + * bounds, anchors will match the beginning of the real input, + * while with opaque bounds they match the beginning of the + * region. {@link #useAnchoringBounds(boolean)} can be used + * to turn on or off the matching of anchors. + * </p> + * + * @param start the start of the region (inclusive). + * @param end the end of the region (exclusive). + * @return a reference to this matcher. + * @throws IndexOutOfBoundsException if either {@code start} or + * {@code end} are less than zero, + * if either {@code start} or + * {@code end} are greater than the + * length of the input, or if + * {@code start} is greater than + * {@code end}. + * @see #regionStart() + * @see #regionEnd() + * @see #hasTransparentBounds() + * @see #useTransparentBounds(boolean) + * @see #hasAnchoringBounds() + * @see #useAnchoringBounds(boolean) + * @since 1.5 + */ + public Matcher region(int start, int end) + { + int length = input.length(); + if (start < 0) + throw new IndexOutOfBoundsException("The start position was less than zero."); + if (start >= length) + throw new IndexOutOfBoundsException("The start position is after the end of the input."); + if (end < 0) + throw new IndexOutOfBoundsException("The end position was less than zero."); + if (end > length) + throw new IndexOutOfBoundsException("The end position is after the end of the input."); + if (start > end) + throw new IndexOutOfBoundsException("The start position is after the end position."); + reset(); + regionStart = start; + regionEnd = end; + return this; + } + + /** + * The start of the region on which to perform matches (inclusive). + * + * @return the start index of the region. + * @see #region(int,int) + * #see #regionEnd() + * @since 1.5 + */ + public int regionStart() + { + return regionStart; + } + + /** + * The end of the region on which to perform matches (exclusive). + * + * @return the end index of the region. + * @see #region(int,int) + * @see #regionStart() + * @since 1.5 + */ + public int regionEnd() + { + return regionEnd; + } + + /** + * Returns true if the bounds of the region marked by + * {@link #regionStart()} and {@link #regionEnd()} are + * transparent. When these bounds are transparent, the + * matching process can look beyond them to perform + * lookahead, lookbehind and boundary matching operations. + * By default, the bounds are opaque. + * + * @return true if the bounds of the matching region are + * transparent. + * @see #useTransparentBounds(boolean) + * @see #region(int,int) + * @see #regionStart() + * @see #regionEnd() + * @since 1.5 + */ + public boolean hasTransparentBounds() + { + return transparentBounds; + } + + /** + * Sets the transparency of the bounds of the region + * marked by {@link #regionStart()} and {@link #regionEnd()}. + * A value of {@code true} makes the bounds transparent, + * so the matcher can see beyond them to perform lookahead, + * lookbehind and boundary matching operations. A value + * of {@code false} (the default) makes the bounds opaque, + * restricting the match to the input region denoted + * by {@link #regionStart()} and {@link #regionEnd()}. + * + * @param transparent true if the bounds should be transparent. + * @return a reference to this matcher. + * @see #hasTransparentBounds() + * @see #region(int,int) + * @see #regionStart() + * @see #regionEnd() + * @since 1.5 + */ + public Matcher useTransparentBounds(boolean transparent) + { + transparentBounds = transparent; + return this; + } + + /** + * Returns true if the matcher will honour the use of + * the anchoring bounds: {@code ^}, {@code \A}, {@code \Z}, + * {@code \z} and {@code $}. By default, the anchors + * are used. Note that the effect of the anchors is + * also affected by {@link #hasTransparentBounds()}. + * + * @return true if the matcher will attempt to match + * the anchoring bounds. + * @see #useAnchoringBounds(boolean) + * @see #hasTransparentBounds() + * @since 1.5 + */ + public boolean hasAnchoringBounds() + { + return anchoringBounds == 0; + } + + /** + * Enables or disables the use of the anchoring bounds: + * {@code ^}, {@code \A}, {@code \Z}, {@code \z} and + * {@code $}. By default, their use is enabled. When + * disabled, the matcher will not attempt to match + * the anchors. + * + * @param useAnchors true if anchoring bounds should be used. + * @return a reference to this matcher. + * @since 1.5 + * @see #hasAnchoringBounds() + */ + public Matcher useAnchoringBounds(boolean useAnchors) + { + if (useAnchors) + anchoringBounds = 0; + else + anchoringBounds = RE.REG_NOTBOL|RE.REG_NOTEOL; + return this; + } + + /** + * Returns a read-only snapshot of the current state of + * the {@link Matcher} as a {@link MatchResult}. Any + * subsequent changes to this instance are not reflected + * in the returned {@link MatchResult}. + * + * @return a {@link MatchResult} instance representing the + * current state of the {@link Matcher}. + */ + public MatchResult toMatchResult() + { + Matcher snapshot = new Matcher(pattern, input); + snapshot.match = (REMatch) match.clone(); + return snapshot; + } + } diff --git a/libjava/classpath/java/util/regex/Pattern.java b/libjava/classpath/java/util/regex/Pattern.java index 217ce0862a9..35ec0b89eb6 100644 --- a/libjava/classpath/java/util/regex/Pattern.java +++ b/libjava/classpath/java/util/regex/Pattern.java @@ -191,7 +191,7 @@ public final class Pattern implements Serializable public String[] split (CharSequence input, int limit) { Matcher matcher = new Matcher(this, input); - ArrayList list = new ArrayList(); + ArrayList<String> list = new ArrayList<String>(); int empties = 0; int count = 0; int start = 0; @@ -251,9 +251,7 @@ public final class Pattern implements Serializable list.add(t); } - String[] output = new String [list.size()]; - list.toArray(output); - return output; + return list.toArray(new String[list.size()]); } public String pattern () diff --git a/libjava/classpath/java/util/regex/PatternSyntaxException.java b/libjava/classpath/java/util/regex/PatternSyntaxException.java index 41e650d324b..38e27db2709 100644 --- a/libjava/classpath/java/util/regex/PatternSyntaxException.java +++ b/libjava/classpath/java/util/regex/PatternSyntaxException.java @@ -37,6 +37,8 @@ exception statement from your version. */ package java.util.regex; +import gnu.java.lang.CPStringBuilder; + /** * Indicates illegal pattern for regular expression. * Includes state to inspect the pattern and what and where the expression @@ -115,7 +117,7 @@ public class PatternSyntaxException extends IllegalArgumentException public String getMessage() { String lineSep = System.getProperty("line.separator"); - StringBuffer sb = new StringBuffer(desc); + CPStringBuilder sb = new CPStringBuilder(desc); sb.append(lineSep); sb.append('\t'); sb.append(pattern); diff --git a/libjava/classpath/java/util/zip/Deflater.java b/libjava/classpath/java/util/zip/Deflater.java index e97c6054ff4..41d9881448c 100644 --- a/libjava/classpath/java/util/zip/Deflater.java +++ b/libjava/classpath/java/util/zip/Deflater.java @@ -241,7 +241,6 @@ public class Deflater /** * Gets the number of input bytes processed so far. */ - @Deprecated public int getTotalIn() { return (int) engine.getTotalIn(); @@ -259,7 +258,6 @@ public class Deflater /** * Gets the number of output bytes so far. */ - @Deprecated public int getTotalOut() { return (int) totalOut; diff --git a/libjava/classpath/java/util/zip/Inflater.java b/libjava/classpath/java/util/zip/Inflater.java index 509b9576429..e3e555ab995 100644 --- a/libjava/classpath/java/util/zip/Inflater.java +++ b/libjava/classpath/java/util/zip/Inflater.java @@ -246,7 +246,6 @@ public class Inflater * Gets the total number of processed compressed input bytes. * @return the total number of bytes of processed input bytes. */ - @Deprecated public int getTotalIn() { return (int) (totalIn - getRemaining()); @@ -266,7 +265,6 @@ public class Inflater * Gets the total number of output bytes returned by inflate(). * @return the total number of output bytes. */ - @Deprecated public int getTotalOut() { return (int) totalOut; diff --git a/libjava/classpath/java/util/zip/ZipEntry.java b/libjava/classpath/java/util/zip/ZipEntry.java index 893f043746d..a6d01af5ff6 100644 --- a/libjava/classpath/java/util/zip/ZipEntry.java +++ b/libjava/classpath/java/util/zip/ZipEntry.java @@ -50,23 +50,39 @@ import java.util.Calendar; */ public class ZipEntry implements ZipConstants, Cloneable { - private static final int KNOWN_SIZE = 1; - private static final int KNOWN_CSIZE = 2; - private static final int KNOWN_CRC = 4; - private static final int KNOWN_TIME = 8; - private static final int KNOWN_EXTRA = 16; - - private static Calendar cal; - - private String name; + private static final byte KNOWN_SIZE = 1; + private static final byte KNOWN_CSIZE = 2; + private static final byte KNOWN_CRC = 4; + private static final byte KNOWN_TIME = 8; + private static final byte KNOWN_DOSTIME = 16; + private static final byte KNOWN_EXTRA = 32; + + /** Immutable name of the entry */ + private final String name; + /** Uncompressed size */ private int size; + /** Compressed size */ private long compressedSize = -1; + /** CRC of uncompressed data */ private int crc; + /** Comment or null if none */ + private String comment = null; + /** The compression method. Either DEFLATED or STORED, by default -1. */ + private byte method = -1; + /** Flags specifying what we know about this entry */ + private byte known = 0; + /** + * The 32bit DOS encoded format for the time of this entry. Only valid if + * KNOWN_DOSTIME is set in known. + */ private int dostime; - private short known = 0; - private short method = -1; + /** + * The 64bit Java encoded millisecond time since the beginning of the epoch. + * Only valid if KNOWN_TIME is set in known. + */ + private long time; + /** Extra data */ private byte[] extra = null; - private String comment = null; int flags; /* used by ZipOutputStream */ int offset; /* used by ZipFile and ZipOutputStream */ @@ -113,6 +129,7 @@ public class ZipEntry implements ZipConstants, Cloneable compressedSize = e.compressedSize; crc = e.crc; dostime = e.dostime; + time = e.time; method = e.method; extra = e.extra; comment = e.comment; @@ -121,37 +138,60 @@ public class ZipEntry implements ZipConstants, Cloneable final void setDOSTime(int dostime) { this.dostime = dostime; - known |= KNOWN_TIME; + known |= KNOWN_DOSTIME; + known &= ~KNOWN_TIME; } final int getDOSTime() { - if ((known & KNOWN_TIME) == 0) - return 0; - else + if ((known & KNOWN_DOSTIME) != 0) return dostime; + else if ((known & KNOWN_TIME) != 0) + { + Calendar cal = Calendar.getInstance(); + cal.setTimeInMillis(time); + dostime = (cal.get(Calendar.YEAR) - 1980 & 0x7f) << 25 + | (cal.get(Calendar.MONTH) + 1) << 21 + | (cal.get(Calendar.DAY_OF_MONTH)) << 16 + | (cal.get(Calendar.HOUR_OF_DAY)) << 11 + | (cal.get(Calendar.MINUTE)) << 5 + | (cal.get(Calendar.SECOND)) >> 1; + known |= KNOWN_DOSTIME; + return dostime; + } + else + return 0; } /** * Creates a copy of this zip entry. */ - /** - * Clones the entry. - */ public Object clone() { - try + // JCL defines this as being the same as the copy constructor above, + // except that value of the "extra" field is also copied. Take care + // that in the case of a subclass we use clone() rather than the copy + // constructor. + ZipEntry clone; + if (this.getClass() == ZipEntry.class) + clone = new ZipEntry(this); + else { - // The JCL says that the `extra' field is also copied. - ZipEntry clone = (ZipEntry) super.clone(); - if (extra != null) - clone.extra = (byte[]) extra.clone(); - return clone; + try + { + clone = (ZipEntry) super.clone(); + } + catch (CloneNotSupportedException e) + { + throw new InternalError(); + } } - catch (CloneNotSupportedException ex) + if (extra != null) { - throw new InternalError(); + clone.extra = new byte[extra.length]; + System.arraycopy(extra, 0, clone.extra, 0, extra.length); } + return clone; } /** @@ -169,18 +209,9 @@ public class ZipEntry implements ZipConstants, Cloneable */ public void setTime(long time) { - Calendar cal = getCalendar(); - synchronized (cal) - { - cal.setTimeInMillis(time); - dostime = (cal.get(Calendar.YEAR) - 1980 & 0x7f) << 25 - | (cal.get(Calendar.MONTH) + 1) << 21 - | (cal.get(Calendar.DAY_OF_MONTH)) << 16 - | (cal.get(Calendar.HOUR_OF_DAY)) << 11 - | (cal.get(Calendar.MINUTE)) << 5 - | (cal.get(Calendar.SECOND)) >> 1; - } + this.time = time; this.known |= KNOWN_TIME; + this.known &= ~KNOWN_DOSTIME; } /** @@ -192,39 +223,34 @@ public class ZipEntry implements ZipConstants, Cloneable // The extra bytes might contain the time (posix/unix extension) parseExtra(); - if ((known & KNOWN_TIME) == 0) - return -1; - - int sec = 2 * (dostime & 0x1f); - int min = (dostime >> 5) & 0x3f; - int hrs = (dostime >> 11) & 0x1f; - int day = (dostime >> 16) & 0x1f; - int mon = ((dostime >> 21) & 0xf) - 1; - int year = ((dostime >> 25) & 0x7f) + 1980; /* since 1900 */ - - try - { - cal = getCalendar(); - synchronized (cal) - { - cal.set(year, mon, day, hrs, min, sec); - return cal.getTimeInMillis(); - } - } - catch (RuntimeException ex) + if ((known & KNOWN_TIME) != 0) + return time; + else if ((known & KNOWN_DOSTIME) != 0) { - /* Ignore illegal time stamp */ - known &= ~KNOWN_TIME; - return -1; + int sec = 2 * (dostime & 0x1f); + int min = (dostime >> 5) & 0x3f; + int hrs = (dostime >> 11) & 0x1f; + int day = (dostime >> 16) & 0x1f; + int mon = ((dostime >> 21) & 0xf) - 1; + int year = ((dostime >> 25) & 0x7f) + 1980; /* since 1900 */ + + try + { + Calendar cal = Calendar.getInstance(); + cal.set(year, mon, day, hrs, min, sec); + time = cal.getTimeInMillis(); + known |= KNOWN_TIME; + return time; + } + catch (RuntimeException ex) + { + /* Ignore illegal time stamp */ + known &= ~KNOWN_TIME; + return -1; + } } - } - - private static synchronized Calendar getCalendar() - { - if (cal == null) - cal = Calendar.getInstance(); - - return cal; + else + return -1; } /** @@ -298,7 +324,7 @@ public class ZipEntry implements ZipConstants, Cloneable if (method != ZipOutputStream.STORED && method != ZipOutputStream.DEFLATED) throw new IllegalArgumentException(); - this.method = (short) method; + this.method = (byte) method; } /** diff --git a/libjava/classpath/java/util/zip/ZipFile.java b/libjava/classpath/java/util/zip/ZipFile.java index 3b34bd1f50b..7cf7007ed8f 100644 --- a/libjava/classpath/java/util/zip/ZipFile.java +++ b/libjava/classpath/java/util/zip/ZipFile.java @@ -340,7 +340,7 @@ public class ZipFile implements ZipConstants } catch (IOException ioe) { - return EmptyEnumeration.getInstance(); + return new EmptyEnumeration<ZipEntry>(); } } |