Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/CoordinateFormatTest.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/CoordinateFormatTest.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/CoordinateFormatTest.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/CoordinateFormatTest.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -21,6 +21,7 @@ import java.util.Locale; import java.util.TimeZone; import java.text.ParsePosition; import java.text.ParseException; +import java.io.IOException; import org.opengis.geometry.DirectPosition; import org.apache.sis.measure.Angle; import org.apache.sis.referencing.crs.HardCodedCRS; @@ -36,6 +37,8 @@ import static org.junit.Assert.*; * Tests the {@link CoordinateFormat} class. * * @author Martin Desruisseaux (IRD, Geomatys) + * @author Michael Hausegger + * * @version 0.8 * * @see org.apache.sis.measure.AngleFormatTest @@ -63,6 +66,7 @@ public final strictfp class CoordinateFo * Try again with a different separator. */ format.setSeparator("; "); + assertEquals("; ", format.getSeparator()); assertEquals("4.64; 10.25; -3.12", format.format(position)); } @@ -75,30 +79,31 @@ public final strictfp class CoordinateFo @Test public void testParseUnknownCRS() throws ParseException { final CoordinateFormat format = new CoordinateFormat(null, null); - final ParsePosition index = new ParsePosition(0); - DirectPosition position = format.parse("23.78 -12.74 127.9 3.25", index); + final ParsePosition charPos = new ParsePosition(0); + DirectPosition position = format.parse("23.78 -12.74 127.9 3.25", charPos); assertArrayEquals(new double[] {23.78, -12.74, 127.9, 3.25}, position.getCoordinate(), STRICT); - assertEquals("ParsePosition.getErrorIndex()", -1, index.getErrorIndex()); - assertEquals("ParsePosition.getIndex()", 23, index.getIndex()); + assertEquals("ParsePosition.getErrorIndex()", -1, charPos.getErrorIndex()); + assertEquals("ParsePosition.getIndex()", 23, charPos.getIndex()); /* * Try another point having a different number of position * for verifying that no cached values are causing problem. */ - index.setIndex(0); - position = format.parse("4.64 10.25 -3.12", index); + charPos.setIndex(0); + position = format.parse("4.64 10.25 -3.12", charPos); assertArrayEquals(new double[] {4.64, 10.25, -3.12}, position.getCoordinate(), STRICT); - assertEquals("ParsePosition.getErrorIndex()", -1, index.getErrorIndex()); - assertEquals("ParsePosition.getIndex()", 16, index.getIndex()); + assertEquals("ParsePosition.getErrorIndex()", -1, charPos.getErrorIndex()); + assertEquals("ParsePosition.getIndex()", 16, charPos.getIndex()); /* * Try again with a different separator. Also put or remove some spaces * around the separator for testing UnitFormat capabilities to ignore them. */ format.setSeparator("; "); - index.setIndex(0); - position = format.parse("4.64;10.25 ; -3.12", index); + assertEquals("; ", format.getSeparator()); + charPos.setIndex(0); + position = format.parse("4.64;10.25 ; -3.12", charPos); assertArrayEquals(new double[] {4.64, 10.25, -3.12}, position.getCoordinate(), STRICT); - assertEquals("ParsePosition.getErrorIndex()", -1, index.getErrorIndex()); - assertEquals("ParsePosition.getIndex()", 19, index.getIndex()); + assertEquals("ParsePosition.getErrorIndex()", -1, charPos.getErrorIndex()); + assertEquals("ParsePosition.getIndex()", 19, charPos.getIndex()); } /** @@ -150,6 +155,7 @@ public final strictfp class CoordinateFo * Try again with the original CRS, but different separator. */ format.setSeparator("; "); + assertEquals("; ", format.getSeparator()); position.setCoordinateReferenceSystem(HardCodedCRS.GEOID_4D); assertEquals("getPattern(Angle)", anglePattern, format.getPattern(Angle.class)); assertEquals("getPattern(Date)", datePattern, format.getPattern(Date .class)); @@ -168,24 +174,97 @@ public final strictfp class CoordinateFo final CoordinateFormat format = new CoordinateFormat(Locale.FRANCE, TimeZone.getTimeZone("GMT+01:00")); format.applyPattern(Date.class, "dd-MM-yyyy HH:mm"); format.setDefaultCRS(HardCodedCRS.GEOID_4D); - final ParsePosition index = new ParsePosition(11); - final DirectPosition pos = format.parse("(to skip); 23°46,8′E 12°44,4′S 127,9 m 22-09-2006 07:00 (ignore)", index); + final ParsePosition charPos = new ParsePosition(11); + final DirectPosition pos = format.parse("(to skip); 23°46,8′E 12°44,4′S 127,9 m 22-09-2006 07:00 (ignore)", charPos); assertArrayEquals(new double[] {23.78, -12.74, 127.90, 54000.25}, pos.getCoordinate(), STRICT); - assertEquals("ParsePosition.getErrorIndex()", -1, index.getErrorIndex()); - assertEquals("ParsePosition.getIndex()", 55, index.getIndex()); + assertEquals("ParsePosition.getErrorIndex()", -1, charPos.getErrorIndex()); + assertEquals("ParsePosition.getIndex()", 55, charPos.getIndex()); /* * Tests error message when parsing the same string but with unknown units of measurement. */ - index.setIndex(11); + charPos.setIndex(11); try { - format.parse("(to skip); 23°46,8′E 12°44,4′S 127,9 Foo 22-09-2006 07:00", index); + format.parse("(to skip); 23°46,8′E 12°44,4′S 127,9 Foo 22-09-2006 07:00", charPos); fail("Should not have parsed a coordinate with unknown units."); } catch (ParseException e) { - assertEquals("ParsePosition.getIndex()", 11, index.getIndex()); - assertEquals("ParsePosition.getErrorIndex()", 37, index.getErrorIndex()); + assertEquals("ParsePosition.getIndex()", 11, charPos.getIndex()); + assertEquals("ParsePosition.getErrorIndex()", 37, charPos.getErrorIndex()); assertEquals("ParseException.getErrorOffset()", 37, e.getErrorOffset()); assertEquals("Les caractères « Foo » après « 23°46,8′E 12°44,4′S 127,9 » sont inattendus.", e.getLocalizedMessage()); // In the language specified at CoordinateFormat construction time. } } + + /** + * Tests formatting a coordinate in default locale, then parsing the result. This test verifies that the + * parsing is consistent with formatting in whatever locale used by the platform. This test does not verify + * if the formatted string is equal to any expected value since it is locale-dependent. + * + * @throws IOException should never happen since we format into a {@link StringBuffer}. + * @throws ParseException if {@code CoordinateFormat} fails to parse the value that it formatted. + */ + @Test + public void testParseInDefaultLocale() throws IOException, ParseException { + CoordinateFormat format = new CoordinateFormat(); + StringBuffer buffer = new StringBuffer(); + format.format(new DirectPosition2D(-3, 4), buffer); + + ParsePosition charPos = new ParsePosition(0); + DirectPosition position = format.parse(buffer, charPos); + assertEquals("Should have parsed the whole text.", buffer.length(), charPos.getIndex()); + assertEquals("DirectPosition.getDimension()", 2, position.getDimension()); + assertArrayEquals(new double[] {-3, 4}, position.getCoordinate(), STRICT); + } + + /** + * Tests parsing from a position different then the beginning of the string. + * + * @throws ParseException if the parsing failed. + */ + @Test + public void testParseFromOffset() throws ParseException { + CoordinateFormat coordinateFormat = new CoordinateFormat(Locale.CANADA, null); + coordinateFormat.setDefaultCRS(VerticalCRSMock.BAROMETRIC_HEIGHT); + ParsePosition charPos = new ParsePosition(7); + DirectPosition position = coordinateFormat.parse("[skip] 12", charPos); + assertEquals("Should have parsed the whole text.", 9, charPos.getIndex()); + assertEquals("DirectPosition.getDimension()", 1, position.getDimension()); + assertArrayEquals(new double[] {12}, position.getCoordinate(), STRICT); + } + + /** + * Verifies the pattern returned by {@link CoordinateFormat#getPattern(Class)}. This includes verifying that + * the method returns {@code null} when invoked for an unknown type, or a type that does not support pattern. + */ + @Test + public void testGetPattern() { + CoordinateFormat coordinateFormat = new CoordinateFormat(Locale.UK, null); + assertEquals("#,##0.###", coordinateFormat.getPattern(Byte.class)); + assertNull(coordinateFormat.getPattern(Object.class)); + assertNull(coordinateFormat.getPattern(Class.class)); + } + + /** + * Verifies that {@link CoordinateFormat#applyPattern(Class, String)} when + * invoked for an unknown type, or for a type that does not support patterns. + */ + @Test + public void testApplyPattern() { + CoordinateFormat format = new CoordinateFormat(); + assertFalse(format.applyPattern(Object.class, "A dummy pattern")); + assertFalse(format.applyPattern(Class.class, "A dummy pattern")); + } + + /** + * Tests {@link CoordinateFormat#clone()}, then verifies that the clone has the same configuration + * than the original object. + */ + @Test + public void testClone() { + CoordinateFormat format = new CoordinateFormat(Locale.CANADA, null); + CoordinateFormat clone = format.clone(); + assertNotSame("clone()", clone, format); + assertEquals("getSeparator()", format.getSeparator(), clone.getSeparator()); + assertEquals("getDefaultCRS()", format.getDefaultCRS(), clone.getDefaultCRS()); + } }
Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/GeneralEnvelopeTest.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -43,7 +43,7 @@ import static org.apache.sis.geometry.Ab * @since 0.3 * @module */ -@DependsOn(AbstractEnvelopeTest.class) +@DependsOn(ArrayEnvelopeTest.class) public strictfp class GeneralEnvelopeTest extends TestCase { /** * Tolerance threshold for floating point comparisons. Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/ImmutableEnvelopeTest.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/ImmutableEnvelopeTest.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/ImmutableEnvelopeTest.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/geometry/ImmutableEnvelopeTest.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -35,7 +35,7 @@ import static org.apache.sis.geometry.Ab * @since 0.3 * @module */ -@DependsOn(AbstractEnvelopeTest.class) +@DependsOn(ArrayEnvelopeTest.class) public final strictfp class ImmutableEnvelopeTest extends TestCase { /** * Tests {@code ImmutableEnvelope} serialization. Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/CommonAuthorityFactoryTest.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -125,7 +125,7 @@ public final strictfp class CommonAuthor assertTrue (Citations.identifierMatches(authority, "WMS")); assertFalse(Citations.identifierMatches(authority, "OGP")); assertFalse(Citations.identifierMatches(authority, "EPSG")); - assertEquals(Constants.OGC, org.apache.sis.internal.util.Citations.getCodeSpace(authority)); + assertEquals(Constants.OGC, Citations.getCodeSpace(authority)); } /** Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/package.html URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/package.html?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/package.html [UTF-8] (original) +++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/referencing/factory/sql/epsg/package.html [UTF-8] Tue Oct 3 10:55:02 2017 @@ -17,7 +17,7 @@ --> <html> <head> - <title>EPSG dateset update procedure</title> + <title>EPSG dataset update procedure</title> <meta charset="UTF-8"> </head> <body> Modified: sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-referencing/src/test/java/org/apache/sis/test/suite/ReferencingTestSuite.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -31,6 +31,7 @@ import org.junit.BeforeClass; */ @Suite.SuiteClasses({ org.apache.sis.internal.metadata.AxisDirectionsTest.class, + org.apache.sis.internal.referencing.LazySetTest.class, org.apache.sis.internal.referencing.FormulasTest.class, org.apache.sis.internal.referencing.j2d.ShapeUtilitiesTest.class, org.apache.sis.internal.referencing.PositionalAccuracyConstantTest.class, @@ -234,6 +235,7 @@ import org.junit.BeforeClass; org.apache.sis.geometry.DirectPosition1DTest.class, org.apache.sis.geometry.DirectPosition2DTest.class, org.apache.sis.geometry.AbstractEnvelopeTest.class, + org.apache.sis.geometry.ArrayEnvelopeTest.class, org.apache.sis.geometry.GeneralEnvelopeTest.class, org.apache.sis.geometry.SubEnvelopeTest.class, org.apache.sis.geometry.ImmutableEnvelopeTest.class, Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/NameAdapter.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/NameAdapter.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/NameAdapter.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/NameAdapter.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -23,7 +23,6 @@ import org.opengis.util.LocalName; import org.opengis.util.ScopedName; import org.opengis.util.MemberName; import org.opengis.util.GenericName; -import org.apache.sis.internal.jaxb.gml.CodeType; import org.apache.sis.util.iso.DefaultLocalName; import org.apache.sis.util.iso.DefaultTypeName; import org.apache.sis.util.iso.DefaultMemberName; @@ -45,7 +44,7 @@ import org.apache.sis.util.resources.Err * @author Cédric Briançon (Geomatys) * @author Martin Desruisseaux (Geomatys) * @author Guilhem Legal (Geomatys) - * @version 0.5 + * @version 0.8 * @since 0.3 * @module */ @@ -76,22 +75,29 @@ abstract class NameAdapter<ValueType ext /** * Returns the {@code LocalName} or {@code ScopedName} to marshall. Returns {@code null} if the name - * is a {@link TypeName} or a {@link MemberName}, in order to use {@link #getNameType()} instead. + * is a {@link TypeName} or a {@link MemberName}, in order to use {@link #getName()} instead. + * Example: + * + * {@preformat xml + * <gml:alias> + * <gco:LocalName codeSpace=\"A code space\">A name in a scope</gco:LocalName> + * </gml:alias> + * } * * @return the code for the current name, or {@code null} if none. */ @XmlElementRef - public final CodeType getCodeType() { + public final NameValue getValue() { final GenericName name = this.name; - final CodeType code; + final NameValue code; if (name instanceof LocalName) { if (name instanceof TypeName || name instanceof MemberName) { return null; } else { - code = new CodeType.LocalName(); + code = new NameValue.Local(); } } else if (name instanceof ScopedName) { - code = new CodeType.ScopedName(); + code = new NameValue.Scoped(); } else { return null; } @@ -100,27 +106,24 @@ abstract class NameAdapter<ValueType ext } /** - * Sets the value for the {@code LocalName} or {@code ScopedName}. - * This method is called at unmarshalling-time by JAXB. - * - * @param code the new name. - * @throws IllegalStateException if a name is already defined. - */ - public final void setCodeType(final CodeType code) throws IllegalStateException { - ensureUndefined(); - if (code != null) { - name = code.getName(); - } - } - - /** * Returns the {@code TypeName} or {@code MemberName} to marshall. Returns {@code null} if the name - * is a {@link LocalName} or {@link ScopedName}, in order to use {@link #getCodeType()} instead. + * is a {@link LocalName} or {@link ScopedName}, in order to use {@link #getValue()} instead. + * Example: + * + * {@preformat xml + * <gml:alias> + * <gco:TypeName> + * <gco:aName> + * <gco:CharacterString>An other local name</gco:CharacterString> + * </gco:aName> + * </gco:TypeName> + * </gml:alias> + * } * * @return the current name, or {@code null} if none. */ @XmlElementRef - public final DefaultLocalName getNameType() { + public final DefaultLocalName getName() { final GenericName name = this.name; if (name instanceof TypeName) { return DefaultTypeName.castOrCopy((TypeName) name); @@ -132,13 +135,27 @@ abstract class NameAdapter<ValueType ext } /** + * Sets the value for the {@code LocalName} or {@code ScopedName}. + * This method is called at unmarshalling-time by JAXB. + * + * @param code the new name. + * @throws IllegalStateException if a name is already defined. + */ + public final void setValue(final NameValue code) throws IllegalStateException { + ensureUndefined(); + if (code != null) { + name = code.getName(); + } + } + + /** * Sets the value from the {@code TypeName} or {@code MemberName}. * This method is called at unmarshalling-time by JAXB. * * @param value the new name. * @throws IllegalStateException if a name is already defined. */ - public final void setNameType(final DefaultLocalName value) throws IllegalStateException { + public final void setName(final DefaultLocalName value) throws IllegalStateException { ensureUndefined(); name = value; } Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/system/DataDirectory.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -17,6 +17,10 @@ package org.apache.sis.internal.system; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.InvalidPathException; import java.util.logging.Level; import java.util.logging.LogRecord; import java.security.AccessController; @@ -24,12 +28,6 @@ import java.security.PrivilegedAction; import org.apache.sis.util.logging.Logging; import org.apache.sis.util.resources.Messages; -// Branch-dependent imports -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.InvalidPathException; - /** * Sub-directories of {@code SIS_DATA} where SIS looks for EPSG database, datum shift grids and other resources. Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/Citations.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -345,7 +345,8 @@ public final class Citations extends Sta * <ul> * <li>For information purpose (e.g. some {@code toString()} methods), use {@code getIdentifier(…, false)}.</li> * <li>For WKT formatting, use {@code getIdentifier(…, true)} in order to preserve formatting characters.</li> - * <li>For assigning a value to a {@code codeSpace} field, use {@link #getUnicodeIdentifier(Citation)}.</li> + * <li>For assigning a value to a {@code codeSpace} field, use + * {@link org.apache.sis.metadata.iso.citation.Citations#getUnicodeIdentifier(Citation)}.</li> * </ul> * * @param citation the citation for which to get the identifier, or {@code null}. @@ -467,6 +468,9 @@ public final class Citations extends Sta * or {@code null} if the given citation is null or does not have any Unicode identifier or title. * * @since 0.6 + * + * @deprecated Implementation will be moved to {@link org.apache.sis.metadata.iso.citation.Citations} + * after we moved the {@code sis-utility} code that use this method. */ public static String getUnicodeIdentifier(final Citation citation) { final String identifier = getIdentifier(citation, true); @@ -529,6 +533,9 @@ public final class Citations extends Sta * or {@code null} if the given citation is null or does not have any Unicode identifier or title. * * @since 0.6 + * + * @deprecated Implementation will be moved to {@link org.apache.sis.metadata.iso.citation.Citations} + * after we moved the {@code sis-utility} code that use this method. */ public static String getCodeSpace(final Citation citation) { if (citation instanceof IdentifierSpace<?>) { Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/collection/RangeSet.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/collection/RangeSet.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/collection/RangeSet.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/collection/RangeSet.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -1133,10 +1133,8 @@ public class RangeSet<E extends Comparab if (object instanceof Range<?>) { @SuppressWarnings("unchecked") // Type will actally be checked on the line after. final Range<E> range = (Range<E>) object; - if (range.getElementType() == elementType) { - if (!subRange.contains(range)) { - return false; - } + if (range.getElementType() == elementType && !subRange.contains(range)) { + return false; } } return RangeSet.this.contains(object); Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/DefaultLocalName.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -91,10 +91,25 @@ public class DefaultLocalName extends Ab * The name, either as a {@link String} or an {@link InternationalString}. * * <div class="section">Note on JAXB annotation</div> - * The {@link XmlElement} annotation applied here is appropriate for subclasses only ({@link DefaultTypeName} - * and {@link DefaultMemberName}). It is <strong>not</strong> appropriate when (un)marshalling directly this - * {@code DefaultLocalName} class. In this later case, we will rather rely on the {@link String} conversion - * performed by {@link org.apache.sis.internal.jaxb.gco.GO_GenericName}. + * The {@link XmlElement} annotation applied here is appropriate for {@code TypeName} and {@code MemberName} + * subtypes only. It is <strong>not</strong> appropriate when (un)marshalling directly a {@code LocalName}. + * The distinction between the two cases is done by {@link org.apache.sis.internal.jaxb.gco.GO_LocalName}, + * which replace the {@code LocalName} instance by an internal {@code NameValue} object (so the XML element + * declared here is never marshalled). Example: + * + * {@preformat xml + * <gco:LocalName codeSpace=\"A code space\">A name in a scope</gco:LocalName> + * } + * + * versus + * + * {@preformat xml + * <gco:TypeName> + * <gco:aName> + * <gco:CharacterString>An other local name</gco:CharacterString> + * </gco:aName> + * </gco:TypeName> + * } */ @XmlJavaTypeAdapter(CharSequenceAdapter.class) @XmlElement(name = "aName", namespace = Namespaces.GCO) Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/TypeNames.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -67,7 +67,7 @@ final class TypeNames { m.put("Real", Double.class); m.put("Decimal", Double.class); m.put("Integer", Integer.class); - }; + } /** * The "OGC" namespace. Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/package-info.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/package-info.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/package-info.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/iso/package-info.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -128,4 +128,4 @@ import javax.xml.bind.annotation.XmlAcce import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters; import org.apache.sis.xml.Namespaces; -import org.apache.sis.internal.jaxb.gco.*; +import org.apache.sis.internal.jaxb.gco.GO_GenericName; Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -399,11 +399,9 @@ abstract class Pooled { if (internal) { name = Implementation.toInternal(name); } - if (!initialProperties.containsKey(name)) { - if (initialProperties.put(name, getStandardProperty(name)) != null) { - // Should never happen, unless on concurrent changes in a backgroung thread. - throw new ConcurrentModificationException(name); - } + if (!initialProperties.containsKey(name) && initialProperties.put(name, getStandardProperty(name)) != null) { + // Should never happen, unless on concurrent changes in a backgroung thread. + throw new ConcurrentModificationException(name); } setStandardProperty(name, value); } Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationsTest.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationsTest.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationsTest.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/util/CitationsTest.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -23,8 +23,6 @@ import org.opengis.metadata.Identifier; import org.opengis.metadata.citation.Citation; import org.apache.sis.internal.simple.SimpleCitation; import org.apache.sis.internal.simple.SimpleIdentifier; -import org.apache.sis.xml.IdentifierSpace; -import org.apache.sis.test.DependsOnMethod; import org.apache.sis.test.TestCase; import org.junit.Test; @@ -114,40 +112,4 @@ public final strictfp class CitationsTes assertEquals("OGC:06-042", Citations.getIdentifier(citation, false)); assertEquals("ISO_19128", Citations.getIdentifier(citation, true)); } - - /** - * Tests {@link Citations#getCodeSpace(Citation)} with some ignorable characters. - * Ignorable character used in this test are: - * - * <ul> - * <li>200B: zero width space</li> - * <li>2060: word joiner</li> - * </ul> - */ - @Test - @DependsOnMethod("testGetIdentifier") - public void testGetCodeSpace() { - final SimpleCitation citation = new SimpleCitation(" Valid\u2060Id\u200Bentifier "); - assertEquals("ValidIdentifier", Citations.getCodeSpace(citation)); - - assertNull("Shall not be taken as a valid identifier.", - Citations.getCodeSpace(new SimpleCitation("Proj.4"))); - assertEquals("Shall fallback on the the identifier space name.", - "TheProj4Space", Citations.getCodeSpace(new Proj4())); - } - - /** - * A citation which is also an {@link IdentifierSpace}, for {@link #testGetCodeSpace()} purpose. - */ - @SuppressWarnings("serial") - private static final class Proj4 extends SimpleCitation implements IdentifierSpace<Integer> { - Proj4() { - super("Proj.4"); - } - - @Override - public String getName() { - return "TheProj4Space"; // Intentionally a very different name than "Proj4". - } - } } Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/Assume.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/Assume.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/Assume.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/Assume.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -16,11 +16,9 @@ */ package org.apache.sis.test; -import org.apache.sis.internal.system.DataDirectory; - -// Branch-specific imports import java.nio.file.Path; import java.nio.file.Files; +import org.apache.sis.internal.system.DataDirectory; /** Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/test/suite/UtilityTestSuite.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -83,7 +83,6 @@ import org.junit.BeforeClass; org.apache.sis.util.collection.CodeListSetTest.class, org.apache.sis.internal.util.CollectionsExtTest.class, org.apache.sis.internal.util.AbstractMapTest.class, - org.apache.sis.internal.util.LazySetTest.class, // GeoAPI most basic types. org.apache.sis.internal.util.DefinitionURITest.class, Modified: sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties URL: http://svn.apache.org/viewvc/sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties [ISO-8859-1] (original) +++ sis/branches/JDK7/ide-project/NetBeans/nbproject/project.properties [ISO-8859-1] Tue Oct 3 10:55:02 2017 @@ -95,24 +95,24 @@ project.GeoAPI = ../../../../GeoAP # jsr363.version = 1.0 jama.version = 1.0.3 -geometry.version = 1.2.1 +geometry.version = 2.0.0 georss.version = 0.9.8 rome.version = 0.9 jdom1.version = 1.0 jdom2.version = 2.0.4 jee.version = 7.0 osgi.version = 6.0.0 -netcdf.version = 4.6.9 +netcdf.version = 4.6.10 joda-time.version = 2.8.1 httpclient.version = 4.5.1 httpcore.version = 4.4.4 cm-logging.version = 1.2 -slf4j.version = 1.7.7 +slf4j.version = 1.7.22 junit.version = 4.12 hamcrest.version = 1.3 jaxb-ns-mapper = 2.2.4 hsqldb.version = 2.3.5 -postgresql.version = 42.1.1.jre7 +postgresql.version = 42.1.4.jre7 icons.version = 3.0.1 # Modified: sis/branches/JDK7/pom.xml URL: http://svn.apache.org/viewvc/sis/branches/JDK7/pom.xml?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/pom.xml (original) +++ sis/branches/JDK7/pom.xml Tue Oct 3 10:55:02 2017 @@ -87,25 +87,25 @@ Apache SIS is a free software, Java lang <mailingLists> <mailingList> + <name>User mailing list</name> + <subscribe>user-subscr...@sis.apache.org</subscribe> + <unsubscribe>user-unsubscr...@sis.apache.org</unsubscribe> + <post>u...@sis.apache.org</post> + <archive>https://lists.apache.org/list.html?u...@sis.apache.org</archive> + </mailingList> + <mailingList> <name>Development mailing list</name> <subscribe>dev-subscr...@sis.apache.org</subscribe> <unsubscribe>dev-unsubscr...@sis.apache.org</unsubscribe> <post>d...@sis.apache.org</post> - <archive>http://mail-archives.apache.org/mod_mbox/sis-dev/</archive> + <archive>https://lists.apache.org/list.html?d...@sis.apache.org</archive> </mailingList> <mailingList> <name>Commit mailing list</name> <subscribe>commits-subscr...@sis.apache.org</subscribe> <unsubscribe>commits-unsubscr...@sis.apache.org</unsubscribe> <post>commits@sis.apache.org</post> - <archive>http://mail-archives.apache.org/mod_mbox/sis-commits/</archive> - </mailingList> - <mailingList> - <name>User mailing list</name> - <subscribe>user-subscr...@sis.apache.org</subscribe> - <unsubscribe>user-unsubscr...@sis.apache.org</unsubscribe> - <post>u...@sis.apache.org</post> - <archive>http://mail-archives.apache.org/mod_mbox/sis-user/</archive> + <archive>https://lists.apache.org/list.html?commits@sis.apache.org</archive> </mailingList> </mailingLists> @@ -408,7 +408,7 @@ Apache SIS is a free software, Java lang <dependency> <groupId>com.esri.geometry</groupId> <artifactId>esri-geometry-api</artifactId> - <version>1.2.1</version> + <version>2.0.0</version> <optional>true</optional> </dependency> <dependency> @@ -439,7 +439,7 @@ Apache SIS is a free software, Java lang <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> - <version>42.1.1.jre7</version> + <version>42.1.4.jre7</version> <scope>test</scope> </dependency> @@ -459,7 +459,7 @@ Apache SIS is a free software, Java lang <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-jdk14</artifactId> - <version>1.7.7</version> <!-- Must matches the version used by netCDF. --> + <version>1.7.22</version> <!-- Must matches the version used by netCDF. --> <scope>runtime</scope> <!-- Should never be needed at compile time. --> </dependency> </dependencies> @@ -485,7 +485,7 @@ Apache SIS is a free software, Java lang The last properties in this list depend on the Apache SIS branch. =================================================================== --> <properties> - <netcdf.version>4.6.9</netcdf.version> + <netcdf.version>4.6.10</netcdf.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <website.encoding>UTF-8</website.encoding> <website.locale>en</website.locale> @@ -591,7 +591,7 @@ Apache SIS is a free software, Java lang <!-- Compile --> <plugin> <artifactId>maven-compiler-plugin</artifactId> - <version>3.6.2</version> + <version>3.7.0</version> <configuration> <source>${maven.compile.source}</source> <target>${maven.compile.target}</target> @@ -607,7 +607,7 @@ Apache SIS is a free software, Java lang <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> - <version>2.20</version> + <version>2.20.1</version> <configuration> <includes> <include>**/*TestSuite.java</include> @@ -897,7 +897,7 @@ Apache SIS is a free software, Java lang <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>findbugs-maven-plugin</artifactId> - <version>3.0.4</version> + <version>3.0.5</version> <dependencies> <dependency> <groupId>org.apache.sis.core</groupId> Modified: sis/branches/JDK7/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Proj4Factory.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Proj4Factory.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Proj4Factory.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-gdal/src/main/java/org/apache/sis/storage/gdal/Proj4Factory.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -52,7 +52,7 @@ import org.apache.sis.internal.metadata. import org.apache.sis.internal.system.DefaultFactories; import org.apache.sis.internal.system.Modules; import org.apache.sis.internal.util.CollectionsExt; -import org.apache.sis.internal.util.LazySet; +import org.apache.sis.internal.referencing.LazySet; import org.apache.sis.util.iso.SimpleInternationalString; import org.apache.sis.util.collection.WeakValueHashMap; import org.apache.sis.util.resources.Vocabulary; Modified: sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/ChannelDecoder.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -556,7 +556,7 @@ public final class ChannelDecoder extend * Following block is almost a copy-and-paste of similar block in the contructor, * but with less cases in the "switch" statements. */ - Map<String,Object> attributes = null; + Map<String,Object> attributes = Collections.emptyMap(); final long tn = input.readLong(); if (tn != 0) { final int tag = (int) (tn >>> Integer.SIZE); Modified: sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/VariableInfo.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/VariableInfo.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/VariableInfo.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/internal/netcdf/impl/VariableInfo.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -196,12 +196,16 @@ final class VariableInfo extends Variabl * Verify if this variable is an enumeration. If yes, we remove the attributes that define the * enumeration since those attributes may be verbose and "pollute" the variable definition. */ - String[] meanings = stringValues(attributes.remove(AttributeNames.FLAG_MEANINGS)); - switch (meanings.length) { - case 0: meanings = null; break; - case 1: meanings = (String[]) CharSequences.split(meanings[0], ' '); break; + if (!attributes.isEmpty()) { // For avoiding UnsupportedOperationException if unmodifiable map. + String[] meanings = stringValues(attributes.remove(AttributeNames.FLAG_MEANINGS)); + switch (meanings.length) { + case 0: meanings = null; break; + case 1: meanings = (String[]) CharSequences.split(meanings[0], ' '); break; + } + this.meanings = meanings; + } else { + meanings = null; } - this.meanings = meanings; } /** Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -45,6 +45,7 @@ import org.apache.sis.internal.referenci import org.apache.sis.internal.util.UnmodifiableArrayList; import org.apache.sis.internal.storage.MetadataBuilder; import org.apache.sis.internal.storage.io.IOUtilities; +import org.apache.sis.internal.storage.io.RewindableLineReader; import org.apache.sis.internal.feature.Geometries; import org.apache.sis.internal.feature.MovingFeature; import org.apache.sis.internal.storage.Resources; @@ -63,6 +64,7 @@ import org.apache.sis.setup.OptionKey; import org.apache.sis.util.ArraysExt; import org.apache.sis.util.CharSequences; import org.apache.sis.util.resources.Errors; +import org.apache.sis.io.InvalidSeekException; import org.apache.sis.measure.Units; // Branch-dependent imports @@ -237,7 +239,7 @@ final class Store extends URIDataStore i throw new UnsupportedStorageException(super.getLocale(), StoreProvider.NAME, connector.getStorage(), connector.getOption(OptionKey.OPEN_OPTIONS)); } - source = (r instanceof BufferedReader) ? (BufferedReader) r : new LineNumberReader(r); + source = (r instanceof BufferedReader) ? (BufferedReader) r : new LineNumberReader(r); geometries = Geometries.implementation(connector.getOption(OptionKey.GEOMETRY_LIBRARY)); dissociate = immediate; GeneralEnvelope envelope = null; @@ -245,7 +247,7 @@ final class Store extends URIDataStore i Foliation foliation = null; try { final List<String> elements = new ArrayList<>(); - source.mark(1024); + source.mark(RewindableLineReader.BUFFER_SIZE); String line; while ((line = source.readLine()) != null) { line = line.trim(); @@ -291,9 +293,9 @@ final class Store extends URIDataStore i } } elements.clear(); - source.mark(1024); + source.mark(RewindableLineReader.BUFFER_SIZE); } - source.reset(); + source.reset(); // Restore position to the first line after the header. } catch (IOException e) { throw new DataStoreException(getLocale(), StoreProvider.NAME, super.getDisplayName(), source).initCause(e); } catch (FactoryException e) { @@ -309,6 +311,33 @@ final class Store extends URIDataStore i } /** + * Moves the reader position to beginning of file, if possible. We try to use the mark defined by the constructor, + * which is set after the last header line. If the mark is no longer valid, then we have to create a new line reader. + * In this later case, we have to skip the header lines (i.e. we reproduce the constructor loop, but without parsing + * metadata). + */ + private void rewind() throws IOException { + final BufferedReader reader = source; + if (!(reader instanceof RewindableLineReader)) { + throw new InvalidSeekException(Resources.forLocale(getLocale()) + .getString(Resources.Keys.StreamIsForwardOnly_1, getDisplayName())); + } + source = ((RewindableLineReader) reader).rewind(); + if (source != reader) { + String line; + while ((line = source.readLine()) != null) { + line = line.trim(); + if (!line.isEmpty()) { + final char c = line.charAt(0); + if (c != COMMENT && c != METADATA) break; + } + source.mark(RewindableLineReader.BUFFER_SIZE); + } + source.reset(); // Restore position to the first line after the header. + } + } + + /** * Parses the envelope described by the header line starting with {@code @stboundedby}. * The envelope returned by this method will be stored in the {@link #envelope} field. * @@ -656,7 +685,7 @@ final class Store extends URIDataStore i * @return a stream over all features in the CSV file. * @throws DataStoreException if an error occurred while creating the feature stream. * - * @todo Needs to reset the position when doing another pass on the features. + * @todo Need to reset the position when doing another pass on the features. See {@link #rewind()}. * @todo If sequential order, publish Feature as soon as identifier changed. */ @Override Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelFactory.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelFactory.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelFactory.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/ChannelFactory.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -57,14 +57,14 @@ import org.apache.sis.storage.ForwardOnl * Opens a readable channel for a given input object (URL, input stream, <i>etc</i>). * The {@link #prepare prepare(…)} method analyzes the given input {@link Object} and tries to return a factory instance * capable to open at least one {@link ReadableByteChannel} for that input. For some kinds of input like {@link Path} or - * {@link URL}, the {@link #reader reader(…)} method can be invoked an arbitrary amount of times for creating as many + * {@link URL}, the {@link #readable readable(…)} method can be invoked an arbitrary amount of times for creating as many * channels as needed. But for other kinds of input like {@link InputStream}, only one channel can be returned. - * In such case, only the first {@link #reader reader(…)} method invocation will succeed and all subsequent ones + * In such case, only the first {@link #readable readable(…)} method invocation will succeed and all subsequent ones * will throw an exception. * * <div class="section">Multi-threading</div> * This class is not thread-safe, except for the static {@link #prepare prepare(…)} method. - * Callers are responsible for synchronizing their call to any member methods ({@link #reader reader(…)}, <i>etc</i>). + * Callers are responsible for synchronizing their call to any member methods ({@link #readable readable(…)}, <i>etc</i>). * * @author Martin Desruisseaux (Geomatys) * @author Johann Sorel (Geomatys) @@ -230,10 +230,10 @@ public abstract class ChannelFactory { if (storage instanceof URL) { final URL file = (URL) storage; return new ChannelFactory() { - @Override public ReadableByteChannel reader(String filename, WarningListeners<DataStore> listeners) throws IOException { + @Override public ReadableByteChannel readable(String filename, WarningListeners<DataStore> listeners) throws IOException { return Channels.newChannel(file.openStream()); } - @Override public WritableByteChannel writer(String filename, WarningListeners<DataStore> listeners) throws IOException { + @Override public WritableByteChannel writable(String filename, WarningListeners<DataStore> listeners) throws IOException { return Channels.newChannel(file.openConnection().getOutputStream()); } }; @@ -242,10 +242,10 @@ public abstract class ChannelFactory { final Path path = (Path) storage; if (Files.isRegularFile(path)) { return new ChannelFactory() { - @Override public ReadableByteChannel reader(String filename, WarningListeners<DataStore> listeners) throws IOException { + @Override public ReadableByteChannel readable(String filename, WarningListeners<DataStore> listeners) throws IOException { return Files.newByteChannel(path, optionSet); } - @Override public WritableByteChannel writer(String filename, WarningListeners<DataStore> listeners) throws IOException { + @Override public WritableByteChannel writable(String filename, WarningListeners<DataStore> listeners) throws IOException { return Files.newByteChannel(path, optionSet); } }; @@ -267,10 +267,11 @@ public abstract class ChannelFactory { } /** - * Returns {@code true} if this factory is capable to create another reader. This method returns {@code false} - * if this factory is capable to create only one channel and {@link #reader reader(…)} has already been invoked. + * Returns {@code true} if this factory is capable to create another readable byte channel. + * This method returns {@code false} if this factory is capable to create only one channel + * and {@link #readable readable(…)} has already been invoked. * - * @return whether {@link #reader reader(…)} or {@link #writer writer(…)} can be invoked. + * @return whether {@link #readable readable(…)} or {@link #writable writable(…)} can be invoked. */ public boolean canOpen() { return true; @@ -289,7 +290,7 @@ public abstract class ChannelFactory { public InputStream inputStream(String filename, WarningListeners<DataStore> listeners) throws DataStoreException, IOException { - return Channels.newInputStream(reader(filename, listeners)); + return Channels.newInputStream(readable(filename, listeners)); } /** @@ -305,7 +306,7 @@ public abstract class ChannelFactory { public OutputStream outputStream(String filename, WarningListeners<DataStore> listeners) throws DataStoreException, IOException { - return Channels.newOutputStream(writer(filename, listeners)); + return Channels.newOutputStream(writable(filename, listeners)); } /** @@ -319,7 +320,7 @@ public abstract class ChannelFactory { * @throws DataStoreException if the channel is read-once. * @throws IOException if an error occurred while opening the channel. */ - public abstract ReadableByteChannel reader(String filename, WarningListeners<DataStore> listeners) + public abstract ReadableByteChannel readable(String filename, WarningListeners<DataStore> listeners) throws DataStoreException, IOException; /** @@ -333,7 +334,7 @@ public abstract class ChannelFactory { * @throws DataStoreException if the channel is write-once. * @throws IOException if an error occurred while opening the channel. */ - public abstract WritableByteChannel writer(String filename, WarningListeners<DataStore> listeners) + public abstract WritableByteChannel writable(String filename, WarningListeners<DataStore> listeners) throws DataStoreException, IOException; /** @@ -362,7 +363,7 @@ public abstract class ChannelFactory { } /** - * Returns whether {@link #reader reader(…)} or {@link #writer writer(…)} can be invoked. + * Returns whether {@link #readable readable(…)} or {@link #writable writable(…)} can be invoked. */ @Override public boolean canOpen() { @@ -374,7 +375,7 @@ public abstract class ChannelFactory { * throws an exception on all subsequent invocations. */ @Override - public ReadableByteChannel reader(final String filename, final WarningListeners<DataStore> listeners) + public ReadableByteChannel readable(final String filename, final WarningListeners<DataStore> listeners) throws DataStoreException, IOException { final Channel in = channel; @@ -396,7 +397,7 @@ public abstract class ChannelFactory { * throws an exception on all subsequent invocations. */ @Override - public WritableByteChannel writer(final String filename, final WarningListeners<DataStore> listeners) + public WritableByteChannel writable(final String filename, final WarningListeners<DataStore> listeners) throws DataStoreException, IOException { final Channel out = channel; @@ -520,7 +521,7 @@ public abstract class ChannelFactory { * Opens a new channel for the file given at construction time. */ @Override - public ReadableByteChannel reader(String filename, WarningListeners<DataStore> listeners) throws IOException { + public ReadableByteChannel readable(String filename, WarningListeners<DataStore> listeners) throws IOException { return inputStream(filename, listeners).getChannel(); } @@ -528,7 +529,7 @@ public abstract class ChannelFactory { * Opens a new channel for the file given at construction time. */ @Override - public WritableByteChannel writer(String filename, WarningListeners<DataStore> listeners) throws IOException { + public WritableByteChannel writable(String filename, WarningListeners<DataStore> listeners) throws IOException { return outputStream(filename, listeners).getChannel(); } } Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/InputStreamAdapter.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/InputStreamAdapter.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/InputStreamAdapter.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/InputStreamAdapter.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -27,6 +27,14 @@ import org.apache.sis.internal.jdk8.Unch /** * Wraps an {@link ImageInputStream} as a standard {@link InputStream}. * + * <div class="section">Thread-safety</div> + * This class is thread-safe only if the underlying {@link ImageInputStream} is itself thread-safe. + * For performance reasons, this class does not synchronize the frequently invoked {@code read(…)} + * methods since they do nothing else than delegating to {@code ImageInputStream}. This means that + * if the wrapped input is {@link ChannelImageInputStream}, then this class is <strong>not</strong> + * thread-safe. This is not necessarily a contradiction with Java API since input streams define no + * explicit synchronization lock (contrarily to {@link java.io.Reader}. + * * @author Martin Desruisseaux (IRD, Geomatys) * @version 0.8 * @@ -56,6 +64,13 @@ public final class InputStreamAdapter ex private int nestedMarks; /** + * Temporarily set to {@code true} if a call to {@link #close()} should not be propagated to the {@link #input}. + * + * @see RewindableLineReader#rewind() + */ + boolean keepOpen; + + /** * Constructs a new input stream. * * @param input the stream to wrap. @@ -130,7 +145,7 @@ public final class InputStreamAdapter ex * @throws UncheckedIOException if the mark can not be set. */ @Override - public void mark(final int readlimit) { + public synchronized void mark(final int readlimit) { try { markPosition = input.getStreamPosition(); input.flushBefore(markPosition); @@ -146,7 +161,7 @@ public final class InputStreamAdapter ex * It is okay to invoke this method after {@link #mark(int)} (but not before). */ @Override - public void mark() { + public synchronized void mark() { input.mark(); nestedMarks++; } @@ -170,7 +185,7 @@ public final class InputStreamAdapter ex * @throws IOException if an I/O error occurs. */ @Override - public void reset() throws IOException { + public synchronized void reset() throws IOException { if (--nestedMarks >= 0) { input.reset(); } else { @@ -195,7 +210,7 @@ public final class InputStreamAdapter ex * @throws IOException if an I/O error occurs. */ @Override - public void close() throws IOException { - input.close(); + public synchronized void close() throws IOException { + if (!keepOpen) input.close(); } } Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/Markable.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/Markable.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/Markable.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/io/Markable.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -36,7 +36,10 @@ import java.io.IOException; * * @author Martin Desruisseaux (Geomatys) * @version 0.8 - * @since 0.8 + * + * @see Readable + * + * @since 0.8 * @module */ public interface Markable { Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreRegistry.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreRegistry.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreRegistry.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStoreRegistry.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -23,7 +23,7 @@ import java.util.Iterator; import java.util.ServiceLoader; import org.apache.sis.internal.storage.Resources; import org.apache.sis.internal.system.DefaultFactories; -import org.apache.sis.internal.util.LazySet; +import org.apache.sis.internal.referencing.LazySet; import org.apache.sis.util.ArgumentChecks; Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/StorageConnector.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -29,7 +29,6 @@ import java.io.InputStreamReader; import java.io.BufferedInputStream; import java.io.Serializable; import java.nio.ByteBuffer; -import java.nio.charset.Charset; import java.nio.channels.Channel; import java.nio.channels.ReadableByteChannel; import java.nio.channels.SeekableByteChannel; @@ -54,6 +53,7 @@ import org.apache.sis.internal.storage.i import org.apache.sis.internal.storage.io.ChannelDataInput; import org.apache.sis.internal.storage.io.ChannelImageInputStream; import org.apache.sis.internal.storage.io.InputStreamAdapter; +import org.apache.sis.internal.storage.io.RewindableLineReader; import org.apache.sis.internal.system.Modules; import org.apache.sis.internal.util.Utilities; import org.apache.sis.io.InvalidSeekException; @@ -101,6 +101,11 @@ public class StorageConnector implements /** * The default size of the {@link ByteBuffer} to be created. * Users can override this value by providing a value for {@link OptionKey#BYTE_BUFFER}. + * Note that it usually don't need to be very large, since {@link RewindableLineReader} + * will have its own buffer (which may be larger) and {@link ChannelDataInput} methods + * writing in existing destination arrays will bypass the buffer. + * + * @see RewindableLineReader#BUFFER_SIZE */ static final int DEFAULT_BUFFER_SIZE = 4096; @@ -923,7 +928,7 @@ public class StorageConnector implements * (potentially an InputStream). We need to remember this chain in 'Coupled' objects. */ final String name = getStorageName(); - final ReadableByteChannel channel = factory.reader(name, null); + final ReadableByteChannel channel = factory.readable(name, null); addView(ReadableByteChannel.class, channel, null, factory.isCoupled() ? CASCADE_ON_RESET : 0); ByteBuffer buffer = getOption(OptionKey.BYTE_BUFFER); // User-supplied buffer. if (buffer == null) { @@ -1153,10 +1158,7 @@ public class StorageConnector implements return null; } input.mark(DEFAULT_BUFFER_SIZE); - final Charset encoding = getOption(OptionKey.ENCODING); - Reader in = (encoding != null) ? new InputStreamReader(input, encoding) - : new InputStreamReader(input); - in = new LineNumberReader(in); + final Reader in = new RewindableLineReader(input, getOption(OptionKey.ENCODING)); addView(Reader.class, in, InputStream.class, (byte) (CLEAR_ON_RESET | CASCADE_ON_RESET)); return in; } Modified: sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/test/suite/StorageTestSuite.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -37,6 +37,7 @@ import org.junit.BeforeClass; org.apache.sis.internal.storage.io.ChannelImageInputStreamTest.class, org.apache.sis.internal.storage.io.ChannelImageOutputStreamTest.class, org.apache.sis.internal.storage.io.HyperRectangleReaderTest.class, + org.apache.sis.internal.storage.io.RewindableLineReaderTest.class, org.apache.sis.internal.storage.MetadataBuilderTest.class, org.apache.sis.storage.FeatureNamingTest.class, org.apache.sis.storage.ProbeResultTest.class, Modified: sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Person.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Person.java?rev=1810976&r1=1810975&r2=1810976&view=diff ============================================================================== --- sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Person.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Person.java [UTF-8] Tue Oct 3 10:55:02 2017 @@ -403,7 +403,7 @@ public final class Person implements Res /** * Returns a string representation of this person statement. - * The statement is formatted in a way similar to the email address in client softwares. + * The statement is formatted in a way similar to the email address in client software applications. * Example: * * <blockquote>