libjava/classpath/ChangeLog.gcj:

2007-05-31  Matthias Klose  <doko@ubuntu.com>

        * javax/management/NotificationBroadcasterSupport.java
        (getNotificationInfo): Add cast.
        * native/jni/qt-peer/Makefile.am (AM_CXXFLAGS): Add libstdc++ include
        directories.
        * native/jni/qt-peer/Makefile.in: Regenerate.

libjava/ChangeLog:

2007-06-03  Matthias Klose  <doko@ubuntu.com>

        * java/io/natFileWin32.cc (setFilePermissions): New (stub only).
        _access: Handle EXEC query, stub only.

2007-06-03  Matthias Klose  <doko@ubuntu.com>

        Merged from classpath:
        * gnu/java/nio/SelectorProviderImpl.java: Whitespace merge.
        * java/lang/System.java(inheritedChannel): New.
        * java/lang/Character.java: Remove stray`;'.
        * java/net/MulticastSocket.java: Merged.
        * java/text/DateFormatSymbols.java(getInstance): New, comment updates.
        * java/text/Collator.java(getInstance): Merged.
        * java/util/Calendar.java: New attributes ALL_STYLES, SHORT, LONG.
        getDisplayName, getDisplayNames: New.
        * java/util/logging/Logger.java: Merged.
        * Regenerate .class and .h files.

2007-06-03  Matthias Klose  <doko@ubuntu.com>

        * java/io/File.java: Merge with classpath-0.95, new method
        setFilePermissions, new attribute EXEC.
        * java/io/natFilePosix.cc (setFilePermissions): New.
        _access: Handle EXEC query.
        * classpath/lib/java/io/File.class, java/io/File.h: Regenerate.

2007-06-03  Matthias Klose  <doko@ubuntu.com>

        Imported GNU Classpath 0.95.

        * classpath/Makefile.in,
        classpath/native/jni/midi-dssi/Makefile.in,
        classpath/native/jni/classpath/Makefile.in,
        classpath/native/jni/Makefile.in,
        classpath/native/jni/gconf-peer/Makefile.in,
        classpath/native/jni/java-io/Makefile.in,
        classpath/native/jni/native-lib/Makefile.in,
        classpath/native/jni/java-util/Makefile.in,
        classpath/native/jni/midi-alsa/Makefile.in,
        classpath/native/jni/java-lang/Makefile.in,
        classpath/native/jni/java-nio/Makefile.in,
        classpath/native/jni/java-net/Makefile.in,
        classpath/native/jni/xmlj/Makefile.in,
        classpath/native/jni/qt-peer/Makefile.in,
        classpath/native/jni/gtk-peer/Makefile.in,
        classpath/native/Makefile.in, classpath/native/jawt/Makefile.in,
        classpath/native/fdlibm/Makefile.in,
        classpath/native/plugin/Makefile.in,
        classpath/resource/Makefile.in, classpath/scripts/Makefile.in,
        classpath/tools/Makefile.in, classpath/doc/Makefile.in,
        classpath/doc/api/Makefile.in, classpath/lib/Makefile.in,
        classpath/external/Makefile.in, classpath/external/jsr166/Makefile.in,
        classpath/external/sax/Makefile.in,
        classpath/external/w3c_dom/Makefile.in,
        classpath/external/relaxngDatatype/Makefile.in,
        classpath/include/Makefile.in,
        classpath/examples/Makefile.in: Regenerate.
        * classpath/config.guess, classpath/config.sub,
        classpath/ltmain.sh : Update.
        * classpath/configure, classpath/depcomp, classpath/missing,
        classpath/aclocal.m4, classpath/install-sh: Regenerate.

        * gnu/classpath/Configuration.java (CLASSPATH_VERSION): Now 0.95.
        * sources.am: Regenerate.
        * Makefile.in: Regenerate.

        * Update the .class files and generated CNI header files, add new
        .class and generated CNI header files.
        * Remove generated files for removed java source files:
        classpath/gnu/java/net/BASE64.java,
        classpath/gnu/java/security/util/Base64.java,
        classpath/gnu/java/awt/peer/gtk/GThreadMutex.java,
        classpath/gnu/java/awt/peer/gtk/GThreadNativeMethodRunner.java,
        classpath/gnu/java/awt/font/autofit/Scaler.java,
        classpath/gnu/classpath/jdwp/util/Value.java,
        classpath/gnu/javax/net/ssl/Base64.java.
        * Remove empty directories.

        * Makefile.am(nat_source_files): Add natVMOperatingSystemMXBeanImpl.cc.
        * java/lang/Class.java(setAccessible): Merge from classpath.
        * java/util/Locale.java: Remove.
        * gnu/java/lang/management/VMOperatingSystemMXBeanImpl.java,
        gnu/java/lang/management/natVMOperatingSystemMXBeanImpl.cc: New.
        * gcj/javaprims.h: Update class declarations.
        * scripts/classes.pl: Update usage.
        * HACKING: Mention to build all peers.

From-SVN: r125302
This commit is contained in:
Matthias Klose 2007-06-03 23:18:43 +00:00
parent af333b9a7f
commit e1bea0c068
2951 changed files with 80982 additions and 68583 deletions

View file

@ -69,10 +69,23 @@ import java.io.Serializable;
*/
public abstract class AbstractMap<K, V> implements Map<K, V>
{
/** @since 1.6 */
/**
* A class containing an immutable key and value. The
* implementation of {@link Entry#setValue(V)} for this class
* simply throws an {@link UnsupportedOperationException},
* thus preventing changes being made. This is useful when
* a static thread-safe view of a map is required.
*
* @since 1.6
*/
public static class SimpleImmutableEntry<K, V>
implements Entry<K, V>, Serializable
{
/**
* Compatible with JDK 1.6
*/
private static final long serialVersionUID = 7138329143949025153L;
K key;
V value;
@ -670,6 +683,12 @@ public abstract class AbstractMap<K, V> implements Map<K, V>
*/
public static class SimpleEntry<K, V> implements Entry<K, V>, Serializable
{
/**
* Compatible with JDK 1.6
*/
private static final long serialVersionUID = -8499721149061103585L;
/**
* The key. Package visible for direct manipulation.
*/
@ -730,7 +749,7 @@ public abstract class AbstractMap<K, V> implements Map<K, V>
*
* @return the key
*/
public final K getKey()
public K getKey()
{
return key;
}
@ -741,7 +760,7 @@ public abstract class AbstractMap<K, V> implements Map<K, V>
*
* @return the value
*/
public final V getValue()
public V getValue()
{
return value;
}
@ -755,7 +774,7 @@ public abstract class AbstractMap<K, V> implements Map<K, V>
*
* @return the hash code
*/
public final int hashCode()
public int hashCode()
{
return (AbstractMap.hashCode(key) ^ AbstractMap.hashCode(value));
}
@ -788,7 +807,7 @@ public abstract class AbstractMap<K, V> implements Map<K, V>
*
* @return the string representation
*/
public final String toString()
public String toString()
{
return key + "=" + value;
}

File diff suppressed because it is too large Load diff

View file

@ -43,9 +43,12 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.text.DateFormatSymbols;
/**
* This class is an abstract base class for Calendars, which can be
* used to convert between <code>Date</code> objects and a set of
@ -99,6 +102,20 @@ day_of_week + week_of_year</pre>
* specific field by one, propagating overflows), or
* <code>add</code>ing/substracting a fixed amount to a field.
*
* @author Aaron M. Renn (arenn@urbanophile.com)
* @author Jochen Hoenicke (Jochen.Hoenicke@Informatik.Uni-Oldenburg.de)
* @author Warren Levy (warrenl@cygnus.com)
* @author Jeff Sturm (jsturm@one-point.com)
* @author Tom Tromey (tromey@redhat.com)
* @author Bryce McKinlay (mckinlay@redhat.com)
* @author Ingo Proetel (proetel@aicas.com)
* @author Jerry Quinn (jlquinn@optonline.net)
* @author Jeroen Frijters (jeroen@frijters.net)
* @author Noa Resare (noa@resare.com)
* @author Sven de Marothy (sven@physto.se)
* @author David Gilbert (david.gilbert@object-refinery.com)
* @author Olivier Jolly (olivier.jolly@pcedev.com)
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @see Date
* @see GregorianCalendar
* @see TimeZone
@ -325,6 +342,34 @@ public abstract class Calendar
*/
public static final int PM = 1;
/**
* A style specifier for {@link #getDisplayNames(int,int,Locale)}
* stating that names should be returned in both long and short variants.
*
* @since 1.6
* @see #SHORT
* @see #LONG
*/
public static final int ALL_STYLES = 0;
/**
* A style specifier for {@link #getDisplayName(int,int,Locale)}
* and {@link #getDisplayNames(int,int,Locale)} stating that names
* should be returned in their short variant if applicable.
*
* @since 1.6
*/
public static final int SHORT = 1;
/**
* A style specifier for {@link #getDisplayName(int,int,Locale)}
* and {@link #getDisplayNames(int,int,Locale)} stating that names
* should be returned in their long variant if applicable.
*
* @since 1.6
*/
public static final int LONG = 2;
/**
* The time fields. The array is indexed by the constants YEAR to
* DST_OFFSET.
@ -527,7 +572,7 @@ public abstract class Calendar
* Cache of locale->calendar-class mappings. This avoids having to do a ResourceBundle
* lookup for every getInstance call.
*/
private static HashMap cache = new HashMap();
private static HashMap<Locale,Class> cache = new HashMap<Locale,Class>();
/** Preset argument types for calendar-class constructor lookup. */
private static Class[] ctorArgTypes = new Class[]
@ -549,7 +594,7 @@ public abstract class Calendar
*/
public static synchronized Calendar getInstance(TimeZone zone, Locale locale)
{
Class calendarClass = (Class) cache.get(locale);
Class calendarClass = cache.get(locale);
Throwable exception = null;
try
@ -1343,4 +1388,205 @@ public abstract class Calendar
areFieldsSet = false;
}
}
/**
* Returns a localised textual representation of the current value
* of the given field using the specified style. If there is no
* applicable textual representation (e.g. the field has a numeric
* value), then <code>null</code> is returned. If one does exist,
* then the value is obtained from {@link #get(int)} and converted
* appropriately. For example, if the <code>MONTH</code> field is
* requested, then <code>get(MONTH)</code> is called. This is then
* converted to a textual representation based on its value and
* the style requested; if the <code>LONG</code> style is requested
* and the returned value is <code>11</code> from a
* {@link GregorianCalendar} implementation, then <code>"December"</code>
* is returned. By default, a textual representation is available
* for all fields which have an applicable value obtainable from
* {@link java.text.DateFormatSymbols}.
*
* @param field the calendar field whose textual representation should
* be obtained.
* @param style the style to use; either {@link #LONG} or {@link #SHORT}.
* @param locale the locale to use for translation.
* @return the textual representation of the given field in the specified
* style, or <code>null</code> if none is applicable.
* @throws IllegalArgumentException if <code>field</code> or <code>style</code>
* or invalid, or the calendar is non-lenient
* and has invalid values.
* @throws NullPointerException if <code>locale</code> is <code>null</code>.
* @since 1.6
*/
public String getDisplayName(int field, int style, Locale locale)
{
if (field < 0 || field >= FIELD_COUNT)
throw new IllegalArgumentException("The field value, " + field +
", is invalid.");
if (style != SHORT && style != LONG)
throw new IllegalArgumentException("The style must be either " +
"short or long.");
if (field == YEAR || field == WEEK_OF_YEAR ||
field == WEEK_OF_MONTH || field == DAY_OF_MONTH ||
field == DAY_OF_YEAR || field == DAY_OF_WEEK_IN_MONTH ||
field == HOUR || field == HOUR_OF_DAY || field == MINUTE ||
field == SECOND || field == MILLISECOND)
return null;
int value = get(field);
DateFormatSymbols syms = DateFormatSymbols.getInstance(locale);
if (field == ERA)
return syms.getEras()[value];
if (field == MONTH)
if (style == LONG)
return syms.getMonths()[value];
else
return syms.getShortMonths()[value];
if (field == DAY_OF_WEEK)
if (style == LONG)
return syms.getWeekdays()[value];
else
return syms.getShortWeekdays()[value];
if (field == AM_PM)
return syms.getAmPmStrings()[value];
if (field == ZONE_OFFSET)
if (style == LONG)
return syms.getZoneStrings()[value][1];
else
return syms.getZoneStrings()[value][2];
if (field == DST_OFFSET)
if (style == LONG)
return syms.getZoneStrings()[value][3];
else
return syms.getZoneStrings()[value][4];
throw new InternalError("Failed to resolve field " + field +
" with style " + style + " for locale " +
locale);
}
/**
* Returns a map linking all specified textual representations
* of the given field to their numerical values. The textual
* representations included are determined by the specified
* style and locale. For example, if the style <code>LONG</code>
* is specified and the German locale, then the map will
* contain "Montag" to {@link #MONDAY}, "Dienstag" to
* {@link #TUESDAY}, "Mittwoch" to {@link #WEDNESDAY} and
* so on. The default implementation uses the values returned
* by {@link DateFormatSymbols} so, for example, the style
* {@link #ALL_STYLES} and the field {@link #MONTH} will return
* a map filled with the values returned from
* {@link DateFormatSymbols#getMonths()} and
* {@link DateFormatSymbols#getShortMonths()}. If there are
* no textual representations for a given field (usually because
* it is purely numeric, such as the year in the
* {@link GregorianCalendar}), <code>null</code> is returned.
*
* @param field the calendar field whose textual representation should
* be obtained.
* @param style the style to use; either {@link #LONG}, {@link #SHORT}
* or {@link ALL_STYLES}.
* @param locale the locale to use for translation.
* @return a map of the textual representations of the given field in the
* specified style to their numeric values, or <code>null</code>
* if none is applicable.
* @throws IllegalArgumentException if <code>field</code> or <code>style</code>
* or invalid, or the calendar is non-lenient
* and has invalid values.
* @throws NullPointerException if <code>locale</code> is <code>null</code>.
* @since 1.6
*/
public Map<String,Integer> getDisplayNames(int field, int style, Locale locale)
{
if (field < 0 || field >= FIELD_COUNT)
throw new IllegalArgumentException("The field value, " + field +
", is invalid.");
if (style != SHORT && style != LONG && style != ALL_STYLES)
throw new IllegalArgumentException("The style must be either " +
"short, long or all styles.");
if (field == YEAR || field == WEEK_OF_YEAR ||
field == WEEK_OF_MONTH || field == DAY_OF_MONTH ||
field == DAY_OF_YEAR || field == DAY_OF_WEEK_IN_MONTH ||
field == HOUR || field == HOUR_OF_DAY || field == MINUTE ||
field == SECOND || field == MILLISECOND)
return null;
DateFormatSymbols syms = DateFormatSymbols.getInstance(locale);
Map<String,Integer> map = new HashMap<String,Integer>();
if (field == ERA)
{
String[] eras = syms.getEras();
for (int a = 0; a < eras.length; ++a)
map.put(eras[a], a);
return map;
}
if (field == MONTH)
{
if (style == LONG || style == ALL_STYLES)
{
String[] months = syms.getMonths();
for (int a = 0; a < months.length; ++a)
map.put(months[a], a);
}
if (style == SHORT || style == ALL_STYLES)
{
String[] months = syms.getShortMonths();
for (int a = 0; a < months.length; ++a)
map.put(months[a], a);
}
return map;
}
if (field == DAY_OF_WEEK)
{
if (style == LONG || style == ALL_STYLES)
{
String[] weekdays = syms.getWeekdays();
for (int a = SUNDAY; a < weekdays.length; ++a)
map.put(weekdays[a], a);
}
if (style == SHORT || style == ALL_STYLES)
{
String[] weekdays = syms.getShortWeekdays();
for (int a = SUNDAY; a < weekdays.length; ++a)
map.put(weekdays[a], a);
}
return map;
}
if (field == AM_PM)
{
String[] ampms = syms.getAmPmStrings();
for (int a = 0; a < ampms.length; ++a)
map.put(ampms[a], a);
return map;
}
if (field == ZONE_OFFSET)
{
String[][] zones = syms.getZoneStrings();
for (int a = 0; a < zones.length; ++a)
{
if (style == LONG || style == ALL_STYLES)
map.put(zones[a][1], a);
if (style == SHORT || style == ALL_STYLES)
map.put(zones[a][2], a);
}
return map;
}
if (field == DST_OFFSET)
{
String[][] zones = syms.getZoneStrings();
for (int a = 0; a < zones.length; ++a)
{
if (style == LONG || style == ALL_STYLES)
map.put(zones[a][3], a);
if (style == SHORT || style == ALL_STYLES)
map.put(zones[a][4], a);
}
return map;
}
throw new InternalError("Failed to resolve field " + field +
" with style " + style + " for locale " +
locale);
}
}

View file

@ -706,14 +706,16 @@ public class Collections
{
if (!forward)
itr.next(); // Changing direction first.
for ( ; i != pos; i++, o = itr.next());
for ( ; i != pos; i++, o = itr.next())
;
forward = true;
}
else
{
if (forward)
itr.previous(); // Changing direction first.
for ( ; i != pos; i--, o = itr.previous());
for ( ; i != pos; i--, o = itr.previous())
;
forward = false;
}
final int d = compare(o, key, c);
@ -1460,8 +1462,10 @@ public class Collections
public static int frequency (Collection<?> c, Object o)
{
int result = 0;
for (Object v : c)
final Iterator<?> it = c.iterator();
while (it.hasNext())
{
Object v = it.next();
if (AbstractCollection.equals(o, v))
++result;
}
@ -1522,8 +1526,9 @@ public class Collections
public static boolean disjoint(Collection<?> c1, Collection<?> c2)
{
Collection<Object> oc1 = (Collection<Object>) c1;
for (Object o : oc1)
if (c2.contains(o))
final Iterator<Object> it = oc1.iterator();
while (it.hasNext())
if (c2.contains(it.next()))
return false;
return true;
}
@ -5113,7 +5118,7 @@ public class Collections
// The array returned is an array of UnmodifiableMapEntry instead of
// Map.Entry
public Map.Entry<K,V>[] toArray()
public Object[] toArray()
{
Object[] mapEntryResult = super.toArray();
UnmodifiableMapEntry<K,V> result[] = null;
@ -5127,7 +5132,7 @@ public class Collections
}
return result;
}
// The array returned is an array of UnmodifiableMapEntry instead of
// Map.Entry
public <S> S[] toArray(S[] array)
@ -5825,8 +5830,10 @@ public class Collections
public boolean addAll(Collection<? extends E> coll)
{
Collection<E> typedColl = (Collection<E>) c;
for (E element : typedColl)
final Iterator<E> it = typedColl.iterator();
while (it.hasNext())
{
final E element = it.next();
if (!type.isInstance(element))
throw new ClassCastException("A member of the collection is not of the correct type.");
}
@ -6167,9 +6174,10 @@ public class Collections
public boolean addAll(int index, Collection<? extends E> coll)
{
Collection<E> typedColl = (Collection<E>) coll;
for (E element : typedColl)
final Iterator<E> it = typedColl.iterator();
while (it.hasNext())
{
if (!type.isInstance(element))
if (!type.isInstance(it.next()))
throw new ClassCastException("A member of the collection is not of the correct type.");
}
return list.addAll(index, coll);
@ -6870,8 +6878,10 @@ public class Collections
public void putAll(Map<? extends K, ? extends V> map)
{
Map<K,V> typedMap = (Map<K,V>) map;
for (Map.Entry<K,V> entry : typedMap.entrySet())
final Iterator<Map.Entry<K,V>> it = typedMap.entrySet().iterator();
while (it.hasNext())
{
final Map.Entry<K,V> entry = it.next();
if (!keyType.isInstance(entry.getKey()))
throw new ClassCastException("A key is of the wrong type.");
if (!valueType.isInstance(entry.getValue()))
@ -7423,4 +7433,189 @@ public class Collections
}
} // class CheckedSortedSet
/**
* Returns a view of a {@link Deque} as a stack or LIFO (Last-In-First-Out)
* {@link Queue}. Each call to the LIFO queue corresponds to one
* equivalent method call to the underlying deque, with the exception
* of {@link Collection#addAll(Collection)}, which is emulated by a series
* of {@link Deque#push(E)} calls.
*
* @param deque the deque to convert to a LIFO queue.
* @return a LIFO queue.
* @since 1.6
*/
public static <T> Queue<T> asLifoQueue(Deque<T> deque)
{
return new LIFOQueue<T>(deque);
}
/**
* Returns a set backed by the supplied map. The resulting set
* has the same performance, concurrency and ordering characteristics
* as the original map. The supplied map must be empty and should not
* be used after the set is created. Each call to the set corresponds
* to one equivalent method call to the underlying map, with the exception
* of {@link Set#addAll(Collection)} which is emulated by a series of
* calls to <code>put</code>.
*
* @param map the map to convert to a set.
* @return a set backed by the supplied map.
* @throws IllegalArgumentException if the map is not empty.
* @since 1.6
*/
public static <E> Set<E> newSetFromMap(Map<E,Boolean> map)
{
return new MapSet<E>(map);
}
/**
* The implementation of {@link #asLIFOQueue(Deque)}.
*
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.6
*/
private static class LIFOQueue<T>
extends AbstractQueue<T>
{
/**
* The backing deque.
*/
private Deque<T> deque;
/**
* Constructs a new {@link LIFOQueue} with the specified
* backing {@link Deque}.
*
* @param deque the backing deque.
*/
public LIFOQueue(Deque<T> deque)
{
this.deque = deque;
}
public boolean add(T e)
{
return deque.offerFirst(e);
}
public boolean addAll(Collection<? extends T> c)
{
boolean result = false;
final Iterator<? extends T> it = c.iterator();
while (it.hasNext())
result |= deque.offerFirst(it.next());
return result;
}
public void clear()
{
deque.clear();
}
public boolean isEmpty()
{
return deque.isEmpty();
}
public Iterator<T> iterator()
{
return deque.iterator();
}
public boolean offer(T e)
{
return deque.offerFirst(e);
}
public T peek()
{
return deque.peek();
}
public T poll()
{
return deque.poll();
}
public int size()
{
return deque.size();
}
} // class LIFOQueue
/**
* The implementation of {@link #newSetFromMap(Map)}.
*
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.6
*/
private static class MapSet<E>
extends AbstractSet<E>
{
/**
* The backing map.
*/
private Map<E,Boolean> map;
/**
* Constructs a new {@link MapSet} using the specified
* backing {@link Map}.
*
* @param map the backing map.
* @throws IllegalArgumentException if the map is not empty.
*/
public MapSet(Map<E,Boolean> map)
{
if (!map.isEmpty())
throw new IllegalArgumentException("The map must be empty.");
this.map = map;
}
public boolean add(E e)
{
return map.put(e, true) == null;
}
public boolean addAll(Collection<? extends E> c)
{
boolean result = false;
final Iterator<? extends E> it = c.iterator();
while (it.hasNext())
result |= (map.put(it.next(), true) == null);
return result;
}
public void clear()
{
map.clear();
}
public boolean contains(Object o)
{
return map.containsKey(o);
}
public boolean isEmpty()
{
return map.isEmpty();
}
public Iterator<E> iterator()
{
return map.keySet().iterator();
}
public boolean remove(Object o)
{
return map.remove(o) != null;
}
public int size()
{
return map.size();
}
} // class MapSet
} // class Collections

View file

@ -44,6 +44,8 @@ import java.io.IOException;
import java.io.ObjectStreamException;
import java.io.Serializable;
import java.util.spi.CurrencyNameProvider;
/**
* Representation of a currency for a particular locale. Each currency
* is identified by its ISO 4217 code, and only one instance of this
@ -402,8 +404,35 @@ public final class Currency
*/
public String getSymbol(Locale locale)
{
return LocaleHelper.getLocalizedString(locale, currencyCode,
"currenciesSymbol", false, true);
String property = "currenciesSymbol." + currencyCode;
try
{
return ResourceBundle.getBundle("gnu.java.locale.LocaleInformation",
locale).getString(property);
}
catch (MissingResourceException exception)
{
/* This means runtime support for the locale
* is not available, so we check providers. */
}
for (CurrencyNameProvider p :
ServiceLoader.load(CurrencyNameProvider.class))
{
for (Locale loc : p.getAvailableLocales())
{
if (loc.equals(locale))
{
String localizedString = p.getSymbol(currencyCode,
locale);
if (localizedString != null)
return localizedString;
break;
}
}
}
if (locale.equals(Locale.ROOT)) // Base case
return currencyCode;
return getSymbol(LocaleHelper.getFallbackLocale(locale));
}
/**

View file

@ -856,7 +856,7 @@ public class Date
hour += 12;
}
else if (parseDayOfWeek(tok))
; // Ignore it; throw the token away.
{ /* Ignore it; throw the token away. */ }
else if (tok.equals("UT") || tok.equals("UTC") || tok.equals("GMT"))
localTimezone = false;
else if (tok.startsWith("UT") || tok.startsWith("GMT"))

View file

@ -1,5 +1,5 @@
/* java.util.GregorianCalendar
Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004
Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004, 2007
Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -223,7 +223,6 @@ public class GregorianCalendar extends Calendar
{
this(zone, locale, false);
setTimeInMillis(System.currentTimeMillis());
complete();
}
/**
@ -842,13 +841,24 @@ public class GregorianCalendar extends Calendar
// which day of the week are we (0..6), relative to getFirstDayOfWeek
int relativeWeekday = (7 + fields[DAY_OF_WEEK] - getFirstDayOfWeek()) % 7;
fields[WEEK_OF_MONTH] = (fields[DAY_OF_MONTH] - relativeWeekday + 12) / 7;
// which day of the week is the first of this month?
// nb 35 is the smallest multiple of 7 that ensures that
// the left hand side of the modulo operator is positive.
int relativeWeekdayOfFirst = (relativeWeekday - fields[DAY_OF_MONTH]
+ 1 + 35) % 7;
// which week of the month is the first of this month in?
int minDays = getMinimalDaysInFirstWeek();
int weekOfFirst = ((7 - relativeWeekdayOfFirst) >= minDays) ? 1 : 0;
// which week of the month is this day in?
fields[WEEK_OF_MONTH] = (fields[DAY_OF_MONTH]
+ relativeWeekdayOfFirst - 1) / 7 + weekOfFirst;
int weekOfYear = (fields[DAY_OF_YEAR] - relativeWeekday + 6) / 7;
// Do the Correction: getMinimalDaysInFirstWeek() is always in the
// first week.
int minDays = getMinimalDaysInFirstWeek();
int firstWeekday = (7 + getWeekDay(fields[YEAR], minDays)
- getFirstDayOfWeek()) % 7;
if (minDays - firstWeekday < 1)

View file

@ -380,11 +380,11 @@ public class HashMap<K, V> extends AbstractMap<K, V>
*/
public void putAll(Map<? extends K, ? extends V> m)
{
Map<K,V> addMap;
addMap = (Map<K,V>) m;
for (Map.Entry<K,V> e : addMap.entrySet())
final Map<K,V> addMap = (Map<K,V>) m;
final Iterator<Map.Entry<K,V>> it = addMap.entrySet().iterator();
while (it.hasNext())
{
final Map.Entry<K,V> e = it.next();
// Optimize in case the Entry is one of our own.
if (e instanceof AbstractMap.SimpleEntry)
{
@ -710,12 +710,12 @@ public class HashMap<K, V> extends AbstractMap<K, V>
*/
void putAllInternal(Map<? extends K, ? extends V> m)
{
Map<K,V> addMap;
addMap = (Map<K,V>) m;
final Map<K,V> addMap = (Map<K,V>) m;
final Iterator<Map.Entry<K,V>> it = addMap.entrySet().iterator();
size = 0;
for (Map.Entry<K,V> e : addMap.entrySet())
while (it.hasNext())
{
final Map.Entry<K,V> e = it.next();
size++;
K key = e.getKey();
int idx = hash(key);

View file

@ -505,12 +505,11 @@ public class Hashtable<K, V> extends Dictionary<K, V>
*/
public synchronized void putAll(Map<? extends K, ? extends V> m)
{
Map<K,V> addMap;
addMap = (Map<K,V>) m;
for (Map.Entry<K,V> e : addMap.entrySet())
final Map<K,V> addMap = (Map<K,V>) m;
final Iterator<Map.Entry<K,V>> it = addMap.entrySet().iterator();
while (it.hasNext())
{
final Map.Entry<K,V> e = it.next();
// Optimize in case the Entry is one of our own.
if (e instanceof AbstractMap.SimpleEntry)
{
@ -857,13 +856,12 @@ public class Hashtable<K, V> extends Dictionary<K, V>
*/
void putAllInternal(Map<? extends K, ? extends V> m)
{
Map<K,V> addMap;
addMap = (Map<K,V>) m;
final Map<K,V> addMap = (Map<K,V>) m;
final Iterator<Map.Entry<K,V>> it = addMap.entrySet().iterator();
size = 0;
for (Map.Entry<K,V> e : addMap.entrySet())
while (it.hasNext())
{
final Map.Entry<K,V> e = it.next();
size++;
K key = e.getKey();
int idx = hash(key);

View file

@ -1,5 +1,5 @@
/* LinkedList.java -- Linked list implementation of the List interface
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -64,15 +64,17 @@ import java.lang.reflect.Array;
* @author Original author unknown
* @author Bryce McKinlay
* @author Eric Blake (ebb9@email.byu.edu)
* @author Tom Tromey (tromey@redhat.com)
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @see List
* @see ArrayList
* @see Vector
* @see Collections#synchronizedList(List)
* @since 1.2
* @status missing javadoc, but complete to 1.4
* @status Complete to 1.6
*/
public class LinkedList<T> extends AbstractSequentialList<T>
implements List<T>, Queue<T>, Cloneable, Serializable
implements List<T>, Deque<T>, Cloneable, Serializable
{
/**
* Compatible with JDK 1.2.
@ -708,6 +710,10 @@ public class LinkedList<T> extends AbstractSequentialList<T>
}
/**
* Adds the specified element to the end of the list.
*
* @param value the value to add.
* @return true.
* @since 1.5
*/
public boolean offer(T value)
@ -716,6 +722,11 @@ public class LinkedList<T> extends AbstractSequentialList<T>
}
/**
* Returns the first element of the list without removing
* it.
*
* @return the first element of the list.
* @throws NoSuchElementException if the list is empty.
* @since 1.5
*/
public T element()
@ -724,6 +735,11 @@ public class LinkedList<T> extends AbstractSequentialList<T>
}
/**
* Returns the first element of the list without removing
* it.
*
* @return the first element of the list, or <code>null</code>
* if the list is empty.
* @since 1.5
*/
public T peek()
@ -734,6 +750,10 @@ public class LinkedList<T> extends AbstractSequentialList<T>
}
/**
* Removes and returns the first element of the list.
*
* @return the first element of the list, or <code>null</code>
* if the list is empty.
* @since 1.5
*/
public T poll()
@ -744,6 +764,10 @@ public class LinkedList<T> extends AbstractSequentialList<T>
}
/**
* Removes and returns the first element of the list.
*
* @return the first element of the list.
* @throws NoSuchElementException if the list is empty.
* @since 1.5
*/
public T remove()
@ -992,4 +1016,245 @@ public class LinkedList<T> extends AbstractSequentialList<T>
lastReturned.data = o;
}
} // class LinkedListItr
/**
* Obtain an Iterator over this list in reverse sequential order.
*
* @return an Iterator over the elements of the list in
* reverse order.
* @since 1.6
*/
public Iterator<T> descendingIterator()
{
return new Iterator<T>()
{
/** Number of modifications we know about. */
private int knownMod = modCount;
/** Entry that will be returned by next(). */
private Entry<T> next = last;
/** Entry that will be affected by remove() or set(). */
private Entry<T> lastReturned;
/** Index of `next'. */
private int position = size() - 1;
// This will get inlined, since it is private.
/**
* Checks for modifications made to the list from
* elsewhere while iteration is in progress.
*
* @throws ConcurrentModificationException if the
* list has been modified elsewhere.
*/
private void checkMod()
{
if (knownMod != modCount)
throw new ConcurrentModificationException();
}
/**
* Tests to see if there are any more objects to
* return.
*
* @return true if the start of the list has not yet been
* reached.
*/
public boolean hasNext()
{
return next != null;
}
/**
* Retrieves the next object from the list.
*
* @return The next object.
* @throws NoSuchElementException if there are
* no more objects to retrieve.
* @throws ConcurrentModificationException if the
* list has been modified elsewhere.
*/
public T next()
{
checkMod();
if (next == null)
throw new NoSuchElementException();
--position;
lastReturned = next;
next = lastReturned.previous;
return lastReturned.data;
}
/**
* Removes the last object retrieved by <code>next()</code>
* from the list, if the list supports object removal.
*
* @throws ConcurrentModificationException if the list
* has been modified elsewhere.
* @throws IllegalStateException if the iterator is positioned
* before the start of the list or the last object has already
* been removed.
*/
public void remove()
{
checkMod();
if (lastReturned == null)
throw new IllegalStateException();
removeEntry(lastReturned);
lastReturned = null;
++knownMod;
}
};
}
/**
* Inserts the specified element at the front of the list.
*
* @param value the element to insert.
* @return true.
* @since 1.6
*/
public boolean offerFirst(T value)
{
addFirst(value);
return true;
}
/**
* Inserts the specified element at the end of the list.
*
* @param value the element to insert.
* @return true.
* @since 1.6
*/
public boolean offerLast(T value)
{
return add(value);
}
/**
* Returns the first element of the list without removing
* it.
*
* @return the first element of the list, or <code>null</code>
* if the list is empty.
* @since 1.6
*/
public T peekFirst()
{
return peek();
}
/**
* Returns the last element of the list without removing
* it.
*
* @return the last element of the list, or <code>null</code>
* if the list is empty.
* @since 1.6
*/
public T peekLast()
{
if (size == 0)
return null;
return getLast();
}
/**
* Removes and returns the first element of the list.
*
* @return the first element of the list, or <code>null</code>
* if the list is empty.
* @since 1.6
*/
public T pollFirst()
{
return poll();
}
/**
* Removes and returns the last element of the list.
*
* @return the last element of the list, or <code>null</code>
* if the list is empty.
* @since 1.6
*/
public T pollLast()
{
if (size == 0)
return null;
return removeLast();
}
/**
* Pops an element from the stack by removing and returning
* the first element in the list. This is equivalent to
* calling {@link #removeFirst()}.
*
* @return the top of the stack, which is the first element
* of the list.
* @throws NoSuchElementException if the list is empty.
* @since 1.6
* @see #removeFirst()
*/
public T pop()
{
return removeFirst();
}
/**
* Pushes an element on to the stack by adding it to the
* front of the list. This is equivalent to calling
* {@link #addFirst(T)}.
*
* @param value the element to push on to the stack.
* @throws NoSuchElementException if the list is empty.
* @since 1.6
* @see #addFirst(T)
*/
public void push(T value)
{
addFirst(value);
}
/**
* Removes the first occurrence of the specified element
* from the list, when traversing the list from head to
* tail. The list is unchanged if the element is not found.
* This is equivalent to calling {@link #remove(Object)}.
*
* @param o the element to remove.
* @return true if an instance of the object was removed.
* @since 1.6
*/
public boolean removeFirstOccurrence(Object o)
{
return remove(o);
}
/**
* Removes the last occurrence of the specified element
* from the list, when traversing the list from head to
* tail. The list is unchanged if the element is not found.
*
* @param o the element to remove.
* @return true if an instance of the object was removed.
* @since 1.6
*/
public boolean removeLastOccurrence(Object o)
{
Entry<T> e = last;
while (e != null)
{
if (equals(o, e.data))
{
removeEntry(e);
return true;
}
e = e.previous;
}
return false;
}
}

