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


Java XMLEncoder.setPersistenceDelegate方法代码示例

本文整理汇总了Java中java.beans.XMLEncoder.setPersistenceDelegate方法的典型用法代码示例。如果您正苦于以下问题:Java XMLEncoder.setPersistenceDelegate方法的具体用法?Java XMLEncoder.setPersistenceDelegate怎么用?Java XMLEncoder.setPersistenceDelegate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.beans.XMLEncoder的用法示例。


在下文中一共展示了XMLEncoder.setPersistenceDelegate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setPersistenceDelegates

import java.beans.XMLEncoder; //导入方法依赖的package包/类
private static void setPersistenceDelegates(XMLEncoder encoder,
        Class<?>[] types) {
    if (types != null && types.length > 0) {
        PersistenceDelegate persistenceDelegate = new EnumPersistenceDelegate();
        for (int i = 0; i < types.length; i++) {
            encoder.setPersistenceDelegate(types[i], persistenceDelegate);
        }
    }

    // Handle "BiGDecimal" manually (has no default constructor)
    encoder.setPersistenceDelegate(BigDecimal.class,
            new BigDecimalPersistenceDelegate());

    encoder.setPersistenceDelegate(byte[].class,
            new ByteArrayPersistenceDelegate());
    encoder.setPersistenceDelegate(UUID.class, new UUIDDelegate());
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:18,代码来源:XMLSerializer.java

示例2: main

import java.beans.XMLEncoder; //导入方法依赖的package包/类
public static void main(String[] args) {
    XMLEncoder encoder = new XMLEncoder(System.out);
    encoder.setPersistenceDelegate(Test4646747.class, new MyPersistenceDelegate());
    // WARNING: This can eat up a lot of memory
    Object[] obs = new Object[10000];
    while (obs != null) {
        try {
            obs = new Object[obs.length + obs.length / 3];
        }
        catch (OutOfMemoryError error) {
            obs = null;
        }
    }
    PersistenceDelegate pd = encoder.getPersistenceDelegate(Test4646747.class);
    if (!(pd instanceof MyPersistenceDelegate))
        throw new Error("persistence delegate has been lost");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:Test4646747.java

示例3: test

import java.beans.XMLEncoder; //导入方法依赖的package包/类
static void test(AbstractTest object) {
    ByteArrayOutputStream output = new ByteArrayOutputStream();

    XMLEncoder encoder = new XMLEncoder(output);
    encoder.setPersistenceDelegate(
            object.getClass(),
            new DefaultPersistenceDelegate(new String[] {"value"}));

    encoder.writeObject(object);
    encoder.close();

    System.out.print(output);

    ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
    XMLDecoder decoder = new XMLDecoder(input);
    AbstractTest result = (AbstractTest) decoder.readObject();
    decoder.close();

    if (object.getValue() != result.getValue())
        throw new Error("Should be " + object);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:AbstractTest.java

示例4: setupXML

import java.beans.XMLEncoder; //导入方法依赖的package包/类
/**
 * Configure the serialization of the File.
 */
@Override
protected void setupXML(XMLEncoder enc) {
	super.setupXML(enc);
	
	PropertyDescriptor[] pdArr;
	try {
		pdArr = Introspector.getBeanInfo(VirtualFileSystemFile.class)
				.getPropertyDescriptors();
	} catch (IntrospectionException e) {
		logger.error("I don't know what to do here", e);
		throw new RuntimeException(e);
	}
	for (PropertyDescriptor pd : pdArr) {
		// logger.debug("PropertyDescriptor - VirtualFileSystemFile - "
		// + pd.getDisplayName());
		if (transientListFile.contains(pd.getName())) {
			pd.setValue("transient", Boolean.TRUE);
		}
	}
	// needed to create a VFSFile object during unserialization
	enc.setPersistenceDelegate(VirtualFileSystemFile.class,
			new DefaultPersistenceDelegate(new String[] { "username",
					"group", "size", "slaves" }));
}
 
开发者ID:drftpd-ng,项目名称:drftpd3,代码行数:28,代码来源:VirtualFileSystemFile.java

示例5: getXMLEncoder

import java.beans.XMLEncoder; //导入方法依赖的package包/类
/**
 * Sets up the XMLEnconder.
 */
public XMLEncoder getXMLEncoder(OutputStream out) {
	XMLEncoder e = new XMLEncoder(out);
	e.setExceptionListener(new ExceptionListener() {
		public void exceptionThrown(Exception e1) {
			logger.error("", e1);
		}
	});
	e.setPersistenceDelegate(BeanUser.class,
			new DefaultPersistenceDelegate(new String[] { "name" }));
	e.setPersistenceDelegate(Key.class, new DefaultPersistenceDelegate(
			new String[] { "owner", "key" }));
	e.setPersistenceDelegate(HostMask.class,
			new DefaultPersistenceDelegate(new String[] { "mask" }));
	return e;
}
 
开发者ID:drftpd-ng,项目名称:drftpd3,代码行数:19,代码来源:BeanUserManager.java

示例6: setupXML

import java.beans.XMLEncoder; //导入方法依赖的package包/类
@Override
protected void setupXML(XMLEncoder enc) {
	super.setupXML(enc);
	
	PropertyDescriptor[] pdArr;
	try {
		pdArr = Introspector.getBeanInfo(VirtualFileSystemLink.class)
				.getPropertyDescriptors();
	} catch (IntrospectionException e) {
		logger.error("I don't know what to do here", e);
		throw new RuntimeException(e);
	}
	for (int x = 0; x < pdArr.length; x++) {
		// logger.debug("PropertyDescriptor - VirtualFileSystemLink - "
		// + pdArr[x].getDisplayName());
		if (transientListLink.contains(pdArr[x].getName())) {
			pdArr[x].setValue("transient", Boolean.TRUE);
		}
	}
	enc.setPersistenceDelegate(VirtualFileSystemLink.class,
			new DefaultPersistenceDelegate(new String[] { "username",
					"group", "linkPath" }));
}
 
开发者ID:drftpd-ng,项目名称:drftpd3,代码行数:24,代码来源:VirtualFileSystemLink.java

示例7: initialize

import java.beans.XMLEncoder; //导入方法依赖的package包/类
protected void initialize(XMLEncoder encoder) {
    encoder.setPersistenceDelegate(Container.class, new PersistenceDelegate() {
        protected Expression instantiate(Object oldInstance, Encoder out) {
            Container container = (Container) oldInstance;
            Component component = container.getComponent();
            return new Expression(container, component, "create", new Object[] {component});
        }
    });
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:Test5023552.java

示例8: initialize

import java.beans.XMLEncoder; //导入方法依赖的package包/类
protected void initialize(XMLEncoder encoder) {
    encoder.setPersistenceDelegate(
            OuterClass.InnerClass.class,
            new DefaultPersistenceDelegate() {
                protected Expression instantiate(Object oldInstance, Encoder out) {
                    OuterClass.InnerClass inner = (OuterClass.InnerClass) oldInstance;
                    OuterClass outer = inner.getOuter();
                    return new Expression(inner, outer, "getInner", new Object[0]);
                }
            }
    );
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:Test4936682.java

示例9: initialize

import java.beans.XMLEncoder; //导入方法依赖的package包/类
protected void initialize(XMLEncoder encoder) {
    encoder.setPersistenceDelegate(C.class, new DefaultPersistenceDelegate() {
        protected Expression instantiate(Object oldInstance, Encoder out) {
            C c = (C) oldInstance;
            return new Expression(c, c.getX(), "createC", new Object[] {});
        }
    });
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:Test4679556.java

示例10: initialize

import java.beans.XMLEncoder; //导入方法依赖的package包/类
@Override
protected void initialize(XMLEncoder encoder) {
    encoder.setOwner(this.owner);
    encoder.setPersistenceDelegate(A.class, new ADelegate());
    encoder.setPersistenceDelegate(B.class, new BDelegate());
    encoder.setPersistenceDelegate(C.class, new CDelegate());
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:Test5023550.java

示例11: toXMLString

import java.beans.XMLEncoder; //导入方法依赖的package包/类
private static String toXMLString( AbstractEnergySkateParkModule module ) {
    ByteArrayOutputStream out = new java.io.ByteArrayOutputStream();
    XMLEncoder e = new XMLEncoder( out );
    e.setPersistenceDelegate( Point2D.Double.class, new Point2DPersistenceDelegate() );
    e.writeObject( new EnergySkateParkModuleBean( module ) );
    e.writeObject( new JButton( "My Button" ) );
    e.close();

    return out.toString();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:11,代码来源:EnergySkateParkIO.java

示例12: getXMLEncoder

import java.beans.XMLEncoder; //导入方法依赖的package包/类
@Override
public XMLEncoder getXMLEncoder(OutputStream out) {
	XMLEncoder e = super.getXMLEncoder(out);
	e.setPersistenceDelegate(EncryptedBeanUser.class,
			new DefaultPersistenceDelegate(new String[] { "name" }));
	return e;
}
 
开发者ID:drftpd-ng,项目名称:drftpd3,代码行数:8,代码来源:EncryptedBeanUserManager.java

示例13: setupXML

import java.beans.XMLEncoder; //导入方法依赖的package包/类
/**
 * Configure the serialization of the Directory.
 */
@Override
protected void setupXML(XMLEncoder enc) {
	super.setupXML(enc);

	PropertyDescriptor[] pdArr;
	try {
		pdArr = Introspector.getBeanInfo(VirtualFileSystemDirectory.class)
		.getPropertyDescriptors();
	} catch (IntrospectionException e) {
		logger.error("I don't know what to do here", e);
		throw new RuntimeException(e);
	}
	for (int x = 0; x < pdArr.length; x++) {
		//logger.debug("PropertyDescriptor - VirtualFileSystemDirectory - " + pdArr[x].getDisplayName());
		if (transientListDirectory.contains(pdArr[x].getName())) {
			pdArr[x].setValue("transient", Boolean.TRUE);
		}
	}
	enc.setPersistenceDelegate(VirtualFileSystemDirectory.class,
			new DefaultPersistenceDelegate(new String[] { "username",
			"group" }));
	enc.setPersistenceDelegate(AtomicInteger.class, 
			new PersistenceDelegate() {
		protected Expression instantiate(Object oldInstance, Encoder out) {
			AtomicInteger ai = (AtomicInteger) oldInstance;
			return new Expression(oldInstance,
					oldInstance.getClass(),
					"new",
					new Object[] { ai.get() });
		}
	});
}
 
开发者ID:drftpd-ng,项目名称:drftpd3,代码行数:36,代码来源:VirtualFileSystemDirectory.java

示例14: initialize

import java.beans.XMLEncoder; //导入方法依赖的package包/类
@Override
protected void initialize(XMLEncoder encoder) {
    encoder.setPersistenceDelegate(B.class, new BDelegate());
    encoder.setPersistenceDelegate(C.class, new CDelegate());
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:Test5023557.java

示例15: initialize

import java.beans.XMLEncoder; //导入方法依赖的package包/类
@Override
protected void initialize(XMLEncoder encoder) {
    super.initialize(encoder);
    encoder.setPersistenceDelegate(Public.class, new PublicPersistenceDelegate());
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:Test8013416.java


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