FileDocCategorySizeDatePackage
EmojiFactory.javaAPI DocAndroid 1.5 API10813Wed May 06 22:41:54 BST 2009android.emoji

EmojiFactory

public final class EmojiFactory extends Object
A class for the factories which produce Emoji (pictgram) images. This is intended to be used by IME, Email app, etc. There's no plan to make this public for now.
hide

Fields Summary
private int
sCacheSize
private int
mNativeEmojiFactory
private String
mName
private Map
mCache
Constructors Summary
private EmojiFactory(int nativeEmojiFactory, String name)

noinspection
UnusedDeclaration

        mNativeEmojiFactory = nativeEmojiFactory;
        mName = name;
        mCache = new CustomLinkedHashMap<Integer, WeakReference<Bitmap>>();
    
Methods Summary
protected voidfinalize()

        try {
            nativeDestructor(mNativeEmojiFactory);
        } finally {
            super.finalize();
        }
    
public java.lang.StringgetAndroidPuaFromVendorSpecificPua(java.lang.String vspString)

        if (vspString == null) {
            return null;
        }
        int minVsp = nativeGetMinimumVendorSpecificPua(mNativeEmojiFactory);
        int maxVsp = nativeGetMaximumVendorSpecificPua(mNativeEmojiFactory);
        int len = vspString.length();
        int[] codePoints = new int[vspString.codePointCount(0, len)];

        int new_len = 0;
        for (int i = 0; i < len; i = vspString.offsetByCodePoints(i, 1), new_len++) {
            int codePoint = vspString.codePointAt(i);
            if (minVsp <= codePoint && codePoint <= maxVsp) {
                int newCodePoint = getAndroidPuaFromVendorSpecificPua(codePoint);
                if (newCodePoint > 0) {
                    codePoints[new_len] = newCodePoint;
                    continue;
                }
            }
            codePoints[new_len] = codePoint;
        }
        return new String(codePoints, 0, new_len);
    
public intgetAndroidPuaFromVendorSpecificPua(int vsp)
Returns Unicode PUA for Android corresponding to the vendor specific Unicode.

param
vsp vendor specific PUA.
return
Unicode PUA for Android, or -1 if there's no map for the Unicode.

        return nativeGetAndroidPuaFromVendorSpecificPua(mNativeEmojiFactory, vsp);
    
public intgetAndroidPuaFromVendorSpecificSjis(char sjis)
Returns Unicode PUA for Android corresponding to the vendor specific sjis.

param
sjis vendor specific sjis
return
Unicode PUA for Android, or -1 if there's no map for the sjis.

        return nativeGetAndroidPuaFromVendorSpecificSjis(mNativeEmojiFactory, sjis);
    
public synchronized android.graphics.BitmapgetBitmapFromAndroidPua(int pua)
Returns Bitmap object corresponding to the AndroidPua. Note that each Bitmap is cached by this class, which means that, if you modify a Bitmap object (using setPos() method), all same emoji Bitmap will be modified. If it is unacceptable, please copy the object before modifying it.

param
pua A unicode codepoint.
return
Bitmap object when this factory knows the Bitmap relevant to the codepoint. Otherwise null is returned.

        WeakReference<Bitmap> cache = mCache.get(pua);
        if (cache == null) {
            Bitmap ret = nativeGetBitmapFromAndroidPua(mNativeEmojiFactory, pua);
            // There is no need to cache returned null, since in most cases it means there
            // is no map from the AndroidPua to a specific image. In other words, it usually does
            // not include the cost of creating Bitmap object.
            if (ret != null) {
               mCache.put(pua, new WeakReference<Bitmap>(ret));
            }
            return ret;
        } else {
            Bitmap tmp = cache.get();
            if (tmp == null) {
                Bitmap ret = nativeGetBitmapFromAndroidPua(mNativeEmojiFactory, pua);
                mCache.put(pua, new WeakReference<Bitmap>(ret));
                return ret;
            } else {
                return tmp;
            }
        }
    
public synchronized android.graphics.BitmapgetBitmapFromVendorSpecificPua(int vsp)
Returns Bitmap object corresponding to the vendor specific Unicode. See comments in getBitmapFromAndroidPua().

param
vsp vendor specific PUA.
return
Bitmap object when this factory knows the Bitmap relevant to the code. Otherwise null is returned.

        return getBitmapFromAndroidPua(getAndroidPuaFromVendorSpecificPua(vsp));
    
public synchronized android.graphics.BitmapgetBitmapFromVendorSpecificSjis(char sjis)
Returns Bitmap object corresponding to the vendor specified sjis. See comments in getBitmapFromAndroidPua().

param
sjis sjis code specific to each career(vendor)
return
Bitmap object when this factory knows the Bitmap relevant to the code. Otherwise null is returned.

        return getBitmapFromAndroidPua(getAndroidPuaFromVendorSpecificSjis(sjis));
    
public intgetMaximumAndroidPua()
Returns the highest code point corresponding to an Android emoji character.

        return nativeGetMaximumAndroidPua(mNativeEmojiFactory);
    
public intgetMinimumAndroidPua()
Returns the lowest code point corresponding to an Android emoji character.

        return nativeGetMinimumAndroidPua(mNativeEmojiFactory);
    
public intgetVendorSpecificPuaFromAndroidPua(int pua)
Returns vendor specific Unicode corresponding to the Unicode AndroidPua.

param
pua Unicode PUA for Android,
return
vendor specific sjis, or -1 if there's no map for the AndroidPua.

        return nativeGetVendorSpecificPuaFromAndroidPua(mNativeEmojiFactory, pua);
    
public java.lang.StringgetVendorSpecificPuaFromAndroidPua(java.lang.String puaString)

        if (puaString == null) {
            return null;
        }
        int minVsp = nativeGetMinimumAndroidPua(mNativeEmojiFactory);
        int maxVsp = nativeGetMaximumAndroidPua(mNativeEmojiFactory);
        int len = puaString.length();
        int[] codePoints = new int[puaString.codePointCount(0, len)];

        int new_len = 0;
        for (int i = 0; i < len; i = puaString.offsetByCodePoints(i, 1), new_len++) {
            int codePoint = puaString.codePointAt(i);
            if (minVsp <= codePoint && codePoint <= maxVsp) {
                int newCodePoint = getVendorSpecificPuaFromAndroidPua(codePoint);
                if (newCodePoint > 0) {
                    codePoints[new_len] = newCodePoint;
                    continue;
                }
            }
            codePoints[new_len] = codePoint;
        }
        return new String(codePoints, 0, new_len);
    
public intgetVendorSpecificSjisFromAndroidPua(int pua)
Returns vendor specific sjis corresponding to the Unicode AndroidPua.

param
pua Unicode PUA for Android,
return
vendor specific sjis, or -1 if there's no map for the AndroidPua.

        return nativeGetVendorSpecificSjisFromAndroidPua(mNativeEmojiFactory, pua);
    
public java.lang.Stringname()

        return mName;
    
private native voidnativeDestructor(int factory)

private native intnativeGetAndroidPuaFromVendorSpecificPua(int nativeEmojiFactory, int vsp)

private native intnativeGetAndroidPuaFromVendorSpecificSjis(int nativeEmojiFactory, char sjis)

private native android.graphics.BitmapnativeGetBitmapFromAndroidPua(int nativeEmojiFactory, int AndroidPua)

private native intnativeGetMaximumAndroidPua(int nativeEmojiFactory)

private native intnativeGetMaximumVendorSpecificPua(int nativeEmojiFactory)

private native intnativeGetMinimumAndroidPua(int nativeEmojiFactory)

private native intnativeGetMinimumVendorSpecificPua(int nativeEmojiFactory)

private native intnativeGetVendorSpecificPuaFromAndroidPua(int nativeEmojiFactory, int pua)

private native intnativeGetVendorSpecificSjisFromAndroidPua(int nativeEmojiFactory, int pua)

public static native android.emoji.EmojiFactorynewAvailableInstance()
Constructs an instance of available EmojiFactory.

return
A concrete EmojiFactory instance. If there are several available EmojiFactory class, preferred one is chosen by the system. If there isn't, null is returned.

public static native android.emoji.EmojiFactorynewInstance(java.lang.String class_name)
Constructs an instance of EmojiFactory corresponding to the name.

param
class_name Name of the factory. This must include complete package name.
return
A concrete EmojiFactory instance corresponding to factory_name. If factory_name is invalid, null is returned.