/** * EXPERIMENTAL: */ public static boolean isSupersetOfContext(ScopedIF obj, TopicIF[] context) { // Get object scope Collection<TopicIF> objscope = obj.getScope(); for (int i=0; i < context.length; i++) { if (!objscope.contains(context[i])) return false; } return true; }
@Override public boolean ok(ScopedIF scoped) { if (context == null || context.isEmpty()) return false; Collection<TopicIF> objscope = scoped.getScope(); if (objscope.containsAll(context)) return true; return false; }
/** * INTERNAL: Return all objects that are in the given scope. */ protected Collection getCharacteristicsInScope(Collection objects, Collection scope) { Iterator it = objects.iterator(); Collection objectsInScope = new ArrayList(); while (it.hasNext()) { ScopedIF scopedObj = (ScopedIF) it.next(); if (scopedObj.getScope().equals(scope)) objectsInScope.add(scopedObj); } return objectsInScope; }
private static void copyScope(ScopedIF target, ScopedIF source) { Iterator<TopicIF> it = source.getScope().iterator(); while (it.hasNext()) target.addTheme(it.next()); }
private void writeScope(ScopedIF obj, ContentHandler dh) throws SAXException { Iterator it = obj.getScope().iterator(); if (!it.hasNext()) return; dh.startElement(EMPTY_NAMESPACE, EMPTY_LOCALNAME, "scope", EMPTY_ATTR_LIST); while (it.hasNext()) writeTopicRef((TopicIF) it.next(), dh); dh.endElement(EMPTY_NAMESPACE, EMPTY_LOCALNAME, "scope"); }
@Override public boolean ok(ScopedIF scoped) { return scoped.getScope().isEmpty() || subdecider.ok(scoped); }
private void writeScope(ScopedIF scoped, ContentHandler dh, ContextHolder context) throws SAXException { if (scoped.getScope().size() > 0) { dh.startElement("", "", "scope", empty); Iterator<TopicIF> it = context.topicRefsInOrder(scoped.getScope()); while (it.hasNext()) writeTopicRef(it.next(), dh, context); dh.endElement("", "", "scope"); } }
private String getScope(ScopedIF scoped) { Iterator it = filterCollection(scoped.getScope()).iterator(); if (!it.hasNext()) return null; StringBuilder buf = new StringBuilder(); while (it.hasNext()) { TopicIF theme = (TopicIF) it.next(); buf.append(getElementTypeName(theme, null) + " "); } return buf.substring(0, buf.length() - 1); // lose last space }
protected static void updateScope(ScopedIF scoped, String[] scope, Entity entity, String[] tuple, Context ctx) { // clear existing scope Collection _scope = scoped.getScope(); if (!_scope.isEmpty()) { Object[] themes = _scope.toArray(); for (int i=0; i < themes.length; i++) { scoped.removeTheme((TopicIF)themes[i]); } } // add new scoping topics addScope(scoped, scope, entity, tuple, ctx); }
@Override public void processEvent(S scoped, String event, TopicIF new_value, TopicIF old_value) { // Register themes Collection<TopicIF> scope = scoped.getScope(); if (scope.size() == 1 && scope.contains(old_value)) // Unregister null theme objects.add(null, scoped); // Unregister theme objects.remove(old_value, scoped); } }
protected static void updateScope(ScopedIF scoped, String[] scope, Entity entity, String[] tuple, Context ctx) { // clear existing scope Collection<TopicIF> _scope = scoped.getScope(); if (!_scope.isEmpty()) { TopicIF[] themes = _scope.toArray(new TopicIF[0]); for (int i=0; i < themes.length; i++) { scoped.removeTheme(themes[i]); } } // add new scoping topics addScope(scoped, scope, entity, tuple, ctx); }
@Override public void processEvent(Object object, String event, S new_value, S removed) { // Unregister themes Collection<TopicIF> scope = removed.getScope(); if (!scope.isEmpty()) { for (TopicIF _scope : scope) removeEvent(removed, child_event, _scope); } // Unregister null theme objects.remove(null, removed); } }
@Override public void processEvent(S scoped, String event, TopicIF new_value, TopicIF old_value) { // Register scope Collection<TopicIF> scope = scoped.getScope(); if (scope.isEmpty()) // Unregister null theme objects.remove(null, scoped); // Register theme objects.add(new_value, scoped); } }
private static void copyScope(ScopedIF target, ScopedIF source, Map<TopicIF, TopicIF> mergemap) { Iterator<TopicIF> it = source.getScope().iterator(); while (it.hasNext()) { TopicIF replacement = it.next(); target.addTheme(resolveTopic(target.getTopicMap(), replacement, mergemap)); } }
private static void copyScope(ScopedIF target, ScopedIF source) { Iterator<TopicIF> it = source.getScope().iterator(); while (it.hasNext()) target.addTheme(copyTopic(target.getTopicMap(), it.next())); }
@Override public Set<Topic> getScope() { return topicMap.wrapSet(((ScopedIF) getWrapped()).getScope()); }
@Get public Collection<TopicIF> getScope() { return resolve().getScope(); }
private void addScopesOf(List matches, Collection scopeds) { Iterator it = scopeds.iterator(); while (it.hasNext()) { ScopedIF object = (ScopedIF) it.next(); Iterator it2 = object.getScope().iterator(); while (it2.hasNext()) addMatch(matches, "SCOPED", object, "THEME", it2.next()); } }
protected void scopedTest(ScopedIF scoped) { LocatorIF loc = base.resolveAbsolute("#theme-1"); TopicIF theme = (TopicIF)tm.getObjectByItemIdentifier(loc); assertTrue("getScope (type check)", scoped.getScope() instanceof java.util.Collection); int scope_count = scoped.getScope().size(); scoped.addTheme(theme); assertTrue("getScope (size check after add)", scoped.getScope().size() == scope_count + 1); scoped.removeTheme(theme); assertTrue("getScope (size check after remove)", scoped.getScope().size() == scope_count); }
@Put public Collection<TopicIF> addScope(Topic scope) { ScopedIF resolved = resolve(); getController(ScopedController.class).add(resolved, scope); store.commit(); return resolved.getScope(); } }