本文整理汇总了Java中clojure.lang.Seqable类的典型用法代码示例。如果您正苦于以下问题:Java Seqable类的具体用法?Java Seqable怎么用?Java Seqable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Seqable类属于clojure.lang包,在下文中一共展示了Seqable类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: map
import clojure.lang.Seqable; //导入依赖的package包/类
public void map(Object key, Object value, Collector<Object, Object> collector){
if(fn == null) {
IFn require = Clojure.var("clojure.core", "require");
require.invoke(Clojure.read(ns));
fn = Clojure.var(ns, sym);
}
for (Object o : (Iterable)fn.invoke(key, value)){
Seqable s = (Seqable)o;
ISeq seq = s.seq();
Object k = seq.first();
Object v = seq.next().first();
collector.emit(k, v);
}
}
开发者ID:danstone,项目名称:immutant-mr,代码行数:17,代码来源:InfinispanMapper.java
示例2: encodeHeaders
import clojure.lang.Seqable; //导入依赖的package包/类
public void encodeHeaders(DynamicBytes bytes) {
final int total = size << 1;
for (int i = 0; i < total; i += 2) {
String k = (String) arrays[i];
Object v = arrays[i + 1];
if (v instanceof String) {
bytes.append(k);
bytes.append(COLON, SP);
// supposed to be ISO-8859-1, but utf-8 is compatible.
// filename in Content-Disposition can be utf8
bytes.append((String) v, HttpUtils.UTF_8);
bytes.append(CR, LF);
// ring spec says it could be a seq
} else if (v instanceof Seqable) {
ISeq seq = ((Seqable) v).seq();
while (seq != null) {
bytes.append(k);
bytes.append(COLON, SP);
bytes.append(seq.first().toString(), HttpUtils.UTF_8);
bytes.append(CR, LF);
seq = seq.next();
}
}
}
bytes.append(CR, LF);
}
开发者ID:nLight,项目名称:jruby-http-kit,代码行数:27,代码来源:HeaderMap.java
示例3: invoke
import clojure.lang.Seqable; //导入依赖的package包/类
@Override
public Object invoke(Object newVal) {
if (newVal instanceof Seqable) {
ISeq seq = ((Seqable) newVal).seq();
// An empty seqable returns null.
if (seq == null) {
return true;
}
int count = seq.count();
while (count --> 0) {
Object o = seq.first();
seq = seq.next();
if (!(o instanceof Runnable)) {
return false;
}
}
return true;
}
else if (newVal == null) {
return true;
}
else {
return false;
}
}
开发者ID:hypirion,项目名称:beckon,代码行数:26,代码来源:SignalAtoms.java
示例4: toJava
import clojure.lang.Seqable; //导入依赖的package包/类
/**
* Turn a Clojure result into an object that is easier for Java to handle.
*
* @param result The result value to wrap.
* @param <T> The type of the return value.
* @return If the result is a core Clojure collection, returns an instanceof IClojureIterable, else returns result.
*/
@SuppressWarnings("unchecked")
public static <T> T toJava(Object result) {
if (result instanceof IPersistentMap) {
return (T) new ClojureMap((IPersistentMap) result);
} else if (result instanceof IPersistentVector) {
return (T) new ClojureVector((IPersistentVector) result);
} else if (result instanceof ISeq) {
return (T) new ClojureSeq((ISeq) result);
} else if (result instanceof Seqable) {
return (T) new ClojureSeq(((Seqable)result).seq());
}
return (T) result;
}
开发者ID:shopsmart,项目名称:ClJ,代码行数:21,代码来源:ClJ.java
示例5: setHandler
import clojure.lang.Seqable; //导入依赖的package包/类
/**
* Registers the new list of functions to the signal name, and returns the
* old SignalHandler.
*/
private static SignalHandler setHandler(String signame, Seqable fns) {
Signal sig = new Signal(signame);
SignalFolder folder = new SignalFolder(fns);
SignalHandler oldHandler = Signal.handle(sig, folder);
return oldHandler;
}
开发者ID:hypirion,项目名称:beckon,代码行数:11,代码来源:SignalRegistererHelper.java
示例6: getHandlerSeq
import clojure.lang.Seqable; //导入依赖的package包/类
/**
* Returns a set of Runnables which is used within the SignalFolder
* handling the Signal, or a PersistentSet with a Runnable SignalHandler if
* the SignalHandler is not a SignalFolder.
*
* @param signame The name of the Signal.
*
* @return A list with the Runnables used in the SignalFolder.
*/
static synchronized Seqable getHandlerSeq(String signame) {
Signal sig = new Signal(signame);
// Urgh, no easy way to get current signal handler.
// Double-handle to get current one without issues.
SignalHandler current = Signal.handle(sig, SignalHandler.SIG_DFL);
Signal.handle(sig, current);
if (current instanceof SignalFolder) {
return ((SignalFolder)current).originalList;
}
else {
Runnable wrappedHandler = new RunnableSignalHandler(sig, current);
return PersistentHashSet.create(wrappedHandler);
}
}
开发者ID:hypirion,项目名称:beckon,代码行数:24,代码来源:SignalRegistererHelper.java
示例7: SignalFolder
import clojure.lang.Seqable; //导入依赖的package包/类
public SignalFolder(Seqable funs) {
ISeq seq = funs.seq();
// seq may be null
if (seq == null) {
fns = new Runnable[0];
}
else {
fns = new Runnable[seq.count()];
for (int i = 0; i < fns.length; i++) {
fns[i] = (Runnable) seq.first();
seq = seq.next();
}
}
originalList = funs;
}
开发者ID:hypirion,项目名称:beckon,代码行数:16,代码来源:SignalFolder.java
示例8: seq
import clojure.lang.Seqable; //导入依赖的package包/类
@Override
public ISeq seq() {
return ((Seqable) map).seq();
}
开发者ID:rschmitt,项目名称:dynamic-object,代码行数:5,代码来源:DynamicObjectInstance.java
示例9: register
import clojure.lang.Seqable; //导入依赖的package包/类
/**
* Registers the signal name to a List of Runnables, where each callable
* returns an Object. The signal handling is performed as follows: The first
* callable is called, and if it returns a value equal to <code>false</code>
* or <code>null</code> it will stop. Otherwise it will repeat on the next
* callable, until there are no more left.
*
* @param signame the signal name to register this list of callables on.
* @param fns the list of Runnables to (potentially) call.
*/
static synchronized void register(String signame, Seqable fns) {
SignalHandler old = setHandler(signame, fns);
if (!originalHandlers.containsKey(signame)) {
originalHandlers.put(signame, old);
}
}
开发者ID:hypirion,项目名称:beckon,代码行数:17,代码来源:SignalRegistererHelper.java
注:本文中的clojure.lang.Seqable类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论