Return-Path: X-Original-To: apmail-sis-commits-archive@www.apache.org Delivered-To: apmail-sis-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D32EC1030D for ; Fri, 16 Jan 2015 17:28:37 +0000 (UTC) Received: (qmail 39208 invoked by uid 500); 16 Jan 2015 17:28:39 -0000 Delivered-To: apmail-sis-commits-archive@sis.apache.org Received: (qmail 39181 invoked by uid 500); 16 Jan 2015 17:28:39 -0000 Mailing-List: contact commits-help@sis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: sis-dev@sis.apache.org Delivered-To: mailing list commits@sis.apache.org Received: (qmail 39171 invoked by uid 99); 16 Jan 2015 17:28:39 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Jan 2015 17:28:39 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id 60453AC0059; Fri, 16 Jan 2015 17:28:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r1652466 - in /sis/branches/JDK7: ./ core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/ core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/ core/sis-metad... Date: Fri, 16 Jan 2015 17:28:38 -0000 To: commits@sis.apache.org From: desruisseaux@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150116172839.60453AC0059@hades.apache.org> Author: desruisseaux Date: Fri Jan 16 17:28:38 2015 New Revision: 1652466 URL: http://svn.apache.org/r1652466 Log: Merge from the JDK8 branch: - Update for GeoAPI change in org.opengis.temporal (pending interfaces). - ISO 19162 requires us that we replace non-ASCII characters by ASCII ones in all WKT elements except REMARKS["..."]. Modified: sis/branches/JDK7/ (props changed) sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ElementKind.java sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/FormatterTest.java sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/DefaultMetadataTest.java sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant.java sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/TemporalUtilities.java sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/StringBuilders.java sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/internal/jaxb/gml/DummyInstant.java sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/util/StringBuildersTest.java Propchange: sis/branches/JDK7/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Fri Jan 16 17:28:38 2015 @@ -1,4 +1,4 @@ /sis/branches/Android:1430670-1480699 /sis/branches/JDK6:1394913-1508480 -/sis/branches/JDK8:1584960-1652019 +/sis/branches/JDK8:1584960-1652464 /sis/trunk:1394364-1508466,1519089-1519674 Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java?rev=1652466&r1=1652465&r2=1652466&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java [UTF-8] Fri Jan 16 17:28:38 2015 @@ -27,6 +27,9 @@ import org.apache.sis.internal.jaxb.Cont import org.apache.sis.util.resources.Messages; import org.apache.sis.util.ArgumentChecks; +// Branch-dependent imports +import java.util.Objects; + /** * An adapter for collections of a legacy type replaced by an other collection. @@ -319,4 +322,46 @@ public abstract class LegacyPropertyAdap } }; } + + /** + * Compares this collection with the given object for equality. This method performs comparisons only with + * instances of {@code LegacyPropertyAdapter}, and returns {@code false} for all other kinds of collection. + * We do not compare with arbitrary collection implementations. + * + *

