當前位置: 首頁>>代碼示例>>Java>>正文


Java CharBuffer.append方法代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:fbacchella,項目名稱:RegexPerf,代碼行數:25,代碼來源:StringToBytes.java

示例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();
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:14,代碼來源:OsgiFilterUtils.java

示例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();
    }
 
開發者ID:akhilkedia,項目名稱:AllTrans,代碼行數:44,代碼來源:SetTextHookHandler.java

示例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();
    }
 
開發者ID:akhilkedia,項目名稱:AllTrans,代碼行數:47,代碼來源:DrawTextHookHandler.java


注:本文中的java.nio.CharBuffer.append方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。