sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1454583 - in /sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis: internal/converter/SurjectiveConverter.java internal/util/SurjectiveConverter.java measure/FormattedCharacterIterator.java
Date Fri, 08 Mar 2013 21:27:44 GMT
Author: desruisseaux
Date: Fri Mar  8 21:27:44 2013
New Revision: 1454583

URL: http://svn.apache.org/r1454583
Log:
Moved SurjectiveConverter to org.apache.sis.internal.converter package.

Added:
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/SurjectiveConverter.java
      - copied, changed from r1454130, sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/SurjectiveConverter.java
Removed:
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/SurjectiveConverter.java
Modified:
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/FormattedCharacterIterator.java

Copied: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/SurjectiveConverter.java
(from r1454130, sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/SurjectiveConverter.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/SurjectiveConverter.java?p2=sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/SurjectiveConverter.java&p1=sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/SurjectiveConverter.java&r1=1454130&r2=1454583&rev=1454583&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/util/SurjectiveConverter.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/converter/SurjectiveConverter.java
[UTF-8] Fri Mar  8 21:27:44 2013
@@ -14,12 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.internal.util;
+package org.apache.sis.internal.converter;
 
 import java.util.Set;
 import java.util.EnumSet;
 import org.apache.sis.util.ObjectConverter;
 import org.apache.sis.math.FunctionProperty;
+import org.apache.sis.util.Classes;
 import org.apache.sis.util.resources.Errors;
 
 
@@ -49,7 +50,8 @@ public abstract class SurjectiveConverte
     }
 
     /**
-     * Returns the function property, which contains only {@link FunctionProperty#SURJECTIVE}.
+     * Returns {@link FunctionProperty#SURJECTIVE} by default.
+     * Subclasses may add more properties (order preserving, <i>etc.</i>).
      */
     @Override
     public Set<FunctionProperty> properties() {
@@ -57,11 +59,32 @@ public abstract class SurjectiveConverte
     }
 
     /**
-     * Unsupported operation, since surjective converters are non-invertible.
+     * Unsupported operation, since surjective converters are non-invertible
+     * (unless the converter is bijective, which is decided by subclasses).
      */
     @Override
     public ObjectConverter<T,S> inverse() throws UnsupportedOperationException {
         throw new UnsupportedOperationException(Errors.format(
                 Errors.Keys.UnsupportedOperation_1, "inverse"));
     }
+
+    /**
+     * Formats an error message for a value that can not be converted.
+     *
+     * @param  value The value that can not be converted.
+     * @return The error message.
+     */
+    final String formatErrorMessage(final S value) {
+        return Errors.format(Errors.Keys.CanNotConvertValue_2, value, getTargetClass());
+    }
+
+    /**
+     * Returns a string representation of this converter for debugging purpose.
+     */
+    @Override
+    public String toString() {
+        return Classes.getShortClassName(this) + '[' +
+                getSourceClass().getSimpleName() + " ⇨ " +
+                getTargetClass().getSimpleName() + ']';
+    }
 }

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/FormattedCharacterIterator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/FormattedCharacterIterator.java?rev=1454583&r1=1454582&r2=1454583&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/FormattedCharacterIterator.java
[UTF-8] (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/FormattedCharacterIterator.java
[UTF-8] Fri Mar  8 21:27:44 2013
@@ -27,7 +27,7 @@ import java.text.Format;
 import java.text.AttributedCharacterIterator;
 import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.collection.CollectionsExt;
-import org.apache.sis.internal.util.SurjectiveConverter;
+import org.apache.sis.internal.converter.SurjectiveConverter;
 import org.apache.sis.internal.simple.SimpleCharacterIterator;
 
 



Mime
View raw message