Rational: {@link Collection#equals(Object)} contract explicitely forbids comparisons with + * {@code List} and {@code Set}. The rational explained in {@code Collection} javadoc applies also to + * other kind of {@code Collection} implementations: we can not enforce {@code Collection.equals(Object)} + * to be symmetric in such cases.

+ * + * @param other The other object to compare with this collection, or {@code null}. + * @return {@code true} if the objects are equal, or {@code false} otherwise. + */ + @Override + public final boolean equals(final Object other) { + if (!(other instanceof LegacyPropertyAdapter)) { + return false; + } + final Iterator ot = ((LegacyPropertyAdapter) other).iterator(); + final Iterator it = iterator(); + while (it.hasNext()) { + if (!ot.hasNext() || !Objects.equals(it.next(), ot.next())) { + return false; + } + } + return !ot.hasNext(); + } + + /** + * Returns a hash code value for this collection. + * + * @return A hash code value calculated from the content of this collection. + */ + @Override + public final int hashCode() { + int code = 0; + for (final L element : this) { + code = code*31 + Objects.hashCode(element); + } + return code; + } } Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java?rev=1652466&r1=1652465&r2=1652466&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Convention.java [UTF-8] Fri Jan 16 17:28:38 2015 @@ -55,7 +55,7 @@ import org.apache.sis.metadata.iso.citat public enum Convention { /** * The ISO 19162 format, also known as “WKT 2”. - * This convention follows the ISO recommendations except the following ones: + * This convention follows the ISO recommendations with the following exceptions: * *
    *
  • {@code Axis} element omits the {@code Order} sub-element.
  • @@ -144,6 +144,7 @@ public enum Convention { * with the following differences: * *
      + *
    • All quoted texts (not only the remarks) preserve non-ASCII characters.
    • *
    • Map projections are shown as SIS stores them internally, i.e. with the separation between * linear and non-linear steps, rather than as a single operation.
    • *
    • {@code CompoundCRS} shows nested compound CRS if any (the structure is not flattened).
    • @@ -155,8 +156,8 @@ public enum Convention { * not only CRS or coordinate operations. *
    • Additional attributes not defined by ISO 19162 may be formatted: *
        - *
      • {@code ImageDatum} includes the {@link org.apache.sis.referencing.datum.DefaultImageDatum#getPixelInCell() Pixel in Cell} code.
      • - *
      • {@code TemporalDatum} includes the {@link org.apache.sis.referencing.datum.DefaultTemporalDatum#getOrigin() Origin} date.
      • + *
      • {@code ImageDatum} includes the {@linkplain org.apache.sis.referencing.datum.DefaultImageDatum#getPixelInCell() Pixel in Cell} code.
      • + *
      • {@code TemporalDatum} includes the {@linkplain org.apache.sis.referencing.datum.DefaultTemporalDatum#getOrigin() Origin} date.
      • *
      *
    • *
    Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ElementKind.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ElementKind.java?rev=1652466&r1=1652465&r2=1652466&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ElementKind.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/ElementKind.java [UTF-8] Fri Jan 16 17:28:38 2015 @@ -114,6 +114,10 @@ public enum ElementKind { /** * {@linkplain org.apache.sis.referencing.AbstractIdentifiedObject#getRemarks() Remarks}, * often represented by {@code REMARKS[…]} elements. + * + *

    When formatting an ISO 19162 Well Known Text, texts quoted as remarks preserve non-ASCII characters. + * By contrast, quoted texts in any other {@code ElementKind} will have some non-ASCII characters replaced + * by ASCII ones (e.g. "é" → "e").

    */ REMARKS, Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java?rev=1652466&r1=1652465&r2=1652466&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/Formatter.java [UTF-8] Fri Jan 16 17:28:38 2015 @@ -168,6 +168,12 @@ public class Formatter implements Locali private Citation authority; /** + * {@code true} for preserving non-ASCII characters. The default value is {@code false}, + * which causes replacements like "é" → "e" in all elements except {@code REMARKS["…"]}. + */ + boolean isNonAsciiAllowed; + + /** * The enclosing WKT element being formatted. * * @see #getEnclosingElement(int) @@ -372,11 +378,12 @@ public class Formatter implements Locali final void configure(Convention convention, final Citation authority, final Colors colors, final boolean toUpperCase, final byte indentation) { - this.convention = convention; - this.authority = (authority != null) ? authority : convention.getNameAuthority(); - this.colors = colors; - this.toUpperCase = toUpperCase; - this.indentation = indentation; + this.convention = convention; + this.authority = (authority != null) ? authority : convention.getNameAuthority(); + this.colors = colors; + this.toUpperCase = toUpperCase; + this.indentation = indentation; + isNonAsciiAllowed = (convention == Convention.INTERNAL); } /** @@ -859,7 +866,8 @@ public class Formatter implements Locali final Matrix matrix = ReferencingServices.getInstance().getMatrix(transform); if (matrix != null) { openElement(true, "Param_MT"); - quote("Affine"); + buffer.appendCodePoint(symbols.getOpeningQuote(0)).append("Affine") + .appendCodePoint(symbols.getClosingQuote(0)); indent(+1); append(matrix); indent(-1); @@ -890,7 +898,7 @@ public class Formatter implements Locali boolean columns = false; do { openElement(true, "Parameter"); - quote(columns ? "num_col" : "num_row"); + buffer.appendCodePoint(openQuote).append(columns ? "num_col" : "num_row").appendCodePoint(closeQuote); append(columns ? numCol : numRow); closeElement(false); } while ((columns = !columns) == true); @@ -932,9 +940,7 @@ public class Formatter implements Locali final String localized = CharSequences.trimWhitespaces(text.toString(locale)); if (localized != null && !localized.isEmpty()) { openElement(true, keyword); - setColor(type); - quote(localized); - resetColor(); + quote(localized, type); closeElement(true); } } @@ -950,9 +956,7 @@ public class Formatter implements Locali public void append(final String text, final ElementKind type) { if (text != null) { appendSeparator(); - setColor(type); - quote(text); - resetColor(); + quote(text, type); } } @@ -961,10 +965,16 @@ public class Formatter implements Locali * that character will be doubled (WKT 2) or deleted (WKT 1). We check for the closing quote only because * it is the character that the parser will look for determining the text end. */ - private void quote(final String text) { + private void quote(final String text, final ElementKind type) { + setColor(type); final int base = buffer.appendCodePoint(symbols.getOpeningQuote(0)).length(); - buffer.append(text); + if (isNonAsciiAllowed || (type == ElementKind.REMARKS)) { + buffer.append(text); + } else { + buffer.append(CharSequences.toASCII(text)); + } closeQuote(base); + resetColor(); } /** Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java?rev=1652466&r1=1652465&r2=1652466&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/io/wkt/WKTFormat.java [UTF-8] Fri Jan 16 17:28:38 2015 @@ -78,7 +78,7 @@ import org.apache.sis.util.resources.Err * @author Martin Desruisseaux (Geomatys) * @author Rémi Eve (IRD) * @since 0.4 (derived from geotk-3.20) - * @version 0.4 + * @version 0.5 * @module */ public class WKTFormat extends CompoundFormat { @@ -146,6 +146,12 @@ public class WKTFormat extends CompoundF private KeywordCase keywordCase; /** + * {@code true} for preserving non-ASCII characters. The default value is {@code false}, + * which causes replacements like "é" → "e" in all elements except {@code REMARKS["…"]}. + */ + private boolean isNonAsciiAllowed; + + /** * The amount of spaces to use in indentation, or {@value #SINGLE_LINE} if indentation is disabled. * The same value is also stored in the {@linkplain #formatter}. * It appears here for serialization purpose. @@ -218,6 +224,34 @@ public class WKTFormat extends CompoundF } /** + * Returns whether non-ASCII characters are preserved. The default value is {@code false}, + * which causes replacements like "é" → "e" in all elements except {@link ElementKind#REMARKS}. + * + *

    This value is always {@code true} when the WKT {@linkplain #getConvention() convention} + * is set to {@link Convention#INTERNAL}.

    + * + * @return Whether non-ASCII characters are preserved. + * + * @since 0.5 + */ + public boolean isNonAsciiAllowed() { + return isNonAsciiAllowed || (convention == Convention.INTERNAL); + } + + /** + * Sets whether non-ASCII characters shall be preserved. The default value is {@code false}, + * which causes replacements like "é" → "e" in all elements except {@link ElementKind#REMARKS}. + * Setting this property to {@code true} will disable such replacements. + * + * @param allowed Whether non-ASCII characters shall be preserved. + * + * @since 0.5 + */ + public void setNonAsciiAllowed(final boolean allowed) { + isNonAsciiAllowed = allowed; + } + + /** * Returns whether WKT keywords should be written with upper cases or camel cases. * * @return The case to use for formatting keywords. @@ -347,6 +381,7 @@ public class WKTFormat extends CompoundF default: toUpperCase = (convention.majorVersion() == 1); break; } formatter.configure(convention, authority, colors, toUpperCase, indentation); + formatter.isNonAsciiAllowed |= isNonAsciiAllowed; } } Modified: sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java?rev=1652466&r1=1652465&r2=1652466&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java [UTF-8] Fri Jan 16 17:28:38 2015 @@ -168,7 +168,7 @@ public class DefaultTemporalExtent exten } else { return null; } - return instant.getPosition().getDate(); + return instant.getDate(); } /** Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/FormatterTest.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/FormatterTest.java?rev=1652466&r1=1652465&r2=1652466&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/FormatterTest.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/io/wkt/FormatterTest.java [UTF-8] Fri Jan 16 17:28:38 2015 @@ -55,6 +55,22 @@ public final strictfp class FormatterTes } /** + * Tests (indirectly) {@link Formatter#quote(String)}. + */ + @Test + public void testQuote() { + assertWktEquals(Convention.WKT2, + "“A “quote”” to double”", // Expect doubling quotes. + "A “quote” to double"); + assertWktEquals(Convention.WKT2, + "“Nouvelle Triangulation Francaise”", // Expect replacement of non-latin characters. + "Nouvelle Triangulation Française"); + assertWktEquals(Convention.INTERNAL, + "“Nouvelle Triangulation Française”", // Non-latin characters shall be preserved in internal mode. + "Nouvelle Triangulation Française"); + } + + /** * Tests (indirectly) {@link Formatter#append(GeographicBoundingBox, int)}. */ @Test Modified: sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/DefaultMetadataTest.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/DefaultMetadataTest.java?rev=1652466&r1=1652465&r2=1652466&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/DefaultMetadataTest.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/DefaultMetadataTest.java [UTF-8] Fri Jan 16 17:28:38 2015 @@ -238,7 +238,9 @@ public final strictfp class DefaultMetad final DefaultMetadata metadata = new DefaultMetadata(); assertTrue("hierarchyLevelNames", metadata.getHierarchyLevelNames().isEmpty()); assertTrue("hierarchyLevels", metadata.getHierarchyLevels().isEmpty()); - + /* + * Tests the setter and verify immediately with the getter methods. + */ metadata.setHierarchyLevelNames(Arrays.asList(names)); metadata.setHierarchyLevels(Arrays.asList(levels)); assertArrayEquals("hierarchyLevelNames", names, metadata.getHierarchyLevelNames().toArray()); @@ -255,7 +257,7 @@ public final strictfp class DefaultMetad assertEquals("metadataScopes[1].name", "Golden Gate Bridge", scope.getName().toString()); assertEquals("metadataScopes[1].resourceScope", ScopeCode.FEATURE, scope.getResourceScope()); /* - * Changes in the MetadataScope object shall be relfected immediately on the scope collection. + * Changes in the MetadataScope object shall be reflected immediately on the scope collection. * Verify that. */ it.remove(); @@ -266,6 +268,17 @@ public final strictfp class DefaultMetad assertTrue(scopes.add(c)); assertArrayEquals("hierarchyLevelNames", names, metadata.getHierarchyLevelNames().toArray()); assertArrayEquals("hierarchyLevels", levels, metadata.getHierarchyLevels().toArray()); + /* + * Test the customized equals(Object) and hashCode() implementations. + * Note: the 'assertNotSame' check is not a contract requirement. It is just that if + * 'n1' and 'n2' are the same, then the test become pointless and should be removed. + */ + Collection n1 = metadata.getHierarchyLevelNames(); + Collection n2 = metadata.getHierarchyLevelNames(); + assertNotSame("Remove this test.", n1, n2); // See above comment. + assertTrue("equals", n1.equals(n2)); + assertTrue("equals", n2.equals(n1)); + assertEquals("hashCode", n1.hashCode(), n2.hashCode()); } /** Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant.java?rev=1652466&r1=1652465&r2=1652466&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TimeInstant.java [UTF-8] Fri Jan 16 17:28:38 2015 @@ -16,13 +16,13 @@ */ package org.apache.sis.internal.jaxb.gml; +import java.util.Date; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.datatype.DatatypeConfigurationException; import org.opengis.temporal.Instant; -import org.opengis.temporal.Position; import org.apache.sis.internal.jaxb.Context; import org.apache.sis.internal.jaxb.XmlUtilities; @@ -78,14 +78,14 @@ public final class TimeInstant extends G */ static XMLGregorianCalendar toXML(final Instant instant) { if (instant != null) { - final Position position = instant.getPosition(); - if (position != null) { + final Date date = instant.getDate(); + if (date != null) { final Context context = Context.current(); try { - final XMLGregorianCalendar date = XmlUtilities.toXML(context, position.getDate()); - if (date != null) { - XmlUtilities.trimTime(date, false); - return date; + final XMLGregorianCalendar gc = XmlUtilities.toXML(context, date); + if (gc != null) { + XmlUtilities.trimTime(gc, false); + return gc; } } catch (DatatypeConfigurationException e) { Context.warningOccured(context, TimeInstant.class, "toXML", e, true); Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/TemporalUtilities.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/TemporalUtilities.java?rev=1652466&r1=1652465&r2=1652466&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/TemporalUtilities.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/internal/util/TemporalUtilities.java [UTF-8] Fri Jan 16 17:28:38 2015 @@ -60,7 +60,7 @@ public final class TemporalUtilities ext * Creates an instant for the given date using the given factory. */ private static Instant createInstant(final TemporalFactory factory, final Date date) { - return factory.createInstant(factory.createPosition(date)); + return factory.createInstant(date); } /** Modified: sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/StringBuilders.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/StringBuilders.java?rev=1652466&r1=1652465&r2=1652466&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/StringBuilders.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/main/java/org/apache/sis/util/StringBuilders.java [UTF-8] Fri Jan 16 17:28:38 2015 @@ -212,21 +212,38 @@ public final class StringBuilders extend */ static CharSequence toASCII(CharSequence text, StringBuilder buffer) { if (text != null) { - final int length = text.length(); - for (int i=0; i 0) { + final int c = codePointBefore(text, i); + final int n = charCount(c); final int r = c - 0xC0; - if (r >= 0 && r= 0) { + final char cr; // The character replacement. + if (r < ASCII.length()) { + cr = ASCII.charAt(r); + } else { + switch (getType(c)) { + case SPACE_SEPARATOR: cr = ' '; break; + case PARAGRAPH_SEPARATOR: // Fall through + case LINE_SEPARATOR: cr = '\n'; break; + default: continue; + } + } if (buffer == null) { buffer = new StringBuilder(text.length()).append(text); text = buffer; } - // Nothing special do to about codepoint here, since 'c' is - // in the basic plane (verified by the r getBegunBy() {return Collections.emptySet();} - @Override public Collection getEndedBy() {return Collections.emptySet();} - @Override public Duration length() {return null;} - - /** * Unsupported operations. */ + @Override public Duration length() {throw new UnsupportedOperationException();} @Override public RelativePosition relativePosition(TemporalPrimitive other) {throw new UnsupportedOperationException();} @Override public Duration distance(TemporalGeometricPrimitive other) {throw new UnsupportedOperationException();} + @Override public TemporalPosition getTemporalPosition() {throw new UnsupportedOperationException();} } Modified: sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/util/StringBuildersTest.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/util/StringBuildersTest.java?rev=1652466&r1=1652465&r2=1652466&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/util/StringBuildersTest.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-utility/src/test/java/org/apache/sis/util/StringBuildersTest.java [UTF-8] Fri Jan 16 17:28:38 2015 @@ -97,8 +97,8 @@ public final strictfp class StringBuilde */ @Test public void testToASCII() { - final StringBuilder metre = new StringBuilder("mètre"); + final StringBuilder metre = new StringBuilder("mètres" + Characters.PARAGRAPH_SEPARATOR); toASCII(metre); - assertEquals("metre", metre.toString()); + assertEquals("metres\n", metre.toString()); } }