View file

@ -46,6 +46,8 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.spi.LocaleNameProvider;
/**
* Locales represent a specific country and culture. Classes which can be
* passed a Locale object tailor their information for a given locale. For
@ -161,6 +163,11 @@ public final class Locale implements Serializable, Cloneable
/** Locale which represents the French speaking portion of Canada. */
public static final Locale CANADA_FRENCH = getLocale("fr", "CA");
/** The root locale, used as the base case in lookups by
* locale-sensitive operations.
*/
public static final Locale ROOT = new Locale("","","");
/**
* Compatible with JDK 1.1+.
*/
@ -674,6 +681,8 @@ public final class Locale implements Serializable, Cloneable
*/
public String getDisplayLanguage(Locale inLocale)
{
if (language.isEmpty())
return "";
try
{
ResourceBundle res =
@ -685,8 +694,27 @@ public final class Locale implements Serializable, Cloneable
}
catch (MissingResourceException e)
{
return language;
/* This means runtime support for the locale
* is not available, so we check providers. */
}
for (LocaleNameProvider p :
ServiceLoader.load(LocaleNameProvider.class))
{
for (Locale loc : p.getAvailableLocales())
{
if (loc.equals(inLocale))
{
String locLang = p.getDisplayLanguage(language,
inLocale);
if (locLang != null)
return locLang;
break;
}
}
}
if (inLocale.equals(Locale.ROOT)) // Base case
return language;
return getDisplayLanguage(LocaleHelper.getFallbackLocale(inLocale));
}
/**
@ -732,6 +760,8 @@ public final class Locale implements Serializable, Cloneable
*/
public String getDisplayCountry(Locale inLocale)
{
if (country.isEmpty())
return "";
try
{
ResourceBundle res =
@ -743,8 +773,27 @@ public final class Locale implements Serializable, Cloneable
}
catch (MissingResourceException e)
{
return country;
/* This means runtime support for the locale
* is not available, so we check providers. */
}
for (LocaleNameProvider p :
ServiceLoader.load(LocaleNameProvider.class))
{
for (Locale loc : p.getAvailableLocales())
{
if (loc.equals(inLocale))
{
String locCountry = p.getDisplayCountry(country,
inLocale);
if (locCountry != null)
return locCountry;
break;
}
}
}
if (inLocale.equals(Locale.ROOT)) // Base case
return country;
return getDisplayCountry(LocaleHelper.getFallbackLocale(inLocale));
}
/**
@ -791,6 +840,8 @@ public final class Locale implements Serializable, Cloneable
*/
public String getDisplayVariant(Locale inLocale)
{
if (variant.isEmpty())
return "";
try
{
ResourceBundle res =
@ -802,8 +853,27 @@ public final class Locale implements Serializable, Cloneable
}
catch (MissingResourceException e)
{
return variant;
/* This means runtime support for the locale
* is not available, so we check providers. */
}
for (LocaleNameProvider p :
ServiceLoader.load(LocaleNameProvider.class))
{
for (Locale loc : p.getAvailableLocales())
{
if (loc.equals(inLocale))
{
String locVar = p.getDisplayVariant(variant,
inLocale);
if (locVar != null)
return locVar;
break;
}
}
}
if (inLocale.equals(Locale.ROOT)) // Base case
return country;
return getDisplayVariant(LocaleHelper.getFallbackLocale(inLocale));
}
/**

View file

@ -164,6 +164,7 @@ public class PriorityQueue<E> extends AbstractQueue<E> implements Serializable
{
while (storage[++index] == null)
;
++count;
return storage[index];
}

View file

@ -0,0 +1,94 @@
/* ServiceConfigurationError.java -- An error on service loading.
Copyright (C) 2007 Free Software Foundation
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;
/**
* <p>
* An error thrown when a problem occurs during the loading
* of a service provider by a {@link ServiceLoader}. Such
* an error can occur for a number of reasons:
* </p>
* <ul>
* <li>An I/O error occurs</li>
* <li>The configuration file doesn't meet the specifications</li>
* <li>A listed class can not be found</li>
* <li>A listed class does not implement the service</li>
* <li>A listed class can not be instantiated</li>
* </ul>
*
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.6
*/
public class ServiceConfigurationError
extends Error
{
/**
* Compatible with JDK 1.6
*/
private static final long serialVersionUID = 74132770414881L;
/**
* Constructs a new {@link ServiceConfigurationError}
* with the specified message.
*
* @param message a message describing the error, or
* <code>null</code> if none is required.
*/
public ServiceConfigurationError(String message)
{
super(message);
}
/**
* Constructs a new {@link ServiceConfigurationError}
* with the specified message and cause.
*
* @param message a message describing the error, or
* <code>null</code> if none is required.
* @param cause the cause of the error, or
* <code>null</code> if this is unknown
* or inappropriate.
*/
public ServiceConfigurationError(String message,
Throwable cause)
{
super(message,cause);
}
}

