@Override public OccurrenceIF makeOccurrence(TopicIF topic, TopicIF occurs_type, String value, LocatorIF datatype) { if (topic == null) throw new NullPointerException(MSG_TOPIC_NOT_NULL); if (occurs_type == null) throw new NullPointerException(MSG_OCCURRENCE_TYPE_NOT_NULL); if (value == null) throw new NullPointerException(MSG_OCCURRENCE_VALUE_NOT_NULL); if (datatype == null) throw new NullPointerException(MSG_OCCURRENCE_DATATYPE_NOT_NULL); CrossTopicMapException.check(topic, this.tm); CrossTopicMapException.check(occurs_type, this.tm); OccurrenceIF occurs = new Occurrence(tm); ((Topic)topic).addOccurrence(occurs); occurs.setType(occurs_type); occurs.setValue(value, datatype); return occurs; }
@Override public OccurrenceIF makeOccurrence(TopicIF topic, TopicIF occurs_type, Reader value, long length, LocatorIF datatype) { if (topic == null) throw new NullPointerException(MSG_TOPIC_NOT_NULL); if (occurs_type == null) throw new NullPointerException(MSG_OCCURRENCE_TYPE_NOT_NULL); if (value == null) throw new NullPointerException(MSG_OCCURRENCE_VALUE_NOT_NULL); if (datatype == null) throw new NullPointerException(MSG_OCCURRENCE_DATATYPE_NOT_NULL); CrossTopicMapException.check(topic, this.tm); CrossTopicMapException.check(occurs_type, this.tm); OccurrenceIF occurs = new Occurrence(tm); ((Topic)topic).addOccurrence(occurs); occurs.setType(occurs_type); occurs.setReader(value, length, datatype); return occurs; }
@Override public OccurrenceIF makeOccurrence(TopicIF topic, TopicIF occurs_type, String value) { if (topic == null) throw new NullPointerException(MSG_TOPIC_NOT_NULL); if (occurs_type == null) throw new NullPointerException(MSG_OCCURRENCE_TYPE_NOT_NULL); if (value == null) throw new NullPointerException(MSG_OCCURRENCE_VALUE_NOT_NULL); CrossTopicMapException.check(topic, this.tm); CrossTopicMapException.check(occurs_type, this.tm); OccurrenceIF occurs = new Occurrence(tm); ((Topic)topic).addOccurrence(occurs); occurs.setType(occurs_type); occurs.setValue(value, DataTypes.TYPE_STRING); return occurs; }
@Override public OccurrenceIF makeOccurrence(TopicIF topic, TopicIF occurs_type, Reader value, long length, LocatorIF datatype) { if (topic == null) throw new NullPointerException(MSG_TOPIC_NOT_NULL); if (occurs_type == null) throw new NullPointerException(MSG_OCCURRENCE_TYPE_NOT_NULL); if (value == null) throw new NullPointerException(MSG_OCCURRENCE_VALUE_NOT_NULL); if (datatype == null) throw new NullPointerException(MSG_OCCURRENCE_DATATYPE_NOT_NULL); CrossTopicMapException.check(topic, this.tm); CrossTopicMapException.check(occurs_type, this.tm); OccurrenceIF occurs = new Occurrence(txn); ((Topic)topic).addOccurrence(occurs); occurs.setType(occurs_type); occurs.setReader(value, length, datatype); return occurs; }
@Override public OccurrenceIF makeOccurrence(TopicIF topic, TopicIF occurs_type, String value, LocatorIF datatype) { if (topic == null) throw new NullPointerException(MSG_TOPIC_NOT_NULL); if (occurs_type == null) throw new NullPointerException(MSG_OCCURRENCE_TYPE_NOT_NULL); if (value == null) throw new NullPointerException(MSG_OCCURRENCE_VALUE_NOT_NULL); if (datatype == null) throw new NullPointerException(MSG_OCCURRENCE_DATATYPE_NOT_NULL); CrossTopicMapException.check(topic, this.tm); CrossTopicMapException.check(occurs_type, this.tm); OccurrenceIF occurs = new Occurrence(txn); ((Topic)topic).addOccurrence(occurs); occurs.setType(occurs_type); occurs.setValue(value, datatype); return occurs; }
@Override public OccurrenceIF makeOccurrence(TopicIF topic, TopicIF occurs_type, LocatorIF locator) { if (topic == null) throw new NullPointerException(MSG_TOPIC_NOT_NULL); if (occurs_type == null) throw new NullPointerException(MSG_OCCURRENCE_TYPE_NOT_NULL); if (locator == null) throw new NullPointerException(MSG_OCCURRENCE_LOCATOR_NOT_NULL); CrossTopicMapException.check(topic, this.tm); CrossTopicMapException.check(occurs_type, this.tm); OccurrenceIF occurs = new Occurrence(tm); ((Topic)topic).addOccurrence(occurs); occurs.setType(occurs_type); occurs.setValue(locator.getAddress(), DataTypes.TYPE_URI); return occurs; }
@Override public OccurrenceIF makeOccurrence(TopicIF topic, TopicIF occurs_type, LocatorIF locator) { if (topic == null) throw new NullPointerException(MSG_TOPIC_NOT_NULL); if (occurs_type == null) throw new NullPointerException(MSG_OCCURRENCE_TYPE_NOT_NULL); if (locator == null) throw new NullPointerException(MSG_OCCURRENCE_LOCATOR_NOT_NULL); CrossTopicMapException.check(topic, this.tm); CrossTopicMapException.check(occurs_type, this.tm); OccurrenceIF occurs = new Occurrence(txn); ((Topic)topic).addOccurrence(occurs); occurs.setType(occurs_type); occurs.setLocator(locator); return occurs; }
@Override public OccurrenceIF makeOccurrence(TopicIF topic, TopicIF occurs_type, String value) { if (topic == null) throw new NullPointerException(MSG_TOPIC_NOT_NULL); if (occurs_type == null) throw new NullPointerException(MSG_OCCURRENCE_TYPE_NOT_NULL); if (value == null) throw new NullPointerException(MSG_OCCURRENCE_VALUE_NOT_NULL); CrossTopicMapException.check(topic, this.tm); CrossTopicMapException.check(occurs_type, this.tm); OccurrenceIF occurs = new Occurrence(txn); ((Topic)topic).addOccurrence(occurs); occurs.setType(occurs_type); occurs.setValue(value); return occurs; }
occurs.setType(referenced_topic);
@Override public void setType(Topic type) { Check.typeNotNull(this, type); Check.typeInTopicMap(getTopicMap(), type); wrapped.setType(topicMap.unwrapTopic(type)); }
@Override public void run() { OccurrenceIF o = getOccurrence(); TopicIF type = builder.makeTopic(); // create type this.data.put("type", type); o.setType(type); this.objectId = o.getObjectId(); this.value = type.getObjectId(); } });
public void testConcurrentModification() { // create some topics for the topic map TopicIF ot1 = builder.makeTopic(); TopicIF ot2 = builder.makeTopic(); TopicIF t1 = builder.makeTopic(); OccurrenceIF occ = builder.makeOccurrence(t1, ot1, ""); try { Iterator it = index.getOccurrences(ot1).iterator(); occ.setType(ot2); it.next(); } catch (java.util.ConcurrentModificationException e) { fail("ClassInstanceIndex returns live collections"); } }
@Override public void run() { OccurrenceIF o = getOccurrence(); TopicIF type = builder.makeTopic(); // create type type.addSubjectIdentifier(URILocator.create("type:cleared")); o.setType(type); TopicIF xtype = (TopicIF)this.data.remove("type"); // remove type xtype.remove(); this.objectId = o.getObjectId(); } });
public void testOccurrencesDynamic() { TopicIF ot1 = builder.makeTopic(); TopicIF ot2 = builder.makeTopic(); TopicIF t1 = builder.makeTopic(); OccurrenceIF o1 = builder.makeOccurrence(t1, ot1, ""); assertTrue("OccurrenceIF.setType does not update index", index.getOccurrences(ot1).size() == 1); o1.setType(ot2); assertTrue("OccurrenceIF.setType(ot2) does not update index", index.getOccurrences(ot1).size() == 0); OccurrenceIF o2 = builder.makeOccurrence(t1, ot1, ""); assertTrue("TopicIF.addOccurrence does not update index", index.getOccurrences(ot1).size() == 1); t1.remove(); assertTrue("TopicMapIF.removeTopic does not update occurrence index", index.getOccurrences(ot1).size() == 0); }
public void testOccurrenceTypes() { // STATE 1: empty topic map assertTrue("index finds occurrence types in empty topic map", clsix.getOccurrenceTypes().size() == 0); TopicIF topic = builder.makeTopic(); OccurrenceIF inst = builder.makeOccurrence(topic, type, ""); // STATE 3: Contains typed occurrences inst.setType(type); assertTrue("Expected one occurrence type.", clsix.getOccurrenceTypes().size() == 1); assertTrue("<type> not indexed as occurrence type.", clsix.getOccurrenceTypes().contains(type)); assertTrue("<type> not indexed as occurrence type.", clsix.usedAsOccurrenceType(type)); assertTrue("Expected one occurrence of type <type>", clsix.getOccurrences(type).size() == 1); assertTrue("Expected <inst> as instance of <type>", clsix.getOccurrences(type).contains(inst)); // STATE 4: Contains duplicate type occurrence OccurrenceIF dup = builder.makeOccurrence(topic, type, ""); assertTrue("occ type not found", clsix.getOccurrences(type).size() == 2); assertTrue("occ not found via type", clsix.getOccurrences(type).contains(dup)); assertTrue("duplicate occ types not suppressed", clsix.getOccurrenceTypes().size() == 1); }
assertTrue("Index of occurrences by value and type is not empty for original type", ix.getOccurrences(value2, DataTypes.TYPE_STRING, otype2).isEmpty()); occ.setType(otype2); assertFalse("Index of occurrences by value and type does not detect changed type", ix.getOccurrences(value2, otype2).isEmpty()); occ2.setType(otype2); assertFalse("Index of occurrences by value and type contains occurrence with wrong value", ix.getOccurrences(value2, otype2).contains(occ2));
occurrence.setType(otype2);
occurrence.setType(otype2); occurrence.setValue(largeValue);
occurrence.setType(otype2);