sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1420226 - in /sis/branches/JDK7/sis-utility/src: main/java/org/apache/sis/internal/jaxb/ main/java/org/apache/sis/internal/jaxb/gmd/ main/java/org/apache/sis/io/ main/java/org/apache/sis/measure/ main/java/org/apache/sis/util/ main/java/or...
Date Tue, 11 Dec 2012 15:36:04 GMT
Author: desruisseaux
Date: Tue Dec 11 15:35:48 2012
New Revision: 1420226

URL: http://svn.apache.org/viewvc?rev=1420226&view=rev
Log:
Minor adjustment in StringBuilder initial capacity (more realist value when we can, rely on
default otherwise).
Removed a unecessary null check in Classes static method (invoked method shall never return
null).

Modified:
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/SpecializedIdentifier.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListProxy.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/TextGroup.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/io/LineFormatter.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/Angle.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Classes.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java
    sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/XLink.java
    sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/measure/AngleFormatTest.java

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java?rev=1420226&r1=1420225&r2=1420226&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java
(original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/IdentifierMapAdapter.java
Tue Dec 11 15:35:48 2012
@@ -536,10 +536,19 @@ public class IdentifierMapAdapter extend
      * Overrides the string representation in order to use only the authority title as keys.
      * We do that because the string representations of {@code DefaultCitation} objects are
      * very big.
+     *
+     * <p>String examples:</p>
+     * <ul>
+     *   <li>{gml:id=“myID”}</li>
+     *   <li>{gco:uuid=“42924124-032a-4dfe-b06e-113e3cb81cf0”}</li>
+     *   <li>{xlink:href=“http://www.mydomain.org/myHREF”}</li>
+     * </ul>
+     *
+     * @see SpecializedIdentifier#toString()
      */
     @Override
     public String toString() {
-	final StringBuilder buffer = new StringBuilder(100).append('{');
+	final StringBuilder buffer = new StringBuilder(50).append('{');
 	for (final Entry<Citation,String> entry : entrySet()) {
 	    if (buffer.length() != 1) {
                 buffer.append(", ");

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/SpecializedIdentifier.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/SpecializedIdentifier.java?rev=1420226&r1=1420225&r2=1420226&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/SpecializedIdentifier.java
(original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/SpecializedIdentifier.java
Tue Dec 11 15:35:48 2012
@@ -197,10 +197,13 @@ public final class SpecializedIdentifier
 
     /**
      * Returns a string representation of this identifier.
+     * Example: {@code Identifier[gco:uuid=“42924124-032a-4dfe-b06e-113e3cb81cf0”]}.
+     *
+     * @see IdentifierMapAdapter#toString()
      */
     @Override
     public String toString() {
-        final StringBuilder buffer = new StringBuilder("Identifier[");
+        final StringBuilder buffer = new StringBuilder(60).append("Identifier[");
         format(buffer, authority, getCode());
         return buffer.append(']').toString();
     }

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListProxy.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListProxy.java?rev=1420226&r1=1420225&r2=1420226&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListProxy.java
(original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/CodeListProxy.java
Tue Dec 11 15:35:48 2012
@@ -61,6 +61,13 @@ public final class CodeListProxy {
     /**
      * Returns the URL to a given code list in the given XML file. This method concatenates
      * the base schema URL with the given directory, file and identifier.
+     * Some examples of strings returned by this method are:
+     *
+     * <ul>
+     *   <li>{@code "http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/ML_gmxCodelists.xml#LanguageCode"}</li>
+     *   <li>{@code "http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#MD_CharacterSetCode"}</li>
+     *   <li>{@code "http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#CI_OnLineFunctionCode"}</li>
+     * </ul>
      *
      * @param  schema     The schema, typically as a result of a call to
      *                    {@link MarshalContext#schema(MarshalContext, String, String)}.

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java?rev=1420226&r1=1420225&r2=1420226&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java
(original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/LocalisedCharacterString.java
Tue Dec 11 15:35:48 2012
@@ -125,13 +125,20 @@ final class LocalisedCharacterString {
 
     /**
      * Returns a string representation of this object for debugging purpose.
+     * Example:
+     *
+     * {@preformat
+     *   LocalisedCharacterString[#locale-fra, “Un texte”]
+     * }
+     *
+     * @see TextGroup#toString()
      */
     @Override
     public String toString() {
-        final StringBuilder buffer = new StringBuilder(getClass().getSimpleName())
-                .append('[').append(getLocale());
+        final StringBuilder buffer = new StringBuilder(80)
+                .append(getClass().getSimpleName()).append('[').append(getLocale());
         if (text != null) {
-            buffer.append(", \"").append(text).append('"');
+            buffer.append(", “").append(text).append('”');
         }
         return buffer.append(']').toString();
     }

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/TextGroup.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/TextGroup.java?rev=1420226&r1=1420225&r2=1420226&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/TextGroup.java
(original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/TextGroup.java
Tue Dec 11 15:35:48 2012
@@ -110,10 +110,12 @@ final class TextGroup {
 
     /**
      * Returns a string representation of this text group for debugging purpose.
+     *
+     * @see LocalisedCharacterString#toString()
      */
     @Override
     public String toString() {
-        final StringBuilder buffer = new StringBuilder(getClass().getSimpleName());
+        final StringBuilder buffer = new StringBuilder(160).append(getClass().getSimpleName());
         if (localized != null) {
             final String lineSeparator = System.lineSeparator();
             for (LocalisedCharacterString string : localized) {

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/io/LineFormatter.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/io/LineFormatter.java?rev=1420226&r1=1420225&r2=1420226&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/io/LineFormatter.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/io/LineFormatter.java Tue Dec
11 15:35:48 2012
@@ -137,7 +137,7 @@ public class LineFormatter extends Filte
      * stream before the non-ignorable one. Otherwise if whitespaces are followed by a line
      * separator, then they are discarded.
      */
-    private final StringBuilder buffer = new StringBuilder(16);
+    private final StringBuilder buffer = new StringBuilder();
 
     /**
      * The number of Java characters (not Unicode code points) in {@link #buffer},

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/Angle.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/Angle.java?rev=1420226&r1=1420225&r2=1420226&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/Angle.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/Angle.java Tue Dec
11 15:35:48 2012
@@ -199,7 +199,7 @@ public class Angle implements Comparable
      */
     @Override
     public String toString() {
-        StringBuffer buffer = new StringBuffer(16);
+        StringBuffer buffer = new StringBuffer();
         double m = Math.abs(θ);
         final boolean isSmall = m <= (1 / 3600E+3); // 1E-3 arc-second.
         if (isSmall || m > maximum()) {
@@ -281,7 +281,7 @@ public class Angle implements Comparable
             if (precision > 0) {
                 format.setMaximumWidth(precision);
             }
-            value = format.format(this, new StringBuffer(16), null).toString();
+            value = format.format(this, new StringBuffer(), null).toString();
         }
         org.apache.sis.internal.util.Utilities.formatTo(formatter, flags, width, value);
     }

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java?rev=1420226&r1=1420225&r2=1420226&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/measure/AngleFormat.java Tue
Dec 11 15:35:48 2012
@@ -559,7 +559,7 @@ scan:   for (int i=0; i<length;) {
      */
     private String toPattern(final char[] symbols, final int decimalSeparator) {
         char symbol = 0;
-        final StringBuilder buffer = new StringBuilder(12);
+        final StringBuilder buffer = new StringBuilder();
         for (int field=DEGREES_FIELD; field<=FRACTION_FIELD; field++) {
             final String previousSuffix;
             int width;
@@ -781,7 +781,7 @@ scan:   for (int i=0; i<length;) {
      * @return The formatted string.
      */
     public final String format(final double angle) {
-        return format(angle, new StringBuffer(20), null).toString();
+        return format(angle, new StringBuffer(), null).toString();
     }
 
     /**
@@ -1053,7 +1053,7 @@ scan:   for (int i=0; i<length;) {
      */
     @Override
     public AttributedCharacterIterator formatToCharacterIterator(final Object value) {
-        final StringBuffer buffer = new StringBuffer(20);
+        final StringBuffer buffer = new StringBuffer();
         final FormattedCharacterIterator it = new FormattedCharacterIterator(buffer);
         try {
             characterIterator = it;

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Classes.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Classes.java?rev=1420226&r1=1420225&r2=1420226&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Classes.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/Classes.java Tue Dec 11
15:35:48 2012
@@ -544,17 +544,15 @@ next:       for (final Class<?> candidat
          * For each interface in the 'c1' array, check if
          * this interface exists also in the 'c2' array.
          */
-        int n = (c2 != null) ? c2.length : 0;
-        if (c1 != null) {
-compare:    for (final Class<?> c : c1) {
-                for (int j=n; --j>=0;) {
-                    if (c == c2[j]) {
-                        System.arraycopy(c2, j+1, c2, j, --n-j);
-                        continue compare;
-                    }
+        int n = c2.length;
+cmp:    for (final Class<?> c : c1) {
+            for (int j=n; --j>=0;) {
+                if (c == c2[j]) {
+                    System.arraycopy(c2, j+1, c2, j, --n-j);
+                    continue cmp;
                 }
-                return false; // Interface not found in 'c2'.
             }
+            return false; // Interface not found in 'c2'.
         }
         return n == 0; // If n>0, at least one interface was not found in 'c1'.
     }

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java?rev=1420226&r1=1420225&r2=1420226&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/util/logging/Logging.java Tue
Dec 11 15:35:48 2012
@@ -548,7 +548,7 @@ public final class Logging extends Stati
          * because in a client-server architecture, we want the locale on the server-side
instead
          * than the locale on the client side.
          */
-        final StringBuilder buffer = new StringBuilder(Classes.getShortClassName(error));
+        final StringBuilder buffer = new StringBuilder(256).append(Classes.getShortClassName(error));
         String message = error.getMessage(); // Targeted to system administrators.
         if (message != null) {
             buffer.append(": ").append(message);

Modified: sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/XLink.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/XLink.java?rev=1420226&r1=1420225&r2=1420226&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/XLink.java (original)
+++ sis/branches/JDK7/sis-utility/src/main/java/org/apache/sis/xml/XLink.java Tue Dec 11 15:35:48
2012
@@ -839,7 +839,7 @@ public class XLink implements Serializab
      */
     @Override
     public synchronized String toString() {
-        final StringBuilder buffer = new StringBuilder(32);
+        final StringBuilder buffer = new StringBuilder(64);
         buffer.append(Classes.getShortClassName(this)).append('[');
         append(buffer, "type",    getType());
         append(buffer, "href",    getHRef());

Modified: sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/measure/AngleFormatTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/measure/AngleFormatTest.java?rev=1420226&r1=1420225&r2=1420226&view=diff
==============================================================================
--- sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/measure/AngleFormatTest.java
(original)
+++ sis/branches/JDK7/sis-utility/src/test/java/org/apache/sis/measure/AngleFormatTest.java
Tue Dec 11 15:35:48 2012
@@ -210,7 +210,7 @@ public final strictfp class AngleFormatT
     public void testFieldPosition() {
         final Latitude latitude = new Latitude(FormattedCharacterIteratorTest.LATITUDE_VALUE);
         final AngleFormat f = new AngleFormat("DD°MM′SS.s″", Locale.CANADA);
-        final StringBuffer buffer = new StringBuffer(12);
+        final StringBuffer buffer = new StringBuffer();
         for (int i=AngleFormat.DEGREES_FIELD; i<=AngleFormat.HEMISPHERE_FIELD; i++) {
             final AngleFormat.Field field;
             final int start, limit;



Mime
View raw message