918 * folding.
919 * <p>
920 * Specifying this flag may impose a performance penalty. </p>
921 * @since 1.7
922 */
923 public static final int UNICODE_CHARACTER_CLASS = 0x100;
924
925 /**
926 * Contains all possible flags for compile(regex, flags).
927 */
928 private static final int ALL_FLAGS = CASE_INSENSITIVE | MULTILINE |
929 DOTALL | UNICODE_CASE | CANON_EQ | UNIX_LINES | LITERAL |
930 UNICODE_CHARACTER_CLASS | COMMENTS;
931
932 /* Pattern has only two serialized components: The pattern string
933 * and the flags, which are all that is needed to recompile the pattern
934 * when it is deserialized.
935 */
936
937 /** use serialVersionUID from Merlin b59 for interoperability */
938 private static final long serialVersionUID = 5073258162644648461L;
939
940 /**
941 * The original regular-expression pattern string.
942 *
943 * @serial
944 */
945 private String pattern;
946
947 /**
948 * The original pattern flags.
949 *
950 * @serial
951 */
952 private int flags;
953
954 /**
955 * The temporary pattern flags used during compiling. The flags might be turn
956 * on and off by embedded flag.
957 */
1359 (lenHint << 1) : (Integer.MAX_VALUE - 8);
1360
1361 StringBuilder sb = new StringBuilder(lenHint);
1362 sb.append("\\Q");
1363 int current = 0;
1364 do {
1365 sb.append(s, current, slashEIndex)
1366 .append("\\E\\\\E\\Q");
1367 current = slashEIndex + 2;
1368 } while ((slashEIndex = s.indexOf("\\E", current)) != -1);
1369
1370 return sb.append(s, current, s.length())
1371 .append("\\E")
1372 .toString();
1373 }
1374
1375 /**
1376 * Recompile the Pattern instance from a stream. The original pattern
1377 * string is read in and the object tree is recompiled from it.
1378 */
1379 private void readObject(java.io.ObjectInputStream s)
1380 throws java.io.IOException, ClassNotFoundException {
1381
1382 // Read in all fields
1383 s.defaultReadObject();
1384
1385 // reset the flags
1386 flags0 = flags;
1387
1388 // Initialize counts
1389 capturingGroupCount = 1;
1390 localCount = 0;
1391 localTCNCount = 0;
1392
1393 // if length > 0, the Pattern is lazily compiled
1394 if (pattern.isEmpty()) {
1395 root = new Start(lastAccept);
1396 matchRoot = lastAccept;
1397 compiled = true;
1398 }
|
918 * folding.
919 * <p>
920 * Specifying this flag may impose a performance penalty. </p>
921 * @since 1.7
922 */
923 public static final int UNICODE_CHARACTER_CLASS = 0x100;
924
925 /**
926 * Contains all possible flags for compile(regex, flags).
927 */
928 private static final int ALL_FLAGS = CASE_INSENSITIVE | MULTILINE |
929 DOTALL | UNICODE_CASE | CANON_EQ | UNIX_LINES | LITERAL |
930 UNICODE_CHARACTER_CLASS | COMMENTS;
931
932 /* Pattern has only two serialized components: The pattern string
933 * and the flags, which are all that is needed to recompile the pattern
934 * when it is deserialized.
935 */
936
937 /** use serialVersionUID from Merlin b59 for interoperability */
938 @java.io.Serial
939 private static final long serialVersionUID = 5073258162644648461L;
940
941 /**
942 * The original regular-expression pattern string.
943 *
944 * @serial
945 */
946 private String pattern;
947
948 /**
949 * The original pattern flags.
950 *
951 * @serial
952 */
953 private int flags;
954
955 /**
956 * The temporary pattern flags used during compiling. The flags might be turn
957 * on and off by embedded flag.
958 */
1360 (lenHint << 1) : (Integer.MAX_VALUE - 8);
1361
1362 StringBuilder sb = new StringBuilder(lenHint);
1363 sb.append("\\Q");
1364 int current = 0;
1365 do {
1366 sb.append(s, current, slashEIndex)
1367 .append("\\E\\\\E\\Q");
1368 current = slashEIndex + 2;
1369 } while ((slashEIndex = s.indexOf("\\E", current)) != -1);
1370
1371 return sb.append(s, current, s.length())
1372 .append("\\E")
1373 .toString();
1374 }
1375
1376 /**
1377 * Recompile the Pattern instance from a stream. The original pattern
1378 * string is read in and the object tree is recompiled from it.
1379 */
1380 @java.io.Serial
1381 private void readObject(java.io.ObjectInputStream s)
1382 throws java.io.IOException, ClassNotFoundException {
1383
1384 // Read in all fields
1385 s.defaultReadObject();
1386
1387 // reset the flags
1388 flags0 = flags;
1389
1390 // Initialize counts
1391 capturingGroupCount = 1;
1392 localCount = 0;
1393 localTCNCount = 0;
1394
1395 // if length > 0, the Pattern is lazily compiled
1396 if (pattern.isEmpty()) {
1397 root = new Start(lastAccept);
1398 matchRoot = lastAccept;
1399 compiled = true;
1400 }
|