View file

@ -0,0 +1,274 @@
/* ServiceLoader.java -- Allows loading of plug-in services.
Copyright (C) 2006, 2007 Free Software Foundation
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 gnu.classpath.ServiceFactory;
/**
* <p>
* Facilities for loading service providers. A service is
* defined by a set of interfaces or abstract classes, and
* a service provider gives a concrete implementation of this.
* Service providers may be installed as part of the runtime
* environment using JAR files in the extension directories,
* or may be simply supplied on the classpath.
* </p>
* <p>
* In terms of loading a service, the service is defined by
* a single interface or abstract class which the provider
* implements. This may not constitute the entire service,
* but is simply a mechanism by which a provider of the
* service can be loaded and its capabilities determined.
* The variety of possible services means that no more
* requirements are made of the service provider other than
* that it must have an accessible zero argument constructor
* in order to allow an instance to be created.
* </p>
* <p>
* Service providers are listed in a file named after the
* service type in the directory <code>META-INF/services</code>.
* The file contains a list of classes, and must be encoded
* using UTF-8. Whitespace is ignored. Comments can be
* included by using a <code>'#'</code> prefix; anything occurring
* on the same line after this symbol is ignored. Duplicate classes
* are ignored.
* </p>
* <p>
* The classes are loaded using the same classloader that was
* queried in order to locate the configuration file. As a result,
* the providers do not need to reside in the same JAR file as the
* resource; they merely have to be accessible to this classloader,
* which may differ from the one that loaded the file itself.
* </p>
* <p>
* Providers are located and instantiated lazily, as calls to the
* {@link #iterator()} are made. Providers are cached, and those in
* the cache are returned first. The cache may be cleared by calling
* {@link #reload()}. Service loaders always execute in the security
* context of the caller, so ideally calls should be made from a trusted
* source.
* </p>
* <p>
* Note that this class is not thread-safe, and that strange errors may
* occur as the result of the use of remote URLs occurring on the classpath,
* which lead to erroneous web pages.
* </p>
*
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.6
*/
public final class ServiceLoader<S>
implements Iterable<S>
{
/**
* The class of the service provider.
*/
private Class<S> spi;
/**
* The class loader for the service provider.
*/
private ClassLoader loader;
/**
* The cache of service providers.
*/
private List<S> cache;
/**
* The {@link gnu.classpath.ServiceFactory} iterator
* from which providers are obtained.
*/
private Iterator<S> serviceIt;
/**
* Constructs a new {@link ServiceLoader} with
* the specified provider and class loader.
*
* @param spi the service to load.
* @param loader the class loader to use.
*/
private ServiceLoader(Class<S> spi, ClassLoader loader)
{
this.spi = spi;
this.loader = loader;
cache = new ArrayList<S>();
}
/**
* Lazily loads the available providers. The iterator first returns
* providers from the cache, in instantiation order, followed by any
* remaining providers, which are added to the cache after loading.
* The actual loading and parsing of the configuration file takes
* place in the {@link Iterator#hasNext()} and {@link Iterator#next()}
* methods, which means that they may result in a
* {@link ServiceConfigurationError} being thrown. If such an error
* does occur, subsequent invocations will attempt to recover.
* The {@link remove()} method is not supported and instead throws
* an {@link UnsupportedOperationException}.
*
* @return an iterator that lazily loads service providers.
*/
public Iterator<S> iterator()
{
return new Iterator<S>()
{
/**
* The cache iterator.
*/
private Iterator<S> cacheIt = cache.iterator();
public boolean hasNext()
{
if (cacheIt.hasNext())
return true;
if (serviceIt == null)
serviceIt =
ServiceFactory.lookupProviders(spi, loader, true);
return serviceIt.hasNext();
}
public S next()
{
if (cacheIt.hasNext())
return cacheIt.next();
if (serviceIt == null)
serviceIt =
ServiceFactory.lookupProviders(spi, loader, true);
S nextService = serviceIt.next();
cache.add(nextService);
return nextService;
}
public void remove()
{
throw new UnsupportedOperationException();
}
};
}
/**
* Creates a new service loader for the given service,
* using the context class loader of the current thread.
* This is equivalent to calling <code>ServiceLoader.load(service,
* Thread.currentThread().getContextClassLoader())</code>.
*
* @param service the interface or abstract class that represents
* the service.
* @return a new {@link ServiceLoader} instance.
*/
public static <S> ServiceLoader<S> load(Class<S> service)
{
return load(service,
Thread.currentThread().getContextClassLoader());
}
/**
* Creates a new service loader for the given service,
* using the specified class loader. The class loader is
* used to access the configuration file and the service
* provider instances themselves. If the loader is
* <code>null</code>, the system class loader (or, if
* this is also <code>null</code>, the bootstrap class
* loader).
*
* @param service the interface or abstract class that represents
* the service.
* @param loader the class loader used to load the configuration
* file and service providers.
* @return a new {@link ServiceLoader} instance.
*/
public static <S> ServiceLoader<S> load(Class<S> service,
ClassLoader loader)
{
if (loader == null)
loader = ClassLoader.getSystemClassLoader();
return new ServiceLoader(service, loader);
}
/**
* Creates a new service loader for the given service,
* using the extension class loader. If the extension
* class loader can not be found, the system class loader
* is used (or, if this is <code>null</code>, the
* bootstrap class loader). The primary use of this method
* is to only obtain installed services, ignoring any which
* may appear on the classpath. This is equivalent to calling
* <code>load(service, extClassLoader)</code> where
* <code>extClassLoader</code> is the extension class loader
* (or <code>null</code> if this is unavailable).
*
* @param service the interface or abstract class that represents
* the service.
* @return a new {@link ServiceLoader} instance.
*/
public static <S> ServiceLoader<S> loadInstalled(Class<S> service)
{
/* We expect the extension class loader to be the parent
* of the system class loader, as in
* ClassLoader.getDefaultSystemClassLoader() */
return load(service,
ClassLoader.getSystemClassLoader().getParent());
}
/**
* Clears the cache of the provider, so that all providers
* are again read from the configuration file and instantiated.
*/
public void reload()
{
cache.clear();
}
/**
* Returns a textual representation of this
* {@link ServiceLoader}.
*
* @return a textual representation of the
* service loader.
*/
public String toString()
{
return getClass().getName() +
"[spi=" + spi +
",loader=" + loader +
"]";
}
}

