本文整理汇总了Java中org.jruby.RubySymbol类的典型用法代码示例。如果您正苦于以下问题:Java RubySymbol类的具体用法?Java RubySymbol怎么用?Java RubySymbol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RubySymbol类属于org.jruby包,在下文中一共展示了RubySymbol类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: map2hash
import org.jruby.RubySymbol; //导入依赖的package包/类
@SuppressWarnings("unchecked") private static RubyHash map2hash(Ruby ruby, Map<String, Object> ourCaps) {
RubyHash hash = new RubyHash(ruby);
Set<String> keySet = ourCaps.keySet();
for (String key : keySet) {
RubySymbol keySym = RubySymbol.newSymbol(ruby, key);
Object v = ourCaps.get(key);
if (v instanceof String) {
hash.put(keySym, RubyString.newString(ruby, (String) v));
} else if(v instanceof Boolean) {
hash.put(keySym, RubyBoolean.newBoolean(ruby, (boolean) v));
} else if (v instanceof List) {
hash.put(keySym, map2list(ruby, (List<?>) v));
} else {
hash.put(keySym, map2hash(ruby, (Map<String, Object>) v));
}
}
return hash;
}
示例2: rubyToPig
import org.jruby.RubySymbol; //导入依赖的package包/类
/**
* A type specific conversion routine.
*
* @param rbObject object to convert
* @return analogous Pig type
*/
@SuppressWarnings("unchecked")
public static Map<String, ?> rubyToPig(RubyHash rbObject) throws ExecException {
Map<String, Object> newMap = Maps.newHashMap();
for (Map.Entry<Object, Object> entry : (Set<Map.Entry<Object, Object>>)rbObject.entrySet()) {
Object key = entry.getKey();
if (!(key instanceof String || key instanceof RubyString || key instanceof RubySymbol))
throw new ExecException("Hash must have String or Symbol key. Was given: " + key.getClass().getName());
String keyStr = key.toString();
if (entry.getValue() instanceof IRubyObject) {
newMap.put(keyStr, rubyToPig((IRubyObject)entry.getValue()));
} else {
newMap.put(keyStr, entry.getValue());
}
}
return newMap;
}
示例3: convertRubyHashMapToMap
import org.jruby.RubySymbol; //导入依赖的package包/类
public static Map<Object, Object> convertRubyHashMapToMap(Map<Object, Object> rubyHashMap) {
Map<Object, Object> map = new HashMap<Object, Object>();
Set<Entry<Object, Object>> elements = rubyHashMap.entrySet();
for (Entry<Object, Object> element : elements) {
if(element.getKey() instanceof RubySymbol) {
map.put(toJavaString((RubySymbol)element.getKey()), toJavaObject(element.getValue()));
} else {
map.put(toJavaObject(element.getKey()).toString(), toJavaObject(element.getValue()));
}
}
return map;
}
示例4: scanToAutoEnable
import org.jruby.RubySymbol; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void scanToAutoEnable() {
Object evalResult = eval("Module.constants");
if (evalResult == null || !(evalResult instanceof Collection)) {
return;
}
List processorRubyTypes = PROCESSOR_CLASSES.values().stream().map(processorClass -> eval(processorClass.getSimpleName()))
.collect(Collectors.toList());
List<Object> autoEnabled = new ArrayList<>();
((Collection) evalResult).forEach(element -> {
Object symbol = eval(((RubySymbol) element).asJavaString());
if (symbol != null && symbol instanceof RubyClass) {
RubyClass rubyClass = (RubyClass) symbol;
if (!processorRubyTypes.contains(rubyClass)
&& CollectionUtils.containsAny(rubyClass.getAncestorList(), processorRubyTypes)) {
if (!isProcessorAbstract(rubyClass.getName())) {
autoEnabled.add(rubyClass);
((JRubyKnowledgeBaseEngineOperations) getEngineOperations()).enable(rubyClass);
}
}
}
});
if (logger.isDebugEnabled() && !autoEnabled.isEmpty()) {
logger.debug("Auto-enabling: {}", autoEnabled);
}
}
示例5: getEntriesDir
import org.jruby.RubySymbol; //导入依赖的package包/类
private Path getEntriesDir(final AbstractBlock abstractBlock, final String target) {
final Map<Object, Object> documentOptions = abstractBlock.document().getOptions();
final String currentDir = documentOptions.entrySet().stream()
.filter(e -> "base_dir".equals(RubySymbol.objectToSymbolString((RubySymbol) e.getKey())))
.map(e -> (String) e.getValue())
.findFirst().orElse("");
return Paths.get(currentDir + '/' + target);
}
示例6: toSymbol
import org.jruby.RubySymbol; //导入依赖的package包/类
public static RubySymbol toSymbol(Ruby rubyRuntime, String key) {
RubySymbol newSymbol = RubySymbol.newSymbol(rubyRuntime, key);
return newSymbol;
}
示例7: convertMapToRubyHashWithSymbolsIfNecessary
import org.jruby.RubySymbol; //导入依赖的package包/类
public static RubyHash convertMapToRubyHashWithSymbolsIfNecessary(Ruby rubyRuntime, Map<Object, Object> options) {
RubyHash rubyHash = new RubyHash(rubyRuntime);
Set<Entry<Object, Object>> optionsSet = options.entrySet();
for (Entry<Object, Object> entry : optionsSet) {
Object keyType = entry.getKey();
if (isNotARubySymbol(keyType)) {
String key = (String) keyType;
Object value = entry.getValue();
RubySymbol newSymbol = RubyUtils.toSymbol(rubyRuntime, key);
IRubyObject iRubyValue = toRubyObject(rubyRuntime, value);
rubyHash.put(newSymbol, iRubyValue);
}
}
return rubyHash;
}
示例8: convertMapToRubyHashWithSymbols
import org.jruby.RubySymbol; //导入依赖的package包/类
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;
}
示例9: toJavaString
import org.jruby.RubySymbol; //导入依赖的package包/类
private static String toJavaString(RubySymbol element) {
return element.asJavaString();
}