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 2015/05/15 21:31:53 UTC
svn commit: r1679633 [5/5] - in /sis/branches/JDK6: ./
application/sis-console/src/main/java/org/apache/sis/console/
application/sis-console/src/test/java/org/apache/sis/console/
core/sis-feature/src/main/java/org/apache/sis/feature/ core/sis-metadata/...
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties?rev=1679633&r1=1679632&r2=1679633&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties [ISO-8859-1] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/util/resources/Errors_fr.properties [ISO-8859-1] Fri May 15 19:31:51 2015
@@ -79,6 +79,7 @@ IllegalRange_2 = La p
IllegalUnicodeCodePoint_2 = La valeur {1} de \u00ab\u202f{0}\u202f\u00bb n\u2019est pas un code Unicode valide.
IllegalUnitFor_2 = L\u2019unit\u00e9 de mesure \u00ab\u202f{1}\u202f\u00bb n\u2019est pas valide pour les valeurs de \u00ab\u202f{0}\u202f\u00bb.
IncompatibleCoordinateSystemTypes = Types de syst\u00e8mes de coordonn\u00e9es incompatibles.
+IncompatibleDatum_2 = Le r\u00e9f\u00e9rentiel de \u00ab\u202f{1}\u202f\u00bb doit \u00eatre \u00ab\u202f{0}\u202f\u00bb.
IncompatiblePropertyValue_1 = La valeur de la propri\u00e9t\u00e9 \u00ab\u202f{0}\u202f\u00bb n\u2019est pas compatible.
IncompatibleUnit_1 = L\u2019unit\u00e9 \u00ab\u202f{0}\u202f\u00bb n\u2019est pas compatible avec la valeur actuelle.
IncompatibleUnits_2 = Les unit\u00e9s \u00ab\u202f{0}\u202f\u00bb et \u00ab\u202f{1}\u202f\u00bb ne sont pas compatibles.
@@ -189,6 +190,7 @@ UnmodifiableMetadata = Cett
UnmodifiableObject_1 = Cette instance de \u2018{0}\u2019 n\u2019est pas modifiable.
UnspecifiedCRS = Le syst\u00e8me de r\u00e9f\u00e9rence des coordonn\u00e9es n\u2019a pas \u00e9t\u00e9 sp\u00e9cifi\u00e9.
UnspecifiedFormatForClass_1 = Aucun format n\u2019est sp\u00e9cifi\u00e9 pour les objets de classe \u2018{0}\u2019.
+UnspecifiedParameterValues = Les valeurs des param\u00e8tres n\u2019ont pas \u00e9t\u00e9 sp\u00e9cifi\u00e9es.
UnparsableStringForClass_2 = Le texte \u00ab\u202f{1}\u202f\u00bb n\u2019est pas reconnu comme un objet de type \u2018{0}\u2019.
UnparsableStringForClass_3 = Le texte \u00ab\u202f{1}\u202f\u00bb n\u2019est pas reconnu comme un objet de type \u2018{0}\u2019, \u00e0 cause des caract\u00e8res \u00ab\u202f{2}\u202f\u00bb.
UnresolvedFeatureName_1 = L\u2019entit\u00e9 nomm\u00e9e \u00ab\u202f{0}\u202f\u00bb n\u2019a pas encore \u00e9t\u00e9 r\u00e9solue.
Modified: sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java?rev=1679633&r1=1679632&r2=1679633&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/main/java/org/apache/sis/xml/XML.java [UTF-8] Fri May 15 19:31:51 2015
@@ -423,14 +423,16 @@ public final class XML extends Static {
/**
* Unmarshall an object from the given string.
+ * Note that the given argument is the XML document itself,
+ * <strong>not</strong> a URL to a XML document.
*
- * @param input The XML representation of an object.
+ * @param xml The XML representation of an object.
* @return The object unmarshalled from the given input.
* @throws JAXBException If an error occurred during the unmarshalling.
*/
- public static Object unmarshal(final String input) throws JAXBException {
- ensureNonNull("input", input);
- final StringReader in = new StringReader(input);
+ public static Object unmarshal(final String xml) throws JAXBException {
+ ensureNonNull("input", xml);
+ final StringReader in = new StringReader(xml);
final MarshallerPool pool = getPool();
final Unmarshaller unmarshaller = pool.acquireUnmarshaller();
final Object object = unmarshaller.unmarshal(in);
Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/util/AbstractMapTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/util/AbstractMapTest.java?rev=1679633&r1=1679632&r2=1679633&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/util/AbstractMapTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/util/AbstractMapTest.java [UTF-8] Fri May 15 19:31:51 2015
@@ -50,7 +50,6 @@ public final strictfp class AbstractMapT
private final List<String> values = new ArrayList<String>(Arrays.asList("one", "two", "three"));
@Override public void clear () { values.clear();}
- @Override public int size () {return values.size();}
@Override public String get (Object k) {return values.get(((Integer) k) - 1);}
@Override public String put (Integer k, String v) {return values.set(k - 1, v);}
@Override protected boolean addKey (Integer k) {return values.add(k == 4 ? "four" : "other");}
@@ -58,7 +57,7 @@ public final strictfp class AbstractMapT
@Override protected EntryIterator<Integer,String> entryIterator() {
return new EntryIterator<Integer,String>() {
private int key;
- @Override protected boolean next() {return ++key <= size();}
+ @Override protected boolean next() {return ++key <= values.size();}
@Override protected Integer getKey() {return key;}
@Override protected String getValue() {return get(key);}
};
@@ -68,15 +67,16 @@ public final strictfp class AbstractMapT
/**
* Tests {@link AbstractMap#keySet()}, {@link AbstractMap#values()} and {@link AbstractMap#entrySet()}.
* This method will also opportunistically tests basic methods like {@link AbstractMap#isEmpty()} and
- * {@link AbstractMap#containsValue(Object)}. This test does not write in the map.
+ * {@link AbstractMap#containsValue(Object)}. This test does not add new values in the map.
*/
@Test
public void testReadOnly() {
final Count map = new Count();
- assertFalse("isEmpty", map.isEmpty());
- assertTrue ("containsKey", map.containsKey(3));
- assertTrue ("containsValue", map.containsValue("three"));
- assertFalse("containsValue", map.containsValue("six"));
+ assertEquals("size", 3, map.size());
+ assertFalse ("isEmpty", map.isEmpty());
+ assertTrue ("containsKey", map.containsKey(3));
+ assertTrue ("containsValue", map.containsValue("three"));
+ assertFalse ("containsValue", map.containsValue("six"));
final Collection<Integer> keys = map.keySet();
assertTrue("contains", keys.contains(3));
@@ -97,11 +97,15 @@ public final strictfp class AbstractMapT
}, entries.toArray());
map.clear();
- assertFalse("containsValue", map.containsValue("three"));
- assertTrue ("isEmpty", map.isEmpty());
- assertTrue ("isEmpty", keys.isEmpty());
- assertTrue ("isEmpty", values.isEmpty());
- assertTrue ("isEmpty", entries.isEmpty());
+ assertFalse ("containsValue", map.containsValue("three"));
+ assertTrue ("isEmpty", map .isEmpty());
+ assertTrue ("isEmpty", keys .isEmpty());
+ assertTrue ("isEmpty", values .isEmpty());
+ assertTrue ("isEmpty", entries.isEmpty());
+ assertEquals("size", 0, map .size());
+ assertEquals("size", 0, keys .size());
+ assertEquals("size", 0, values .size());
+ assertEquals("size", 0, entries.size());
}
/**
@@ -112,7 +116,9 @@ public final strictfp class AbstractMapT
@DependsOnMethod("testReadOnly")
public void testAddKey() {
final Count map = new Count();
+ assertEquals("size", 3, map.size());
assertTrue(map.keySet().add(4));
+ assertEquals("size", 4, map.size());
assertArrayEquals("entrySet", new SimpleEntry<?,?>[] {
new SimpleEntry<Integer,String>(1, "one"),
new SimpleEntry<Integer,String>(2, "two"),
@@ -129,7 +135,9 @@ public final strictfp class AbstractMapT
@DependsOnMethod("testReadOnly")
public void testAddValue() {
final Count map = new Count();
+ assertEquals("size", 3, map.size());
assertTrue(map.values().add("quatre"));
+ assertEquals("size", 4, map.size());
assertArrayEquals("entrySet", new SimpleEntry<?,?>[] {
new SimpleEntry<Integer,String>(1, "one"),
new SimpleEntry<Integer,String>(2, "two"),
Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/util/DoubleDoubleTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/util/DoubleDoubleTest.java?rev=1679633&r1=1679632&r2=1679633&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/util/DoubleDoubleTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/internal/util/DoubleDoubleTest.java [UTF-8] Fri May 15 19:31:51 2015
@@ -63,11 +63,6 @@ public final strictfp class DoubleDouble
private static final double PRODUCT_TOLERANCE_FACTOR = 1E-15;
/**
- * Tolerance threshold for strict comparisons of floating point values.
- */
- private static final double STRICT = 0;
-
- /**
* The random number generator to use for the test.
*/
private final Random random = TestUtilities.createRandomNumberGenerator();
Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/math/DecimalFunctionsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/math/DecimalFunctionsTest.java?rev=1679633&r1=1679632&r2=1679633&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/math/DecimalFunctionsTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/math/DecimalFunctionsTest.java [UTF-8] Fri May 15 19:31:51 2015
@@ -40,11 +40,6 @@ import static org.apache.sis.math.Decima
@DependsOn(org.apache.sis.internal.util.NumericsTest.class)
public final strictfp class DecimalFunctionsTest extends TestCase {
/**
- * Tolerance threshold for strict comparisons of floating point values.
- */
- private static final double STRICT = 0;
-
- /**
* Verifies the values of {@link DecimalFunctions#EXPONENT_FOR_ZERO}.
*/
@Test
Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java?rev=1679633&r1=1679632&r2=1679633&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/math/MathFunctionsTest.java [UTF-8] Fri May 15 19:31:51 2015
@@ -45,11 +45,6 @@ import org.apache.sis.internal.jdk8.JDK8
})
public final strictfp class MathFunctionsTest extends TestCase {
/**
- * Tolerance threshold for strict comparisons of floating point values.
- */
- private static final double STRICT = 0;
-
- /**
* Small number for floating point comparisons.
*/
private static final double EPS = 1E-12;
Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/math/StatisticsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/math/StatisticsTest.java?rev=1679633&r1=1679632&r2=1679633&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/math/StatisticsTest.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/math/StatisticsTest.java [UTF-8] Fri May 15 19:31:51 2015
@@ -52,11 +52,6 @@ public final strictfp class StatisticsTe
private static final double EPS = 1E-10;
/**
- * Tolerance threshold for strict comparisons of floating point values.
- */
- private static final double STRICT = 0;
-
- /**
* Tests the initial state of newly constructed instance.
*/
@Test
Modified: sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/TestCase.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/TestCase.java?rev=1679633&r1=1679632&r2=1679633&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/TestCase.java [UTF-8] (original)
+++ sis/branches/JDK6/core/sis-utility/src/test/java/org/apache/sis/test/TestCase.java [UTF-8] Fri May 15 19:31:51 2015
@@ -56,6 +56,16 @@ import static org.apache.sis.test.TestCo
@RunWith(TestRunner.class)
public abstract strictfp class TestCase {
/**
+ * Tolerance threshold for strict comparisons of floating point numbers.
+ * This constant can be used like below, where {@code expected} and {@code actual} are {@code double} values:
+ *
+ * {@preformat java
+ * assertEquals(expected, actual, STRICT);
+ * }
+ */
+ protected static final double STRICT = 0;
+
+ /**
* A flag for code that are pending future SIS development before to be enabled.
* This flag is always set to {@code false}. It shall be used as below:
*
Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java?rev=1679633&r1=1679632&r2=1679633&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/ShapefileByteReader.java [UTF-8] Fri May 15 19:31:51 2015
@@ -25,6 +25,7 @@ import java.util.*;
import org.apache.sis.feature.DefaultAttributeType;
import org.apache.sis.feature.DefaultFeatureType;
import org.apache.sis.internal.shapefile.jdbc.*;
+import org.apache.sis.storage.shapefile.InvalidShapefileFormatException;
import org.apache.sis.storage.shapefile.ShapeTypeEnum;
import org.opengis.feature.Feature;
@@ -42,7 +43,7 @@ import org.apache.sis.internal.jdk7.Obje
* @since 0.5
* @module
*/
-public class ShapefileByteReader extends CommonByteReader<InvalidShapefileFormatException, ShapefileNotFoundException> {
+public class ShapefileByteReader extends CommonByteReader<InvalidShapefileFormatException, SQLShapefileNotFoundException> {
/** Name of the Geometry field. */
private static final String GEOMETRY_NAME = "geometry";
@@ -60,12 +61,12 @@ public class ShapefileByteReader extends
* @param shapefile Shapefile.
* @param dbaseFile underlying database file name.
* @throws InvalidShapefileFormatException if the shapefile format is invalid.
- * @throws InvalidDbaseFileFormatException if the database file format is invalid.
- * @throws ShapefileNotFoundException if the shapefile has not been found.
- * @throws DbaseFileNotFoundException if the database file has not been found.
+ * @throws SQLInvalidDbaseFileFormatException if the database file format is invalid.
+ * @throws SQLShapefileNotFoundException if the shapefile has not been found.
+ * @throws SQLDbaseFileNotFoundException if the database file has not been found.
*/
- public ShapefileByteReader(File shapefile, File dbaseFile) throws InvalidShapefileFormatException, InvalidDbaseFileFormatException, ShapefileNotFoundException, DbaseFileNotFoundException {
- super(shapefile, InvalidShapefileFormatException.class, ShapefileNotFoundException.class);
+ public ShapefileByteReader(File shapefile, File dbaseFile) throws InvalidShapefileFormatException, SQLInvalidDbaseFileFormatException, SQLShapefileNotFoundException, SQLDbaseFileNotFoundException {
+ super(shapefile, InvalidShapefileFormatException.class, SQLShapefileNotFoundException.class);
loadDatabaseFieldDescriptors(dbaseFile);
loadDescriptor();
@@ -133,10 +134,10 @@ public class ShapefileByteReader extends
/**
* Load database field descriptors.
* @param dbaseFile Database file.
- * @throws InvalidDbaseFileFormatException if the database format is incorrect.
- * @throws DbaseFileNotFoundException if the database file cannot be found.
+ * @throws SQLInvalidDbaseFileFormatException if the database format is incorrect.
+ * @throws SQLDbaseFileNotFoundException if the database file cannot be found.
*/
- private void loadDatabaseFieldDescriptors(File dbaseFile) throws InvalidDbaseFileFormatException, DbaseFileNotFoundException {
+ private void loadDatabaseFieldDescriptors(File dbaseFile) throws SQLInvalidDbaseFileFormatException, SQLDbaseFileNotFoundException {
MappedByteReader databaseReader = null;
try {
Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java?rev=1679633&r1=1679632&r2=1679633&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/AbstractDbase3ByteReader.java [UTF-8] Fri May 15 19:31:51 2015
@@ -35,7 +35,7 @@ import org.apache.sis.internal.jdk7.Obje
* @since 0.5
* @module
*/
-abstract class AbstractDbase3ByteReader extends CommonByteReader<InvalidDbaseFileFormatException, DbaseFileNotFoundException> implements Dbase3ByteReader {
+abstract class AbstractDbase3ByteReader extends CommonByteReader<SQLInvalidDbaseFileFormatException, SQLDbaseFileNotFoundException> implements Dbase3ByteReader {
/** Number of bytes in the header. */
protected short dbaseHeaderBytes;
@@ -95,11 +95,11 @@ abstract class AbstractDbase3ByteReader
/**
* Map a dbf file.
* @param file Database file.
- * @throws DbaseFileNotFoundException if the DBF file has not been found.
- * @throws InvalidDbaseFileFormatException if the database has an invalid format.
+ * @throws SQLDbaseFileNotFoundException if the DBF file has not been found.
+ * @throws SQLInvalidDbaseFileFormatException if the database has an invalid format.
*/
- public AbstractDbase3ByteReader(File file) throws DbaseFileNotFoundException, InvalidDbaseFileFormatException {
- super(file, InvalidDbaseFileFormatException.class, DbaseFileNotFoundException.class);
+ public AbstractDbase3ByteReader(File file) throws SQLDbaseFileNotFoundException, SQLInvalidDbaseFileFormatException {
+ super(file, SQLInvalidDbaseFileFormatException.class, SQLDbaseFileNotFoundException.class);
}
/**
@@ -138,11 +138,11 @@ abstract class AbstractDbase3ByteReader
* Convert the binary code page value of the Dbase 3 file to a recent Charset.
* @param codePageBinaryValue page code binary value.
* @return Charset.
- * @throws InvalidDbaseFileFormatException if the binary value is not one of the standard values that the DBF file should carry : the Dbase 3
+ * @throws SQLInvalidDbaseFileFormatException if the binary value is not one of the standard values that the DBF file should carry : the Dbase 3
* file might be corrupted.
* @throws UnsupportedCharsetException if the code page as no representation in recents Charset (legacy DOS or macintosh charsets).
*/
- protected Charset toCharset(byte codePageBinaryValue) throws InvalidDbaseFileFormatException, UnsupportedCharsetException {
+ protected Charset toCharset(byte codePageBinaryValue) throws SQLInvalidDbaseFileFormatException, UnsupportedCharsetException {
// Attempt to find a known conversion.
String dbfCodePage = toCodePage(codePageBinaryValue);
@@ -165,7 +165,7 @@ abstract class AbstractDbase3ByteReader
// If the code page is invalid, the database itself has chances to be invalid too.
if (dbfCodePage.equals("invalid")) {
String message = format(Level.WARNING, "excp.illegal_codepage", codePageBinaryValue, getFile().getAbsolutePath());
- throw new InvalidDbaseFileFormatException(message);
+ throw new SQLInvalidDbaseFileFormatException(message);
}
// If the code page cannot find a match for a more recent Charset, we wont be able to handle this DBF.
Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java?rev=1679633&r1=1679632&r2=1679633&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/DBFDriver.java [UTF-8] Fri May 15 19:31:51 2015
@@ -66,13 +66,13 @@ public class DBFDriver extends AbstractJ
* @param url The path to a {@code .dbf} file.
* @param info Ignored in current implementation.
* @return A connection to the given DBF file.
- * @throws InvalidDbaseFileFormatException if the database file format is invalid.
- * @throws DbaseFileNotFoundException if the database file doesn't exist.
- * @throws InvalidDbaseFileFormatException if the database file has a wrong format.
+ * @throws SQLInvalidDbaseFileFormatException if the database file format is invalid.
+ * @throws SQLDbaseFileNotFoundException if the database file doesn't exist.
+ * @throws SQLInvalidDbaseFileFormatException if the database file has a wrong format.
*/
@Override
@SuppressWarnings("resource") // the function opens a connection.
- public Connection connect(final String url, @SuppressWarnings("unused") Properties info) throws InvalidDbaseFileFormatException, DbaseFileNotFoundException {
+ public Connection connect(final String url, @SuppressWarnings("unused") Properties info) throws SQLInvalidDbaseFileFormatException, SQLDbaseFileNotFoundException {
Objects.requireNonNull(url, "the DBase3 url cannot be null");
File file = new File(url);
Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java?rev=1679633&r1=1679632&r2=1679633&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/MappedByteReader.java [UTF-8] Fri May 15 19:31:51 2015
@@ -42,10 +42,10 @@ public class MappedByteReader extends Ab
/**
* Construct a mapped byte reader on a file.
* @param dbase3File File.
- * @throws InvalidDbaseFileFormatException if the database seems to be invalid.
- * @throws DbaseFileNotFoundException if the Dbase file has not been found.
+ * @throws SQLInvalidDbaseFileFormatException if the database seems to be invalid.
+ * @throws SQLDbaseFileNotFoundException if the Dbase file has not been found.
*/
- public MappedByteReader(File dbase3File) throws InvalidDbaseFileFormatException, DbaseFileNotFoundException {
+ public MappedByteReader(File dbase3File) throws SQLInvalidDbaseFileFormatException, SQLDbaseFileNotFoundException {
super(dbase3File);
loadDescriptor();
}
@@ -115,9 +115,9 @@ public class MappedByteReader extends Ab
/**
* Loading the database file content from binary .dbf file.
- * @throws InvalidDbaseFileFormatException if descriptor is not readable.
+ * @throws SQLInvalidDbaseFileFormatException if descriptor is not readable.
*/
- private void loadDescriptor() throws InvalidDbaseFileFormatException {
+ private void loadDescriptor() throws SQLInvalidDbaseFileFormatException {
try {
this.dbaseVersion = getByteBuffer().get();
getByteBuffer().get(this.dbaseLastUpdate);
@@ -152,7 +152,7 @@ public class MappedByteReader extends Ab
// If the last character read after the field descriptor isn't 0x0D, the expected mark has not been found and the DBF is corrupted.
if (descriptorTerminator != 0x0D) {
String message = format(Level.WARNING, "excp.filedescriptor_problem", getFile().getAbsolutePath(), "Character marking the end of the fields descriptors (0x0D) has not been found.");
- throw new InvalidDbaseFileFormatException(message);
+ throw new SQLInvalidDbaseFileFormatException(message);
}
}
catch(BufferUnderflowException e) {
@@ -161,7 +161,7 @@ public class MappedByteReader extends Ab
// Therefore, an internal structure problem cause maybe a premature End of file or anything else, but the only thing
// we can conclude is : we are not before a device trouble, but a file format trouble.
String message = format(Level.WARNING, "excp.filedescriptor_problem", getFile().getAbsolutePath(), e.getMessage());
- throw new InvalidDbaseFileFormatException(message);
+ throw new SQLInvalidDbaseFileFormatException(message);
}
}
Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java?rev=1679633&r1=1679632&r2=1679633&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/connection/DBFConnection.java [UTF-8] Fri May 15 19:31:51 2015
@@ -53,17 +53,17 @@ public class DBFConnection extends Abstr
* Constructs a connection to the given database.
* @param datafile Data file ({@code .dbf} extension).
* @param br Byte reader to use for reading binary content.
- * @throws DbaseFileNotFoundException if the Database file cannot be found or is not a file.
+ * @throws SQLDbaseFileNotFoundException if the Database file cannot be found or is not a file.
*/
- public DBFConnection(final File datafile, Dbase3ByteReader br) throws DbaseFileNotFoundException {
+ public DBFConnection(final File datafile, Dbase3ByteReader br) throws SQLDbaseFileNotFoundException {
// Check that file exists.
if (!datafile.exists()) {
- throw new DbaseFileNotFoundException(format(Level.WARNING, "excp.file_not_found", datafile.getAbsolutePath()));
+ throw new SQLDbaseFileNotFoundException(format(Level.WARNING, "excp.file_not_found", datafile.getAbsolutePath()));
}
// Check that its not a directory.
if (datafile.isDirectory()) {
- throw new DbaseFileNotFoundException(format(Level.WARNING, "excp.directory_not_expected", datafile.getAbsolutePath()));
+ throw new SQLDbaseFileNotFoundException(format(Level.WARNING, "excp.directory_not_expected", datafile.getAbsolutePath()));
}
databaseFile = datafile;
Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java?rev=1679633&r1=1679632&r2=1679633&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.java [UTF-8] Fri May 15 19:31:51 2015
@@ -413,8 +413,17 @@ public class DBFRecordBasedResultSet ext
* @see org.apache.sis.internal.shapefile.jdbc.resultset.DBFResultSet#getObject(java.lang.String)
*/
@Override
- public Object getObject(String columnLabel) throws SQLConnectionClosedException, SQLIllegalColumnIndexException, SQLFeatureNotSupportedException, SQLNoSuchFieldException, SQLNotNumericException, SQLNotDateException {
- return getObject(findColumn(columnLabel));
+ public Object getObject(String columnLabel) throws SQLConnectionClosedException, SQLFeatureNotSupportedException, SQLNoSuchFieldException, SQLNotNumericException, SQLNotDateException {
+ int index = -1;
+
+ try {
+ index = findColumn(columnLabel);
+ return getObject(index);
+ }
+ catch(SQLIllegalColumnIndexException e) {
+ String message = format(Level.SEVERE, "assert.wrong_index_for_column_name", index, columnLabel);
+ throw new RuntimeException(message, e);
+ }
}
/**
Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java?rev=1679633&r1=1679632&r2=1679633&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/InputFeatureStream.java [UTF-8] Fri May 15 19:31:51 2015
@@ -19,12 +19,12 @@ package org.apache.sis.storage.shapefile
import java.io.File;
import java.io.InputStream;
import java.sql.SQLFeatureNotSupportedException;
-import java.text.*;
+import java.text.DecimalFormat;
+import java.text.MessageFormat;
import org.apache.sis.feature.DefaultFeatureType;
-import org.apache.sis.internal.shapefile.InvalidShapefileFormatException;
+import org.apache.sis.internal.shapefile.SQLShapefileNotFoundException;
import org.apache.sis.internal.shapefile.ShapefileByteReader;
-import org.apache.sis.internal.shapefile.ShapefileNotFoundException;
import org.apache.sis.internal.shapefile.jdbc.*;
import org.apache.sis.internal.shapefile.jdbc.connection.DBFConnection;
import org.apache.sis.internal.shapefile.jdbc.metadata.DBFDatabaseMetaData;
@@ -33,6 +33,7 @@ import org.apache.sis.internal.shapefile
import org.apache.sis.internal.shapefile.jdbc.sql.SQLInvalidStatementException;
import org.apache.sis.internal.shapefile.jdbc.sql.SQLUnsupportedParsingFeatureException;
import org.apache.sis.internal.shapefile.jdbc.statement.DBFStatement;
+import org.apache.sis.storage.DataStoreClosedException;
import org.opengis.feature.Feature;
/**
@@ -75,27 +76,44 @@ public class InputFeatureStream extends
* Create an input stream of features over a connection.
* @param shpfile Shapefile.
* @param dbaseFile Database file.
- * @throws SQLInvalidStatementException if the given SQL Statement is invalid.
* @throws InvalidShapefileFormatException if the shapefile format is invalid.
* @throws InvalidDbaseFileFormatException if the Dbase file format is invalid.
* @throws ShapefileNotFoundException if the shapefile has not been found.
* @throws DbaseFileNotFoundException if the database file has not been found.
*/
- public InputFeatureStream(File shpfile, File dbaseFile) throws SQLInvalidStatementException, InvalidDbaseFileFormatException, InvalidShapefileFormatException, ShapefileNotFoundException, DbaseFileNotFoundException {
- connection = (DBFConnection)new DBFDriver().connect(dbaseFile.getAbsolutePath(), null);
- sql = MessageFormat.format("SELECT * FROM {0}", dbaseFile.getName());
- shapefile = shpfile;
- databaseFile = dbaseFile;
-
- shapefileReader = new ShapefileByteReader(shapefile, databaseFile);
- featuresType = shapefileReader.getFeaturesType();
-
+ public InputFeatureStream(File shpfile, File dbaseFile) throws InvalidDbaseFileFormatException, InvalidShapefileFormatException, ShapefileNotFoundException, DbaseFileNotFoundException {
try {
- executeQuery();
+ connection = (DBFConnection)new DBFDriver().connect(dbaseFile.getAbsolutePath(), null);
+ sql = MessageFormat.format("SELECT * FROM {0}", dbaseFile.getName());
+ shapefile = shpfile;
+ databaseFile = dbaseFile;
+
+ shapefileReader = new ShapefileByteReader(shapefile, databaseFile);
+ featuresType = shapefileReader.getFeaturesType();
+
+ try {
+ executeQuery();
+ }
+ catch(SQLConnectionClosedException e) {
+ // This would be an internal trouble because in this function (at least) it should be open.
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ catch(SQLInvalidStatementException e) {
+ // This would be an internal trouble because if any SQL statement is executed for the dbase file initialization, it should has a correct syntax or grammar.
+ throw new RuntimeException(e.getMessage(), e);
+ }
}
- catch(SQLConnectionClosedException e) {
- // This would be an internal trouble because in this function (at least) it should be open.
- throw new RuntimeException(e.getMessage(), e);
+ catch(SQLInvalidDbaseFileFormatException ex) {
+ // Promote this exception to an DataStoreException compatible exception.
+ throw new InvalidDbaseFileFormatException(ex.getMessage(), ex);
+ }
+ catch(SQLDbaseFileNotFoundException ex) {
+ // Promote this exception to an DataStoreException compatible exception.
+ throw new DbaseFileNotFoundException(ex.getMessage(), ex);
+ }
+ catch(SQLShapefileNotFoundException ex) {
+ // Promote this exception to an DataStoreException compatible exception.
+ throw new ShapefileNotFoundException(ex.getMessage(), ex);
}
}
@@ -126,7 +144,33 @@ public class InputFeatureStream extends
}
/**
- * Read next feature responding to the SQL request.
+ * Read next feature responding to the SQL query.
+ * @return Feature, null if no more feature is available.
+ * @throws DataStoreClosedException if the current connection used to query the shapefile has been closed.
+ * @throws DataStoreQueryException if the statement used to query the shapefile content is incorrect.
+ * @throws DataStoreQueryResultException if the shapefile results cause a trouble (wrong format, for example).
+ * @throws InvalidShapefileFormatException if the shapefile structure shows a problem.
+ */
+ public Feature readFeature() throws DataStoreClosedException, DataStoreQueryException, DataStoreQueryResultException, InvalidShapefileFormatException {
+ try {
+ return internalReadFeature();
+ }
+ catch(SQLConnectionClosedException e) {
+ throw new DataStoreClosedException(e.getMessage(), e);
+ }
+ catch(SQLNotNumericException e) {
+ throw new DataStoreQueryResultException(e.getMessage(), e);
+ }
+ catch(SQLNotDateException e) {
+ throw new DataStoreQueryResultException(e.getMessage(), e);
+ }
+ catch(java.sql.SQLException e) {
+ throw new DataStoreQueryException(e.getMessage(), e);
+ }
+ }
+
+ /**
+ * Read next feature responding to the SQL query.
* @return Feature, null if no more feature is available.
* @throws SQLNotNumericException if a field expected numeric isn't.
* @throws SQLNotDateException if a field expected of date kind, isn't.
@@ -135,11 +179,10 @@ public class InputFeatureStream extends
* @throws SQLInvalidStatementException if the SQL statement is invalid.
* @throws SQLConnectionClosedException if the connection is closed.
* @throws SQLUnsupportedParsingFeatureException if a SQL ability is not currently available through this driver.
- * @throws SQLIllegalColumnIndexException if a column index is illegal.
* @throws SQLFeatureNotSupportedException if a SQL ability is not currently available through this driver.
* @throws InvalidShapefileFormatException if the shapefile format is invalid.
*/
- public Feature readFeature() throws SQLConnectionClosedException, SQLInvalidStatementException, SQLIllegalParameterException, SQLNoSuchFieldException, SQLUnsupportedParsingFeatureException, SQLNotNumericException, SQLNotDateException, SQLFeatureNotSupportedException, SQLIllegalColumnIndexException, InvalidShapefileFormatException {
+ private Feature internalReadFeature() throws SQLConnectionClosedException, SQLInvalidStatementException, SQLIllegalParameterException, SQLNoSuchFieldException, SQLUnsupportedParsingFeatureException, SQLNotNumericException, SQLNotDateException, SQLFeatureNotSupportedException, InvalidShapefileFormatException {
try {
if (endOfFile) {
return null;
Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java?rev=1679633&r1=1679632&r2=1679633&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/java/org/apache/sis/storage/shapefile/ShapeFile.java [UTF-8] Fri May 15 19:31:51 2015
@@ -18,12 +18,6 @@ package org.apache.sis.storage.shapefile
import java.io.File;
-import org.apache.sis.internal.shapefile.InvalidShapefileFormatException;
-import org.apache.sis.internal.shapefile.ShapefileNotFoundException;
-import org.apache.sis.internal.shapefile.jdbc.DbaseFileNotFoundException;
-import org.apache.sis.internal.shapefile.jdbc.InvalidDbaseFileFormatException;
-import org.apache.sis.internal.shapefile.jdbc.sql.SQLInvalidStatementException;
-
// Branch-dependent imports
import org.apache.sis.internal.jdk7.Objects;
@@ -64,13 +58,12 @@ public class ShapeFile {
/**
* Find features corresponding to an SQL request SELECT * FROM database.
* @return Features
- * @throws SQLInvalidStatementException if the SQL statement is invalid.
* @throws DbaseFileNotFoundException if the database file has not been found.
* @throws ShapefileNotFoundException if the shapefile has not been found.
* @throws InvalidDbaseFileFormatException if the database file format is invalid.
* @throws InvalidShapefileFormatException if the shapefile format is invalid.
*/
- public InputFeatureStream findAll() throws InvalidDbaseFileFormatException, ShapefileNotFoundException, DbaseFileNotFoundException, SQLInvalidStatementException, InvalidShapefileFormatException {
+ public InputFeatureStream findAll() throws InvalidDbaseFileFormatException, ShapefileNotFoundException, DbaseFileNotFoundException, InvalidShapefileFormatException {
return new InputFeatureStream(shapeFile, databaseFile);
}
}
Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.properties?rev=1679633&r1=1679632&r2=1679633&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.properties [ISO-8859-1] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet.properties [ISO-8859-1] Fri May 15 19:31:51 2015
@@ -1,3 +1,7 @@
+# Assertion : if this exception is thrown, the involved code that produced it is sure to have a bug.
+#0 : Wrong index returned by findColumn.
+#1 : Field name that caused the wrong calculation.
+assert.wrong_index_for_column_name=[Erreur interne de l''API] The column index {0}, illegal, has been returned by findColumn for the field ''{1}''.
# Exception : field is not a date.
#0 : Field name.
Modified: sis/branches/JDK6/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet_fr.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet_fr.properties?rev=1679633&r1=1679632&r2=1679633&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet_fr.properties [ISO-8859-1] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/main/resources/org/apache/sis/internal/shapefile/jdbc/resultset/DBFRecordBasedResultSet_fr.properties [ISO-8859-1] Fri May 15 19:31:51 2015
@@ -1,3 +1,8 @@
+# Assertion : if this exception is thrown, the involved code that produced it is sure to have a bug.
+#0 : Wrong index returned by findColumn.
+#1 : Field name that caused the wrong calculation.
+assert.wrong_index_for_column_name=[Erreur interne de l''API] L''index de colonne {0}, illégal, a été renvoyé par findColumn pour le champ ''{1}''.
+
# Exception : field is not a date.
#0 : Field name.
#1 : SQL Query.
Modified: sis/branches/JDK6/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK6/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java?rev=1679633&r1=1679632&r2=1679633&view=diff
==============================================================================
--- sis/branches/JDK6/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java [UTF-8] (original)
+++ sis/branches/JDK6/storage/sis-shapefile/src/test/java/org/apache/sis/storage/shapefile/ShapeFileTest.java [UTF-8] Fri May 15 19:31:51 2015
@@ -18,9 +18,8 @@ package org.apache.sis.storage.shapefile
import java.io.File;
import java.net.URISyntaxException;
-import java.sql.SQLException;
-import org.apache.sis.internal.shapefile.InvalidShapefileFormatException;
+import org.apache.sis.storage.DataStoreException;
import org.apache.sis.test.TestCase;
import org.junit.Test;
import org.opengis.feature.Feature;
@@ -48,11 +47,10 @@ public final strictfp class ShapeFileTes
/**
* Test polylines count.
* @throws URISyntaxException if the resource name is incorrect.
- * @throws InvalidShapefileFormatException if the shapefile format is invalid.
- * @throws SQLException if any SQL Exception occuring.
+ * @throws DataStoreException if a general file reading trouble occurs.
*/
@Test
- public void testPolyineCount() throws URISyntaxException, SQLException, InvalidShapefileFormatException {
+ public void testPolyineCount() throws URISyntaxException, DataStoreException {
ShapeFile shp = new ShapeFile(path("SignedBikeRoute_4326_clipped.shp"));
readAll(shp);
}
@@ -60,11 +58,10 @@ public final strictfp class ShapeFileTes
/**
* Test polygon count.
* @throws URISyntaxException if the resource name is incorrect.
- * @throws InvalidShapefileFormatException if the shapefile format is invalid.
- * @throws SQLException if any SQL Exception occuring.
+ * @throws DataStoreException if a general file reading trouble occurs.
*/
@Test
- public void testPolygonCount() throws URISyntaxException, SQLException, InvalidShapefileFormatException {
+ public void testPolygonCount() throws URISyntaxException, DataStoreException {
ShapeFile shp = new ShapeFile(path("ANC90Ply_4326.shp"));
readAll(shp);
}
@@ -72,11 +69,10 @@ public final strictfp class ShapeFileTes
/**
* Test point count.
* @throws URISyntaxException if the resource name is incorrect.
- * @throws InvalidShapefileFormatException if the shapefile format is invalid.
- * @throws SQLException if any SQL Exception occuring.
+ * @throws DataStoreException if a general file reading trouble occurs.
*/
@Test
- public void testPointCount() throws URISyntaxException, SQLException, InvalidShapefileFormatException {
+ public void testPointCount() throws URISyntaxException, DataStoreException {
ShapeFile shp = new ShapeFile(path("ABRALicenseePt_4326_clipped.shp"));
readAll(shp);
}
@@ -84,10 +80,9 @@ public final strictfp class ShapeFileTes
/**
* Read all the shapefile content.
* @param shp Shapefile to read.
- * @throws InvalidShapefileFormatException if the shapefile format is invalid.
- * @throws SQLException if any SQL Exception occuring.
+ * @throws DataStoreException if a general file reading trouble occurs.
*/
- private void readAll(ShapeFile shp) throws SQLException, InvalidShapefileFormatException {
+ private void readAll(ShapeFile shp) throws DataStoreException {
InputFeatureStream is = shp.findAll();
try {
Feature feature = is.readFeature();