View file

@ -181,13 +181,15 @@ public class StringTokenizer implements Enumeration<Object>
{
if (retDelims)
return str.substring(pos, ++pos);
while (++pos < len && delim.indexOf(str.charAt(pos)) >= 0);
while (++pos < len && delim.indexOf(str.charAt(pos)) >= 0)
;
}
if (pos < len)
{
int start = pos;
while (++pos < len && delim.indexOf(str.charAt(pos)) < 0);
while (++pos < len && delim.indexOf(str.charAt(pos)) < 0)
;
return str.substring(start, pos);
}
throw new NoSuchElementException();

File diff suppressed because it is too large Load diff

View file

@ -79,10 +79,10 @@ import java.io.Serializable;
* @see Collections#synchronizedSortedSet(SortedSet)
* @see TreeMap
* @since 1.2
* @status updated to 1.4
* @status updated to 1.6
*/
public class TreeSet<T> extends AbstractSet<T>
implements SortedSet<T>, Cloneable, Serializable
implements NavigableSet<T>, Cloneable, Serializable
{
/**
* Compatible with JDK 1.2.
@ -90,11 +90,11 @@ public class TreeSet<T> extends AbstractSet<T>
private static final long serialVersionUID = -2479143000061671589L;
/**
* The SortedMap which backs this Set.
* The NavigableMap which backs this Set.
*/
// Not final because of readObject. This will always be one of TreeMap or
// TreeMap.SubMap, which both extend AbstractMap.
private transient SortedMap<T, String> map;
private transient NavigableMap<T, String> map;
/**
* Construct a new TreeSet whose backing TreeMap using the "natural"
@ -163,7 +163,7 @@ public class TreeSet<T> extends AbstractSet<T>
*
* @param backingMap the submap
*/
private TreeSet(SortedMap<T,String> backingMap)
private TreeSet(NavigableMap<T,String> backingMap)
{
map = backingMap;
}
@ -220,7 +220,7 @@ public class TreeSet<T> extends AbstractSet<T>
{
copy = (TreeSet<T>) super.clone();
// Map may be either TreeMap or TreeMap.SubMap, hence the ugly casts.
copy.map = (SortedMap<T, String>) ((AbstractMap<T, String>) map).clone();
copy.map = (NavigableMap<T, String>) ((AbstractMap<T, String>) map).clone();
}
catch (CloneNotSupportedException x)
{
@ -269,7 +269,9 @@ public class TreeSet<T> extends AbstractSet<T>
* in one appear in the other. The subset will throw an
* {@link IllegalArgumentException} for any attempt to access or add an
* element beyond the specified cutoff. The returned set does not include
* the endpoint; if you want inclusion, pass the successor element.
* the endpoint; if you want inclusion, pass the successor element or
* call {@link #headSet(T,boolean)}. This call is equivalent to
* <code>headSet(to, false)</code>.
*
* @param to the (exclusive) cutoff point
* @return a view of the set less than the cutoff
@ -280,7 +282,28 @@ public class TreeSet<T> extends AbstractSet<T>
*/
public SortedSet<T> headSet(T to)
{
return new TreeSet<T>(map.headMap(to));
return headSet(to, false);
}
/**
* Returns a view of this Set including all elements less than
* (or equal to, if <code>inclusive</code> is true) <code>to</code>.
* The returned set is backed by the original, so changes
* in one appear in the other. The subset will throw an
* {@link IllegalArgumentException} for any attempt to access or add an
* element beyond the specified cutoff.
*
* @param to the cutoff point
* @param inclusive true if <code>to</code> should be included.
* @return a view of the set for the specified range.
* @throws ClassCastException if <code>to</code> is not compatible with
* the comparator (or is not Comparable, for natural ordering)
* @throws NullPointerException if to is null, but the comparator does not
* tolerate null elements
*/
public NavigableSet<T> headSet(T to, boolean inclusive)
{
return new TreeSet<T>(map.headMap(to, inclusive));
}
/**
@ -345,7 +368,9 @@ public class TreeSet<T> extends AbstractSet<T>
* the other. The subset will throw an {@link IllegalArgumentException}
* for any attempt to access or add an element beyond the specified cutoffs.
* The returned set includes the low endpoint but not the high; if you want
* to reverse this behavior on either end, pass in the successor element.
* to reverse this behavior on either end, pass in the successor element
* or call {@link #subSet(T,boolean,T,boolean)}. This is equivalent to
* calling <code>subSet(from,true,to,false)</code>.
*
* @param from the (inclusive) low cutoff point
* @param to the (exclusive) high cutoff point
@ -358,7 +383,33 @@ public class TreeSet<T> extends AbstractSet<T>
*/
public SortedSet<T> subSet(T from, T to)
{
return new TreeSet<T>(map.subMap(from, to));
return subSet(from, true, to, false);
}
/**
* Returns a view of this Set including all elements greater than (or equal to,
* if <code>fromInclusive</code> is true</code> <code>from</code> and less than
* (or equal to, if <code>toInclusive</code> is true) <code>to</code>.
* The returned set is backed by the original, so changes in one appear in
* the other. The subset will throw an {@link IllegalArgumentException}
* for any attempt to access or add an element beyond the specified cutoffs.
*
* @param from the low cutoff point
* @param fromInclusive true if <code>from</code> should be included.
* @param to the high cutoff point
* @param toInclusive true if <code>to</code> should be included.
* @return a view of the set for the specified range.
* @throws ClassCastException if either cutoff is not compatible with
* the comparator (or is not Comparable, for natural ordering)
* @throws NullPointerException if from or to is null, but the comparator
* does not tolerate null elements
* @throws IllegalArgumentException if from is greater than to
*/
public NavigableSet<T> subSet(T from, boolean fromInclusive,
T to, boolean toInclusive)
{
return new TreeSet<T>(map.subMap(from, fromInclusive,
to, toInclusive));
}
/**
@ -367,7 +418,9 @@ public class TreeSet<T> extends AbstractSet<T>
* changes in one appear in the other. The subset will throw an
* {@link IllegalArgumentException} for any attempt to access or add an
* element beyond the specified cutoff. The returned set includes the
* endpoint; if you want to exclude it, pass in the successor element.
* endpoint; if you want to exclude it, pass in the successor element
* or call {@link #tailSet(T,boolean)}. This is equivalent to calling
* <code>tailSet(from, true)</code>.
*
* @param from the (inclusive) low cutoff point
* @return a view of the set above the cutoff
@ -378,7 +431,27 @@ public class TreeSet<T> extends AbstractSet<T>
*/
public SortedSet<T> tailSet(T from)
{
return new TreeSet<T>(map.tailMap(from));
return tailSet(from, true);
}
/**
* Returns a view of this Set including all elements greater (or equal to,
* if <code>inclusive</code> is true) <code>from</code>. The returned set
* is backed by the original, so changes in one appear in the other. The
* subset will throw an {@link IllegalArgumentException} for any attempt
* to access or add an element beyond the specified cutoff.
*
* @param from the low cutoff point.
* @param inclusive true if <code>from</code> should be included.
* @return a view of the set for the specified range.
* @throws ClassCastException if <code>from</code> is not compatible with
* the comparator (or is not Comparable, for natural ordering)
* @throws NullPointerException if from is null, but the comparator
* does not tolerate null elements
*/
public NavigableSet<T> tailSet(T from, boolean inclusive)
{
return new TreeSet<T>(map.tailMap(from, inclusive));
}
/**
@ -418,4 +491,151 @@ public class TreeSet<T> extends AbstractSet<T>
map = new TreeMap<T, String>(comparator);
((TreeMap<T, String>) map).putFromObjStream(s, size, false);
}
/**
* Returns the least or lowest element in the set greater than or
* equal to the given element, or <code>null</code> if there is
* no such element.
*
* @param e the element relative to the returned element.
* @return the least element greater than or equal
* to the given element, or <code>null</code> if there is
* no such element.
* @throws ClassCastException if the specified element can not
* be compared with those in the map.
* @throws NullPointerException if the element is <code>null</code>
* and this set either uses natural
* ordering or a comparator that does
* not permit null elements.
* @since 1.6
*/
public T ceiling(T e)
{
return map.ceilingKey(e);
}
/**
* Returns an iterator over the elements of this set in descending
* order. This is equivalent to calling
* <code>descendingSet().iterator()</code>.
*
* @return an iterator over the elements in descending order.
* @since 1.6
*/
public Iterator<T> descendingIterator()
{
return descendingSet().iterator();
}
/**
* Returns a view of the set in reverse order. The descending set
* is backed by the original set, so that changes affect both sets.
* Any changes occurring to either set while an iteration is taking
* place (with the exception of a {@link Iterator#remove()} operation)
* result in undefined behaviour from the iteration. The ordering
* of the descending set is the same as for a set with a
* {@link Comparator} given by {@link Collections#reverseOrder()},
* and calling {@link #descendingSet()} on the descending set itself
* results in a view equivalent to the original set.
*
* @return a reverse order view of the set.
* @since 1.6
*/
public NavigableSet<T> descendingSet()
{
return map.descendingKeySet();
}
/**
* Returns the greatest or highest element in the set less than or
* equal to the given element, or <code>null</code> if there is
* no such element.
*
* @param e the element relative to the returned element.
* @return the greatest element less than or equal
* to the given element, or <code>null</code> if there is
* no such element.
* @throws ClassCastException if the specified element can not
* be compared with those in the map.
* @throws NullPointerException if the element is <code>null</code>
* and this set either uses natural
* ordering or a comparator that does
* not permit null elements.
* @since 1.6
*/
public T floor(T e)
{
return map.floorKey(e);
}
/**
* Returns the least or lowest element in the set strictly greater
* than the given element, or <code>null</code> if there is
* no such element.
*
* @param e the element relative to the returned element.
* @return the least element greater than
* the given element, or <code>null</code> if there is
* no such element.
* @throws ClassCastException if the specified element can not
* be compared with those in the map.
* @throws NullPointerException if the element is <code>null</code>
* and this set either uses natural
* ordering or a comparator that does
* not permit null elements.
* @since 1.6
*/
public T higher(T e)
{
return map.higherKey(e);
}
/**
* Returns the greatest or highest element in the set strictly less
* than the given element, or <code>null</code> if there is
* no such element.
*
* @param e the element relative to the returned element.
* @return the greatest element less than
* the given element, or <code>null</code> if there is
* no such element.
* @throws ClassCastException if the specified element can not
* be compared with those in the map.
* @throws NullPointerException if the element is <code>null</code>
* and this set either uses natural
* ordering or a comparator that does
* not permit null elements.
* @since 1.6
*/
public T lower(T e)
{
return map.lowerKey(e);
}
/**
* Removes and returns the least or lowest element in the set,
* or <code>null</code> if the map is empty.
*
* @return the removed first element, or <code>null</code> if the
* map is empty.
* @since 1.6
*/
public T pollFirst()
{
return map.pollFirstEntry().getKey();
}
/**
* Removes and returns the greatest or highest element in the set,
* or <code>null</code> if the map is empty.
*
* @return the removed last element, or <code>null</code> if the
* map is empty.
* @since 1.6
*/
public T pollLast()
{
return map.pollLastEntry().getKey();
}
}

View file

@ -1,78 +0,0 @@
# This property file contains dependencies of classes, methods, and
# field on other methods or classes.
#
# Syntax:
#
# <used>: <needed 1> [... <needed N>]
#
# means that when <used> is included, <needed 1> (... <needed N>) must
# be included as well.
#
# <needed X> and <used> are of the form
#
# <class.methodOrField(signature)>
#
# or just
#
# <class>
#
# Within dependencies, variables can be used. A variable is defined as
# follows:
#
# {variable}: value1 value2 ... value<n>
#
# variables can be used on the right side of dependencies as follows:
#
# <used>: com.bla.blu.{variable}.Class.m()V
#
# The use of the variable will expand to <n> dependencies of the form
#
# <used>: com.bla.blu.value1.Class.m()V
# <used>: com.bla.blu.value2.Class.m()V
# ...
# <used>: com.bla.blu.value<n>.Class.m()V
#
# Variables can be redefined when building a system to select the
# required support for features like encodings, protocols, etc.
#
# Hints:
#
# - For methods and fields, the signature is mandatory. For
# specification, please see the Java Virtual Machine Specification by
# SUN. Unlike in the spec, field signatures (types) are in brackets.
#
# - Package names must be separated by '/' (and not '.'). E.g.,
# java/lang/Class (this is necessary, because the '.' is used to
# separate method or field names from classes)
#
# - In case <needed> refers to a class, only the class itself will be
# included in the resulting binary, NOT necessarily all its methods
# and fields. If you want to refer to all methods and fields, you can
# write class.* as an abbreviation.
#
# - Abbreviations for packages are also possible: my/package/* means all
# methods and fields of all classes in my/package.
#
# - A line with a trailing '\' continues in the next line.
# All calendars supported are loaded via java/util/Calendar.getBundle or
# java/util/GregorianCalendar.getBundle from class
# gnu/java/locale/Calendar_{locale_id}
#
# This introduces a dependency for the localized calendars. To allow an easy
# selection and addition of locales, the library variable {calendar_locales}
# can be set to the set of supported calendar locales.
#
{calendar_locales}: de en nl
java/util/Calendar.getBundle(Ljava/util/Locale;)Ljava/util/ResourceBundle;: \
gnu/java/locale/Calendar.* \
gnu/java/locale/Calendar_{calendar_locales}.*
java/util/GregorianCalendar.getBundle(Ljava/util/Locale;)Ljava/util/ResourceBundle;: \
gnu/java/locale/Calendar.* \
gnu/java/locale/Calendar_{calendar_locales}.*
# end of file

View file

@ -349,7 +349,8 @@ public class CopyOnWriteArrayList<E> extends AbstractList<E> implements
{
E[] data = this.data;
E[] newData = (E[]) new Object[data.length - 1];
System.arraycopy(data, 0, newData, 0, index - 1);
if (index > 0)
System.arraycopy(data, 0, newData, 0, index - 1);
System.arraycopy(data, index + 1, newData, index,
data.length - index - 1);
E r = data[index];

View file

@ -1,6 +1,6 @@
/* LogManager.java -- a class for maintaining Loggers and managing
configuration properties
Copyright (C) 2002, 2005, 2006 Free Software Foundation, Inc.
Copyright (C) 2002, 2005, 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -446,8 +446,8 @@ public class LogManager
Iterator<WeakReference<Logger>> iter = loggers.values().iterator();
while (iter.hasNext())
for (WeakReference<Logger> ref : loggers.values())
{
WeakReference<Logger> ref;
Logger logger;
ref = iter.next();
@ -559,13 +559,21 @@ public class LogManager
if ("handlers".equals(key))
{
StringTokenizer tokenizer = new StringTokenizer(value);
// In Java 5 and earlier this was specified to be
// whitespace-separated, but in reality it also accepted
// commas (tomcat relied on this), and in Java 6 the
// documentation was updated to fit the implementation.
StringTokenizer tokenizer = new StringTokenizer(value,
" \t\n\r\f,");
while (tokenizer.hasMoreTokens())
{
String handlerName = tokenizer.nextToken();
Handler handler = (Handler)
createInstance(handlerName, Handler.class, key);
Logger.root.addHandler(handler);
// Tomcat also relies on the implementation ignoring
// items in 'handlers' which are not class names.
if (handler != null)
Logger.root.addHandler(handler);
}
}

View file

@ -1,5 +1,5 @@
/* Logger.java -- a class for logging messages
Copyright (C) 2002, 2004, 2006 Free Software Foundation, Inc.
Copyright (C) 2002, 2004, 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -276,8 +276,8 @@ public class Logger
LogManager lm = LogManager.getLogManager();
Logger result;
/* Throw NullPointerException if name is null. */
name.getClass();
if (name == null)
throw new NullPointerException();
/* Without synchronized(lm), it could happen that another thread
* would create a logger between our calls to getLogger and
@ -1013,8 +1013,8 @@ public class Logger
public synchronized void addHandler(Handler handler)
throws SecurityException
{
/* Throw a new NullPointerException if handler is null. */
handler.getClass();
if (handler == null)
throw new NullPointerException();
/* An application is allowed to control an anonymous logger
* without having the permission to control the logging
@ -1057,8 +1057,8 @@ public class Logger
if (!anonymous)
LogManager.getLogManager().checkAccess();
/* Throw a new NullPointerException if handler is null. */
handler.getClass();
if (handler == null)
throw new NullPointerException();
handlerList.remove(handler);
handlers = getHandlers();
@ -1166,8 +1166,8 @@ public class Logger
*/
public synchronized void setParent(Logger parent)
{
/* Throw a new NullPointerException if parent is null. */
parent.getClass();
if (parent == null)
throw new NullPointerException();
if (this == root)
throw new IllegalArgumentException(

View file

@ -45,6 +45,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.TreeSet;
@ -97,17 +98,18 @@ public abstract class AbstractPreferences extends Preferences {
* accessed by earlier <code>getChild()</code> or <code>childSpi()</code>
* invocations and that have not been removed.
*/
private HashMap childCache = new HashMap();
private HashMap<String, AbstractPreferences> childCache
= new HashMap<String, AbstractPreferences>();
/**
* A list of all the registered NodeChangeListener objects.
*/
private ArrayList nodeListeners;
private ArrayList<NodeChangeListener> nodeListeners;
/**
* A list of all the registered PreferenceChangeListener objects.
*/
private ArrayList preferenceListeners;
private ArrayList<PreferenceChangeListener> preferenceListeners;
// constructor
@ -202,7 +204,8 @@ public abstract class AbstractPreferences extends Preferences {
*/
protected final AbstractPreferences[] cachedChildren()
{
return (AbstractPreferences[]) childCache.values().toArray();
Collection<AbstractPreferences> vals = childCache.values();
return vals.toArray(new AbstractPreferences[vals.size()]);
}
/**
@ -228,7 +231,7 @@ public abstract class AbstractPreferences extends Preferences {
if (isRemoved())
throw new IllegalStateException("Node removed");
TreeSet childrenNames = new TreeSet();
TreeSet<String> childrenNames = new TreeSet<String>();
// First get all cached node names
childrenNames.addAll(childCache.keySet());
@ -1165,7 +1168,7 @@ public abstract class AbstractPreferences extends Preferences {
if (listener == null)
throw new NullPointerException("listener is null");
if (nodeListeners == null)
nodeListeners = new ArrayList();
nodeListeners = new ArrayList<NodeChangeListener>();
nodeListeners.add(listener);
}
}
@ -1184,7 +1187,7 @@ public abstract class AbstractPreferences extends Preferences {
if (listener == null)
throw new NullPointerException("listener is null");
if (preferenceListeners == null)
preferenceListeners = new ArrayList();
preferenceListeners = new ArrayList<PreferenceChangeListener>();
preferenceListeners.add(listener);
}
}

View file

@ -183,9 +183,9 @@ public abstract class Preferences {
// Get the factory
if (factory == null) {
// Caller might not have enough permissions
factory = (PreferencesFactory) AccessController.doPrivileged(
new PrivilegedAction() {
public Object run() {
factory = AccessController.doPrivileged(
new PrivilegedAction<PreferencesFactory>() {
public PreferencesFactory run() {
PreferencesFactory pf = null;
String className = System.getProperty
("java.util.prefs.PreferencesFactory");

View file

@ -1,5 +1,5 @@
/* Pattern.java -- Compiled regular expression ready to be applied.
Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
Copyright (C) 2002, 2004, 2005, 2007 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@ -246,7 +246,7 @@ public final class Pattern implements Serializable
{
String t = input.subSequence(start, input.length()).toString();
if ("".equals(t) && limit == 0)
; // Don't add.
{ /* Don't add. */ }
else
list.add(t);
}
@ -260,4 +260,14 @@ public final class Pattern implements Serializable
{
return regex;
}
/**
* Return the regular expression used to construct this object.
* @specnote Prior to JDK 1.5 this method had a different behavior
* @since 1.5
*/
public String toString()
{
return regex;
}
}

View file

@ -0,0 +1,100 @@
/* CurrencyNameProvider.java -- Providers of localized currency symbols
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.spi;
import java.util.Locale;
/**
* A {@link CurrencyNameProvider} provides localized
* versions of the symbols that represent a particular
* currency. Note that currency symbols are regarded
* as names, and thus a <code>null</code> value may
* be returned, which should be treated as a lack of
* support for the specified {@link Locale}.
*
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.6
*/
public abstract class CurrencyNameProvider
extends LocaleServiceProvider
{
/**
* Constructs a new {@link CurrencyNameProvider}.
* Provided for implicit invocation by subclasses.
*/
protected CurrencyNameProvider()
{
}
/**
* <p>
* This method returns the symbol which precedes or follows a
* value in this particular currency. The returned value is
* the symbol used to denote the currency in the specified locale.
* </p>
* <p>
* For example, a supplied locale may specify a different symbol
* for the currency, due to conflicts with its own currency.
* This would be the case with the American currency, the dollar.
* Locales that also use a dollar-based currency (e.g. Canada, Australia)
* need to differentiate the American dollar using 'US$' rather than '$'.
* So, supplying one of these locales to <code>getSymbol()</code> would
* return this value, rather than the standard '$'.
* </p>
* <p>
* In cases where there is no such symbol for a particular currency,
* <code>null</code> should be returned.
* </p>
*
* @param currencyCode the ISO 4217 currency code, consisting
* of three uppercase letters from 'A' to 'Z'
* @param locale the locale to express the symbol in.
* @return the currency symbol, or <code>null</code> if one is
* unavailable.
* @throws NullPointerException if the locale is null.
* @throws IllegalArgumentException if the currency code is
* not in the correct format
* or the locale is not one
* returned by
* {@link getAvailableLocales()}
* @see java.util.Currency#getSymbol(java.util.Locale)
*/
public abstract String getSymbol(String currencyCode, Locale locale);
}

View file

@ -0,0 +1,135 @@
/* LocaleNameProvider.java -- Providers of localized locale names
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.spi;
import java.util.Locale;
/**
* A {@link LocaleNameProvider} provides localized
* versions of the names that represent a particular
* locale. Note that a <code>null</code> value may
* be returned, which should be treated as a lack of
* support for the specified {@link Locale}.
*
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.6
*/
public abstract class LocaleNameProvider
extends LocaleServiceProvider
{
/**
* Constructs a new {@link LocaleNameProvider}.
* Provided for implicit invocation by subclasses.
*/
protected LocaleNameProvider()
{
}
/**
* Returns the localized name for the specified ISO 3166
* country in the supplied {@link java.util.Locale}.
* For example, if the country code is <code>"DE"</code>,
* this method will return <code>"Germany"</code> for
* {@link Locale.ENGLISH} but <code>"Deutschland"</code>
* for {@link Locale.GERMANY}. If the name of the country
* in the given locale is not supported, <code>null</code>
* is returned.
*
* @param countryCode the ISO 3166 country code, consisting
* of two uppercase letters from 'A' to 'Z'
* @param locale the locale to express the country in.
* @return the country name, or <code>null</code> if one is
* not available.
* @throws NullPointerException if the locale is null.
* @throws IllegalArgumentException if the country code is
* not in the correct format
* or the locale is not one
* returned by
* {@link getAvailableLocales()}
* @see java.util.Locale#getDisplayCountry(java.util.Locale)
*/
public abstract String getDisplayCountry(String countryCode,
Locale locale);
/**
* Returns the localized name for the specified ISO 639
* language in the supplied {@link java.util.Locale}.
* For example, if the language code is <code>"de"</code>,
* this method will return <code>"German"</code> for
* {@link Locale.ENGLISH} but <code>"Deutsch"</code>
* for {@link Locale.GERMANY}. If the name of the language
* in the given locale is not supported, <code>null</code>
* is returned.
*
* @param langCode the ISO 639 language code, consisting
* of two lowercase letters from 'a' to 'z'
* @param locale the locale to express the language in.
* @return the country name, or <code>null</code> if one is
* not available.
* @throws NullPointerException if the locale is null.
* @throws IllegalArgumentException if the language code is
* not in the correct format
* or the locale is not one
* returned by
* {@link getAvailableLocales()}
* @see java.util.Locale#getDisplayLanguage(java.util.Locale)
*/
public abstract String getDisplayLanguage(String langCode,
Locale locale);
/**
* Returns the localized name for the specified variant
* in the supplied {@link java.util.Locale}. If the name
* of the variant in the given locale is not supported,
* <code>null</code> is returned.
*
* @param variant the variant.
* @param locale the locale to express the variant in.
* @return the localized variant, or <code>null</code> if one is
* not available.
* @throws NullPointerException if the locale is null.
* @throws IllegalArgumentException if the locale is not one
* returned by
* {@link getAvailableLocales()}
* @see java.util.Locale#getDisplayVariant(java.util.Locale)
*/
public abstract String getDisplayVariant(String variant,
Locale locale);
}

View file

@ -0,0 +1,125 @@
/* LocaleServiceProvider.java -- Superclass of locale SPIs
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.spi;
import java.util.Locale;
/**
* <p>
* This is the superclass of all the {@link Locale} service
* provider interfaces or SPIs. The locale SPIs are used
* to allow for the provision of additional support for
* locale-specific data. The runtime environment has its
* own collection of locale data, but these interfaces allow
* this to be extended by external classes.
* </p>
* <p>
* Service providers are created as concrete implementations
* of these interfaces, and accessed using the extension
* mechanism, realised by {@link ServiceLoader}. When a factory
* method of one of the locale-specific classes (such as
* {@link java.text.DateFormatSymbols} or {@link java.util.Currency})
* is called, the runtime environment is first asked to
* provide data for the specified locale. If the runtime
* environment fails to provide this, then the offer is
* made to service providers which implement the appropriate
* interface.
* </p>
* <p>
* Each provider implements the method specified by this
* class, {@link #getAvailableLocales()}. This method is
* called first to determine whether the provider will be of
* any use in providing data for the specified locale. If
* a provider is found to be capable, then a more specific
* method appropriate to the class requiring the data will
* be called. In the case of {@link java.text.DateFormatSymbols},
* this would be
* {@link java.text.spi.DateFormatSymbols#getInstance(Locale)}.
* </p>
* <p>
* If neither a service provider nor the runtime environment
* itself can fulfill the request, a fallback procedure is
* engaged. The locale is modified by applying the first
* applicable rule:
* </p>
* <ol>
* <li>If the variant contains a <code>'_'</code>, then
* this and everything following it is trimmed.</li>
* <li>If the variant is non-empty, it is converted to
* an empty string.</li>
* <li>If the country is non-empty, it is converted to
* an empty string.</li>
* <li>If the language is non-empty, it is converted to
* an empty string.</li>
* </ol>
* <p>
* The modified locale is then used to start the same
* process again. The root locale (@link java.util.Locale#ROOT}
* must be supported by the runtime environment in order
* to terminate this cycle.
* </p>
* <p>
* Note that any names returned by the providers may
* be <code>null</code>. Returning a <code>null</code>
* name is considered equivalent to not supporting a
* particular locale.
* </p>
*
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.6
*/
public abstract class LocaleServiceProvider
{
/**
* Constructs a new {@link LocaleServiceProvider}.
* Provided for implicit invocation by subclasses.
*/
protected LocaleServiceProvider()
{
}
/**
* Returns an array of {@link Locale} instances,
* for which the provider can supply localized data.
*
* @return an array of supported locales.
*/
public abstract Locale[] getAvailableLocales();
}

View file

@ -0,0 +1,97 @@
/* TimeZoneNameProvider.java -- Providers of localized currency symbols
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.spi;
import java.util.Locale;
/**
* A {@link TimeZoneNameProvider} provides localized
* versions of the names that represent a particular
* timezone. A <code>null</code> value may
* be returned, which should be treated as a lack of
* support for the specified {@link Locale}. The names
* from this class are also used by
* {@link DateFormatSymbols#getZoneStrings()}.
*
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
* @since 1.6
*/
public abstract class TimeZoneNameProvider
extends LocaleServiceProvider
{
/**
* Constructs a new {@link TimeZoneNameProvider}.
* Provided for implicit invocation by subclasses.
*/
protected TimeZoneNameProvider()
{
}
/**
* Returns a name for the specified time zone identifier
* localized to the supplied {@link java.util.Locale}.
* The time zone identifier is either <code>"GMT"</code>
* or one of the identifiers from the public domain "tz
* database" found at <a href="ftp://elsie.nci.nih.gov/pub/">
* ftp://elsie.nci.nih.gov/pub</a>. Note that a translated
* name for the daylight savings time variant should be returned,
* even if the timezone has not observed daylight savings
* time in the past. If the name of the timezone
* in the given locale is not supported, <code>null</code>
* is returned.
*
* @param id a time zone identifier.
* @param daylight true if the daylight savings time variant
* should be returned.
* @param style either {@link java.util.TimeZone.LONG} or
* {@link java.util.TimeZone.SHORT}
* @param locale the locale to express the timezone in.
* @return the localized time zone name, or <code>null</code>
* if one is not available.
* @throws NullPointerException if the identifer or locale is null.
* @throws IllegalArgumentException if the style is invalid
* or the locale is not one
* returned by
* {@link getAvailableLocales()}
* @see java.util.TimeZone#getDisplayName(boolean,int,java.util.Locale)
*/
public abstract String getDisplayName(String id, boolean daylight,
int style, Locale locale);
}

View file

@ -0,0 +1,50 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<!-- package.html - describes classes in java.util.spi package.
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. -->
<html>
<head><title>GNU Classpath - java.util.spi</title></head>
<body>
<p>
A series of service provider interfaces for use by the
classes in <code>java.util</code>.
</p>
<p><span style="font-weight: bold;">Since</span>: 1.6</p>
</body>
</html>

View file

@ -377,7 +377,8 @@ class DeflaterEngine implements DeflaterConstants
&& window[++scan] == window[++match]
&& window[++scan] == window[++match]
&& window[++scan] == window[++match]
&& scan < strend);
&& scan < strend)
;
if (scan > best_end) {
// if (DeflaterConstants.DEBUGGING && ins_h == 0)

View file

@ -238,6 +238,7 @@ public class ZipInputStream extends InflaterInputStream implements ZipConstants
byte[] tmp = new byte[2048];
while (read(tmp) > 0)
;
/* read will close this entry */
return;
}