< prev index next >

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

Print this page

 227 
 228     /**
 229      * Number of times this matcher's state has been modified
 230      */
 231     int modCount;
 232 
 233     /**
 234      * No default constructor.
 235      */
 236     Matcher() {
 237     }
 238 
 239     /**
 240      * All matchers have the state used by Pattern during a match.
 241      */
 242     Matcher(Pattern parent, CharSequence text) {
 243         this.parentPattern = parent;
 244         this.text = text;
 245 
 246         // Allocate state storage
 247         int parentGroupCount = Math.max(parent.capturingGroupCount, 10);
 248         groups = new int[parentGroupCount * 2];



 249         locals = new int[parent.localCount];
 250         localsPos = new IntHashSet[parent.localTCNCount];
 251 
 252         // Put fields into initial states
 253         reset();
 254     }
 255 
 256     /**
 257      * Returns the pattern that is interpreted by this matcher.
 258      *
 259      * @return  The pattern for which this matcher was created
 260      */
 261     public Pattern pattern() {
 262         return parentPattern;
 263     }
 264 
 265     /**
 266      * Returns the match state of this matcher as a {@link MatchResult}.
 267      * The result is unaffected by subsequent operations performed upon this
 268      * matcher.

 227 
 228     /**
 229      * Number of times this matcher's state has been modified
 230      */
 231     int modCount;
 232 
 233     /**
 234      * No default constructor.
 235      */
 236     Matcher() {
 237     }
 238 
 239     /**
 240      * All matchers have the state used by Pattern during a match.
 241      */
 242     Matcher(Pattern parent, CharSequence text) {
 243         this.parentPattern = parent;
 244         this.text = text;
 245 
 246         // Allocate state storage
 247         if (parent.capturingGroupCount > 10) {
 248             groups = new int[parent.capturingGroupCount * 2];
 249         } else {
 250             groups = new int[20];
 251         }
 252         locals = new int[parent.localCount];
 253         localsPos = new IntHashSet[parent.localTCNCount];
 254 
 255         // Put fields into initial states
 256         reset();
 257     }
 258 
 259     /**
 260      * Returns the pattern that is interpreted by this matcher.
 261      *
 262      * @return  The pattern for which this matcher was created
 263      */
 264     public Pattern pattern() {
 265         return parentPattern;
 266     }
 267 
 268     /**
 269      * Returns the match state of this matcher as a {@link MatchResult}.
 270      * The result is unaffected by subsequent operations performed upon this
 271      * matcher.
< prev index next >