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


Java Bindings.get方法代码示例

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


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

示例1: testThing

import javax.script.Bindings; //导入方法依赖的package包/类
public void testThing()
{
  Product thing = Product.create();
  thing.setPrice( 1.55 );
  assertEquals( 1.55, thing.getPrice() );

  Product.dimensions dims = Product.dimensions.create();
  dims.setLength( 3.0 );
  dims.setWidth( 4.0 );
  dims.setHeight( 5.0 );
  thing.setDimensions( dims );
  Product.dimensions dims2 = thing.getDimensions();
  assertSame( dims, dims2 );

  Bindings bindings = (Bindings)thing;
  dims2 = (Product.dimensions)bindings.get( "dimensions" );
  assertSame( dims, dims2 );
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:19,代码来源:JsonTest.java

示例2: readList

import javax.script.Bindings; //导入方法依赖的package包/类
static <E extends IJsonIO> List<E> readList( String tag, Bindings bindings )
{
  //noinspection unchecked
  List<Bindings> list = (List<Bindings>)bindings.get( tag );
  if( list == null )
  {
    return Collections.emptyList();
  }

  List<E> objs = list.isEmpty() ? Collections.emptyList() : new ArrayList<>();
  for( Bindings elem : list )
  {
    objs.add( read( elem ) );
  }
  return objs;
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:17,代码来源:IJsonIO.java

示例3: cacheById

import javax.script.Bindings; //导入方法依赖的package包/类
private void cacheById( IJsonParentType parent, IJsonType type, Bindings jsonObj )
{
  Object value = jsonObj.get( JSCH_ID );
  if( value == null )
  {
    return;
  }

  String id;
  Token[] tokens = null;
  if( value instanceof Pair )
  {
    id = (String)((Pair)value).getSecond();
    tokens = (Token[])((Pair)value).getFirst();
  }
  else
  {
    id = (String)value;
  }
  cacheById( parent, type, id, tokens != null ? tokens[1] : null );
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:22,代码来源:JsonSchemaTransformer.java

示例4: transferIssuesFromErrantType

import javax.script.Bindings; //导入方法依赖的package包/类
private void transferIssuesFromErrantType( JsonSchemaType parent, IJsonType result, Bindings jsonObj )
{
  if( result instanceof ErrantType )
  {
    Object value = jsonObj.get( JSCH_REF );
    Token token = null;
    if( value instanceof Pair )
    {
      token = ((Token[])((Pair)value).getFirst())[1];
    }

    for( JsonIssue issue: ((ErrantType)result).getIssues() )
    {
      parent.addIssue( new JsonIssue( issue.getKind(), token, issue.getMessage() ) );
    }
  }
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:18,代码来源:JsonSchemaTransformer.java

示例5: init

import javax.script.Bindings; //导入方法依赖的package包/类
@Override
public void init(Bindings bindings) {
    final PrintWriter out = (PrintWriter) bindings.get(OUT_BINDING);
    final SlingHttpServletRequest request = (SlingHttpServletRequest) bindings.get(REQUEST_BINDING);
    final String template = (String) bindings.get(PatternLabConstants.TEMPLATE_PROPERTY);
    final String path = (String) bindings.get(PatternLabConstants.PATH_PROPERTY);
    final String data = (String) bindings.get(PatternLabConstants.DATA_PROPERTY);
    final SlingScriptHelper slingScriptHelper = (SlingScriptHelper) bindings.get(SLING_BINDING);
    final Map<String, Object> patternData = retrievePatternData(request, data);
    renderPattern(template, path, patternData, bindings, slingScriptHelper, out);
}
 
开发者ID:deepthinkit,项目名称:patternlab-for-sling,代码行数:12,代码来源:RenderPatternUse.java

示例6: isSchema

import javax.script.Bindings; //导入方法依赖的package包/类
public static boolean isSchema( Bindings bindings )
{
         // Ideally the "$schema" element would be required, but JSchema does not require it.
  return bindings.get( JsonSchemaTransformer.JSCH_SCHEMA ) != null ||
         // As a fallback check for "$id" as this is pretty uniquely Json Schema
         bindings.get( JsonSchemaTransformer.JSCH_ID ) != null ||
         // As a fallback to the fallback, check for: "type": "object" or "type": "array"
         bindings.get( JsonSchemaTransformer.JSCH_TYPE ) != null &&
         (bindings.get( JsonSchemaTransformer.JSCH_TYPE ).equals( Type.Object.getName() ) ||
          bindings.get( JsonSchemaTransformer.JSCH_TYPE ).equals( Type.Array.getName() ));
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:12,代码来源:JsonSchemaTransformer.java

示例7: getJSchema_Name

import javax.script.Bindings; //导入方法依赖的package包/类
private static String getJSchema_Name( Bindings docObj )
{
  Object value = docObj.get( JSCH_NAME );
  String name;
  if( value instanceof Pair )
  {
    name = (String)((Pair)value).getSecond();
  }
  else
  {
    name = (String)value;
  }
  return name;
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:15,代码来源:JsonSchemaTransformer.java

示例8: toJson

import javax.script.Bindings; //导入方法依赖的package包/类
/**
 * Serializes this Bindings instance into a JSON formatted StringBuilder with the specified indent of spaces
 */
public static void toJson( @This Bindings thiz, StringBuilder sb, int indent )
{
  int iKey = 0;
  if( isNewLine( sb ) )
  {
    indent( sb, indent );
  }
  if( thiz.size() > 0 )
  {
    sb.append( "{\n" );
    for( String key : thiz.keySet() )
    {
      indent( sb, indent + 2 );
      sb.append( '\"' ).append( key ).append( '\"' ).append( ": " );
      Object value = thiz.get( key );
      if( value instanceof Pair )
      {
        value = ((Pair)value).getSecond();
      }
      if( value instanceof Bindings )
      {
        toJson( ((Bindings)value), sb, indent + 2 );
      }
      else if( value instanceof List )
      {
        listToJson( sb, indent, (List)value );
      }
      else
      {
        JsonUtil.appendValue( sb, value );
      }
      appendCommaNewLine( sb, iKey < thiz.size() - 1 );
      iKey++;
    }
  }
  indent( sb, indent );
  sb.append( "}" );
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:42,代码来源:ManBindingsExt.java

示例9: toJson

import javax.script.Bindings; //导入方法依赖的package包/类
/**
 * Serializes this Bindings instance into a JSON formatted StringBuilder with the specified indent of spaces
 */
public static void toJson( Bindings thisBindings, StringBuilder sb, int indent )
{
  int iKey = 0;
  if( isNewLine( sb ) )
  {
    indent( sb, indent );
  }
  if( thisBindings.size() > 0 )
  {
    sb.append( "{\n" );
    for( String key : thisBindings.keySet() )
    {
      indent( sb, indent + 2 );
      sb.append( '\"' ).append( key ).append( '\"' ).append( ": " );
      Object value = thisBindings.get( key );
      if( value instanceof Bindings )
      {
        toJson( (Bindings)value, sb, indent + 2 );
      }
      else if( value instanceof List )
      {
        listToJson( sb, indent, (List)value );
      }
      else
      {
        appendValue( sb, value );
      }
      appendCommaNewLine( sb, iKey < thisBindings.size() - 1 );
      iKey++;
    }
  }
  indent( sb, indent );
  sb.append( "}" );
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:38,代码来源:JsonUtil.java

示例10: updateBindings

import javax.script.Bindings; //导入方法依赖的package包/类
public static Bindings updateBindings(Bindings bindings, UpdateAttributesRequest msg) {
  Map<String, Object> attrMap = (Map<String, Object>) bindings.get(CLIENT_SIDE);
  for (AttributeKvEntry attr : msg.getAttributes()) {
    if (!CLIENT_SIDE.equalsIgnoreCase(attr.getKey()) && !SERVER_SIDE.equalsIgnoreCase(attr.getKey())
        && !SHARED.equalsIgnoreCase(attr.getKey())) {
      bindings.put(attr.getKey(), getValue(attr));
    }
    attrMap.put(attr.getKey(), getValue(attr));
  }
  bindings.put(CLIENT_SIDE, attrMap);
  return bindings;
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:13,代码来源:NashornJsEvaluator.java

示例11: checkBuiltinsInNewBindingsTest

import javax.script.Bindings; //导入方法依赖的package包/类
@Test
// check that engine.js definitions are visible in all new global instances
public void checkBuiltinsInNewBindingsTest() throws ScriptException {
    final ScriptEngineManager m = new ScriptEngineManager();
    final ScriptEngine e = m.getEngineByName("nashorn");

    // check default global instance has engine.js definitions
    final Bindings g = (Bindings) e.eval("this");
    Object value = g.get("__noSuchProperty__");
    assertTrue(value instanceof ScriptObjectMirror && ((ScriptObjectMirror)value).isFunction());
    value = g.get("print");
    assertTrue(value instanceof ScriptObjectMirror && ((ScriptObjectMirror)value).isFunction());

    // check new global instance created has engine.js definitions
    final Bindings b = e.createBindings();
    value = b.get("__noSuchProperty__");
    assertTrue(value instanceof ScriptObjectMirror && ((ScriptObjectMirror)value).isFunction());
    value = b.get("print");
    assertTrue(value instanceof ScriptObjectMirror && ((ScriptObjectMirror)value).isFunction());

    // put a mapping into GLOBAL_SCOPE
    final Bindings globalScope = e.getContext().getBindings(ScriptContext.GLOBAL_SCOPE);
    globalScope.put("x", "hello");

    // GLOBAL_SCOPE mapping should be visible from default ScriptContext eval
    assertTrue(e.eval("x").equals("hello"));

    final ScriptContext ctx = new SimpleScriptContext();
    ctx.setBindings(globalScope, ScriptContext.GLOBAL_SCOPE);
    ctx.setBindings(b, ScriptContext.ENGINE_SCOPE);

    // GLOBAL_SCOPE mapping should be visible from non-default ScriptContext eval
    assertTrue(e.eval("x", ctx).equals("hello"));

    // try some arbitray Bindings for ENGINE_SCOPE
    final Bindings sb = new SimpleBindings();
    ctx.setBindings(sb, ScriptContext.ENGINE_SCOPE);

    // GLOBAL_SCOPE mapping should be visible from non-default ScriptContext eval
    assertTrue(e.eval("x", ctx).equals("hello"));

    // engine.js builtins are still defined even with arbitrary Bindings
    assertTrue(e.eval("typeof print", ctx).equals("function"));
    assertTrue(e.eval("typeof __noSuchProperty__", ctx).equals("function"));

    // ENGINE_SCOPE definition should 'hide' GLOBAL_SCOPE definition
    sb.put("x", "newX");
    assertTrue(e.eval("x", ctx).equals("newX"));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:50,代码来源:ScopeTest.java

示例12: funcBindings

import javax.script.Bindings; //导入方法依赖的package包/类
public static Object funcBindings(final Bindings bindings) {
    return bindings.get("foo");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:Window.java

示例13: loadFields

import javax.script.Bindings; //导入方法依赖的package包/类
static void loadFields( IJsonIO obj, Class cls, Bindings bindings )
{
  Field[] fields = cls.getDeclaredFields();
  for( Field f : fields )
  {
    if( f.isSynthetic() || Modifier.isStatic( f.getModifiers() ) || Modifier.isTransient( f.getModifiers() ) )
    {
      continue;
    }
    f.setAccessible( true );
    try
    {
      Object value = bindings.get( f.getName() );
      if( value instanceof Bindings )
      {
        value = read( (Bindings)value );
      }
      else if( value instanceof List && ((List)value).size() > 0 && ((List)value).get( 0 ) instanceof Bindings )
      {
        value = readList( bindings );
      }
      else if( f.getType().isEnum() && value instanceof String )
      {
        value = Enum.valueOf( (Class)f.getType(), (String)value );
      }
      else if( f.getType() == Boolean.class || f.getType() == boolean.class )
      {
        value = (Integer)value != 0;
      }
      else if( !isSimpleType( f.getType() ) )
      {
        throw new UnsupportedOperationException( "Unsupported Json type: " + f.getType() );
      }
      f.set( obj, value );
    }
    catch( IllegalAccessException e )
    {
      throw new RuntimeException( e );
    }
  }
  Class superclass = cls.getSuperclass();
  if( superclass != null )
  {
    loadFields( obj, superclass, bindings );
  }
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:47,代码来源:IJsonIO.java

示例14: getJSchema_Definitions

import javax.script.Bindings; //导入方法依赖的package包/类
private static Bindings getJSchema_Definitions( Bindings docObj )
{
  Object value = docObj.get( JSCH_DEFINITIONS );
  return getBindings( value );
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:6,代码来源:JsonSchemaTransformer.java

示例15: getJSchema_Properties

import javax.script.Bindings; //导入方法依赖的package包/类
private static Bindings getJSchema_Properties( Bindings docObj )
{
  Object value = docObj.get( JSCH_PROPERTIES );
  return getBindings( value );
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:6,代码来源:JsonSchemaTransformer.java


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