java.lang.String.startEndAndLength()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(13.9k)|赞(0)|评价(0)|浏览(122)

本文整理了Java中java.lang.String.startEndAndLength()方法的一些代码示例,展示了String.startEndAndLength()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。String.startEndAndLength()方法的具体详情如下:
包路径:java.lang.String
类名称:String
方法名:startEndAndLength

String.startEndAndLength介绍

暂无

代码示例

代码示例来源:origin: robovm/robovm

/**
 * Copies the specified characters in this string to the character array
 * starting at the specified offset in the character array.
 *
 * @param start
 *            the starting offset of characters to copy.
 * @param end
 *            the ending offset of characters to copy.
 * @param buffer
 *            the destination character array.
 * @param index
 *            the starting offset in the character array.
 * @throws NullPointerException
 *             if {@code buffer} is {@code null}.
 * @throws IndexOutOfBoundsException
 *             if {@code start < 0}, {@code end > length()}, {@code start >
 *             end}, {@code index < 0}, {@code end - start > buffer.length -
 *             index}
 */
public void getChars(int start, int end, char[] buffer, int index) {
  // Note: last character not copied!
  if (start >= 0 && start <= end && end <= count) {
    System.arraycopy(value, start + offset, buffer, index, end - start);
  } else {
    // We throw StringIndexOutOfBoundsException rather than System.arraycopy's AIOOBE.
    throw startEndAndLength(start, end);
  }
}

代码示例来源:origin: robovm/robovm

/**
 * Returns a string containing a subsequence of characters from this string.
 * The returned string shares this string's <a href="#backing_array">backing
 * array</a>.
 *
 * @param start
 *            the offset of the first character.
 * @param end
 *            the offset one past the last character.
 * @return a new string containing the characters from start to end - 1
 * @throws IndexOutOfBoundsException
 *             if {@code start < 0}, {@code start > end} or {@code end >
 *             length()}.
 */
public String substring(int start, int end) {
  if (start == 0 && end == count) {
    return this;
  }
  // NOTE last character not copied!
  // Fast range check.
  if (start >= 0 && start <= end && end <= count) {
    return new String(offset + start, end - start, value);
  }
  throw startEndAndLength(start, end);
}

代码示例来源:origin: robovm/robovm

/**
 * Calculates the number of Unicode code points between {@code start}
 * and {@code end}.
 *
 * @param start
 *            the inclusive beginning index of the subsequence.
 * @param end
 *            the exclusive end index of the subsequence.
 * @return the number of Unicode code points in the subsequence.
 * @throws IndexOutOfBoundsException
 *         if {@code start < 0 || end > length() || start > end}
 * @see Character#codePointCount(CharSequence, int, int)
 * @since 1.5
 */
public int codePointCount(int start, int end) {
  if (start < 0 || end > count || start > end) {
    throw startEndAndLength(start, end);
  }
  return Character.codePointCount(value, offset + start, end - start);
}

代码示例来源:origin: robovm/robovm

throw startEndAndLength(start, end);

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * Returns a string containing a subsequence of characters from this string.
 * The returned string shares this string's <a href="#backing_array">backing
 * array</a>.
 *
 * @param start
 *            the offset of the first character.
 * @param end
 *            the offset one past the last character.
 * @return a new string containing the characters from start to end - 1
 * @throws IndexOutOfBoundsException
 *             if {@code start < 0}, {@code start > end} or {@code end >
 *             length()}.
 */
