Update of /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/tmdm/tm4j1
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv28261/src/org/tm4j/topicmap/tmdm/tm4j1
Modified Files:
TopicMapImpl.java TopicMapObjectImpl.java
Log Message:
Infrastructure for adding item identifiers by id Strings easily if these id Strings are supplied.
Index: TopicMapObjectImpl.java
===================================================================
RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/tmdm/tm4j1/TopicMapObjectImpl.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** TopicMapObjectImpl.java 22 Jan 2008 20:12:15 -0000 1.3
--- TopicMapObjectImpl.java 23 Jan 2008 20:17:43 -0000 1.4
***************
*** 14,17 ****
--- 14,18 ----
import org.tm4j.topicmap.tmdm.DuplicateItemIdentifierException;
+ import org.tm4j.topicmap.tmdm.TopicMapConstruct;
***************
*** 369,372 ****
--- 370,381 ----
}
+ protected <T extends TopicMapConstruct> T maybeAddID(String id,T tmo) throws DuplicateObjectIDException {
+ if (id!=null) {
+ getContainer().addIdTo(tmo,id);
+ }
+
+ return tmo;
+ }
+
public String toString() {
return "TopicMapObjectImpl[sourceLocators="+getSourceLocators()+"]";
Index: TopicMapImpl.java
===================================================================
RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/tmdm/tm4j1/TopicMapImpl.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** TopicMapImpl.java 23 Jan 2008 19:35:38 -0000 1.15
--- TopicMapImpl.java 23 Jan 2008 20:17:43 -0000 1.16
***************
*** 422,429 ****
*/
public Association createAssociation(String id, org.tm4j.net.Locator resourceLocator,Topic type, Topic[] themes) throws DuplicateObjectIDException, DuplicateResourceLocatorException,PropertyVetoException {
- assert id==null; // not implemented
assert resourceLocator==null; // not implemented
! return unmergedToExternal(getRepresentedObject().createAssociation(type!=null?(((TopicImpl) type).getRepresentedObject()):getInternalUnspecifiedTopic(),convertToInternalScope(themes)));
}
--- 422,428 ----
*/
public Association createAssociation(String id, org.tm4j.net.Locator resourceLocator,Topic type, Topic[] themes) throws DuplicateObjectIDException, DuplicateResourceLocatorException,PropertyVetoException {
assert resourceLocator==null; // not implemented
! return unmergedToExternal(maybeAddID(id,getRepresentedObject().createAssociation(type!=null?(((TopicImpl) type).getRepresentedObject()):getInternalUnspecifiedTopic(),convertToInternalScope(themes))));
}
***************
*** 439,446 ****
*/
public Topic createTopic(String id) throws DuplicateObjectIDException, PropertyVetoException {
! org.tm4j.topicmap.tmdm.Topic topic = getRepresentedObject().createTopic();
- addIdTo(topic,id);
-
return unmergedToExternal(topic);
}
--- 438,443 ----
*/
public Topic createTopic(String id) throws DuplicateObjectIDException, PropertyVetoException {
! org.tm4j.topicmap.tmdm.Topic topic = maybeAddID(id,getRepresentedObject().createTopic());
return unmergedToExternal(topic);
}
|