@Override protected void setValue(String value, LocatorIF datatype) { wrapped.setValue(value, datatype); }
@Override public void setValue(String value) { Check.valueNotNull(this, value); wrapped.setValue(value); }
public void updateRecentFiles(File f) { TopicIF recentFile = this.getRecentFile(f); if (recentFile == null) recentFile = this.createRecentFile(f); // Update timestamp OccurrenceIF lastVisited = this.getOccurrence(recentFile, timestamp); lastVisited.setValue(Long.toString(new Date().getTime())); // Limit recent files list to 10 items List recentFiles = this.getRecentFiles(); if (recentFiles.size() == 10) this.getRecentFile((File) recentFiles.get(9)).remove(); }
@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, 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, 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; }
protected void setOccurenceValue(TopicIF type, TopicIF occtype, String value) { TopicIF cfgtopic = getConfigTopic(type); OccurrenceIF occ = getOccurrence(cfgtopic, occtype); if (value == null) return; // don't make the occ if there is no value to give it if (occ == null) occ = builder.makeOccurrence(cfgtopic, occtype, value); else occ.setValue(value); }
@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; }
@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 void modify(TMObjectIF object, Object v) { String value = (String) v; if (object instanceof OccurrenceIF) ((OccurrenceIF) object).setValue(value); else if (object instanceof TopicNameIF) ((TopicNameIF) object).setValue(value); else if (object instanceof VariantNameIF) ((VariantNameIF) object).setValue(value); else throw new OntopiaRuntimeException("OUCH!"); } }
@Override public void run() { OccurrenceIF o = getOccurrence(); o.setValue("New occurrence"); this.objectId = o.getObjectId(); } });
@Override public void run() { OccurrenceIF o = getOccurrence(); o.setValue(""); this.objectId = o.getObjectId(); } });
private void set(TopicIF topic, String value, LocatorIF psi) { for (OccurrenceIF occ : topic.getOccurrences()) { TopicIF type = occ.getType(); if (type.getSubjectIdentifiers().contains(psi)) { occ.setValue(value); return; } } TopicMapIF tm = topic.getTopicMap(); TopicMapBuilderIF builder = tm.getBuilder(); TopicIF type = tm.getTopicBySubjectIdentifier(psi); builder.makeOccurrence(topic, type, value); }
private void set(TopicIF topic, String value, LocatorIF psi) { for (OccurrenceIF occ : topic.getOccurrences()) { TopicIF type = occ.getType(); if (type.getSubjectIdentifiers().contains(psi)) { occ.setValue(value); return; } } TopicMapIF tm = topic.getTopicMap(); TopicMapBuilderIF builder = tm.getBuilder(); TopicIF type = tm.getTopicBySubjectIdentifier(psi); builder.makeOccurrence(topic, type, value); }
protected void setValue(ActionParametersIF params, ActionResponseIF response, int typeParamIx) { // we now assume that the caller has validated the parameters // for SetValue: o t? t? // for SetValueUnique: o t? s? t? OccurrenceIF occurrence = (OccurrenceIF) params.get(0); TopicIF topic = (TopicIF) params.get(1); String value = params.getStringValue(); if (!isUnique(params, response, typeParamIx)) return; if (occurrence == null) { // check if new occurrence should be created, otherwise do nothing if (value == null || value.trim().length() == 0) return; // create new occurrence TopicMapBuilderIF builder = topic.getTopicMap().getBuilder(); occurrence = builder.makeOccurrence(topic, (TopicIF) params.get(typeParamIx), value); } else { occurrence.setValue(value); } }
lastocc = topicmap.getBuilder().makeOccurrence(topic, lastmod, getTimeStamp()); else lastocc.setValue(getTimeStamp());
/** * INTERNAL: Copies the occurrence value and datatype from the * source topic to the target topic. * * @since 4.0 */ public static void copyOccurrenceData(OccurrenceIF target, OccurrenceIF source) { if (source.getLength() > DataTypes.SIZE_THRESHOLD) { Reader r = source.getReader(); try { target.setReader(r, source.getLength(), source.getDataType()); } catch (Exception e) { try { r.close(); } catch (Exception e2) { } throw new OntopiaRuntimeException(e); } } else { target.setValue(source.getValue(), source.getDataType()); } }
public void testValue() { assertTrue("initial locator not null", "".equals(occurrence.getValue())); String value = "foo"; occurrence.setValue(value); assertTrue("value not maintained after set", occurrence.getValue().equals(value)); assertTrue("data type is incorrect. should be xsd:string", Objects.equals(occurrence.getDataType(), DataTypes.TYPE_STRING)); try { occurrence.setValue(null); fail("value could be set to null"); } catch (NullPointerException e) { } assertTrue("value not maintained after set", occurrence.getValue().equals(value)); assertTrue("data type is incorrect. should be xsd:string", Objects.equals(occurrence.getDataType(), DataTypes.TYPE_STRING)); }
public OccurrenceIF change(TopicMapIF tm, OccurrenceIF result, Occurrence occurrence) { // OccurrenceIF if ((occurrence.getValue() != null) && (!occurrence.getValue().equals(result.getValue()))) { result.setValue(occurrence.getValue()); } if ((occurrence.getDataType() != null) && (!occurrence.getDataType().equals(result.getDataType()))) { result.setValue(result.getValue(), occurrence.getDataType()); // no shortcut } // TypedIF typed.setType(result, occurrence.getType()); // ScopedIF scoped.setScope(result, occurrence.getScope()); // ReifiableIF reifiable.setReifier(result, occurrence.getReifier()); // TMObjectIF tmobject.setItemIdentifiers(result, occurrence); return result; }
public void testNonURILocator() { try { occurrence.setLocator(new GenericLocator("URG", "l/e")); fail("non URI-locator could be set"); } catch (ConstraintViolationException e) { } try { occurrence.setValue("foo", new GenericLocator("URG", "l/e")); fail("non URI datatype could be set"); } catch (ConstraintViolationException e) { } try { occurrence.setReader(new StringReader("foo"), 3, new GenericLocator("URG", "l/e")); fail("non URI datatype could be set"); } catch (ConstraintViolationException e) { } }