@Override public TopicIF getTopic() { TopicNameIF name = getTopicName(); if (name == null) return null; return name.getTopic(); }
@Override public TopicIF getTopic() { TopicNameIF name = getTopicName(); if (name == null) return null; return name.getTopic(); }
/** * INTERNAL: Gets the topics of a collection of basenames. * * @param basenames A collection of TopicNameIFs. * @return A collection of TopicIF objects; the topics to which the * basenames belong. */ public static Collection<TopicIF> getTopicsOfTopicNames(Collection<TopicNameIF> basenames) { Collection<TopicIF> topics = new HashSet<TopicIF>(); Iterator<TopicNameIF> iter = basenames.iterator(); while (iter.hasNext()) { TopicIF topic = iter.next().getTopic(); if (topic != null) topics.add(topic); } return topics; }
@Override public void processEvent(Object object, String event, Object new_value, Object old_value) { TopicNameIF bn = (TopicNameIF)object; TopicIF topic = bn.getTopic(); if (topic != null) topicModified(topic); } }
@Override public Topic getParent() { return topicMap.wrapTopic(wrapped.getTopic()); }
/** * INTERNAL: Returns the topics that have a basename with the given * string value in the given scope.<p> * * This method is used to look up topics in the socalled topic name * space. Note that whether a single topic is returned depends on * whether the topic map have been completely processed or not. */ public Collection<TopicIF> getTopics(String basename_string, Collection<TopicIF> scope) { HashSet<TopicIF> topics = new HashSet<TopicIF>(); Iterator<TopicNameIF> it = nameix.getTopicNames(basename_string).iterator(); while (it.hasNext()) { TopicNameIF bn = it.next(); if (bn.getScope().equals(scope)) topics.add(bn.getTopic()); } return topics; }
public static TopicIF getTopic(TMObjectIF tmobject) { if (tmobject == null) return null; else if (tmobject instanceof TopicNameIF) return ((TopicNameIF)tmobject).getTopic(); else if (tmobject instanceof VariantNameIF) return ((VariantNameIF)tmobject).getTopic(); else if (tmobject instanceof OccurrenceIF) return ((OccurrenceIF)tmobject).getTopic(); else if (tmobject instanceof TopicIF) return ((TopicIF)tmobject); else return null; }
@Override public void processEvent(Object object, String event, Object new_value, Object old_value) { VariantNameIF vn = (VariantNameIF)object; TopicNameIF bn = vn.getTopicName(); if (bn != null) { TopicIF topic = bn.getTopic(); if (topic != null) topicModified(topic); } } }
protected void addTopicName(TopicNameIF name) { if (name == null) throw new NullPointerException(MSG_NULL_ARGUMENT); // Check to see if name is already a member of this topic if (name.getTopic() == this) return; // Check if used elsewhere. if (name.getTopic() != null) throw new ConstraintViolationException("Moving objects is not allowed."); // Notify listeners fireEvent(TopicIF.EVENT_ADD_TOPICNAME, name, null); // Set topic property ((TopicName)name).setTopic(this); // Notify transaction valueAdded(LF_names, name, false); }
protected void removeTopicName(TopicNameIF name) { if (name == null) throw new NullPointerException(MSG_NULL_ARGUMENT); // Check to see if name is not a member of this topic if (name.getTopic() != this) return; // Notify listeners fireEvent(TopicIF.EVENT_REMOVE_TOPICNAME, null, name); // Unset topic property ((TopicName)name).setTopic(null); // Notify transaction valueRemoved(LF_names, name, false); }
public void testTopic() { if (parent instanceof TopicIF) { // we are now testing a basename assertTrue("parent is not right object", parent.equals(basename.getTopic())); } else { VariantNameIF variant = (VariantNameIF) basename; assertTrue("parent and grandparent do not agree", variant.getTopicName().getTopic().equals(basename.getTopic())); } }
this.objectId = original.getObjectId(); this.srclocs = new ArrayList<LocatorIF>(original.getItemIdentifiers()); this.topic = SnapshotTopic.makeSnapshot(original.getTopic(), SnapshotTopic.SNAPSHOT_REFERENCE, processed); this.value = original.getValue(); this.variants = new ArrayList<VariantNameIF>();
while (it.hasNext()) { TopicNameIF bn = (TopicNameIF) it.next(); if (bn.getTopic().equals(topic)) continue; // we've found ourselves
public void testTopic() { TopicIF topic = variant.getTopicName().getTopic(); assertTrue("parent is not right object", variant.getTopic().equals(topic)); }
public static String toString(TMObjectIF tmobject) { if (tmobject == null) return "null"; else if (tmobject instanceof TopicNameIF) return ((TopicNameIF)tmobject).getTopic().getObjectId(); else if (tmobject instanceof VariantNameIF) return ((VariantNameIF)tmobject).getTopic().getObjectId(); else if (tmobject instanceof OccurrenceIF) return ((OccurrenceIF)tmobject).getTopic().getObjectId(); else if (tmobject instanceof TopicIF) return ((TopicIF)tmobject).getObjectId(); else return "null"; }
public void testName() { LocatorIF loc = base.resolveAbsolute("#topic-2"); TopicIF topic = (TopicIF)tm.getObjectByItemIdentifier(loc); TopicNameIF topic_name = (TopicNameIF)topic.getTopicNames().iterator().next(); tmobjectTest(topic_name, true, true); assertTrue("getTopicName", topic_name.getTopic() == topic); }
writer.object(); } else { serializeParent(name.getTopic());
public void testTopicName() { LocatorIF loc1 = base.resolveAbsolute("#topic-2"); LocatorIF loc2 = base.resolveAbsolute("#double"); TopicIF topic = (TopicIF)tm.getObjectByItemIdentifier(loc1); TopicIF dtheme = (TopicIF)tm.getObjectByItemIdentifier(loc2); assertTrue("TopicIF.getTopicNames() size == 3", topic.getTopicNames().size() == 3); // Get appropriate base name by scope filtering Iterator deciter = new DeciderIterator(new IntersectionOfContextDecider(Collections.singleton(dtheme)), topic.getTopicNames().iterator()); TopicNameIF topic_name = (TopicNameIF)deciter.next(); //TopicNameIF topic_name = (TopicNameIF)ScopeUtils.getInBroadScope(topic.getTopicNames(), dtheme).iterator().next(); tmobjectTest(topic_name, true, true); assertTrue("getTopic", topic_name.getTopic() == topic); // assertTrue("getTopicNames (size check before add)", topic_name.getTopicNames().size() == 2); // assertTrue("getDisplayNames (size check before add)", topic_name.getDisplayNames().size() == 2); // assertTrue("getSortNames (size check before add)", topic_name.getSortNames().size() == 2); int org_count = topic.getTopicNames().size(); TopicMapBuilderIF builder = tm.getBuilder(); TopicNameIF basename = builder.makeTopicName(topic, ""); assertTrue("getTopicNames (size check after add)"+topic.getTopicNames().size(), topic.getTopicNames().size() == org_count + 1); basename.remove(); assertTrue("getTopicNames (size check after remove)", topic.getTopicNames().size() == org_count); }
@Test public void testTopicName() throws Exception { TopicNameIF name = tm1.getBuilder().makeTopicName(foo1, foo1, "foo"); name.setReifier(foo1); // todo: scope, pending #265 concurrentCommit(); // verify no inconsistenties were created check(tm1, name.getType(), "Topic name", "type"); check(tm1, name.getTopic(), "Topic name", "topic"); check(tm1, name.getReifier(), "Topic name", "reifier"); }