本文整理匯總了Java中java.nio.CharBuffer.append方法的典型用法代碼示例。如果您正苦於以下問題:Java CharBuffer.append方法的具體用法?Java CharBuffer.append怎麽用?Java CharBuffer.append使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.nio.CharBuffer
的用法示例。
在下文中一共展示了CharBuffer.append方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: byCharsetEncoder_US_ASCII
import java.nio.CharBuffer; //導入方法依賴的package包/類
@Benchmark
public byte[] byCharsetEncoder_US_ASCII() {
try {
CharsetEncoder encoder = asciiencode.get();
CharBuffer buffer = charbuffergenerator.get();
buffer.clear();
buffer.append(STR);
buffer.flip();
ByteBuffer outbuffer = bytebuffergenerator.get();
outbuffer.clear();
CoderResult result = encoder.encode(buffer, outbuffer, false);
if (result.isError()) {
result.throwException();
}
byte[] b = new byte[STR.length()];
outbuffer.flip();
outbuffer.get(b);
return b;
} catch (CharacterCodingException e) {
throw new RuntimeException(e);
}
}
示例2: escapeFilterCharacters
import java.nio.CharBuffer; //導入方法依賴的package包/類
private static String escapeFilterCharacters(String value) {
CharBuffer buffer = allocate(value.length() * 2);
for ( char c : value.toCharArray()) {
switch (c) {
case '*' : buffer.append('\\'); break;
case '\\' : buffer.append('\\'); break;
case '(' : buffer.append('\\'); break;
case ')' : buffer.append('\\'); break;
}
buffer.append(c);
}
return buffer.flip().toString();
}
示例3: callOriginalMethod
import java.nio.CharBuffer; //導入方法依賴的package包/類
public void callOriginalMethod(CharSequence translatedString, Object userData) {
MethodHookParam methodHookParam = (MethodHookParam) userData;
Method myMethod = (Method) methodHookParam.method;
myMethod.setAccessible(true);
Object[] myArgs = methodHookParam.args;
if (myMethod.getName().equals("setText")) {
//if((myMethod.getName()=="setText")) {
if (myArgs[0].getClass().equals(AlteredCharSequence.class)) {
myArgs[0] = AlteredCharSequence.make(translatedString, null, 0, 0);
} else if (myArgs[0].getClass().equals(CharBuffer.class)) {
CharBuffer charBuffer = CharBuffer.allocate(translatedString.length() + 1);
charBuffer.append(translatedString);
myArgs[0] = charBuffer;
} else if (myArgs[0].getClass().equals(SpannableString.class)) {
myArgs[0] = new SpannableString(translatedString);
} else if (myArgs[0].getClass().equals(SpannedString.class)) {
myArgs[0] = new SpannedString(translatedString);
} else if (myArgs[0].getClass().equals(String.class)) {
myArgs[0] = translatedString.toString();
} else if (myArgs[0].getClass().equals(StringBuffer.class)) {
myArgs[0] = new StringBuffer(translatedString);
} else if (myArgs[0].getClass().equals(StringBuilder.class)) {
myArgs[0] = new StringBuilder(translatedString);
} else {
myArgs[0] = new SpannableStringBuilder(translatedString);
}
} else {
myArgs[0] = TextUtils.stringOrSpannedString(translatedString);
}
alltrans.hookAccess.acquireUninterruptibly();
unhookMethod(methodHookParam.method, alltrans.setTextHook);
try {
utils.debugLog("In Thread " + Thread.currentThread().getId() + " Invoking original function " + methodHookParam.method.getName() + " and setting text to " + myArgs[0].toString());
myMethod.invoke(methodHookParam.thisObject, myArgs);
} catch (Exception e) {
Log.e("AllTrans", "AllTrans: Got error in invoking method as : " + Log.getStackTraceString(e));
}
hookMethod(methodHookParam.method, alltrans.setTextHook);
alltrans.hookAccess.release();
}
示例4: callOriginalMethod
import java.nio.CharBuffer; //導入方法依賴的package包/類
public void callOriginalMethod(CharSequence translatedString, Object userData) {
MethodHookParam methodHookParam = (MethodHookParam) userData;
Method myMethod = (Method) methodHookParam.method;
myMethod.setAccessible(true);
Object[] myArgs = methodHookParam.args;
if (myArgs[0].getClass().equals(AlteredCharSequence.class)) {
myArgs[0] = AlteredCharSequence.make(translatedString, null, 0, 0);
} else if (myArgs[0].getClass().equals(CharBuffer.class)) {
CharBuffer charBuffer = CharBuffer.allocate(translatedString.length() + 1);
charBuffer.append(translatedString);
myArgs[0] = charBuffer;
} else if (myArgs[0].getClass().equals(SpannableString.class)) {
myArgs[0] = new SpannableString(translatedString);
} else if (myArgs[0].getClass().equals(SpannedString.class)) {
myArgs[0] = new SpannedString(translatedString);
} else if (myArgs[0].getClass().equals(String.class)) {
myArgs[0] = translatedString.toString();
} else if (myArgs[0].getClass().equals(StringBuffer.class)) {
myArgs[0] = new StringBuffer(translatedString);
} else if (myArgs[0].getClass().equals(StringBuilder.class)) {
myArgs[0] = new StringBuilder(translatedString);
} else {
myArgs[0] = new SpannableStringBuilder(translatedString);
}
Paint tempPaint = (Paint) myArgs[myArgs.length - 1];
Canvas tempCanvas = (Canvas) methodHookParam.thisObject;
myArgs[myArgs.length - 1] = copyPaint(tempPaint, tempCanvas, myArgs[0].toString());
if (myArgs[1].getClass().equals(int.class)) {
myArgs[1] = 0;
myArgs[2] = translatedString.length();
}
alltrans.hookAccess.acquireUninterruptibly();
unhookMethod(methodHookParam.method, alltrans.setTextHook);
try {
utils.debugLog("In Thread " + Thread.currentThread().getId() + " Invoking original function " + methodHookParam.method.getName() + " and setting text to " + myArgs[0].toString());
myMethod.invoke(methodHookParam.thisObject, myArgs);
} catch (Exception e) {
Log.e("AllTrans", "AllTrans: Got error in invoking method as : " + Log.getStackTraceString(e));
}
hookMethod(methodHookParam.method, alltrans.setTextHook);
alltrans.hookAccess.release();
}