⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 appendingstringbuffer.java

📁 Wicket一个开发Java Web应用程序框架。它使得开发web应用程序变得容易而轻松。 Wicket利用一个POJO data beans组件使得它可以与任何持久层技术相结合。
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
	 * @param end	 *            the end index, exclusive.	 * @return the specified subsequence.	 * 	 * @throws IndexOutOfBoundsException	 *             if <tt>start</tt> or <tt>end</tt> are negative, if <tt>end</tt> is greater	 *             than <tt>length()</tt>, or if <tt>start</tt> is greater than <tt>end</tt>	 * 	 * @since 1.4	 * @spec JSR-51	 */	public CharSequence subSequence(int start, int end)	{		return this.substring(start, end);	}	/**	 * Returns a new <code>String</code> that contains a subsequence of characters currently	 * contained in this <code>AppendingStringBuffer</code>. The substring begins at the	 * specified <code>start</code> and extends to the character at index <code>end - 1</code>.	 * An exception is thrown if	 * 	 * @param start	 *            The beginning index, inclusive.	 * @param end	 *            The ending index, exclusive.	 * @return The new string.	 * @exception StringIndexOutOfBoundsException	 *                if <code>start</code> or <code>end</code> are negative or greater than	 *                <code>length()</code>, or <code>start</code> is greater than	 *                <code>end</code>.	 * @since 1.2	 */	public String substring(int start, int end)	{		if (start < 0)		{			throw new StringIndexOutOfBoundsException(start);		}		if (end > count)		{			throw new StringIndexOutOfBoundsException(end);		}		if (start > end)		{			throw new StringIndexOutOfBoundsException(end - start);		}		return new String(value, start, end - start);	}	/**	 * Inserts the string representation of a subarray of the <code>str</code> array argument into	 * this string buffer. The subarray begins at the specified <code>offset</code> and extends	 * <code>len</code> characters. The characters of the subarray are inserted into this string	 * buffer at the position indicated by <code>index</code>. The length of this	 * <code>AppendingStringBuffer</code> increases by <code>len</code> characters.	 * 	 * @param index	 *            position at which to insert subarray.	 * @param str	 *            A character array.	 * @param offset	 *            the index of the first character in subarray to to be inserted.	 * @param len	 *            the number of characters in the subarray to to be inserted.	 * @return This string buffer.	 * @exception StringIndexOutOfBoundsException	 *                if <code>index</code> is negative or greater than <code>length()</code>,	 *                or <code>offset</code> or <code>len</code> are negative, or	 *                <code>(offset+len)</code> is greater than <code>str.length</code>.	 * @since 1.2	 */	public AppendingStringBuffer insert(int index, char str[], int offset, int len)	{		if ((index < 0) || (index > count))		{			throw new StringIndexOutOfBoundsException();		}		if ((offset < 0) || (offset + len < 0) || (offset + len > str.length))		{			throw new StringIndexOutOfBoundsException(offset);		}		if (len < 0)		{			throw new StringIndexOutOfBoundsException(len);		}		int newCount = count + len;		if (newCount > value.length)		{			expandCapacity(newCount);		}		System.arraycopy(value, index, value, index + len, count - index);		System.arraycopy(str, offset, value, index, len);		count = newCount;		return this;	}	/**	 * Inserts the string representation of the <code>Object</code> argument into this string	 * buffer.	 * <p>	 * The second argument is converted to a string as if by the method <code>String.valueOf</code>,	 * and the characters of that string are then inserted into this string buffer at the indicated	 * offset.	 * <p>	 * The offset argument must be greater than or equal to <code>0</code>, and less than or	 * equal to the length of this string buffer.	 * 	 * @param offset	 *            the offset.	 * @param obj	 *            an <code>Object</code>.	 * @return a reference to this <code>AppendingStringBuffer</code> object.	 * @exception StringIndexOutOfBoundsException	 *                if the offset is invalid.	 * @see java.lang.String#valueOf(java.lang.Object)	 * @see AppendingStringBuffer#insert(int, java.lang.String)	 * @see AppendingStringBuffer#length()	 */	public AppendingStringBuffer insert(int offset, Object obj)	{		if (obj instanceof AppendingStringBuffer)		{			AppendingStringBuffer asb = (AppendingStringBuffer)obj;			return insert(offset, asb.value, 0, asb.count);		}		else if (obj instanceof StringBuffer)		{			return insert(offset, (StringBuffer)obj);		}		return insert(offset, String.valueOf(obj));	}	/**	 * Inserts the string into this string buffer.	 * <p>	 * The characters of the <code>String</code> argument are inserted, in order, into this string	 * buffer at the indicated offset, moving up any characters originally above that position and	 * increasing the length of this string buffer by the length of the argument. If	 * <code>str</code> is <code>null</code>, then the four characters <code>"null"</code>	 * are inserted into this string buffer.	 * <p>	 * The character at index <i>k</i> in the new character sequence is equal to:	 * <ul>	 * <li>the character at index <i>k</i> in the old character sequence, if <i>k</i> is less	 * than <code>offset</code>	 * <li>the character at index <i>k</i><code>-offset</code> in the argument <code>str</code>,	 * if <i>k</i> is not less than <code>offset</code> but is less than	 * <code>offset+str.length()</code>	 * <li>the character at index <i>k</i><code>-str.length()</code> in the old character	 * sequence, if <i>k</i> is not less than <code>offset+str.length()</code>	 * </ul>	 * <p>	 * The offset argument must be greater than or equal to <code>0</code>, and less than or	 * equal to the length of this string buffer.	 * 	 * @param offset	 *            the offset.	 * @param str	 *            a string.	 * @return a reference to this <code>AppendingStringBuffer</code> object.	 * @exception StringIndexOutOfBoundsException	 *                if the offset is invalid.	 * @see java.lang.StringBuffer#length()	 */	public AppendingStringBuffer insert(int offset, String str)	{		if ((offset < 0) || (offset > count))		{			throw new StringIndexOutOfBoundsException();		}		if (str == null)		{			str = String.valueOf(str);		}		int len = str.length();		int newcount = count + len;		if (newcount > value.length)		{			expandCapacity(newcount);		}		System.arraycopy(value, offset, value, offset + len, count - offset);		str.getChars(0, len, value, offset);		count = newcount;		return this;	}	/**	 * Inserts the string into this string buffer.	 * <p>	 * The characters of the <code>String</code> argument are inserted, in order, into this string	 * buffer at the indicated offset, moving up any characters originally above that position and	 * increasing the length of this string buffer by the length of the argument. If	 * <code>str</code> is <code>null</code>, then the four characters <code>"null"</code>	 * are inserted into this string buffer.	 * <p>	 * The character at index <i>k</i> in the new character sequence is equal to:	 * <ul>	 * <li>the character at index <i>k</i> in the old character sequence, if <i>k</i> is less	 * than <code>offset</code>	 * <li>the character at index <i>k</i><code>-offset</code> in the argument <code>str</code>,	 * if <i>k</i> is not less than <code>offset</code> but is less than	 * <code>offset+str.length()</code>	 * <li>the character at index <i>k</i><code>-str.length()</code> in the old character	 * sequence, if <i>k</i> is not less than <code>offset+str.length()</code>	 * </ul>	 * <p>	 * The offset argument must be greater than or equal to <code>0</code>, and less than or	 * equal to the length of this string buffer.	 * 	 * @param offset	 *            the offset.	 * @param str	 *            a string.	 * @return a reference to this <code>AppendingStringBuffer</code> object.	 * @exception StringIndexOutOfBoundsException	 *                if the offset is invalid.	 * @see java.lang.StringBuffer#length()	 */	public AppendingStringBuffer insert(int offset, StringBuffer str)	{		if ((offset < 0) || (offset > count))		{			throw new StringIndexOutOfBoundsException();		}		if (str == null)		{			str = SB_NULL;		}		int len = str.length();		int newcount = count + len;		if (newcount > value.length)		{			expandCapacity(newcount);		}		System.arraycopy(value, offset, value, offset + len, count - offset);		str.getChars(0, len, value, offset);		count = newcount;		return this;	}	/**	 * Inserts the string representation of the <code>char</code> array argument into this string	 * buffer.	 * <p>	 * The characters of the array argument are inserted into the contents of this string buffer at	 * the position indicated by <code>offset</code>. The length of this string buffer increases	 * by the length of the argument.	 * <p>	 * The overall effect is exactly as if the argument were converted to a string by the method	 * {@link String#valueOf(char[])} and the characters of that string were then	 * {@link #insert(int,String) inserted} into this <code>AppendingStringBuffer</code> object at	 * the position indicated by <code>offset</code>.	 * 	 * @param offset	 *            the offset.	 * @param str	 *            a character array.	 * @return a reference to this <code>AppendingStringBuffer</code> object.	 * @exception StringIndexOutOfBoundsException	 *                if the offset is invalid.	 */	public AppendingStringBuffer insert(int offset, char str[])	{		if ((offset < 0) || (offset > count))		{			throw new StringIndexOutOfBoundsException();		}		int len = str.length;		int newcount = count + len;		if (newcount > value.length)		{			expandCapacity(newcount);		}		System.arraycopy(value, offset, value, offset + len, count - offset);		System.arraycopy(str, 0, value, offset, len);		count = newcount;		return this;	}	/**	 * Inserts the string representation of the <code>boolean</code> argument into this string	 * buffer.	 * <p>	 * The second argument is converted to a string as if by the method <code>String.valueOf</code>,	 * and the characters of that string are then inserted into this string buffer at the indicated	 * offset.	 * <p>	 * The offset argument must be greater than or equal to <code>0</code>, and less than or	 * equal to the length of this string buffer.	 * 	 * @param offset	 *            the offset.	 * @param b	 *            a <code>boolean</code>.	 * @return a reference to this <code>AppendingStringBuffer</code> object.	 * @exception StringIndexOutOfBoundsException	 *                if the offset is invalid.	 * @see java.lang.String#valueOf(boolean)	 * @see java.lang.StringBuffer#insert(int, java.lang.String)	 * @see java.lang.StringBuffer#length()	 */	public AppendingStringBuffer insert(int offset, boolean b)	{		return insert(offset, String.valueOf(b));	}	/**	 * Inserts the string representation of the <code>char</code> argument into this string	 * buffer.	 * <p>	 * The second argument is inserted into the contents of this string buffer at the position	 * indicated by <code>offset</code>. The length of this string buffer increases by one.	 * <p>	 * The overall effect is exactly as if the argument were converted to a string by the method	 * {@link String#valueOf(char)} and the character in that string were then	 * {@link #insert(int, String) inserted} into this <code>AppendingStringBuffer</code> object	 * at the position indicated by <code>offset</code>.	 * <p>	 * The offset argument must be greater than or equal to <code>0</code>, and less than or	 * equal to the length of this string buffer.	 * 	 * @param offset	 *            the offset.	 * @param c	 *            a <code>char</code>.	 * @return a reference to this <code>AppendingStringBuffer</code> object.	 * @exception IndexOutOfBoundsException	 *                if the offset is invalid.	 * @see java.lang.StringBuffer#length()	 */	public AppendingStringBuffer insert(int offset, char c)	{		int newcount = count + 1;		if (newcount > value.length)		{			expandCapacity(newcount);		}		System.arraycopy(value, offset, value, offset + 1, count - offset);		value[offset] = c;		count = newcount;		return this;	}	/**	 * Inserts the string representation of the second <code>int</code> argument into this string	 * buffer.	 * <p>	 * The second argument is converted to a string as if by the method <code>String.valueOf</code>,	 * and the characters of that string are then inserted into this string buffer at the indicated	 * offset.	 * <p>	 * The offset argument must be greater than or equal to <code>0</code>, and less than or	 * equal to the length of this string buffer.	 * 	 * @param offset	 *            the offset.	 * @param i	 *            an <code>int</code>.	 * @return a reference to this <code>AppendingStringBuffer</code> object.	 * @exception StringIndexOutOfBoundsException	 *                if the offset is invalid.	 * @see java.lang.String#valueOf(int)	 * @see java.lang.StringBuffer#insert(int, java.lang.String)	 * @see java.lang.StringBuffer#length()	 */	public AppendingStringBuffer insert(int offset, int i)	{		return insert(offset, String.valueOf(i));	}	/**	 * Inserts the string representation of the <code>long</code> argument into this string	 * buffer.	 * <p>	 * The second argument is converted to a string as if by the method <code>String.valueOf</code>,	 * and the characters of that string are then inserted into this string buffer at the position	 * indicated by <code>offset</code>.	 * <p>	 * The offset argument must be greater than or equal to <code>0</code>, and less than or	 * equal to the length of this string buffer.	 * 	 * @param offset	 *            the offset.	 * @param l	 *            a <code>long</code>.	 * @return a reference to this <code>AppendingStringBuffer</code> object.	 * @exception StringIndexOutOfBoundsException	 *                if the offset is invalid.	 * @see java.lang.String#valueOf(long)	 * @see java.lang.StringBuffer#insert(int, java.lang.String)	 * @see java.lang.StringBuffer#length()	 */	public AppendingStringBuffer insert(int offset, long l)	{		return insert(offset, String.valueOf(l));	}	/**	 * Inserts the string representation of the <code>float</code> argument into this string	 * buffer.	 * <p>	 * The second argument is converted to a string as if by the method <code>String.valueOf</code>,	 * and the characters of that string are then inserted into this string buffer at the indicated	 * offset.	 * <p>	 * The offset argument must be greater than or equal to <code>0</code>, and less than or	 * equal to the length of this string buffer.	 * 	 * @param offset	 *            the offset.	 * @param f	 *            a <code>float</code>.	 * @return a reference to this <code>AppendingStringBuffer</code> object.	 * @exception StringIndexOutOfBoundsException	 *                if the offset is invalid.	 * @see java.lang.String#valueOf(float)	 * @see java.lang.StringBuffer#insert(int, java.lang.String)	 * @see java.lang.StringBuffer#length()	 */	public AppendingStringBuffer insert(int offset, float f)	{		return insert(offset, String.valueOf(f));	}	/**	 * Inserts the string representation of the <code>double</code> argument into this string	 * buffer.	 * <p>	 * The second argument is converted to a string as if by the method <code>String.valueOf</code>,	 * and the characters of that string are then inserted into this string buffer at the indicated	 * offset.	 * <p>	 * The offset argument must be greater than or equal to <code>0</code>, and less than or

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -