ReExp builds on top of mini emul Character
authorJaroslav Tulach <jtulach@netbeans.org>
Mon, 07 Oct 2013 16:17:21 +0200
changeset 1350f14e9730d4e9
parent 1349 7df5f83fff8d
child 1353 e0b7e23a1ff2
child 1355 ae20214a816c
ReExp builds on top of mini emul Character
rt/emul/compact/src/main/java/java/util/regex/Pattern.java
rt/emul/compact/src/main/java/java/util/regex/PatternSyntaxException.java
rt/emul/mini/src/main/java/java/lang/Character.java
     1.1 --- a/rt/emul/compact/src/main/java/java/util/regex/Pattern.java	Mon Oct 07 16:14:56 2013 +0200
     1.2 +++ b/rt/emul/compact/src/main/java/java/util/regex/Pattern.java	Mon Oct 07 16:17:21 2013 +0200
     1.3 @@ -25,10 +25,6 @@
     1.4  
     1.5  package java.util.regex;
     1.6  
     1.7 -import java.security.AccessController;
     1.8 -import java.security.PrivilegedAction;
     1.9 -import java.text.CharacterIterator;
    1.10 -import java.text.Normalizer;
    1.11  import java.util.Locale;
    1.12  import java.util.Map;
    1.13  import java.util.ArrayList;
    1.14 @@ -1350,7 +1346,7 @@
    1.15          int lastCodePoint = -1;
    1.16  
    1.17          // Convert pattern into normalizedD form
    1.18 -        normalizedPattern = Normalizer.normalize(pattern, Normalizer.Form.NFD);
    1.19 +        normalizedPattern = Normalizer.normalize(pattern, Normalizer.NFD);
    1.20          patternLength = normalizedPattern.length();
    1.21  
    1.22          // Modify pattern to match canonical equivalences
    1.23 @@ -1541,7 +1537,7 @@
    1.24      }
    1.25  
    1.26      private int getClass(int c) {
    1.27 -        return sun.text.Normalizer.getCombiningClass(c);
    1.28 +        return Normalizer.getCombiningClass(c);
    1.29      }
    1.30  
    1.31      /**
    1.32 @@ -1554,7 +1550,7 @@
    1.33      private String composeOneStep(String input) {
    1.34          int len = countChars(input, 0, 2);
    1.35          String firstTwoCharacters = input.substring(0, len);
    1.36 -        String result = Normalizer.normalize(firstTwoCharacters, Normalizer.Form.NFC);
    1.37 +        String result = Normalizer.normalize(firstTwoCharacters, Normalizer.NFC);
    1.38  
    1.39          if (result.equals(firstTwoCharacters))
    1.40              return null;
    1.41 @@ -2651,18 +2647,18 @@
    1.42              // property construct \p{name=value}
    1.43              String value = name.substring(i + 1);
    1.44              name = name.substring(0, i).toLowerCase(Locale.ENGLISH);
    1.45 -            if ("sc".equals(name) || "script".equals(name)) {
    1.46 +    /*        if ("sc".equals(name) || "script".equals(name)) {
    1.47                  node = unicodeScriptPropertyFor(value);
    1.48              } else if ("blk".equals(name) || "block".equals(name)) {
    1.49                  node = unicodeBlockPropertyFor(value);
    1.50 -            } else if ("gc".equals(name) || "general_category".equals(name)) {
    1.51 +            } else*/ if ("gc".equals(name) || "general_category".equals(name)) {
    1.52                  node = charPropertyNodeFor(value);
    1.53              } else {
    1.54                  throw error("Unknown Unicode property {name=<" + name + ">, "
    1.55                               + "value=<" + value + ">}");
    1.56              }
    1.57          } else {
    1.58 -            if (name.startsWith("In")) {
    1.59 +            /*if (name.startsWith("In")) {
    1.60                  // \p{inBlockName}
    1.61                  node = unicodeBlockPropertyFor(name.substring(2));
    1.62              } else if (name.startsWith("Is")) {
    1.63 @@ -2675,7 +2671,7 @@
    1.64                      node = CharPropertyNames.charPropertyFor(name);
    1.65                  if (node == null)
    1.66                      node = unicodeScriptPropertyFor(name);
    1.67 -            } else {
    1.68 +            } else*/ {
    1.69                  if (has(UNICODE_CHARACTER_CLASS)) {
    1.70                      UnicodeProp uprop = UnicodeProp.forPOSIXName(name);
    1.71                      if (uprop != null)
    1.72 @@ -2686,7 +2682,7 @@
    1.73              }
    1.74          }
    1.75          if (maybeComplement) {
    1.76 -            if (node instanceof Category || node instanceof Block)
    1.77 +            if (node instanceof Category /*|| node instanceof Block*/)
    1.78                  hasSupplementary = true;
    1.79              node = node.complement();
    1.80          }
    1.81 @@ -2697,7 +2693,7 @@
    1.82      /**
    1.83       * Returns a CharProperty matching all characters belong to
    1.84       * a UnicodeScript.
    1.85 -     */
    1.86 +     *
    1.87      private CharProperty unicodeScriptPropertyFor(String name) {
    1.88          final Character.UnicodeScript script;
    1.89          try {
    1.90 @@ -2710,7 +2706,7 @@
    1.91  
    1.92      /**
    1.93       * Returns a CharProperty matching all characters in a UnicodeBlock.
    1.94 -     */
    1.95 +     *
    1.96      private CharProperty unicodeBlockPropertyFor(String name) {
    1.97          final Character.UnicodeBlock block;
    1.98          try {
    1.99 @@ -3775,7 +3771,7 @@
   1.100  
   1.101      /**
   1.102       * Node class that matches a Unicode block.
   1.103 -     */
   1.104 +     *
   1.105      static final class Block extends CharProperty {
   1.106          final Character.UnicodeBlock block;
   1.107          Block(Character.UnicodeBlock block) {
   1.108 @@ -3788,7 +3784,7 @@
   1.109  
   1.110      /**
   1.111       * Node class that matches a Unicode script
   1.112 -     */
   1.113 +     *
   1.114      static final class Script extends CharProperty {
   1.115          final Character.UnicodeScript script;
   1.116          Script(Character.UnicodeScript script) {
   1.117 @@ -5645,4 +5641,17 @@
   1.118                      return Character.isMirrored(ch);}});
   1.119          }
   1.120      }
   1.121 +    
   1.122 +    private static final class Normalizer {
   1.123 +        public static final int NFD = 1;
   1.124 +        public static final int NFC = 2;
   1.125 +
   1.126 +        static String normalize(String pattern, int NFD) {
   1.127 +            return pattern;
   1.128 +        }
   1.129 +
   1.130 +        private static int getCombiningClass(int c) {
   1.131 +            return 1;
   1.132 +        }
   1.133 +    }
   1.134  }
     2.1 --- a/rt/emul/compact/src/main/java/java/util/regex/PatternSyntaxException.java	Mon Oct 07 16:14:56 2013 +0200
     2.2 +++ b/rt/emul/compact/src/main/java/java/util/regex/PatternSyntaxException.java	Mon Oct 07 16:17:21 2013 +0200
     2.3 @@ -25,9 +25,6 @@
     2.4  
     2.5  package java.util.regex;
     2.6  
     2.7 -import sun.security.action.GetPropertyAction;
     2.8 -
     2.9 -
    2.10  /**
    2.11   * Unchecked exception thrown to indicate a syntax error in a
    2.12   * regular-expression pattern.
    2.13 @@ -93,9 +90,7 @@
    2.14          return pattern;
    2.15      }
    2.16  
    2.17 -    private static final String nl =
    2.18 -        java.security.AccessController
    2.19 -            .doPrivileged(new GetPropertyAction("line.separator"));
    2.20 +    private static final String nl = System.lineSeparator();
    2.21  
    2.22      /**
    2.23       * Returns a multi-line string containing the description of the syntax
     3.1 --- a/rt/emul/mini/src/main/java/java/lang/Character.java	Mon Oct 07 16:14:56 2013 +0200
     3.2 +++ b/rt/emul/mini/src/main/java/java/lang/Character.java	Mon Oct 07 16:17:21 2013 +0200
     3.3 @@ -572,6 +572,46 @@
     3.4       */
     3.5      public static final int MAX_CODE_POINT = 0X10FFFF;
     3.6  
     3.7 +    public static boolean isAlphabetic(int ch) {
     3.8 +        throw new UnsupportedOperationException("isAlphabetic: " + (char)ch);
     3.9 +    }
    3.10 +
    3.11 +    public static boolean isIdeographic(int ch) {
    3.12 +        throw new UnsupportedOperationException("isIdeographic: " + (char)ch);
    3.13 +    }
    3.14 +
    3.15 +    public static boolean isLowerCase(int ch) {
    3.16 +        throw new UnsupportedOperationException("isLowerCase: " + (char)ch);
    3.17 +    }
    3.18 +
    3.19 +    public static boolean isUpperCase(int ch) {
    3.20 +        throw new UnsupportedOperationException("isUpperCase: " + (char)ch);
    3.21 +    }
    3.22 +
    3.23 +    public static boolean isMirrored(int ch) {
    3.24 +        throw new UnsupportedOperationException("isMirrored: " + (char)ch);
    3.25 +    }
    3.26 +
    3.27 +    public static boolean isIdentifierIgnorable(int ch) {
    3.28 +        throw new UnsupportedOperationException("isIdentifierIgnorable: " + (char)ch);
    3.29 +    }
    3.30 +
    3.31 +    public static boolean isUnicodeIdentifierPart(int ch) {
    3.32 +        throw new UnsupportedOperationException("isUnicodeIdentifierPart: " + (char)ch);
    3.33 +    }
    3.34 +
    3.35 +    public static boolean isUnicodeIdentifierStart(int ch) {
    3.36 +        throw new UnsupportedOperationException("isUnicodeIdentifierStart: " + (char)ch);
    3.37 +    }
    3.38 +
    3.39 +    public static char toUpperCase(int ch) {
    3.40 +        throw new UnsupportedOperationException("toUpperCase: " + (char)ch);
    3.41 +    }
    3.42 +
    3.43 +    public static int toLowerCase(int ch) {
    3.44 +        throw new UnsupportedOperationException("toLowerCase: " + (char)ch);
    3.45 +    }
    3.46 +
    3.47  
    3.48      /**
    3.49       * Instances of this class represent particular subsets of the Unicode
    3.50 @@ -1892,8 +1932,8 @@
    3.51          return fromCodeChars(codePoint).matches("\\w");
    3.52      }
    3.53      
    3.54 -    static int getType(int x) {
    3.55 -        throw new UnsupportedOperationException();
    3.56 +    public static int getType(int x) {
    3.57 +        throw new UnsupportedOperationException("getType: " + (char)x);
    3.58      }
    3.59   
    3.60      /**