本文整理汇总了Java中com.apple.jobjc.PrimitiveCoder.SCharCoder类的典型用法代码示例。如果您正苦于以下问题:Java SCharCoder类的具体用法?Java SCharCoder怎么用?Java SCharCoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SCharCoder类属于com.apple.jobjc.PrimitiveCoder包,在下文中一共展示了SCharCoder类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCoderDescriptorFor
import com.apple.jobjc.PrimitiveCoder.SCharCoder; //导入依赖的package包/类
public static PrimitiveCoderDescriptor createCoderDescriptorFor(final char encoding) {
switch(encoding) {
case 'B': return new PrimitiveCoderDescriptor(BoolCoder.INST, "false");
case 'c': return new PrimitiveCoderDescriptor(SCharCoder.INST, "0");
case 'C': return new PrimitiveCoderDescriptor(UCharCoder.INST, "0");
case 's': return new PrimitiveCoderDescriptor(SShortCoder.INST, "0");
case 'S': return new PrimitiveCoderDescriptor(UShortCoder.INST, "0");
case 'i': return new PrimitiveCoderDescriptor(SIntCoder.INST, "0");
case 'I': return new PrimitiveCoderDescriptor(UIntCoder.INST, "0");
case 'l': return new PrimitiveCoderDescriptor(SLongCoder.INST, "0");
case 'L': return new PrimitiveCoderDescriptor(ULongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long.");
case 'q': return new PrimitiveCoderDescriptor(SLongLongCoder.INST, "0");
case 'Q': return new PrimitiveCoderDescriptor(ULongLongCoder.INST, "0", "x86_64: no suitable Java primitive for unsigned long long.");
case 'f': return new PrimitiveCoderDescriptor(PrimitiveCoder.FloatCoder.INST, "0");
case 'd': return new PrimitiveCoderDescriptor(PrimitiveCoder.DoubleCoder.INST, "0");
default: throw new RuntimeException("unknown encoding: " + encoding);
}
}
示例2: getCoderAtRuntimeForType
import com.apple.jobjc.PrimitiveCoder.SCharCoder; //导入依赖的package包/类
static public Coder getCoderAtRuntimeForType(Class cls){
if(runtimeCoders == null) runtimeCoders = new Coder[]{
NSClassCoder.INST, IDCoder.INST, PointerCoder.INST,
DoubleCoder.INST, FloatCoder.INST, SLongLongCoder.INST,
SIntCoder.INST, SShortCoder.INST, SCharCoder.INST, BoolCoder.INST,
VoidCoder.INST
};
for(Coder c : runtimeCoders)
if((c.getJavaClass() != null && c.getJavaClass().isAssignableFrom(cls)) ||
(c.getJavaPrimitive() != null && c.getJavaPrimitive().isAssignableFrom(cls)))
return c;
if(Struct.class.isAssignableFrom(cls)){
try {
Method m = cls.getDeclaredMethod("getStructCoder");
m.setAccessible(true);
return (Coder) m.invoke(null);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
throw new RuntimeException("Could not find suitable coder for " + cls);
}