本文整理汇总了Java中java.beans.Encoder.writeExpression方法的典型用法代码示例。如果您正苦于以下问题:Java Encoder.writeExpression方法的具体用法?Java Encoder.writeExpression怎么用?Java Encoder.writeExpression使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.beans.Encoder
的用法示例。
在下文中一共展示了Encoder.writeExpression方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import java.beans.Encoder; //导入方法依赖的package包/类
protected void initialize(Class type, Object oldInstance, Object newInstance, Encoder out)
{
// This is a hack to make serializing primitive arrays work correctly.
// Instead of modifying an existing primitive instance to make it equal
// with another instance (which is not possible because primitives are
// immutable) we create a new instance. This is against the specification
// of the initialize method but make things work fine.
out.writeExpression(new Expression(oldInstance, oldInstance.getClass(), "new",
new Object[] { oldInstance.toString() }));
}
示例2: instantiate
import java.beans.Encoder; //导入方法依赖的package包/类
@Override
protected Expression instantiate(Object oldInstance, Encoder out) {
Area a = (Area)oldInstance;
//use the default constructor
AffineTransform tx = new AffineTransform();
PathIterator itr = a.getPathIterator(tx);
GeneralPath path = new GeneralPath();
out.writeExpression(new Expression(path, GeneralPath.class, "new", new Object[0]));
while (!itr.isDone()) {
float[] segment = new float[6]; //must use floats because lineTo etc use floats
int pathType = itr.currentSegment(segment);
switch (pathType) {
case PathIterator.SEG_CLOSE:
out.writeStatement(new Statement(path, "closePath", new Object[0]));
break;
case PathIterator.SEG_CUBICTO:
out.writeStatement(new Statement(path, "curveTo", new Object[] {segment[0], segment[1], segment[2], segment[3], segment[4], segment[5]}));
break;
case PathIterator.SEG_LINETO:
out.writeStatement(new Statement(path, "lineTo", new Object[] {segment[0], segment[1]}));
break;
case PathIterator.SEG_MOVETO:
out.writeStatement(new Statement(path, "moveTo", new Object[] {segment[0], segment[1]}));
break;
case PathIterator.SEG_QUADTO:
out.writeStatement(new Statement(path, "quadTo", new Object[] {segment[0], segment[1], segment[2], segment[3]}));
break;
}
itr.next();
}
return new Expression(a, Area.class, "new", new Object[] {path});
}
示例3: testWriteExpression_Null
import java.beans.Encoder; //导入方法依赖的package包/类
public void testWriteExpression_Null() {
Encoder enc = new Encoder();
try {
enc.writeExpression(null);
fail();
} catch (NullPointerException e) {
// expected
}
}