svn commit: r1391370 - in /sis/trunk/sis-utility/src/main/java/org/apache/sis/util: ./ collection/
Author: desruisseaux Date: Fri Sep 28 09:09:11 2012 New Revision: 1391370 URL: http://svn.apache.org/viewvc?rev=1391370view=rev Log: Initial commit of org.apache.sis.util.collection. Added: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/BackingStoreException.java (with props) sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/Collections.java (with props) sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/EmptyQueue.java (with props) sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/EmptySortedSet.java (with props) sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/package-info.java (with props) Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Static.java Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Static.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Static.java?rev=1391370r1=1391369r2=1391370view=diff == --- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Static.java (original) +++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Static.java Fri Sep 28 09:09:11 2012 @@ -31,6 +31,8 @@ package org.apache.sis.util; * tdMethods working on {@link Class} instances./td/tr * * trth colspan=2 class=hsepStructures (trees, collections, arrays, parameters)/th/tr + * trtd{@link org.apache.sis.util.collection.Collections}/td + * tdAdditions to the JDK {@link java.util.Collections} methods./td/tr * trtd{@link Arrays}/td * tdInsert or remove elements in the middle of arrays./td/tr * Added: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/BackingStoreException.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/BackingStoreException.java?rev=1391370view=auto == --- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/BackingStoreException.java (added) +++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/BackingStoreException.java Fri Sep 28 09:09:11 2012 @@ -0,0 +1,135 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the License); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sis.util.collection; + +import java.io.IOException; +import java.sql.SQLException; + + +/** + * Thrown to indicate that an operation could not complete because of a failure in the backing + * store (a file or a database). This exception is thrown by collection implementations that are + * not allowed to throw checked exceptions. This exception usually has an {@link IOException} or + * a {@link SQLException} as its {@linkplain #getCause() cause}. + * p + * This method provides a {@link #unwrapOrRethrow(Class)} convenience method which can be used + * for re-throwing the cause as in the example below. This allows client code to behave as if a + * {@link java.util.Collection} interface was allowed to declare checked exceptions. + * + * {@preformat java + * void myMethod() throws IOException { + * Collection c = ...; + * try { + * c.doSomeStuff(); + * } catch (BackingStoreException e) { + * throw e.unwrapOrRethrow(IOException.class); + * } + * } + * } + * + * @author Martin Desruisseaux (IRD, Geomatys) + * @since 0.3 (derived from geotk-2.3) + * @version 0.3 + * @module + */ +public class BackingStoreException extends RuntimeException { +/** + * For cross-version compatibility. + */ +private static final long serialVersionUID = -1714319767053628606L; + +/** + * Constructs a new exception with no detail message. + */ +public BackingStoreException() { +} + +/** + * Constructs a new exception with the specified detail message. + * + * @param message The detail message, saved for later retrieval by the {@link #getMessage()} method. + */ +public BackingStoreException(final String message) { +super(message); +} + +
svn commit: r1391413 - in /sis/trunk: sis-utility/src/main/java/org/apache/sis/util/Locales.java sis-utility/src/main/java/org/apache/sis/util/collection/Collections.java src/site/resources/book/book.
Author: desruisseaux Date: Fri Sep 28 11:55:41 2012 New Revision: 1391413 URL: http://svn.apache.org/viewvc?rev=1391413view=rev Log: Documentation updates. Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Locales.java sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/Collections.java sis/trunk/src/site/resources/book/book.css Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Locales.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Locales.java?rev=1391413r1=1391412r2=1391413view=diff == --- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Locales.java (original) +++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Locales.java Fri Sep 28 11:55:41 2012 @@ -34,7 +34,7 @@ import static org.apache.sis.util.collec /** - * Utilities methods working on {@link Locale} instances. While this class is documented as + * Static methods working on {@link Locale} instances. While this class is documented as * providing static methods, a few methods are actually non-static. Those methods need to be * invoked on the {@link #SYSTEM} or {@link #LIBRARY} instance in order to specify the scope. * Examples: @@ -161,7 +161,7 @@ public final class Locales extends Stati /** * Returns the list of {@linkplain #getAvailableLocales() available locales} formatted - * as string in the specified locale. + * as strings in the specified locale. * * @param locale The locale to use for formatting the strings to be returned. * @return String descriptions of available locales. @@ -178,7 +178,8 @@ public final class Locales extends Stati /** * Returns the languages of the given locales, without duplicated values. - * The instances returned by this method have no country and no variant information. + * The instances returned by this method have no {@linkplain Locale#getCountry() country} + * and no {@linkplain Locale#getVariant() variant} information. * * @param locales The locales from which to get the languages. * @return The languages, without country or variant information. @@ -197,10 +198,13 @@ public final class Locales extends Stati } /** - * Returns the 3-letters ISO language code if available, or the 2-letters code otherwise. + * Returns the {@linkplain Locale#getISO3Language() 3-letters ISO language code} if available, + * or the {@linkplain Locale#getLanguage() 2-letters code} otherwise. * * @param locale The locale for which we want the language. * @return The language code, 3 letters if possible or 2 letters otherwise. + * + * @see Locale#getISO3Language() */ public static String getLanguageCode(final Locale locale) { try { Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/Collections.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/Collections.java?rev=1391413r1=1391412r2=1391413view=diff == --- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/Collections.java (original) +++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/collection/Collections.java Fri Sep 28 11:55:41 2012 @@ -39,13 +39,13 @@ import static java.util.Collections.unmo * liNull-safe {@link #clear(Collection) clear}, {@link #isNullOrEmpty(Collection) isNullOrEmpty} * and {@link #addIfNonNull(Collection, Object) addIfNonNull} methods, for the convenience of * classes using the citelazy instantiation/cite pattern./li - * li{@link #unmodifiableOrCopy(Set) unmodifiableOrCopy} methods, which may be slightly more - * compact than the standard {@link java.util.Collections#unmodifiableSet(Set)} equivalent - * when the unmodifiable collection is not required to be a view over the original collection./li * li{@link #asCollection(Object) asCollection} for wrapping arbitrary objects to list or collection./li * liList and collection {@linkplain #listComparator() comparators}./li - * li{@link #modifiableCopy(Collection) copy} method for taking a snapshot of an arbitrary + * li{@link #modifiableCopy(Collection) modifiableCopy} method for taking a snapshot of an arbitrary * implementation into an unsynchronized, modifiable, in-memory object./li + * li{@link #unmodifiableOrCopy(Set) unmodifiableOrCopy} methods, which may be slightly more + * compact than the standard {@link java.util.Collections#unmodifiableSet(Set)} equivalent + * when the unmodifiable collection is not required to be a view over the original collection./li * /ul * * @author Martin Desruisseaux (IRD, Geomatys) @@ -188,14 +188,13 @@ public final class Collections
svn commit: r1391417 - /sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Locales.java
Author: desruisseaux Date: Fri Sep 28 12:05:20 2012 New Revision: 1391417 URL: http://svn.apache.org/viewvc?rev=1391417view=rev Log: Field names shall be consistent with the ones used in other class having such kind of fields (namely: Loggings). Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Locales.java Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Locales.java URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Locales.java?rev=1391417r1=1391416r2=1391417view=diff == --- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Locales.java (original) +++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/Locales.java Fri Sep 28 12:05:20 2012 @@ -36,12 +36,12 @@ import static org.apache.sis.util.collec /** * Static methods working on {@link Locale} instances. While this class is documented as * providing static methods, a few methods are actually non-static. Those methods need to be - * invoked on the {@link #SYSTEM} or {@link #LIBRARY} instance in order to specify the scope. + * invoked on the {@link #ALL} or {@link #SIS} instance in order to specify the scope. * Examples: * * {@preformat java - * Locales[] lc1 = Locales.SYSTEM .getAvailableLanguages(); // All languages installed on the JavaVM. - * Locales[] lc2 = Locales.LIBRARY.getAvailableLanguages(); // Only the languages known to Apache SIS. + * Locales[] lc1 = Locales.ALL.getAvailableLanguages(); // All languages installed on the JavaVM. + * Locales[] lc2 = Locales.SIS.getAvailableLanguages(); // Only the languages known to Apache SIS. * } * * @author Martin Desruisseaux (IRD, Geomatys) @@ -89,13 +89,13 @@ public final class Locales extends Stati /** * All locales available on the JavaVM. */ -public final Locales SYSTEM = new Locales(); +public final Locales ALL = new Locales(); /** * Only locales available in the Apache SIS library. They are the locales for which localized * resources are provided in the {@link org.apache.sis.util.resources} package. */ -public final Locales LIBRARY = new Locales(); +public final Locales SIS = new Locales(); /** * Do not allow instantiation of this class, @@ -105,14 +105,14 @@ public final class Locales extends Stati } /** - * Returns the languages known to the JavaVM ({@link #SYSTEM}) or to the Apache SIS library - * ({@link #LIBRARY}). In the later case, this method returns only the languages for which + * Returns the languages known to the JavaVM ({@link #ALL}) or to the Apache SIS library + * ({@link #SIS}). In the later case, this method returns only the languages for which * localized resources are provided in the {@link org.apache.sis.util.resources} package. * * @return The list of supported languages. */ public Locale[] getAvailableLanguages() { -if (this == SYSTEM) { +if (this == ALL) { return getLanguages(Locale.getAvailableLocales()); } return new Locale[] { @@ -122,14 +122,14 @@ public final class Locales extends Stati } /** - * Returns the locales known to the JavaVM ({@link #SYSTEM}) or to the Apache SIS library - * ({@link #LIBRARY}). In the later case, this method returns only the locales for which + * Returns the locales known to the JavaVM ({@link #ALL}) or to the Apache SIS library + * ({@link #SIS}). In the later case, this method returns only the locales for which * localized resources are provided in the {@link org.apache.sis.util.resources} package. * * @return The list of supported locales. */ public Locale[] getAvailableLocales() { -if (this == SYSTEM) { +if (this == ALL) { return Locale.getAvailableLocales(); } final Locale[] languages = getAvailableLanguages();