Java Code Examples for com.ibm.icu.util.UResourceBundle#BINARY
The following examples show how to use
com.ibm.icu.util.UResourceBundle#BINARY .
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: ICUResourceBundleReader.java From fitnotifications with Apache License 2.0 | 5 votes |
byte[] getBinary(int res, byte[] ba) { int offset=RES_GET_OFFSET(res); int length; if(RES_GET_TYPE(res)==UResourceBundle.BINARY) { if(offset==0) { return emptyBytes; } else { offset=getResourceByteOffset(offset); length=getInt(offset); if(length==0) { return emptyBytes; } // Not cached: The array would have to be cloned anyway because // the cache must not be writable via the returned reference. if(ba==null || ba.length!=length) { ba=new byte[length]; } offset += 4; if(length <= 16) { for(int i = 0; i < length; ++i) { ba[i] = bytes.get(offset++); } } else { ByteBuffer temp = bytes.duplicate(); temp.position(offset); temp.get(ba); } return ba; } } else { return null; } }
Example 2
Source File: ICUResourceBundleReader.java From fitnotifications with Apache License 2.0 | 5 votes |
ByteBuffer getBinary(int res) { int offset=RES_GET_OFFSET(res); int length; if(RES_GET_TYPE(res)==UResourceBundle.BINARY) { if(offset==0) { // Don't just // return emptyByteBuffer; // in case it matters whether the buffer's mark is defined or undefined. return emptyByteBuffer.duplicate(); } else { // Not cached: The returned buffer is small (shares its bytes with the bundle) // and usually quickly discarded after use. // Also, even a cached buffer would have to be cloned because it is mutable // (position & mark). offset=getResourceByteOffset(offset); length=getInt(offset); if(length == 0) { return emptyByteBuffer.duplicate(); } offset += 4; ByteBuffer result = bytes.duplicate(); result.position(offset).limit(offset + length); result = ICUBinary.sliceWithOrder(result); if(!result.isReadOnly()) { result = result.asReadOnlyBuffer(); } return result; } } else { return null; } }
Example 3
Source File: UResource.java From fitnotifications with Apache License 2.0 | 5 votes |
/** * Only for debugging. */ @Override public String toString() { switch(getType()) { case UResourceBundle.STRING: return getString(); case UResourceBundle.INT: return Integer.toString(getInt()); case UResourceBundle.INT_VECTOR: int[] iv = getIntVector(); StringBuilder sb = new StringBuilder("["); sb.append(iv.length).append("]{"); if (iv.length != 0) { sb.append(iv[0]); for (int i = 1; i < iv.length; ++i) { sb.append(", ").append(iv[i]); } } return sb.append('}').toString(); case UResourceBundle.BINARY: return "(binary blob)"; case UResourceBundle.ARRAY: return "(array)"; case UResourceBundle.TABLE: return "(table)"; default: // should not occur return "???"; } }
Example 4
Source File: ICUResourceBundleReader.java From trekarta with GNU General Public License v3.0 | 5 votes |
byte[] getBinary(int res, byte[] ba) { int offset=RES_GET_OFFSET(res); int length; if(RES_GET_TYPE(res)==UResourceBundle.BINARY) { if(offset==0) { return emptyBytes; } else { offset=getResourceByteOffset(offset); length=getInt(offset); if(length==0) { return emptyBytes; } // Not cached: The array would have to be cloned anyway because // the cache must not be writable via the returned reference. if(ba==null || ba.length!=length) { ba=new byte[length]; } offset += 4; if(length <= 16) { for(int i = 0; i < length; ++i) { ba[i] = bytes.get(offset++); } } else { ByteBuffer temp = bytes.duplicate(); temp.position(offset); temp.get(ba); } return ba; } } else { return null; } }
Example 5
Source File: ICUResourceBundleReader.java From trekarta with GNU General Public License v3.0 | 5 votes |
ByteBuffer getBinary(int res) { int offset=RES_GET_OFFSET(res); int length; if(RES_GET_TYPE(res)==UResourceBundle.BINARY) { if(offset==0) { // Don't just // return emptyByteBuffer; // in case it matters whether the buffer's mark is defined or undefined. return emptyByteBuffer.duplicate(); } else { // Not cached: The returned buffer is small (shares its bytes with the bundle) // and usually quickly discarded after use. // Also, even a cached buffer would have to be cloned because it is mutable // (position & mark). offset=getResourceByteOffset(offset); length=getInt(offset); if(length == 0) { return emptyByteBuffer.duplicate(); } offset += 4; ByteBuffer result = bytes.duplicate(); result.position(offset).limit(offset + length); result = ICUBinary.sliceWithOrder(result); if(!result.isReadOnly()) { result = result.asReadOnlyBuffer(); } return result; } } else { return null; } }
Example 6
Source File: UResource.java From trekarta with GNU General Public License v3.0 | 5 votes |
/** * Only for debugging. */ @Override public String toString() { switch(getType()) { case UResourceBundle.STRING: return getString(); case UResourceBundle.INT: return Integer.toString(getInt()); case UResourceBundle.INT_VECTOR: int[] iv = getIntVector(); StringBuilder sb = new StringBuilder("["); sb.append(iv.length).append("]{"); if (iv.length != 0) { sb.append(iv[0]); for (int i = 1; i < iv.length; ++i) { sb.append(", ").append(iv[i]); } } return sb.append('}').toString(); case UResourceBundle.BINARY: return "(binary blob)"; case UResourceBundle.ARRAY: return "(array)"; case UResourceBundle.TABLE: return "(table)"; default: // should not occur return "???"; } }