android.database.CharArrayBuffer Java Examples
The following examples show how to use
android.database.CharArrayBuffer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConversationView.java From zom-android-matrix with Apache License 2.0 | 6 votes |
public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) { checkPosition(); if (columnIndex == mDeltaColumn) { long value = getDeltaValue(); String strValue = Long.toString(value); int len = strValue.length(); char[] data = buffer.data; if (data == null || data.length < len) { buffer.data = strValue.toCharArray(); } else { strValue.getChars(0, len, data, 0); } buffer.sizeCopied = strValue.length(); } else { mInnerCursor.copyStringToBuffer(columnIndex, buffer); } }
Example #2
Source File: AbstractCursor.java From sqlite-android with Apache License 2.0 | 6 votes |
@Override public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) { // Default implementation, uses getString String result = getString(columnIndex); if (result != null) { char[] data = buffer.data; if (data == null || data.length < result.length()) { buffer.data = result.toCharArray(); } else { result.getChars(0, result.length(), data, 0); } buffer.sizeCopied = result.length(); } else { buffer.sizeCopied = 0; } }
Example #3
Source File: ConversationView.java From Zom-Android-XMPP with GNU General Public License v3.0 | 6 votes |
public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) { checkPosition(); if (columnIndex == mDeltaColumn) { long value = getDeltaValue(); String strValue = Long.toString(value); int len = strValue.length(); char[] data = buffer.data; if (data == null || data.length < len) { buffer.data = strValue.toCharArray(); } else { strValue.getChars(0, len, data, 0); } buffer.sizeCopied = strValue.length(); } else { mInnerCursor.copyStringToBuffer(columnIndex, buffer); } }
Example #4
Source File: PaCursor.java From PluginLoader with Apache License 2.0 | 6 votes |
/** * Retrieves the requested column text and stores it in the buffer provided. * If the buffer size is not sufficient, a new char buffer will be allocated * and assigned to CharArrayBuffer.data * * @param columnIndex * the zero-based index of the target column. if the target * column is null, return buffer * @param buffer * the buffer to copy the text into. */ @Override public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) { try { if (mCursor != null) { mCursor.copyStringToBuffer(columnIndex, buffer); } } catch (Exception e) { PaLog.d("Cursor exception: " + e); if (mCursor != null) { try { mCursor.close(); } catch (Exception exception) { PaLog.d("Cursor close exception: " + e); } mCursor = null; } } }
Example #5
Source File: AbsSimpleCursor.java From cathode with Apache License 2.0 | 5 votes |
public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) { // Default implementation, uses getString String result = getString(columnIndex); if (result != null) { char[] data = buffer.data; if (data == null || data.length < result.length()) { buffer.data = result.toCharArray(); } else { result.getChars(0, result.length(), data, 0); } buffer.sizeCopied = result.length(); } else { buffer.sizeCopied = 0; } }
Example #6
Source File: LockSafeCursor.java From RxZhihuDaily with MIT License | 5 votes |
@Override public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) { for (int chance = 0; chance < LOCK_RETRY_CHANCES; chance++) { try { cursor.copyStringToBuffer(columnIndex, buffer); } catch (RuntimeException e) { if (!isSQLiteDatabaseLockedException(e)) { throw e; } } } }
Example #7
Source File: DatabaseGeneralTest.java From sqlite-android with Apache License 2.0 | 4 votes |
@MediumTest @Test public void testCopyString() throws Exception { mDatabase.execSQL("CREATE TABLE guess (numi INTEGER, numf FLOAT, str TEXT);"); mDatabase.execSQL( "INSERT INTO guess (numi,numf,str) VALUES (0,0.0,'ZoomZoomZoomZoom');"); mDatabase.execSQL("INSERT INTO guess (numi,numf,str) VALUES (2000000000,3.1415926535,'');"); String chinese = "\u4eac\u4ec5 \u5c3d\u5f84\u60ca"; String[] arr = new String[1]; arr[0] = chinese; mDatabase.execSQL("INSERT INTO guess (numi,numf,str) VALUES (-32768,-1.0,?)", arr); Cursor c; c = mDatabase.rawQuery("SELECT * FROM guess", null); c.moveToFirst(); CharArrayBuffer buf = new CharArrayBuffer(14); String compareTo = c.getString(c.getColumnIndexOrThrow("numi")); int numiIdx = c.getColumnIndexOrThrow("numi"); int numfIdx = c.getColumnIndexOrThrow("numf"); int strIdx = c.getColumnIndexOrThrow("str"); c.copyStringToBuffer(numiIdx, buf); assertEquals(1, buf.sizeCopied); assertEquals(compareTo, new String(buf.data, 0, buf.sizeCopied)); c.copyStringToBuffer(strIdx, buf); assertEquals("ZoomZoomZoomZoom", new String(buf.data, 0, buf.sizeCopied)); c.moveToNext(); compareTo = c.getString(numfIdx); c.copyStringToBuffer(numfIdx, buf); assertEquals(compareTo, new String(buf.data, 0, buf.sizeCopied)); c.copyStringToBuffer(strIdx, buf); assertEquals(0, buf.sizeCopied); c.moveToNext(); c.copyStringToBuffer(numfIdx, buf); assertEquals(new Double(-1.0), Double.valueOf( new String(buf.data, 0, buf.sizeCopied))); c.copyStringToBuffer(strIdx, buf); compareTo = c.getString(strIdx); assertEquals(chinese, compareTo); assertEquals(chinese, new String(buf.data, 0, buf.sizeCopied)); c.close(); }
Example #8
Source File: FastCursor.java From sqlitemagic with Apache License 2.0 | 4 votes |
@Override public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) { backingCursor.copyStringToBuffer(columnIndex, buffer); }
Example #9
Source File: APODActivity.java From stetho with MIT License | 4 votes |
private static void setTextWithBuffer(TextView textView, CharArrayBuffer buffer) { textView.setText(buffer.data, 0, buffer.sizeCopied); }
Example #10
Source File: AbstractWindowedCursor.java From sqlite-android with Apache License 2.0 | 4 votes |
@Override public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) { mWindow.copyStringToBuffer(mPos, columnIndex, buffer); }
Example #11
Source File: SQLiteCursor.java From kripton with Apache License 2.0 | 4 votes |
@Override public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) { // TODO Auto-generated method stub }
Example #12
Source File: FastCursor.java From MiBandDecompiled with Apache License 2.0 | 4 votes |
public void copyStringToBuffer(int i, CharArrayBuffer chararraybuffer) { throw new UnsupportedOperationException(); }
Example #13
Source File: CursorList.java From cursor-utils with MIT License | 4 votes |
@Override public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) { throw new IllegalArgumentException("CursorList is not backed by columns."); }
Example #14
Source File: SQLiteCursorNative.java From commcare-android with Apache License 2.0 | 4 votes |
@Override public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) { cursor.copyStringToBuffer(columnIndex, buffer); }
Example #15
Source File: CursorUtilTest.java From droitatedDB with Apache License 2.0 | 4 votes |
@Override public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) { // DUMMY }
Example #16
Source File: ProxyableCursor.java From droitatedDB with Apache License 2.0 | 4 votes |
@Override public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) { // no implementation needed, proxy will request the original cursor }
Example #17
Source File: IndexCursor.java From LiveBlurListView with Apache License 2.0 | 4 votes |
@Override public void copyStringToBuffer(int arg0, CharArrayBuffer arg1) {}
Example #18
Source File: SQLiteTable.java From android-skeleton-project with MIT License | 4 votes |
@Override public void copyStringToBuffer(int i, CharArrayBuffer charArrayBuffer) { baseCursor.copyStringToBuffer(i, charArrayBuffer); }
Example #19
Source File: CursorWindow.java From sqlite-android with Apache License 2.0 | 3 votes |
/** * Copies the text of the field at the specified row and column index into * a {@link CharArrayBuffer}. * <p> * The buffer is populated as follows: * <ul> * <li>If the buffer is too small for the value to be copied, then it is * automatically resized.</li> * <li>If the field is of type {@link Cursor#FIELD_TYPE_NULL}, then the buffer * is set to an empty string.</li> * <li>If the field is of type {@link Cursor#FIELD_TYPE_STRING}, then the buffer * is set to the contents of the string.</li> * <li>If the field is of type {@link Cursor#FIELD_TYPE_INTEGER}, then the buffer * is set to a string representation of the integer in decimal, obtained by formatting the * value with the <code>printf</code> family of functions using * format specifier <code>%lld</code>.</li> * <li>If the field is of type {@link Cursor#FIELD_TYPE_FLOAT}, then the buffer is * set to a string representation of the floating-point value in decimal, obtained by * formatting the value with the <code>printf</code> family of functions using * format specifier <code>%g</code>.</li> * <li>If the field is of type {@link Cursor#FIELD_TYPE_BLOB}, then a * {@link SQLiteException} is thrown.</li> * </ul> * </p> * * @param row The zero-based row index. * @param column The zero-based column index. * @param buffer The {@link CharArrayBuffer} to hold the string. It is automatically * resized if the requested string is larger than the buffer's current capacity. */ public void copyStringToBuffer(int row, int column, CharArrayBuffer buffer) { if (buffer == null) { throw new IllegalArgumentException("CharArrayBuffer should not be null"); } // TODO not as optimal as the original code char[] chars = getString(row, column).toCharArray(); buffer.data = chars; buffer.sizeCopied = chars.length; }
Example #20
Source File: EmptyCursor.java From SweetBlue with GNU General Public License v3.0 | 2 votes |
@Override public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) { }
Example #21
Source File: EmptyCursor.java From AsteroidOSSync with GNU General Public License v3.0 | 2 votes |
@Override public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) { }