Commenting out extra-adventurous methods in String emul
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Sat, 29 Sep 2012 08:26:30 +0200
branchemul
changeset 6455745bf6696c
parent 63 032f4064b2a7
child 65 f99a92839285
Commenting out extra-adventurous methods in String
emul/src/main/java/java/lang/String.java
     1.1 --- a/emul/src/main/java/java/lang/String.java	Sat Sep 29 08:18:39 2012 +0200
     1.2 +++ b/emul/src/main/java/java/lang/String.java	Sat Sep 29 08:26:30 2012 +0200
     1.3 @@ -28,9 +28,6 @@
     1.4  import java.io.ObjectStreamField;
     1.5  import java.io.UnsupportedEncodingException;
     1.6  import java.util.Comparator;
     1.7 -import java.util.regex.Matcher;
     1.8 -import java.util.regex.Pattern;
     1.9 -import java.util.regex.PatternSyntaxException;
    1.10  
    1.11  /**
    1.12   * The <code>String</code> class represents character strings. All
    1.13 @@ -2108,7 +2105,7 @@
    1.14       * @spec JSR-51
    1.15       */
    1.16      public boolean matches(String regex) {
    1.17 -        return Pattern.matches(regex, this);
    1.18 +        throw new UnsupportedOperationException();
    1.19      }
    1.20  
    1.21      /**
    1.22 @@ -2164,7 +2161,7 @@
    1.23       * @spec JSR-51
    1.24       */
    1.25      public String replaceFirst(String regex, String replacement) {
    1.26 -        return Pattern.compile(regex).matcher(this).replaceFirst(replacement);
    1.27 +        throw new UnsupportedOperationException();
    1.28      }
    1.29  
    1.30      /**
    1.31 @@ -2207,7 +2204,7 @@
    1.32       * @spec JSR-51
    1.33       */
    1.34      public String replaceAll(String regex, String replacement) {
    1.35 -        return Pattern.compile(regex).matcher(this).replaceAll(replacement);
    1.36 +        throw new UnsupportedOperationException();
    1.37      }
    1.38  
    1.39      /**
    1.40 @@ -2225,8 +2222,7 @@
    1.41       * @since 1.5
    1.42       */
    1.43      public String replace(CharSequence target, CharSequence replacement) {
    1.44 -        return Pattern.compile(target.toString(), Pattern.LITERAL).matcher(
    1.45 -            this).replaceAll(Matcher.quoteReplacement(replacement.toString()));
    1.46 +        throw new UnsupportedOperationException("This one should be supported, but without dep on rest of regexp");
    1.47      }
    1.48  
    1.49      /**
    1.50 @@ -2310,55 +2306,7 @@
    1.51       * @spec JSR-51
    1.52       */
    1.53      public String[] split(String regex, int limit) {
    1.54 -        /* fastpath if the regex is a
    1.55 -           (1)one-char String and this character is not one of the
    1.56 -              RegEx's meta characters ".$|()[{^?*+\\", or
    1.57 -           (2)two-char String and the first char is the backslash and
    1.58 -              the second is not the ascii digit or ascii letter.
    1.59 -        */
    1.60 -        char ch = 0;
    1.61 -        if (((regex.count == 1 &&
    1.62 -             ".$|()[{^?*+\\".indexOf(ch = regex.charAt(0)) == -1) ||
    1.63 -             (regex.length() == 2 &&
    1.64 -              regex.charAt(0) == '\\' &&
    1.65 -              (((ch = regex.charAt(1))-'0')|('9'-ch)) < 0 &&
    1.66 -              ((ch-'a')|('z'-ch)) < 0 &&
    1.67 -              ((ch-'A')|('Z'-ch)) < 0)) &&
    1.68 -            (ch < Character.MIN_HIGH_SURROGATE ||
    1.69 -             ch > Character.MAX_LOW_SURROGATE))
    1.70 -        {/*
    1.71 -            int off = 0;
    1.72 -            int next = 0;
    1.73 -            boolean limited = limit > 0;
    1.74 -            ArrayList<String> list = new ArrayList<String>();
    1.75 -            while ((next = indexOf(ch, off)) != -1) {
    1.76 -                if (!limited || list.size() < limit - 1) {
    1.77 -                    list.add(substring(off, next));
    1.78 -                    off = next + 1;
    1.79 -                } else {    // last one
    1.80 -                    //assert (list.size() == limit - 1);
    1.81 -                    list.add(substring(off, count));
    1.82 -                    off = count;
    1.83 -                    break;
    1.84 -                }
    1.85 -            }
    1.86 -            // If no match was found, return this
    1.87 -            if (off == 0)
    1.88 -                return new String[] { this };
    1.89 -
    1.90 -            // Add remaining segment
    1.91 -            if (!limited || list.size() < limit)
    1.92 -                list.add(substring(off, count));
    1.93 -
    1.94 -            // Construct result
    1.95 -            int resultSize = list.size();
    1.96 -            if (limit == 0)
    1.97 -                while (resultSize > 0 && list.get(resultSize-1).length() == 0)
    1.98 -                    resultSize--;
    1.99 -            String[] result = new String[resultSize];
   1.100 -            return list.subList(0, resultSize).toArray(result);
   1.101 -        */}
   1.102 -        return Pattern.compile(regex).split(this, limit);
   1.103 +        throw new UnsupportedOperationException("Needs regexp");
   1.104      }
   1.105  
   1.106      /**
   1.107 @@ -2569,7 +2517,7 @@
   1.108       * @see     java.lang.String#toLowerCase(Locale)
   1.109       */
   1.110      public String toLowerCase() {
   1.111 -        return toLowerCase(Locale.getDefault());
   1.112 +        throw new UnsupportedOperationException("Should be supported but without connection to locale");
   1.113      }
   1.114  
   1.115      /**
   1.116 @@ -2844,7 +2792,7 @@
   1.117       * @since  1.5
   1.118       */
   1.119      public static String format(String format, Object ... args) {
   1.120 -        return new Formatter().format(format, args).toString();
   1.121 +        throw new UnsupportedOperationException();
   1.122      }
   1.123  
   1.124      /**