Region.java revision 953:221a84ef44c0
12322Sdg/* 22322Sdg * Permission is hereby granted, free of charge, to any person obtaining a copy of 32322Sdg * this software and associated documentation files (the "Software"), to deal in 42322Sdg * the Software without restriction, including without limitation the rights to 52322Sdg * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 62322Sdg * of the Software, and to permit persons to whom the Software is furnished to do 72322Sdg * so, subject to the following conditions: 82322Sdg * 92322Sdg * The above copyright notice and this permission notice shall be included in all 102322Sdg * copies or substantial portions of the Software. 112322Sdg * 122322Sdg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 132322Sdg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 142322Sdg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 152322Sdg * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 162322Sdg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 172322Sdg * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 182322Sdg * SOFTWARE. 192322Sdg */ 202322Sdgpackage jdk.nashorn.internal.runtime.regexp.joni; 212322Sdg 222322Sdgpublic final class Region { 232322Sdg static final int REGION_NOTPOS = -1; 242322Sdg 252322Sdg public final int numRegs; 262322Sdg public final int[]beg; 272322Sdg public final int[]end; 282322Sdg 292322Sdg public Region(final int num) { 302322Sdg this.numRegs = num; 312322Sdg this.beg = new int[num]; 322322Sdg this.end = new int[num]; 33116176Sobrien } 34116176Sobrien 35116176Sobrien @Override 36116176Sobrien public String toString() { 372322Sdg final StringBuilder sb = new StringBuilder(); 382322Sdg sb.append("Region: \n"); 3974914Sjhb for (int i=0; i<beg.length; i++) sb.append(" " + i + ": (" + beg[i] + "-" + end[i] + ")"); 4074914Sjhb return sb.toString(); 412322Sdg } 4249558Sphk 43108338Sjulian void clear() { 44108338Sjulian for (int i=0; i<beg.length; i++) { 45108338Sjulian beg[i] = end[i] = REGION_NOTPOS; 4612734Sbde } 4712734Sbde } 4812734Sbde} 49115903Sjhb