1adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project/* 2adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * Licensed to the Apache Software Foundation (ASF) under one or more 3adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * contributor license agreements. See the NOTICE file distributed with 4adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * this work for additional information regarding copyright ownership. 5adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * The ASF licenses this file to You under the Apache License, Version 2.0 6adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * (the "License"); you may not use this file except in compliance with 7adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * the License. You may obtain a copy of the License at 8adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * 9adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * http://www.apache.org/licenses/LICENSE-2.0 10adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * 11adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * Unless required by applicable law or agreed to in writing, software 12adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS, 13adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * See the License for the specific language governing permissions and 15adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * limitations under the License. 16adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project */ 17adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 18adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Projectpackage java.lang; 19adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 20adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project/** 21adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * Thrown when the a string is indexed with a value less than zero, or greater 22adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * than or equal to the size of the array. 23adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project */ 24adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Projectpublic class StringIndexOutOfBoundsException extends IndexOutOfBoundsException { 25adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 26adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project private static final long serialVersionUID = -6762910422159637258L; 27adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 28adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project /** 29adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * Constructs a new {@code StringIndexOutOfBoundsException} that includes 30adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * the current stack trace. 31adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project */ 32adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public StringIndexOutOfBoundsException() { 33adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 34adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 35adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project /** 36adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * Constructs a new {@code StringIndexOutOfBoundsException} with the current 37adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * stack trace and a detail message that is based on the specified invalid 38adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * {@code index}. 39f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * 40adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * @param index 41adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * the index which is out of bounds. 42f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes */ 43adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public StringIndexOutOfBoundsException(int index) { 44b1396870f92135aa140bd2b86221768dea5bc11dElliott Hughes super("String index out of range: " + index); 45adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 46adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 47adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project /** 48adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * Constructs a new {@code StringIndexOutOfBoundsException} with the current 49adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * stack trace and the specified detail message. 50f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * 51adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * @param detailMessage 52adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * the detail message for this exception. 53adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project */ 54adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public StringIndexOutOfBoundsException(String detailMessage) { 55adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project super(detailMessage); 56adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project } 5744a9f03a2d602c7179112284d878b0db9284eb30Elliott Hughes 5844a9f03a2d602c7179112284d878b0db9284eb30Elliott Hughes /** 5944a9f03a2d602c7179112284d878b0db9284eb30Elliott Hughes * Used internally for consistent high-quality error reporting. 6044a9f03a2d602c7179112284d878b0db9284eb30Elliott Hughes * @hide 6144a9f03a2d602c7179112284d878b0db9284eb30Elliott Hughes */ 62363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein public StringIndexOutOfBoundsException(String s, int index) { 63363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein this(s.length(), index); 64363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein } 65363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein 66363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein /** 67363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein * Used internally for consistent high-quality error reporting. 68363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein * @hide 69363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein */ 70363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein public StringIndexOutOfBoundsException(int sourceLength, int index) { 71363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein super("length=" + sourceLength + "; index=" + index); 72363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein } 73363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein 74363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein /** 75363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein * Used internally for consistent high-quality error reporting. 76363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein * @hide 77363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein */ 7844a9f03a2d602c7179112284d878b0db9284eb30Elliott Hughes public StringIndexOutOfBoundsException(String s, int offset, int count) { 79363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein this(s.length(), offset, count); 80363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein } 81363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein 82363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein /** 83363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein * Used internally for consistent high-quality error reporting. 84363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein * @hide 85363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein */ 86363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein public StringIndexOutOfBoundsException(int sourceLength, int offset, 87363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein int count) { 88363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein super("length=" + sourceLength + "; regionStart=" + offset 89363291564f107e500e0b584baa0377757cc2ae09Dan Bornstein + "; regionLength=" + count); 9044a9f03a2d602c7179112284d878b0db9284eb30Elliott Hughes } 91adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project} 92