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


Java MarshalledObject.get方法代码示例

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


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

示例1: checkHistory

import java.rmi.MarshalledObject; //导入方法依赖的package包/类
private boolean checkHistory (TransformHistory history, int xi, int ti, String xml, String xsl, String output) {
    // modify history
    history.setOverwriteOutput (!history.isOverwriteOutput()); // negate
    history.setProcessOutput ((history.getProcessOutput()+1)%3); // rotate
    if ( xml != null ) {
        history.addXML (xml, output);
    }
    if ( xsl != null ) {
        history.addXSL (xsl, output);
    }

    // test number of XMLs
    if ( history.getXMLs().length != xi ) {
        System.out.println("    history.getXMLs().length: " + history.getXMLs().length);
        return false;
    }
    // test number of XSLs
    if ( history.getXSLs().length != ti ) {
        System.out.println("    history.getXSLs().length: " + history.getXSLs().length);
        return false;
    }
    
    // (de)marshal
    TransformHistory newHistory = null;
    try {
        MarshalledObject marshalled = new MarshalledObject (history);
        newHistory = (TransformHistory) marshalled.get();
    } catch (Exception exc) {
        System.err.println("!!! " + exc);
        return false;
    }
    
    // test if equals
    return (history.equals (newHistory));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:TransformHistoryTest.java

示例2: delegatesToMO

import java.rmi.MarshalledObject; //导入方法依赖的package包/类
/**
 * Test that MarshalledObject inherits the ObjectInputFilter from
 * the stream it was deserialized from.
 */
@Test(dataProvider="FilterCases")
static void delegatesToMO(boolean withFilter) {
    try {
        Serializable testobj = Integer.valueOf(5);
        MarshalledObject<Serializable> mo = new MarshalledObject<>(testobj);
        Assert.assertEquals(mo.get(), testobj, "MarshalledObject.get returned a non-equals test object");

        byte[] bytes = writeObjects(mo);

        try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
             ObjectInputStream ois = new ObjectInputStream(bais)) {

            CountingFilter filter1 = new CountingFilter();
            ObjectInputFilter.Config.setObjectInputFilter(ois, withFilter ? filter1 : null);
            MarshalledObject<?> actualMO = (MarshalledObject<?>)ois.readObject();
            int count = filter1.getCount();

            actualMO.get();
            int expectedCount = withFilter ? count + 2 : count;
            int actualCount = filter1.getCount();
            Assert.assertEquals(actualCount, expectedCount, "filter called wrong number of times during get()");
        }
    } catch (IOException ioe) {
        Assert.fail("Unexpected IOException", ioe);
    } catch (ClassNotFoundException cnf) {
        Assert.fail("Deserializing", cnf);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:33,代码来源:MOFilterTest.java

示例3: delegatesToMO

import java.rmi.MarshalledObject; //导入方法依赖的package包/类
/**
 * Test that MarshalledObject inherits the ObjectInputFilter from
 * the stream it was deserialized from.
 */
@Test(dataProvider="FilterCases")
static void delegatesToMO(boolean withFilter) {
    try {
        Serializable testobj = Integer.valueOf(5);
        MarshalledObject<Serializable> mo = new MarshalledObject<>(testobj);
        Assert.assertEquals(mo.get(), testobj, "MarshalledObject.get returned a non-equals test object");

        byte[] bytes = writeObjects(mo);

        try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
             ObjectInputStream ois = new ObjectInputStream(bais)) {

            CountingFilter filter1 = new CountingFilter();
            ois.setObjectInputFilter(withFilter ? filter1 : null);
            MarshalledObject<?> actualMO = (MarshalledObject<?>)ois.readObject();
            int count = filter1.getCount();

            actualMO.get();
            int expectedCount = withFilter ? count + 2 : count;
            int actualCount = filter1.getCount();
            Assert.assertEquals(actualCount, expectedCount, "filter called wrong number of times during get()");
        }
    } catch (IOException ioe) {
        Assert.fail("Unexpected IOException", ioe);
    } catch (ClassNotFoundException cnf) {
        Assert.fail("Deserializing", cnf);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:MOFilterTest.java

示例4: unmarshal

import java.rmi.MarshalledObject; //导入方法依赖的package包/类
public Object unmarshal(MarshalledObject mobj)
    throws IOException, ClassNotFoundException
{
    return mobj.get();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:FnnClass.java


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