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


Java ScriptUtils.wrap方法代码示例

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


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

示例1: Deserialize

import jdk.nashorn.api.scripting.ScriptUtils; //导入方法依赖的package包/类
@Override
public Object Deserialize(Object input) {
    // Make sure we can continue:
    if(!ScriptObjectMirror.class.isAssignableFrom(input.getClass()) &&
            !ScriptObject.class.isAssignableFrom(input.getClass())) return null;

    ScriptObjectMirror mirror;

    // The first case will probably not happen, but, just in case...
    if(ScriptObjectMirror.class.isAssignableFrom(input.getClass())) {
        mirror = (ScriptObjectMirror) input;
    } else {
        mirror = ScriptUtils.wrap((ScriptObject) input);
    }

    Map<String, Object> properties = new HashMap<>();

    for(String key : mirror.keySet()) {
        properties.put(key, mirror.get(key));
    }

    return new BlockStateMatcher(properties);
}
 
开发者ID:legendblade,项目名称:CraftingHarmonics,代码行数:24,代码来源:BlockStateMatcher.java

示例2: Deserialize

import jdk.nashorn.api.scripting.ScriptUtils; //导入方法依赖的package包/类
@Override
public final Object Deserialize(Object input) {
    // Make sure we can continue:
    if(!ScriptObjectMirror.class.isAssignableFrom(input.getClass()) &&
            !ScriptObject.class.isAssignableFrom(input.getClass())) return null;

    ScriptObjectMirror mirror;

    // The first case will probably not happen, but, just in case...
    if(ScriptObjectMirror.class.isAssignableFrom(input.getClass())) {
        mirror = (ScriptObjectMirror) input;
    } else {
        mirror = ScriptUtils.wrap((ScriptObject) input);
    }

    return DeserializeMirror(mirror);
}
 
开发者ID:legendblade,项目名称:CraftingHarmonics,代码行数:18,代码来源:BaseMirroredDeserializer.java

示例3: exportArgument

