org.jruby.RubyHash.put()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(149)

本文整理了Java中org.jruby.RubyHash.put方法的一些代码示例,展示了RubyHash.put的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RubyHash.put方法的具体详情如下:
包路径:org.jruby.RubyHash
类名称:RubyHash
方法名:put

RubyHash.put介绍

暂无

代码示例

代码示例来源:origin: asciidoctor/asciidoctorj

public static RubyHash toNoneSymbolsRubyHash(Ruby rubyRuntime, Map<String, Object> map) {
  RubyHash rubyHash = new RubyHash(rubyRuntime);
  Set<Entry<String, Object>> entrySet = map.entrySet();
  for (Entry<String, Object> entry : entrySet) {
    rubyHash.put(toJavaObject(entry.getKey()), toJavaObject(entry.getValue()));
  }
  return rubyHash;
}

代码示例来源:origin: org.asciidoctor/asciidoctorj

public static RubyHash toNoneSymbolsRubyHash(Ruby rubyRuntime, Map<String, Object> map) {
  RubyHash rubyHash = new RubyHash(rubyRuntime);
  Set<Entry<String, Object>> entrySet = map.entrySet();
  for (Entry<String, Object> entry : entrySet) {
    rubyHash.put(toJavaObject(entry.getKey()), toJavaObject(entry.getValue()));
  }
  return rubyHash;
}

代码示例来源:origin: org.asciidoctor/asciidoctor-java-integration

public static RubyHash toNoneSymbolsRubyHash(Ruby rubyRuntime,
    Map<String, Object> map) {
  RubyHash rubyHash = new RubyHash(rubyRuntime);
  Set<Entry<String, Object>> entrySet = map.entrySet();
  for (Entry<String, Object> entry : entrySet) {
    rubyHash.put(toJavaObject(entry.getKey()),
        toJavaObject(entry.getValue()));
  }
  return rubyHash;
}

代码示例来源:origin: square/rack-servlet

private RubyHash convertToRubyHash(Set<Map.Entry<String, Object>> entries) {
 RubyHash hash = newHash(runtime);
 for (Map.Entry<String, Object> entry : entries) {
  String key = entry.getKey();
  Object value = entry.getValue();
  if (key.equals("rack.input")) {
   value = new JRubyRackInput(runtime, (RackInput) value);
  }
  if (key.equals("rack.version")) {
   value = convertToRubyArray((List<Integer>) value);
  }
  hash.put(key, value);
 }
 return hash;
}

代码示例来源:origin: org.asciidoctor/asciidoctor-java-integration

public static RubyHash convertMapToRubyHashWithSymbols(Ruby rubyRuntime,
    Map<String, Object> options) {
  RubyHash rubyHash = new RubyHash(rubyRuntime);
  Set<Entry<String, Object>> optionsSet = options.entrySet();
  for (Entry<String, Object> entry : optionsSet) {
    String key = entry.getKey();
    Object value = entry.getValue();
    RubySymbol newSymbol = RubyUtils.toSymbol(rubyRuntime, key);
    IRubyObject iRubyValue = toRubyObject(rubyRuntime, value);
    rubyHash.put(newSymbol, iRubyValue);
  }
  return rubyHash;
}

代码示例来源:origin: asciidoctor/asciidoctorj

public void setASTNode(ContentNode astNode) {
  cache.put(getRuntime().newSymbol(KEY_AST_NODE), astNode);
}

代码示例来源:origin: org.asciidoctor/asciidoctorj

public void setASTNode(ContentNode astNode) {
  cache.put(getRuntime().newSymbol(KEY_AST_NODE), astNode);
}

代码示例来源:origin: asciidoctor/asciidoctorj

public static RubyHash convertMapToRubyHashWithSymbols(Ruby rubyRuntime, Map<String, Object> options) {
  if (options instanceof RubyHashMapDecorator) {
    return ((RubyHashMapDecorator) options).getRubyHash();
  }
  RubyHash rubyHash = new RubyHash(rubyRuntime);
  Set<Entry<String, Object>> optionsSet = options.entrySet();
  for (Entry<String, Object> entry : optionsSet) {
    String key = entry.getKey();
    Object value = entry.getValue();
    RubySymbol newSymbol = RubyUtils.toSymbol(rubyRuntime, key);
    IRubyObject iRubyValue = toRubyObject(rubyRuntime, value);
    rubyHash.put(newSymbol, iRubyValue);
  }
  return rubyHash;
}

代码示例来源:origin: org.asciidoctor/asciidoctorj

public static RubyHash convertMapToRubyHashWithSymbols(Ruby rubyRuntime, Map<String, Object> options) {
  if (options instanceof RubyHashMapDecorator) {
    return ((RubyHashMapDecorator) options).getRubyHash();
  }
  RubyHash rubyHash = new RubyHash(rubyRuntime);
  Set<Entry<String, Object>> optionsSet = options.entrySet();
  for (Entry<String, Object> entry : optionsSet) {
    String key = entry.getKey();
    Object value = entry.getValue();
    RubySymbol newSymbol = RubyUtils.toSymbol(rubyRuntime, key);
    IRubyObject iRubyValue = toRubyObject(rubyRuntime, value);
    rubyHash.put(newSymbol, iRubyValue);
  }
  return rubyHash;
}

代码示例来源:origin: org.asciidoctor/asciidoctorj

@Override
public Object put(String key, Object value) {
  final Object convertedKey = convertJavaToRubyKey(key);
  Object oldValue = rubyHash.get(convertedKey);
  rubyHash.put(convertedKey, convertJavaValue(value));
  return oldValue;
}

