當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。