src/java.base/share/classes/java/util/regex/Pattern.java

Print this page




3850         }
3851         boolean study(TreeInfo info) {
3852             next.study(info);
3853             return info.deterministic;
3854         }
3855     }
3856 
3857     /**
3858      * Node class that matches a Unicode line ending '\R'
3859      */
3860     static final class LineEnding extends Node {
3861         boolean match(Matcher matcher, int i, CharSequence seq) {
3862             // (u+000Du+000A|[u+000Au+000Bu+000Cu+000Du+0085u+2028u+2029])
3863             if (i < matcher.to) {
3864                 int ch = seq.charAt(i);
3865                 if (ch == 0x0A || ch == 0x0B || ch == 0x0C ||
3866                     ch == 0x85 || ch == 0x2028 || ch == 0x2029)
3867                     return next.match(matcher, i + 1, seq);
3868                 if (ch == 0x0D) {
3869                     i++;
3870                     if (i < matcher.to && seq.charAt(i) == 0x0A)
3871                         i++;


3872                     return next.match(matcher, i, seq);
3873                 }
3874             } else {
3875                 matcher.hitEnd = true;
3876             }
3877             return false;
3878         }
3879         boolean study(TreeInfo info) {
3880             info.minLength++;
3881             info.maxLength += 2;
3882             return next.study(info);
3883         }
3884     }
3885 
3886     /**
3887      * Abstract node class to match one character satisfying some
3888      * boolean property.
3889      */
3890     static class CharProperty extends Node {
3891         CharPredicate predicate;




3850         }
3851         boolean study(TreeInfo info) {
3852             next.study(info);
3853             return info.deterministic;
3854         }
3855     }
3856 
3857     /**
3858      * Node class that matches a Unicode line ending '\R'
3859      */
3860     static final class LineEnding extends Node {
3861         boolean match(Matcher matcher, int i, CharSequence seq) {
3862             // (u+000Du+000A|[u+000Au+000Bu+000Cu+000Du+0085u+2028u+2029])
3863             if (i < matcher.to) {
3864                 int ch = seq.charAt(i);
3865                 if (ch == 0x0A || ch == 0x0B || ch == 0x0C ||
3866                     ch == 0x85 || ch == 0x2028 || ch == 0x2029)
3867                     return next.match(matcher, i + 1, seq);
3868                 if (ch == 0x0D) {
3869                     i++;
3870                     if (i < matcher.to && seq.charAt(i) == 0x0A &&
3871                         next.match(matcher, i + 1, seq)) {
3872                         return true;
3873                     }
3874                     return next.match(matcher, i, seq);
3875                 }
3876             } else {
3877                 matcher.hitEnd = true;
3878             }
3879             return false;
3880         }
3881         boolean study(TreeInfo info) {
3882             info.minLength++;
3883             info.maxLength += 2;
3884             return next.study(info);
3885         }
3886     }
3887 
3888     /**
3889      * Abstract node class to match one character satisfying some
3890      * boolean property.
3891      */
3892     static class CharProperty extends Node {
3893         CharPredicate predicate;