public String substring(int start, int end) {
  if (start == 0 && end == count) {
    return this;
  }
  // NOTE last character not copied!
  // Fast range check.
  if (start >= 0 && start <= end && end <= count) {
    return new String(offset + start, end - start, value);
  }
  throw startEndAndLength(start, end);
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
 * Returns a string containing a subsequence of characters from this string.
 * The returned string shares this string's <a href="#backing_array">backing
 * array</a>.
 *
 * @param start
 *            the offset of the first character.
 * @param end
 *            the offset one past the last character.
 * @return a new string containing the characters from start to end - 1
 * @throws IndexOutOfBoundsException
 *             if {@code start < 0}, {@code start > end} or {@code end >
 *             length()}.
 */
public String substring(int start, int end) {
  if (start == 0 && end == count) {
    return this;
  }
  // NOTE last character not copied!
  // Fast range check.
  if (start >= 0 && start <= end && end <= count) {
    return new String(offset + start, end - start, value);
  }
  throw startEndAndLength(start, end);
}

代码示例来源:origin: ibinti/bugvm

/**
 * Returns a string containing a subsequence of characters from this string.
 * The returned string shares this string's <a href="#backing_array">backing
 * array</a>.
 *
 * @param start
 *            the offset of the first character.
 * @param end
 *            the offset one past the last character.
 * @return a new string containing the characters from start to end - 1
 * @throws IndexOutOfBoundsException
 *             if {@code start < 0}, {@code start > end} or {@code end >
 *             length()}.
 */
public String substring(int start, int end) {
  if (start == 0 && end == count) {
    return this;
  }
  // NOTE last character not copied!
  // Fast range check.
  if (start >= 0 && start <= end && end <= count) {
    return new String(offset + start, end - start, value);
  }
  throw startEndAndLength(start, end);
}

代码示例来源:origin: MobiVM/robovm

/**
 * Returns a string containing a subsequence of characters from this string.
 * The returned string shares this string's <a href="#backing_array">backing
 * array</a>.
 *
 * @param start
 *            the offset of the first character.
 * @param end
 *            the offset one past the last character.
 * @return a new string containing the characters from start to end - 1
 * @throws IndexOutOfBoundsException
 *             if {@code start < 0}, {@code start > end} or {@code end >
 *             length()}.
 */
public String substring(int start, int end) {
  if (start == 0 && end == count) {
    return this;
  }
  // NOTE last character not copied!
  // Fast range check.
  if (start >= 0 && start <= end && end <= count) {
    return new String(offset + start, end - start, value);
  }
  throw startEndAndLength(start, end);
}

代码示例来源:origin: ibinti/bugvm

/**
 * Copies the specified characters in this string to the character array
 * starting at the specified offset in the character array.
 *
 * @param start
 *            the starting offset of characters to copy.
 * @param end
 *            the ending offset of characters to copy.
 * @param buffer
 *            the destination character array.
 * @param index
 *            the starting offset in the character array.
 * @throws NullPointerException
 *             if {@code buffer} is {@code null}.
 * @throws IndexOutOfBoundsException
 *             if {@code start < 0}, {@code end > length()}, {@code start >
 *             end}, {@code index < 0}, {@code end - start > buffer.length -
 *             index}
 */
public void getChars(int start, int end, char[] buffer, int index) {
  // Note: last character not copied!
  if (start >= 0 && start <= end && end <= count) {
    System.arraycopy(value, start + offset, buffer, index, end - start);
  } else {
    // We throw StringIndexOutOfBoundsException rather than System.arraycopy's AIOOBE.
    throw startEndAndLength(start, end);
  }
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
 * Returns a string containing a subsequence of characters from this string.
 * The returned string shares this string's <a href="#backing_array">backing
 * array</a>.
 *
 * @param start
 *            the offset of the first character.
 * @param end
 *            the offset one past the last character.
 * @return a new string containing the characters from start to end - 1
 * @throws IndexOutOfBoundsException
 *             if {@code start < 0}, {@code start > end} or {@code end >
 *             length()}.
 */
public String substring(int start, int end) {
  if (start == 0 && end == count) {
    return this;
  }
  // NOTE last character not copied!
  // Fast range check.
  if (start >= 0 && start <= end && end <= count) {
    return new String(offset + start, end - start, value);
  }
  throw startEndAndLength(start, end);
}

代码示例来源:origin: MobiVM/robovm

/**
 * Copies the specified characters in this string to the character array
 * starting at the specified offset in the character array.
 *
 * @param start
 *            the starting offset of characters to copy.
 * @param end
 *            the ending offset of characters to copy.
 * @param buffer
 *            the destination character array.
 * @param index
 *            the starting offset in the character array.
 * @throws NullPointerException
 *             if {@code buffer} is {@code null}.
 * @throws IndexOutOfBoundsException
 *             if {@code start < 0}, {@code end > length()}, {@code start >
 *             end}, {@code index < 0}, {@code end - start > buffer.length -
 *             index}
 */
public void getChars(int start, int end, char[] buffer, int index) {
  // Note: last character not copied!
  if (start >= 0 && start <= end && end <= count) {
    System.arraycopy(value, start + offset, buffer, index, end - start);
  } else {
    // We throw StringIndexOutOfBoundsException rather than System.arraycopy's AIOOBE.
    throw startEndAndLength(start, end);
  }
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
 * Copies the specified characters in this string to the character array
 * starting at the specified offset in the character array.
 *
 * @param start
 *            the starting offset of characters to copy.
 * @param end
 *            the ending offset of characters to copy.
 * @param buffer
 *            the destination character array.
 * @param index
 *            the starting offset in the character array.
 * @throws NullPointerException
 *             if {@code buffer} is {@code null}.
 * @throws IndexOutOfBoundsException
 *             if {@code start < 0}, {@code end > length()}, {@code start >
 *             end}, {@code index < 0}, {@code end - start > buffer.length -
 *             index}
 */
public void getChars(int start, int end, char[] buffer, int index) {
  // Note: last character not copied!
  if (start >= 0 && start <= end && end <= count) {
    System.arraycopy(value, start + offset, buffer, index, end - start);
  } else {
    // We throw StringIndexOutOfBoundsException rather than System.arraycopy's AIOOBE.
    throw startEndAndLength(start, end);
  }
}

代码示例来源:origin: FlexoVM/flexovm

/**
 * Returns a string containing a subsequence of characters from this string.
 * The returned string shares this string's <a href="#backing_array">backing
 * array</a>.
 *
 * @param start
 *            the offset of the first character.
 * @param end
 *            the offset one past the last character.
 * @return a new string containing the characters from start to end - 1
 * @throws IndexOutOfBoundsException
 *             if {@code start < 0}, {@code start > end} or {@code end >
 *             length()}.
 */
public String substring(int start, int end) {
  if (start == 0 && end == count) {
    return this;
  }
  // NOTE last character not copied!
  // Fast range check.
  if (start >= 0 && start <= end && end <= count) {
    return new String(offset + start, end - start, value);
  }
  throw startEndAndLength(start, end);
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * Copies the specified characters in this string to the character array
 * starting at the specified offset in the character array.
 *
 * @param start
 *            the starting offset of characters to copy.
 * @param end
 *            the ending offset of characters to copy.
 * @param buffer
 *            the destination character array.
 * @param index
 *            the starting offset in the character array.
 * @throws NullPointerException
 *             if {@code buffer} is {@code null}.
 * @throws IndexOutOfBoundsException
 *             if {@code start < 0}, {@code end > length()}, {@code start >
 *             end}, {@code index < 0}, {@code end - start > buffer.length -
 *             index}
 */
public void getChars(int start, int end, char[] buffer, int index) {
  // Note: last character not copied!
  if (start >= 0 && start <= end && end <= count) {
    System.arraycopy(value, start + offset, buffer, index, end - start);
  } else {
    // We throw StringIndexOutOfBoundsException rather than System.arraycopy's AIOOBE.
    throw startEndAndLength(start, end);
  }
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
 * Calculates the number of Unicode code points between {@code start}
 * and {@code end}.
 *
 * @param start
 *            the inclusive beginning index of the subsequence.
 * @param end
 *            the exclusive end index of the subsequence.
 * @return the number of Unicode code points in the subsequence.
 * @throws IndexOutOfBoundsException
 *         if {@code start < 0 || end > length() || start > end}
 * @see Character#codePointCount(CharSequence, int, int)
 * @since 1.5
 */
public int codePointCount(int start, int end) {
  if (start < 0 || end > count || start > end) {
    throw startEndAndLength(start, end);
  }
  return Character.codePointCount(value, offset + start, end - start);
}

代码示例来源:origin: FlexoVM/flexovm

/**
 * Calculates the number of Unicode code points between {@code start}
 * and {@code end}.
 *
 * @param start
 *            the inclusive beginning index of the subsequence.
 * @param end
 *            the exclusive end index of the subsequence.
 * @return the number of Unicode code points in the subsequence.
 * @throws IndexOutOfBoundsException
 *         if {@code start < 0 || end > length() || start > end}
 * @see Character#codePointCount(CharSequence, int, int)
 * @since 1.5
 */
public int codePointCount(int start, int end) {
  if (start < 0 || end > count || start > end) {
    throw startEndAndLength(start, end);
  }
  return Character.codePointCount(value, offset + start, end - start);
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * Calculates the number of Unicode code points between {@code start}
 * and {@code end}.
 *
 * @param start
 *            the inclusive beginning index of the subsequence.
 * @param end
 *            the exclusive end index of the subsequence.
 * @return the number of Unicode code points in the subsequence.
 * @throws IndexOutOfBoundsException
 *         if {@code start < 0 || end > length() || start > end}
 * @see Character#codePointCount(CharSequence, int, int)
 * @since 1.5
 */
public int codePointCount(int start, int end) {
  if (start < 0 || end > count || start > end) {
    throw startEndAndLength(start, end);
  }
  return Character.codePointCount(value, offset + start, end - start);
}

代码示例来源:origin: MobiVM/robovm

/**
 * Calculates the number of Unicode code points between {@code start}
 * and {@code end}.
 *
 * @param start
 *            the inclusive beginning index of the subsequence.
 * @param end
 *            the exclusive end index of the subsequence.
 * @return the number of Unicode code points in the subsequence.
 * @throws IndexOutOfBoundsException
 *         if {@code start < 0 || end > length() || start > end}
 * @see Character#codePointCount(CharSequence, int, int)
 * @since 1.5
 */
public int codePointCount(int start, int end) {
  if (start < 0 || end > count || start > end) {
    throw startEndAndLength(start, end);
  }
  return Character.codePointCount(value, offset + start, end - start);
}

代码示例来源:origin: ibinti/bugvm

/**
 * Calculates the number of Unicode code points between {@code start}
 * and {@code end}.
 *
 * @param start
 *            the inclusive beginning index of the subsequence.
 * @param end
 *            the exclusive end index of the subsequence.
 * @return the number of Unicode code points in the subsequence.
 * @throws IndexOutOfBoundsException
 *         if {@code start < 0 || end > length() || start > end}
 * @see Character#codePointCount(CharSequence, int, int)
 * @since 1.5
 */
public int codePointCount(int start, int end) {
  if (start < 0 || end > count || start > end) {
    throw startEndAndLength(start, end);
  }
  return Character.codePointCount(value, offset + start, end - start);
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
 * Calculates the number of Unicode code points between {@code start}
 * and {@code end}.
 *
 * @param start
 *            the inclusive beginning index of the subsequence.
 * @param end
 *            the exclusive end index of the subsequence.
 * @return the number of Unicode code points in the subsequence.
 * @throws IndexOutOfBoundsException
 *         if {@code start < 0 || end > length() || start > end}
 * @see Character#codePointCount(CharSequence, int, int)
 * @since 1.5
 */
public int codePointCount(int start, int end) {
  if (start < 0 || end > count || start > end) {
    throw startEndAndLength(start, end);
  }
  return Character.codePointCount(value, offset + start, end - start);
}

相关文章

微信公众号

最新文章

更多