001: /***
002: * Retrotranslator: a Java bytecode transformer that translates Java classes
003: * compiled with JDK 5.0 into classes that can be run on JVM 1.4.
004: *
005: * Copyright (c) 2005 - 2008 Taras Puchko
006: * All rights reserved.
007: *
008: * Redistribution and use in source and binary forms, with or without
009: * modification, are permitted provided that the following conditions
010: * are met:
011: * 1. Redistributions of source code must retain the above copyright
012: * notice, this list of conditions and the following disclaimer.
013: * 2. Redistributions in binary form must reproduce the above copyright
014: * notice, this list of conditions and the following disclaimer in the
015: * documentation and/or other materials provided with the distribution.
016: * 3. Neither the name of the copyright holders nor the names of its
017: * contributors may be used to endorse or promote products derived from
018: * this software without specific prior written permission.
019: *
020: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
021: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
022: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
023: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
024: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
025: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
026: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
027: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
028: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
029: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
030: * THE POSSIBILITY OF SUCH DAMAGE.
031: */package net.sf.retrotranslator.runtime.java.lang;
032:
033: import net.sf.retrotranslator.registry.Advanced;
034:
035: /**
036: * @author Taras Puchko
037: */
038: public class _StringBuffer {
039:
040: public static String convertConstructorArguments(CharSequence s) {
041: return s == null ? null : s.toString();
042: }
043:
044: public static StringBuffer append(StringBuffer buffer,
045: CharSequence s) {
046: return s instanceof StringBuffer ? buffer
047: .append((StringBuffer) s) : buffer.append((Object) s);
048: }
049:
050: public static StringBuffer append(StringBuffer buffer,
051: CharSequence s, int start, int end) {
052: return append(buffer, s.subSequence(start, end));
053: }
054:
055: public static StringBuffer appendCodePoint(StringBuffer buffer,
056: int codePoint) {
057: buffer.append(_Character.toChars(codePoint));
058: return buffer;
059: }
060:
061: public static int codePointAt(StringBuffer buffer, int index) {
062: synchronized (buffer) {
063: return _Character.codePointAt(buffer, index);
064: }
065: }
066:
067: public static int codePointBefore(StringBuffer buffer, int index) {
068: synchronized (buffer) {
069: return _Character.codePointBefore(buffer, index);
070: }
071: }
072:
073: public static int codePointCount(StringBuffer buffer,
074: int beginIndex, int endIndex) {
075: synchronized (buffer) {
076: return _Character.codePointCount(buffer, beginIndex,
077: endIndex);
078: }
079: }
080:
081: public static StringBuffer insert(StringBuffer buffer,
082: int dstOffset, CharSequence s) {
083: return buffer.insert(dstOffset, (Object) s);
084: }
085:
086: public static StringBuffer insert(StringBuffer buffer,
087: int dstOffset, CharSequence s, int start, int end) {
088: return insert(buffer, dstOffset, s.subSequence(start, end));
089: }
090:
091: public static int offsetByCodePoints(StringBuffer buffer,
092: int index, int codePointOffset) {
093: synchronized (buffer) {
094: return _Character.offsetByCodePoints(buffer, index,
095: codePointOffset);
096: }
097: }
098:
099: @Advanced("StringBuffer.trimToSize")
100: public static void trimToSize(StringBuffer buffer) {
101: //do nothing
102: }
103:
104: }
|