代码示例来源:origin: asciidoctor/asciidoctorj

@Override
public Object put(String key, Object value) {
  final Object convertedKey = convertJavaToRubyKey(key);
  Object oldValue = rubyHash.get(convertedKey);
  rubyHash.put(convertedKey, convertJavaValue(value));
  return oldValue;
}

代码示例来源:origin: asciidoctor/asciidoctorj

private static void handleDefaultAttributeAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) {
  Ruby rubyRuntime = rubyClass.getRuntime();
  if (processor.isAnnotationPresent(DefaultAttribute.class)) {
    DefaultAttribute defaultAttribute = processor.getAnnotation(DefaultAttribute.class);
    RubyHash defaultAttrs = RubyHash.newHash(rubyRuntime);
    defaultAttrs.put(defaultAttribute.key(), defaultAttribute.value());
    rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{
        rubyRuntime.newSymbol("default_attrs"),
        defaultAttrs
    });
  }
}

代码示例来源:origin: org.asciidoctor/asciidoctorj

private static void handleDefaultAttributeAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) {
  Ruby rubyRuntime = rubyClass.getRuntime();
  if (processor.isAnnotationPresent(DefaultAttribute.class)) {
    DefaultAttribute defaultAttribute = processor.getAnnotation(DefaultAttribute.class);
    RubyHash defaultAttrs = RubyHash.newHash(rubyRuntime);
    defaultAttrs.put(defaultAttribute.key(), defaultAttribute.value());
    rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{
        rubyRuntime.newSymbol("default_attrs"),
        defaultAttrs
    });
  }
}

代码示例来源:origin: asciidoctor/asciidoctorj

private static void handleDefaultAttributesAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) {
  Ruby rubyRuntime = rubyClass.getRuntime();
  if (processor.isAnnotationPresent(DefaultAttributes.class)) {
    DefaultAttributes defaultAttributes = processor.getAnnotation(DefaultAttributes.class);
    RubyHash defaultAttrs = RubyHash.newHash(rubyRuntime);
    for (DefaultAttribute defaultAttribute : defaultAttributes.value()) {
      defaultAttrs.put(defaultAttribute.key(), defaultAttribute.value());
    }
    rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{
        rubyRuntime.newSymbol("default_attrs"),
        defaultAttrs
    });
  }
}

代码示例来源:origin: asciidoctor/asciidoctorj

@Override
public Object put(String key, Object value) {
  Object oldValue = get(key);
  RubySymbol symbol = rubyHash.getRuntime().getSymbolTable().getSymbol(key);
  rubyHash.put(symbol, convertJavaValue(value));
  return oldValue;
}

代码示例来源:origin: org.asciidoctor/asciidoctorj

private static void handleDefaultAttributesAnnotation(Class<? extends Processor> processor, RubyClass rubyClass) {
  Ruby rubyRuntime = rubyClass.getRuntime();
  if (processor.isAnnotationPresent(DefaultAttributes.class)) {
    DefaultAttributes defaultAttributes = processor.getAnnotation(DefaultAttributes.class);
    RubyHash defaultAttrs = RubyHash.newHash(rubyRuntime);
    for (DefaultAttribute defaultAttribute : defaultAttributes.value()) {
      defaultAttrs.put(defaultAttribute.key(), defaultAttribute.value());
    }
    rubyClass.callMethod(rubyRuntime.getCurrentContext(), "option", new IRubyObject[]{
        rubyRuntime.newSymbol("default_attrs"),
        defaultAttrs
    });
  }
}

代码示例来源:origin: org.asciidoctor/asciidoctorj

@Override
public Object put(String key, Object value) {
  Object oldValue = get(key);
  RubySymbol symbol = rubyHash.getRuntime().getSymbolTable().getSymbol(key);
  rubyHash.put(symbol, convertJavaValue(value));
  return oldValue;
}

代码示例来源:origin: asciidoctor/asciidoctorj

@Override
public Title getStructuredDoctitle() {
  Ruby runtime = getRubyObject().getRuntime();
  RubyHash options = RubyHash.newHash(runtime);
  RubySymbol partitioned = RubySymbol.newSymbol(runtime, "partition");
  options.put(partitioned, RubyBoolean.newBoolean(runtime, true));
  Object doctitle = getRubyProperty("doctitle", options);
  return toJava((IRubyObject) doctitle, Title.class);
}

代码示例来源:origin: asciidoctor/asciidoctorj

/**
 * Creates an inner document for the given parent document.
 * Inner documents are used for tables cells with style {@code asciidoc}.
 *
 * @param parentDocument The parent document of the new document.
 * @return A new inner document.
 */
@Override
public Document createDocument(Document parentDocument) {
  Ruby runtime = JRubyRuntimeContext.get(parentDocument);
  RubyHash options = RubyHash.newHash(runtime);
  options.put(
      runtime.newSymbol("parent"),
      ((DocumentImpl) parentDocument).getRubyObject());
  return (Document) NodeConverter.createASTNode(runtime, DOCUMENT_CLASS, runtime.getNil(), options);
}

代码示例来源:origin: org.asciidoctor/asciidoctorj

@Override
public Title getStructuredDoctitle() {
  Ruby runtime = getRubyObject().getRuntime();
  RubyHash options = RubyHash.newHash(runtime);
  RubySymbol partitioned = RubySymbol.newSymbol(runtime, "partition");
  options.put(partitioned, RubyBoolean.newBoolean(runtime, true));
  Object doctitle = getRubyProperty("doctitle", options);
  return toJava((IRubyObject) doctitle, Title.class);
}

相关文章

微信公众号

最新文章

更多

RubyHash类方法