import jdk.nashorn.api.scripting.ScriptUtils; //导入方法依赖的package包/类
static Object exportArgument(final Object arg, final boolean mirrorAlways) {
    if (arg instanceof ConsString) {
        return arg.toString();
    } else if (mirrorAlways && arg instanceof ScriptObject) {
        return ScriptUtils.wrap((ScriptObject)arg);
    } else {
        return arg;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:NashornBeansLinker.java

示例4: exportArgument

import jdk.nashorn.api.scripting.ScriptUtils; //导入方法依赖的package包/类
static Object exportArgument(final Object arg, final boolean mirrorAlways) {
    if (arg instanceof ConsString) {
        return arg.toString();
    } else if (mirrorAlways && arg instanceof ScriptObject) {
        return ScriptUtils.wrap(arg);
    } else {
        return arg;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:NashornBeansLinker.java

示例5: TranslateToItemStack

import jdk.nashorn.api.scripting.ScriptUtils; //导入方法依赖的package包/类
/**
 * Translates script data to an item stack
 * @param data  The data to translate
 * @return      The ItemStack requested
 * @throws OperationException When the item cannot be found in the registry.
 */
private static RecipeComponent TranslateToItemStack(Object data) throws OperationException {
    RecipeComponent component = new RecipeComponent();

    if(data instanceof String) {
        String itemString = (String)data;

        if(ItemUtility.isOreDictionaryEntry(itemString)) {
            component.setOreDictName(itemString, ItemUtility.getOreDictionaryName(itemString));
        } else {
            component.setItemStack(itemString, ItemUtility.translateToItemStack(itemString));
        }

        return component;
    }

    ScriptObjectMirror item;

    if(ScriptObjectMirror.class.isAssignableFrom(data.getClass())) {
        item = (ScriptObjectMirror)data;
    } else if(ScriptObject.class.isAssignableFrom(data.getClass())) {
        item = ScriptUtils.wrap((ScriptObject) data);
    } else {
        return null;
    }

    if(!item.hasMember("item")) return null;

    NashornConfigProcessor.getInstance().nashorn.parseScriptObject(item,component);

    return component;
}
 
开发者ID:legendblade,项目名称:CraftingHarmonics,代码行数:38,代码来源:RecipeComponentDeserializer.java

示例6: deserialize

import jdk.nashorn.api.scripting.ScriptUtils; //导入方法依赖的package包/类
public static InteractionTargetData deserialize(Object input) {
    // Figure out if we have a valid input here:
    if(input == null || (!ScriptObjectMirror.class.isAssignableFrom(input.getClass()) &&
            !ScriptObject.class.isAssignableFrom(input.getClass()))) return new InteractionTargetData(null, null, null, null);

    ScriptObjectMirror mirror;

    // Convert it over...
    if(ScriptObjectMirror.class.isAssignableFrom(input.getClass())) {
        mirror = (ScriptObjectMirror) input;
    } else {
        mirror = ScriptUtils.wrap((ScriptObject) input);
    }

    // Gather our callbacks:
    IEntityCallback[] onAllowed = mirror.containsKey("onAllowed")
            ? DeserializerHelpers.convertArrayWithDeserializer(mirror, "onAllowed", CALLBACK_DESERIALIZER, IEntityCallback.class)
            : new IEntityCallback[0];
    IEntityCallback[] onDenied = mirror.containsKey("onDenied")
            ? DeserializerHelpers.convertArrayWithDeserializer(mirror, "onDenied", CALLBACK_DESERIALIZER, IEntityCallback.class)
            : new IEntityCallback[0];
    IEntityCallback[] onPassed = mirror.containsKey("onPassed")
            ? DeserializerHelpers.convertArrayWithDeserializer(mirror, "onPassed", CALLBACK_DESERIALIZER, IEntityCallback.class)
            : new IEntityCallback[0];

    // Finally, get our matchers:
    ComponentRegistry registry = ComponentRegistry.compileRegistryFor(new Class[]{IEntityMatcher.class}, mirror);
    List<IEntityMatcher> components = registry.getComponentsOf(IEntityMatcher.class);

    // And build it out...
    return new InteractionTargetData(components != null ? components.toArray(new IEntityMatcher[components.size()]) : null,
            onAllowed, onDenied, onPassed);
}
 
开发者ID:legendblade,项目名称:CraftingHarmonics,代码行数:34,代码来源:EntityInteractionData.java

示例7: setMember

import jdk.nashorn.api.scripting.ScriptUtils; //导入方法依赖的package包/类
@Override
public void setMember(String name, Object value) {
    value = value instanceof ScriptObject ? ScriptUtils.wrap((ScriptObject)value) : value;
    if (value instanceof JSObject) {
        if (session.getId() == null) {
            throw new IllegalStateException(RESIDENT_MODULES_MODIFICATION_MSG);
        } else {
            session.registerModule(name, (JSObject) value);
        }
    } else if (JSType.nullOrUndefined(value)) {
        session.unregisterModule(name);
    }
}
 
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:14,代码来源:ModulesJSFacade.java

示例8: createMirror

import jdk.nashorn.api.scripting.ScriptUtils; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private static Object createMirror(final Object obj) {
    return obj instanceof ScriptObject? ScriptUtils.wrap((ScriptObject)obj) : obj;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:5,代码来源:NashornLinker.java

示例9: Deserialize

import jdk.nashorn.api.scripting.ScriptUtils; //导入方法依赖的package包/类
@Override
public Object Deserialize(Object input) {
    RecipeInput output = new RecipeInput();

    if(input instanceof String) {
        addItemStringBasedMatchers(output, (String)input);
        return output;
    }

    // Make sure we can continue:
    if(!ScriptObjectMirror.class.isAssignableFrom(input.getClass()) &&
            !ScriptObject.class.isAssignableFrom(input.getClass())) return output;

    ScriptObjectMirror mirror;

    // The first case will probably not happen, but, just in case...
    if(ScriptObjectMirror.class.isAssignableFrom(input.getClass())) {
        mirror = (ScriptObjectMirror) input;
    } else {
        mirror = ScriptUtils.wrap((ScriptObject) input);
    }

    // If we don't have an item... /sigh
    if (!mirror.containsKey("item")) return output;
    Object item = mirror.get("item");

    // Make sure we have a string and somebody's not trying to be clever..
    if(!(item instanceof String)) {
        LogHelper.error("Couldn't convert '" + item.toString() + "' to a valid item string.");
        return output;
    }

    addItemStringBasedMatchers(output, (String)item);

    // And if we still don't have anything, means we still had a bad input string...
    if(RecipeInput.isNullOrEmpty(output)) {
        LogHelper.error("Couldn't convert '" + item.toString() + "' to a valid item string.");
        return output;
    }

    // Get our registry data...
    ComponentRegistry registry = ComponentRegistry.compileRegistryFor(new Class[]{
            IRecipeInputMatcher.class,
            IItemStackTransformer.class}, mirror);

    List<IRecipeInputMatcher> matchers = registry.getComponentsOf(IRecipeInputMatcher.class);
    List<IItemStackTransformer> transformers = registry.getComponentsOf(IItemStackTransformer.class);

    // Deal with matchers
    if(matchers != null) {
        for (IRecipeInputMatcher matcher : matchers) {
            // Quick hack; should do a global registration of this later for faster lookup...
            PrioritizedObject priority = matcher.getClass().getAnnotation(PrioritizedObject.class);
            output.addMatcher(matcher, priority.priority());
        }
    }

    if(transformers != null) {
        for(IItemStackTransformer transformer : transformers) {
            output.addTransformer(transformer);

            // Also deal with any implied transformers we have (if any)
            IItemStackTransformer[] impliedTransformers = transformer.getImpliedTransformers();
            for(IItemStackTransformer implied : impliedTransformers) {
                output.addTransformer(implied);
            }
        }
    }

    return output;
}
 
开发者ID:legendblade,项目名称:CraftingHarmonics,代码行数:72,代码来源:RecipeInputDeserializer.java

示例10: createMirror

import jdk.nashorn.api.scripting.ScriptUtils; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private static Object createMirror(final Object obj) {
    return ScriptUtils.wrap(obj);
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:5,代码来源:NashornLinker.java


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