当前位置: 首页>>代码示例>>Java>>正文


Java Encoder.writeExpression方法代码示例

本文整理汇总了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() }));
}
 
开发者ID:vilie,项目名称:javify,代码行数:11,代码来源:PrimitivePersistenceDelegate.java

示例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});
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:38,代码来源:PainterPropertyEditor.java

示例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
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:10,代码来源:EncoderTest.java


注:本文中的java.beans.Encoder.writeExpression方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。