use of clojure.lang.Namespace in project invesdwin-context by invesdwin.
the class ClojureBindings method map.
private Map<String, Object> map() {
final Map<String, Object> map = new HashMap<String, Object>();
final Namespace ns = Namespace.find(namespaceIntern);
for (final Object el : ns.getMappings()) {
final MapEntry entry = (MapEntry) el;
final Symbol key = (Symbol) entry.key();
final Object valAt = ns.getMappings().valAt(key);
final Var valVar = valAt instanceof Var ? ((Var) valAt) : null;
if (valVar == null) {
// skip non-variables
continue;
}
if (valVar.ns != ns) {
// skip non-user vars
continue;
}
if (!valVar.isBound()) {
// skip unbound vars
continue;
}
map.put(key.getName(), valVar.get());
}
return map;
}
use of clojure.lang.Namespace in project invesdwin-context by invesdwin.
the class ClojureBindings method clear.
@Override
public void clear() {
final Symbol nsSymbol = namespaceIntern;
final Namespace ns = Namespace.find(nsSymbol);
for (final Object el : ns.getMappings()) {
final MapEntry entry = (MapEntry) el;
final Symbol key = (Symbol) entry.key();
final Object valAt = ns.getMappings().valAt(key);
final Var valVar = valAt instanceof Var ? ((Var) valAt) : null;
if (valVar == null) {
// skip non-variables
continue;
}
if (valVar.ns != ns) {
// skip non-user vars
continue;
}
if (!valVar.isBound()) {
// skip unbound vars
continue;
}
RT.var(CORE_NS, "ns-unmap").invoke(nsSymbol, key);
}
}