You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2012/11/20 09:17:49 UTC
svn commit: r1411578 [2/2] - in /sis/trunk: ./
sis-build-helper/src/main/java/org/apache/sis/util/resources/
sis-utility/src/main/java/org/apache/sis/internal/util/
sis-utility/src/main/java/org/apache/sis/io/
sis-utility/src/main/java/org/apache/sis/m...
Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties?rev=1411578&r1=1411577&r2=1411578&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties Tue Nov 20 08:17:47 2012
@@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+DuplicatedValue_1 = La valeur \u201c{0}\u201d est dupliqu\u00e9e.
+ElementAlreadyPresent_1 = L\u2019\u00e9lement \u201c{0}\u201d est d\u00e9j\u00e0 pr\u00e9sent.
EmptyArgument_1 = L\u2019argument \u2018{0}\u2019 ne doit pas \u00eatre vide.
ForbiddenAttribute_2 = L\u2019attribut \u201c{0}\u201d n\u2019est pas autoris\u00e9 pour un objet de type \u2018{1}\u2019.
IllegalArgument_1 = Valeur ill\u00e9gale pour l\u2019argument \u2018{0}\u2019.
@@ -26,10 +28,15 @@ IllegalFormatPatternForClass_2 = Le mod
IllegalLanguageCode_1 = Le code de langue \u201c{0}\u201d n\u2019est pas reconnu.
IllegalRange_2 = La plage [{0} \u2026 {1}] n\u2019est pas valide.
InconsistentAttribute_2 = La valeur \u201c{1}\u201d de l\u2019attribut \u2018{0}\u2019 n\u2019est pas coh\u00e9rente avec celles des autres attributs.
+InconsistentTableColumns = Les colonnes des tables ne sont pas coh\u00e9rentes.
IndexOutOfBounds_1 = L\u2019index {0} est en dehors des limites permises.
KeyCollision_1 = Une valeur diff\u00e9rente est d\u00e9j\u00e0 associ\u00e9e \u00e0 la cl\u00e9 \u201c{0}\u201d.
MandatoryAttribute_2 = L\u2019attribut \u201c{0}\u201d est obligatoire pour un objet de type \u2018{1}\u2019.
NegativeArgument_2 = L\u2019argument \u2018{0}\u2019 ne doit pas \u00eatre n\u00e9gatif. La valeur donn\u00e9e \u00e9tait {1}.
+NodeChildOfItself_1 = Le n\u0153ud \u201c{0}\u201d ne peut pas \u00eatre un enfant de lui-m\u00eame.
+NodeHasAnotherParent_1 = Le n\u0153ud \u201c{0}\u201d a d\u00e9j\u00e0 un autre parent.
+NodeHasNoParent_1 = Le n\u0153ud \u201c{0}\u201d n\u2019a pas de parent.
+NodeNotFound_1 = Aucun n\u0153ud \u201c{0}\u201d n\u2019a \u00e9t\u00e9 trouv\u00e9.
NotANumber_1 = L\u2019argument \u2018{0}\u2019 ne doit pas \u00eatre NaN (Not-a-Number).
NotAPrimitiveWrapper_1 = La classe \u2018{0}\u2019 n\u2019est pas un adaptateur d\u2019un type primitif.
NullArgument_1 = L\u2019argument \u2018{0}\u2019 ne doit pas \u00eatre nul.
@@ -41,6 +48,7 @@ UnmodifiableAffineTransform = Cette
UnmodifiableGeometry = Cette g\u00e9om\u00e9trie n\u2019est pas modifiable.
UnmodifiableMetadata = Cette m\u00e9ta-donn\u00e9e n\u2019est pas modifiable.
UnmodifiableObject_1 = L\u2019objet \u2018{0}\u2019 n\u2019est pas modifiable.
+UnspecifiedFormatForClass_1 = Aucun format n\u2019est sp\u00e9cifi\u00e9 pour les objets de classe \u2018{0}\u2019.
UnparsableStringForClass_2 = Le texte \u201c{1}\u201d n\u2019est pas reconnu comme un objet de type \u2018{0}\u2019.
UnparsableStringForClass_3 = Le texte \u201c{1}\u201d n\u2019est pas reconnu comme un objet de type \u2018{0}\u2019, \u00e0 cause des caract\u00e8res \u201c{2}\u201d.
UnsupportedImplementation_1 = Les instances de \u2018{0}\u2019 ne peuvent pas \u00eatre g\u00e9r\u00e9es parce que les impl\u00e9mentations arbitraires ne sont pas encore support\u00e9es.
Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java?rev=1411578&r1=1411577&r2=1411578&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/resources/IndexedResourceBundle.java Tue Nov 20 08:17:47 2012
@@ -559,6 +559,7 @@ public class IndexedResourceBundle exten
* Constructs a new MessageFormat for formatting the arguments.
*/
format = new MessageFormat(pattern, getFormatLocale());
+ lastKey = key;
} else if (key != lastKey) {
/*
* Method MessageFormat.applyPattern(...) is costly! We will avoid
Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/type/AbstractInternationalString.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/type/AbstractInternationalString.java?rev=1411578&r1=1411577&r2=1411578&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/type/AbstractInternationalString.java (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/type/AbstractInternationalString.java Tue Nov 20 08:17:47 2012
@@ -67,13 +67,15 @@ public abstract class AbstractInternatio
*/
@Override
public int length() {
- if (defaultValue == null) {
- defaultValue = toString();
- if (defaultValue == null) {
+ String text = defaultValue;
+ if (text == null) {
+ text = toString();
+ if (text == null) {
return 0;
}
+ defaultValue = text;
}
- return defaultValue.length();
+ return text.length();
}
/**
@@ -86,13 +88,15 @@ public abstract class AbstractInternatio
*/
@Override
public char charAt(final int index) throws IndexOutOfBoundsException {
- if (defaultValue == null) {
- defaultValue = toString();
- if (defaultValue == null) {
+ String text = defaultValue;
+ if (text == null) {
+ text = toString();
+ if (text == null) {
throw new StringIndexOutOfBoundsException();
}
+ defaultValue = text;
}
- return defaultValue.charAt(index);
+ return text.charAt(index);
}
/**
@@ -107,16 +111,18 @@ public abstract class AbstractInternatio
*/
@Override
public CharSequence subSequence(final int start, final int end) {
- if (defaultValue == null) {
- defaultValue = toString();
- if (defaultValue == null) {
+ String text = defaultValue;
+ if (text == null) {
+ text = toString();
+ if (text == null) {
if (start == 0 && end == 0) {
return "";
}
throw new StringIndexOutOfBoundsException();
}
+ defaultValue = text;
}
- return defaultValue.substring(start, end);
+ return text.substring(start, end);
}
/**
@@ -142,13 +148,15 @@ public abstract class AbstractInternatio
*/
@Override
public String toString() {
- if (defaultValue == null) {
- defaultValue = toString(Locale.getDefault());
- if (defaultValue == null) {
+ String text = defaultValue;
+ if (text == null) {
+ text = toString(Locale.getDefault());
+ if (text == null) {
return "";
}
+ defaultValue = text;
}
- return defaultValue;
+ return text;
}
/**
Modified: sis/trunk/sis-utility/src/main/java/org/apache/sis/util/type/DefaultInternationalString.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/main/java/org/apache/sis/util/type/DefaultInternationalString.java?rev=1411578&r1=1411577&r2=1411578&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/main/java/org/apache/sis/util/type/DefaultInternationalString.java (original)
+++ sis/trunk/sis-utility/src/main/java/org/apache/sis/util/type/DefaultInternationalString.java Tue Nov 20 08:17:47 2012
@@ -266,8 +266,7 @@ public class DefaultInternationalString
* {@code null} locale, then that string is returned.</li>
* <li>Otherwise, acknowledging that UML identifiers in OGC/ISO specifications are primarily
* expressed in the English language, this method looks for an English string as an
- * approximation of a "unlocalized" string. The {@link Locale#UK} variant is
- * preferred because ISO specifications seem to use that language.</li>
+ * approximation of a "unlocalized" string.</li>
* <li>If no English string was found, this method looks for a string for the
* {@linkplain Locale#getDefault() system default locale}.</li>
* <li>If none of the above steps found a string, then this method returns
@@ -295,7 +294,7 @@ public class DefaultInternationalString
*/
text = localeMap.get(null);
if (text == null) {
- Locale def = Locale.UK; // The default language for "unlocalized" string.
+ Locale def = Locale.US; // The default language for "unlocalized" string.
if (locale != def) { // Avoid requesting the same locale twice (optimization).
text = getString(def);
if (text != null) {
@@ -303,7 +302,7 @@ public class DefaultInternationalString
}
}
def = Locale.getDefault();
- if (locale != def && def != Locale.UK) {
+ if (locale != def && def != Locale.US) {
text = getString(def);
if (text != null) {
return text;
Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/FormattedCharacterIteratorTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/FormattedCharacterIteratorTest.java?rev=1411578&r1=1411577&r2=1411578&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/FormattedCharacterIteratorTest.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/measure/FormattedCharacterIteratorTest.java Tue Nov 20 08:17:47 2012
@@ -109,15 +109,15 @@ public final strictfp class FormattedCha
/**
* Returns all expected attribute keys for the tests in this class.
*
- * @param overlapping {@code true}Â for including the keys for overlapping attributes.
+ * @param withNumberFields {@code true}Â for including the keys for {@code NumberFormat} fields.
*/
- private static Set<Attribute> getAllAttributeKeys(final boolean overlapping) {
+ private static Set<Attribute> getAllAttributeKeys(final boolean withNumberFields) {
final Set<Attribute> keys = new HashSet<Attribute>(8);
assertTrue(keys.add(DEGREES));
assertTrue(keys.add(MINUTES));
assertTrue(keys.add(SECONDS));
assertTrue(keys.add(HEMISPHERE));
- if (overlapping) {
+ if (withNumberFields) {
assertTrue(keys.add(INTEGER));
assertTrue(keys.add(FRACTION));
assertTrue(keys.add(DECIMAL_SEPARATOR));
@@ -149,7 +149,7 @@ public final strictfp class FormattedCha
start=upper; upper= 8; if (o) it.addFieldLimit(INTEGER, 15, start);
start=upper; upper= 9; if (o) it.addFieldLimit(DECIMAL_SEPARATOR, '.', start);
start=upper; upper=10; if (o) it.addFieldLimit(FRACTION, 0, start);
- start=6; upper=11; it.addFieldLimit(SECONDS, 15, start);
+ start=6; upper=11; it.addFieldLimit(SECONDS, 15f, start);
start=upper; upper=12; it.addFieldLimit(HEMISPHERE, 'N', start);
assertEquals(text.length(), upper);
return it;
@@ -164,8 +164,8 @@ public final strictfp class FormattedCha
* <p>This test is leveraged by {@link AngleFormatTest#testFormatToCharacterIterator()}.</p>
*/
@SuppressWarnings("fallthrough")
- static void testAttributes(final AttributedCharacterIterator it, final boolean overlapping) {
- assertEquals(getAllAttributeKeys(overlapping), it.getAllAttributeKeys());
+ static void testAttributes(final AttributedCharacterIterator it, final boolean withNumberFields) {
+ assertEquals(getAllAttributeKeys(withNumberFields), it.getAllAttributeKeys());
assertEquals(0, it.getIndex());
assertEquals(3, it.getRunLimit(MINUTES));
assertEquals(6, it.getRunLimit(SECONDS));
@@ -175,9 +175,9 @@ public final strictfp class FormattedCha
final AngleFormat.Field key;
final Comparable<?> value;
final int start, limit;
- if (index < 3) {key=DEGREES; value= 45; start= 0; limit= 3;}
- else if (index < 6) {key=MINUTES; value= 30; start= 3; limit= 6;}
- else if (index < 11) {key=SECONDS; value= 15; start= 6; limit=11;}
+ if (index < 3) {key=DEGREES; value=45 ; start= 0; limit= 3;}
+ else if (index < 6) {key=MINUTES; value=30 ; start= 3; limit= 6;}
+ else if (index < 11) {key=SECONDS; value=15f; start= 6; limit=11;}
else {key=HEMISPHERE; value='N'; start=11; limit=12;}
/*
* Expected values when asking for a NumberFormat field.
@@ -194,7 +194,7 @@ public final strictfp class FormattedCha
int startFraction = 0;
int limitFraction = 12;
int numAttributes = 1;
- if (overlapping) {
+ if (withNumberFields) {
/*
* Update the above expected values when the current position
* is inside a NumberFormat field.
Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/test/Assert.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/test/Assert.java?rev=1411578&r1=1411577&r2=1411578&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/test/Assert.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/test/Assert.java Tue Nov 20 08:17:47 2012
@@ -79,13 +79,7 @@ public strictfp class Assert extends org
* @param actual The actual string.
*/
public static void assertMultilinesEquals(final String message, final CharSequence expected, final CharSequence actual) {
- final CharSequence[] a1 = CharSequences.split(expected, '\n');
- final CharSequence[] a2 = CharSequences.split(actual, '\n');
- final int length = Math.min(a1.length, a2.length);
- for (int i=0; i<length; i++) {
- assertEquals("Line " + (i+1) + ':', a1[i], a2[i]);
- }
- assertArrayEquals(message, a1, a2);
+ assertArrayEquals(message, CharSequences.split(expected, '\n'), CharSequences.split(actual, '\n'));
}
/**
Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java?rev=1411578&r1=1411577&r2=1411578&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java Tue Nov 20 08:17:47 2012
@@ -51,6 +51,7 @@ import org.junit.runners.Suite;
org.apache.sis.util.collection.CacheTest.class,
org.apache.sis.util.collection.DerivedSetTest.class,
org.apache.sis.util.collection.DerivedMapTest.class,
+ org.apache.sis.util.collection.DefaultTreeTableTest.class,
// GeoAPI most basic types.
org.apache.sis.util.type.TypesTest.class,
@@ -58,12 +59,14 @@ import org.junit.runners.Suite;
org.apache.sis.util.type.DefaultInternationalStringTest.class,
// Formatting
+ org.apache.sis.internal.util.LocalizedParseExceptionTest.class,
org.apache.sis.measure.FormattedCharacterIteratorTest.class,
org.apache.sis.measure.AngleFormatTest.class,
org.apache.sis.measure.AngleTest.class,
org.apache.sis.internal.util.X364Test.class,
org.apache.sis.io.LineFormatterTest.class,
org.apache.sis.io.TableFormatterTest.class,
+ org.apache.sis.util.collection.TreeTableFormatTest.class,
// XML most basic types.
org.apache.sis.xml.XLinkTest.class,
Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java?rev=1411578&r1=1411577&r2=1411578&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/util/CharSequencesTest.java Tue Nov 20 08:17:47 2012
@@ -87,11 +87,12 @@ public final strictfp class CharSequence
case 3: string = new SimpleInternationalString((String) string); break;
default: throw new AssertionError(i);
}
- assertEquals(-1, indexOf(string, "dummy", 0));
- assertEquals( 0, indexOf(string, "An", 0));
- assertEquals(-1, indexOf(string, "An", 1));
- assertEquals(12, indexOf(string, "sentence.", 0));
- assertEquals(-1, indexOf(string, "sentence;", 0));
+ final int length = string.length();
+ assertEquals(-1, indexOf(string, "dummy", 0, length));
+ assertEquals( 0, indexOf(string, "An", 0, length));
+ assertEquals(-1, indexOf(string, "An", 1, length));
+ assertEquals(12, indexOf(string, "sentence.", 0, length));
+ assertEquals(-1, indexOf(string, "sentence;", 0, length));
}
}
Modified: sis/trunk/sis-utility/src/test/java/org/apache/sis/util/resources/IndexedResourceBundleTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/sis-utility/src/test/java/org/apache/sis/util/resources/IndexedResourceBundleTest.java?rev=1411578&r1=1411577&r2=1411578&view=diff
==============================================================================
--- sis/trunk/sis-utility/src/test/java/org/apache/sis/util/resources/IndexedResourceBundleTest.java (original)
+++ sis/trunk/sis-utility/src/test/java/org/apache/sis/util/resources/IndexedResourceBundleTest.java Tue Nov 20 08:17:47 2012
@@ -17,6 +17,7 @@
package org.apache.sis.util.resources;
import java.io.IOException;
+import java.io.PrintStream;
import java.util.Locale;
import java.util.Enumeration;
import java.util.logging.Level;
@@ -27,6 +28,7 @@ import org.apache.sis.test.DependsOnMeth
import org.apache.sis.test.DependsOn;
import org.apache.sis.test.TestCase;
import org.junit.Test;
+import org.junit.After;
import static org.junit.Assert.*;
@@ -41,6 +43,13 @@ import static org.junit.Assert.*;
@DependsOn(org.apache.sis.util.ArraysTest.class)
public final strictfp class IndexedResourceBundleTest extends TestCase {
/**
+ * The resource bundle in process of being tested. Shall be reset to {@code null} after every
+ * test. If non-null, then {@link #dumpResourcesOnError()} will consider that the test failed
+ * and will dump the resource bundle content to the standard error stream.
+ */
+ private IndexedResourceBundle testing;
+
+ /**
* Tests the {@link Errors#getResources(Locale)} method on different locales.
*/
@Test
@@ -80,7 +89,8 @@ public final strictfp class IndexedResou
@Test
@DependsOnMethod("testGetResources")
public void testGetKeys() {
- final Enumeration<String> e=Errors.getResources(Locale.ENGLISH).getKeys();
+ testing = Errors.getResources(Locale.ENGLISH);
+ final Enumeration<String> e = testing.getKeys();
int count = 0;
boolean foundNullArgument_1 = false;
while (e.hasMoreElements()) {
@@ -92,6 +102,7 @@ public final strictfp class IndexedResou
}
assertTrue("foundNullArgument_1:", foundNullArgument_1);
assertTrue("count > 5", count > 5);
+ testing = null;
}
/**
@@ -103,8 +114,9 @@ public final strictfp class IndexedResou
final Errors english = Errors.getResources(Locale.ENGLISH);
final Errors french = Errors.getResources(Locale.FRENCH);
- assertEquals("Argument â{0}â shall not be null.", english.getString(Errors.Keys.NullArgument_1));
- assertEquals("Lâargument â{0}â ne doit pas être nul.", french.getString(Errors.Keys.NullArgument_1));
+ assertEquals("Argument â{0}â shall not be null.", (testing = english).getString(Errors.Keys.NullArgument_1));
+ assertEquals("Lâargument â{0}â ne doit pas être nul.", (testing = french) .getString(Errors.Keys.NullArgument_1));
+ testing = null;
}
/**
@@ -116,8 +128,9 @@ public final strictfp class IndexedResou
final Errors english = Errors.getResources(Locale.ENGLISH);
final Errors french = Errors.getResources(Locale.FRENCH);
- assertEquals("Argument â{0}â shall not be null.", english.getString("NullArgument_1"));
- assertEquals("Lâargument â{0}â ne doit pas être nul.", french.getString("NullArgument_1"));
+ assertEquals("Argument â{0}â shall not be null.", (testing = english).getString("NullArgument_1"));
+ assertEquals("Lâargument â{0}â ne doit pas être nul.", (testing = french) .getString("NullArgument_1"));
+ testing = null;
}
/**
@@ -126,10 +139,11 @@ public final strictfp class IndexedResou
@Test
@DependsOnMethod("testGetString")
public void testGetStringWithParameter() {
- assertEquals("Argument âCRSâ shall not be null.",
- Errors.getResources(Locale.ENGLISH).getString(Errors.Keys.NullArgument_1, "CRS"));
- assertEquals("Lâargument âCRSâ ne doit pas être nul.",
- Errors.getResources(Locale.FRENCH).getString(Errors.Keys.NullArgument_1, "CRS"));
+ testing = Errors.getResources(Locale.ENGLISH);
+ assertEquals("Argument âCRSâ shall not be null.", testing.getString(Errors.Keys.NullArgument_1, "CRS"));
+ testing = Errors.getResources(Locale.FRENCH);
+ assertEquals("Lâargument âCRSâ ne doit pas être nul.", testing.getString(Errors.Keys.NullArgument_1, "CRS"));
+ testing = null;
}
/**
@@ -153,12 +167,31 @@ public final strictfp class IndexedResou
@Test
@DependsOnMethod("testGetResources")
public void testGetLogRecord() {
- final IndexedResourceBundle resources = Errors.getResources(Locale.ENGLISH);
- final LogRecord record = resources.getLogRecord(Level.FINE, Errors.Keys.NullArgument_1, "CRS");
+ testing = Errors.getResources(Locale.ENGLISH);
+ final LogRecord record = testing.getLogRecord(Level.FINE, Errors.Keys.NullArgument_1, "CRS");
assertEquals("NullArgument_1", record.getMessage());
final SimpleFormatter formatter = new SimpleFormatter();
final String message = formatter.format(record);
assertTrue(message.contains("Argument âCRSâ shall not be null."));
+ testing = null;
+ }
+
+ /**
+ * If a test failed, lists the resource bundle content to the
+ * {@linkplain System#err standard error stream}.
+ *
+ * @throws IOException Should never happen.
+ */
+ @After
+ public void dumpResourcesOnError() throws IOException {
+ if (testing != null) {
+ final PrintStream err = System.err;
+ err.print("Error while testing ");
+ err.print(testing);
+ err.println(". Bundle content is:");
+ testing.list(err);
+ err.flush();
+ }
}
}