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


Java PersistenceDelegate类代码示例

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


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

示例1: setPersistenceDelegates

import java.beans.PersistenceDelegate; //导入依赖的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.PersistenceDelegate; //导入依赖的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: recordCall

import java.beans.PersistenceDelegate; //导入依赖的package包/类
private void recordCall(Object param) {
    StackTraceElement[] eles = (new Throwable()).getStackTrace();
    int i = 0;
    // skip Throwable.init()
    while (eles[i].getClassName().equals("java.lang.Throwable")) {
        i++;
    }
    // skip calls from MockEncoder
    while (eles[i].getClassName().equals(MockEncoder.class.getName())) {
        i++;
    }
    // skip calls from DefaultPersistenceDelegate & PersistenceDelegate
    while (eles[i].getClassName().equals(
            DefaultPersistenceDelegate.class.getName())
            || eles[i].getClassName().equals(
                    PersistenceDelegate.class.getName())) {
        i++;
    }
    if (i > 2
            && eles[++i].getClassName().equals(
                    DefaultPersistenceDelegateTest.class.getName())) {
        CallVerificationStack.getInstance().push(param);
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:25,代码来源:DefaultPersistenceDelegateTest.java

示例4: testGetPersistenceDelegate_Default

import java.beans.PersistenceDelegate; //导入依赖的package包/类
public void testGetPersistenceDelegate_Default() {
    Encoder enc = new Encoder();
    Encoder enc2 = new Encoder();

    PersistenceDelegate pd1 = enc.getPersistenceDelegate(SampleBean.class);
    assertTrue(pd1 instanceof DefaultPersistenceDelegate);

    PersistenceDelegate pd2 = enc.getPersistenceDelegate(SampleBean.class);
    assertTrue(pd2 instanceof DefaultPersistenceDelegate);

    PersistenceDelegate pd3 = enc2
            .getPersistenceDelegate(MockBean4Codec.class);
    assertTrue(pd3 instanceof DefaultPersistenceDelegate);

    assertSame(pd1, pd2);
    assertSame(pd1, pd3);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:18,代码来源:EncoderTest.java

示例5: register

import java.beans.PersistenceDelegate; //导入依赖的package包/类
public void register(Class<?> type, PersistenceDelegate delegate) {
    synchronized (this.registry) {
        if (delegate != null) {
            this.registry.put(type, delegate);
        }
        else {
            this.registry.remove(type);
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:PersistenceDelegateFinder.java

示例6: find

import java.beans.PersistenceDelegate; //导入依赖的package包/类
@Override
public PersistenceDelegate find(Class<?> type) {
    PersistenceDelegate delegate;
    synchronized (this.registry) {
        delegate = this.registry.get(type);
    }
    return (delegate != null) ? delegate : super.find(type);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:9,代码来源:PersistenceDelegateFinder.java

示例7: test

import java.beans.PersistenceDelegate; //导入依赖的package包/类
private static void test(Class<?> type, Class<? extends PersistenceDelegate> expected) {
    PersistenceDelegate actual = ENCODER.getPersistenceDelegate(type);
    if ((actual == null) && (expected != null)) {
        throw new Error("expected delegate is not found");
    }
    if ((actual != null) && !actual.getClass().equals(expected)) {
        throw new Error("found unexpected delegate");
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:TestPersistenceDelegate.java

示例8: initialize

import java.beans.PersistenceDelegate; //导入依赖的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

示例9: test

import java.beans.PersistenceDelegate; //导入依赖的package包/类
private static void test(Class<?> type, PersistenceDelegate pd) {
    Encoder encoder1 = new Encoder();
    Encoder encoder2 = new XMLEncoder(System.out);

    PersistenceDelegate pd1 = encoder1.getPersistenceDelegate(type);
    PersistenceDelegate pd2 = encoder2.getPersistenceDelegate(type);

    encoder1.setPersistenceDelegate(type, pd);

    if (pd1 == encoder1.getPersistenceDelegate(type))
        throw new Error("first persistence delegate is not changed");

    if (pd2 != encoder2.getPersistenceDelegate(type))
        throw new Error("second persistence delegate is changed");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:Test4968523.java


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