You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(9) |
Jun
(30) |
Jul
(74) |
Aug
(2) |
Sep
(91) |
Oct
(27) |
Nov
(77) |
Dec
(33) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(175) |
Feb
(133) |
Mar
(94) |
Apr
(65) |
May
(108) |
Jun
(100) |
Jul
(46) |
Aug
(19) |
Sep
(145) |
Oct
(289) |
Nov
(134) |
Dec
(211) |
2003 |
Jan
(106) |
Feb
(269) |
Mar
(106) |
Apr
(202) |
May
(300) |
Jun
(83) |
Jul
(70) |
Aug
(217) |
Sep
(183) |
Oct
(292) |
Nov
(324) |
Dec
(117) |
2004 |
Jan
(318) |
Feb
(151) |
Mar
(64) |
Apr
(195) |
May
(279) |
Jun
(263) |
Jul
(280) |
Aug
(167) |
Sep
(91) |
Oct
(175) |
Nov
(34) |
Dec
(38) |
2005 |
Jan
|
Feb
|
Mar
(4) |
Apr
|
May
(5) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(5) |
2006 |
Jan
|
Feb
|
Mar
(5) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(6) |
2007 |
Jan
(2) |
Feb
(11) |
Mar
(1) |
Apr
(33) |
May
(13) |
Jun
(1) |
Jul
(3) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2008 |
Jan
(191) |
Feb
|
Mar
(1) |
Apr
|
May
(1) |
Jun
(33) |
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(14) |
2009 |
Jan
(39) |
Feb
(6) |
Mar
(22) |
Apr
(31) |
May
(78) |
Jun
(74) |
Jul
(39) |
Aug
(22) |
Sep
(16) |
Oct
(32) |
Nov
(4) |
Dec
(5) |
2010 |
Jan
(1) |
Feb
|
Mar
(33) |
Apr
(45) |
May
(66) |
Jun
(63) |
Jul
(32) |
Aug
(56) |
Sep
(19) |
Oct
(1) |
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(4) |
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
(1) |
2016 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
|
May
(1) |
Jun
|
Jul
(2) |
Aug
(1) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
|
From: Xuan B. <med...@us...> - 2007-04-17 05:29:12
|
Update of /cvsroot/tm4j/tmnav/src/org/tm4j/tmnav/app/util In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv7519/src/org/tm4j/tmnav/app/util Modified Files: Util.java Log Message: Adapt TMNav source to recent BrowserLauncher2. Index: Util.java =================================================================== RCS file: /cvsroot/tm4j/tmnav/src/org/tm4j/tmnav/app/util/Util.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Util.java 16 Aug 2004 18:38:57 -0000 1.7 --- Util.java 17 Apr 2007 05:29:12 -0000 1.8 *************** *** 1,3 **** ! /* * LICENSE * ------------ --- 1,3 ---- ! /* :indentSize=2:tabSize=2: * LICENSE * ------------ *************** *** 79,84 **** public static void openURL(String url) { try { ! BrowserLauncher.openURL(url); ! } catch (IOException ex) { LogManager.logEx("While opening url [" + url + "]", ex); } --- 79,84 ---- public static void openURL(String url) { try { ! new BrowserLauncher().openURLinBrowser(url); ! } catch (Exception ex) { LogManager.logEx("While opening url [" + url + "]", ex); } |
From: Xuan B. <med...@us...> - 2007-04-17 05:29:12
|
Update of /cvsroot/tm4j/tmnav/src/org/tm4j/tmnav/app/ui In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv7519/src/org/tm4j/tmnav/app/ui Modified Files: OpenInBrowserItem.java Log Message: Adapt TMNav source to recent BrowserLauncher2. Index: OpenInBrowserItem.java =================================================================== RCS file: /cvsroot/tm4j/tmnav/src/org/tm4j/tmnav/app/ui/OpenInBrowserItem.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** OpenInBrowserItem.java 16 Aug 2004 18:38:55 -0000 1.6 --- OpenInBrowserItem.java 17 Apr 2007 05:29:12 -0000 1.7 *************** *** 1,3 **** ! /* * LICENSE * ------------ --- 1,3 ---- ! /* :indentSize=4:tabSize=4: * LICENSE * ------------ *************** *** 79,87 **** public void invokeWithSelection(Selection selection) throws Exception { if (url != null) { ! try { ! BrowserLauncher.openURL(url); ! } catch (IOException ex) { ! ex.printStackTrace(); ! } } --- 79,83 ---- public void invokeWithSelection(Selection selection) throws Exception { if (url != null) { ! new BrowserLauncher().openURLinBrowser(url); } |
From: Xuan B. <med...@us...> - 2007-04-17 05:28:41
|
Update of /cvsroot/tm4j/tmnav/lib In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv7130/lib Modified Files: panckoucke-0.3.2pre3.jar Log Message: Update used panckoucke to a more current version. Index: panckoucke-0.3.2pre3.jar =================================================================== RCS file: /cvsroot/tm4j/tmnav/lib/panckoucke-0.3.2pre3.jar,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 Binary files /tmp/cvsl45gek and /tmp/cvswTPTgF differ |
From: Xuan B. <med...@us...> - 2007-04-17 05:04:34
|
Update of /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/memory In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv29252/src/org/tm4j/topicmap/memory Modified Files: TopicImpl.java TopicMapImpl.java TopicMapObjectImpl.java Log Message: Support for removing a topic from a merged topic in response to bug https://sourceforge.net/tracker/index.php?func=detail&aid=1698885&group_id=27895&atid=391879 . Also adds some diagnostics support. Index: TopicImpl.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/memory/TopicImpl.java,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** TopicImpl.java 7 Mar 2006 15:36:35 -0000 1.72 --- TopicImpl.java 17 Apr 2007 05:04:33 -0000 1.73 *************** *** 1027,1033 **** --- 1027,1056 ---- */ public Collection getMergedTopics() { + assert checkMergedTopics(); + return m_mergedTopics == null ? Collections.EMPTY_LIST : Collections.unmodifiableCollection(m_mergedTopics); } + + protected boolean checkMergedTopics() { + if (m_mergedTopics!=null) { + try { + for (TopicImpl topic : (ArrayList<TopicImpl>) m_mergedTopics) { + if (!topic.checkNotDestroyed()) { + return false; + } + } + } catch (AssertionError e) { + m_log.error("While checking "+this+": ",e); + throw e; + } + } + + return true; + } + + protected boolean checkNotDestroyed() { + return super.checkNotDestroyed(); + } /** *************** *** 1107,1110 **** --- 1130,1140 ---- } + protected void removeMergedTopic(Topic mergedTopic) { + assert m_mergedTopics!=null; + boolean success = m_mergedTopics.remove(mergedTopic); + + assert success; + } + private void staticMerge(Topic merged) throws MergedTopicSubjectClashException { *************** *** 1545,1548 **** --- 1575,1596 ---- try { + /* XB: + + It may be that + (1) this topic is either a base topic serving for other topics or + (2) that this topic is a merged topic having a base topic. + + In such cases, this topic needs to be detached from the other topics properly. + + */ + + if (!staticallyMerged()) { + if (m_baseTopic!=null) { // We are a slave topic. We just need to sign off from our base topic. + ((TopicImpl) m_baseTopic).removeMergedTopic(this); + } else if ((m_mergedTopics!=null)&&!m_mergedTopics.isEmpty()) { // We are a base topic with at least one slave. + throw new UnsupportedOperationException(); + } + } + // If we get here, it is OK to destroy this Topic. // Remove all types *************** *** 1586,1589 **** --- 1634,1639 ---- protected void _destroy() { + // m_log.warn("Destroying "+this+".", new Exception()); + m_subject = null; *************** *** 1621,1624 **** --- 1671,1677 ---- m_baseTopic = null; + + + super._destroy(); } *************** *** 1646,1649 **** --- 1699,1706 ---- } } + + public String toString() { + return "TopicImpl[m_subjectIdentifiers="+m_subjectIdentifiers+"]"+super.toString(); + } } *************** *** 1651,1657 **** /* * $Log$ ! * Revision 1.72 2006/03/07 15:36:35 lheuer ! * - Fixed bugs #1430090, #143009, #1430800, #1433530 ! * - Applied feature patches #1432895, #1432892, #1432888, #1432883, #1432880, #1432877, #1432872 * * Revision 1.71 2004/12/08 10:50:57 kal_ahmed --- 1708,1717 ---- /* * $Log$ ! * Revision 1.73 2007/04/17 05:04:33 mediumnet ! * Support for removing a topic from a merged topic in response to bug https://sourceforge.net/tracker/index.php?func=detail&aid=1698885&group_id=27895&atid=391879 . Also adds some diagnostics support. ! * ! * Revision 1.72 2006/03/07 15:36:35 lheuer ! * - Fixed bugs #1430090, #143009, #1430800, #1433530 ! * - Applied feature patches #1432895, #1432892, #1432888, #1432883, #1432880, #1432877, #1432872 * * Revision 1.71 2004/12/08 10:50:57 kal_ahmed Index: TopicMapObjectImpl.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/memory/TopicMapObjectImpl.java,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** TopicMapObjectImpl.java 7 Mar 2006 15:36:35 -0000 1.37 --- TopicMapObjectImpl.java 17 Apr 2007 05:04:33 -0000 1.38 *************** *** 172,175 **** --- 172,176 ---- public Set getSourceLocators() { + assert m_sourceLocators!=null : toString()+": trying to access m_sourceLocators while apparently already destroyed."; return Collections.unmodifiableSet(m_sourceLocators); } *************** *** 489,492 **** --- 490,499 ---- } + protected boolean checkNotDestroyed() { + assert m_sourceLocators!=null : toString()+" already destroyed."; + + return m_sourceLocators!=null; + } + protected void removeChangeListeners() { if (m_namedPropertyListeners != null) { *************** *** 510,513 **** --- 517,528 ---- return other.getTopicMap().equals(getTopicMap()); } + + public String toString() { + if (m_topicMap!=this) { + return "TopicMapObjectImpl[m_sourceLocators="+m_sourceLocators+",m_topicMap="+m_topicMap+"]"+super.toString(); + } else { + return "TopicMapObjectImpl[m_sourceLocators="+m_sourceLocators+"]"+super.toString(); + } + } } *************** *** 515,521 **** /* * $Log$ ! * Revision 1.37 2006/03/07 15:36:35 lheuer ! * - Fixed bugs #1430090, #143009, #1430800, #1433530 ! * - Applied feature patches #1432895, #1432892, #1432888, #1432883, #1432880, #1432877, #1432872 * * Revision 1.36 2004/04/22 20:45:56 kal_ahmed --- 530,539 ---- /* * $Log$ ! * Revision 1.38 2007/04/17 05:04:33 mediumnet ! * Support for removing a topic from a merged topic in response to bug https://sourceforge.net/tracker/index.php?func=detail&aid=1698885&group_id=27895&atid=391879 . Also adds some diagnostics support. ! * ! * Revision 1.37 2006/03/07 15:36:35 lheuer ! * - Fixed bugs #1430090, #143009, #1430800, #1433530 ! * - Applied feature patches #1432895, #1432892, #1432888, #1432883, #1432880, #1432877, #1432872 * * Revision 1.36 2004/04/22 20:45:56 kal_ahmed Index: TopicMapImpl.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/memory/TopicMapImpl.java,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** TopicMapImpl.java 7 Mar 2006 15:36:35 -0000 1.72 --- TopicMapImpl.java 17 Apr 2007 05:04:33 -0000 1.73 *************** *** 1383,1386 **** --- 1383,1389 ---- } + public String toString() { + return "TopicMapImpl[m_topics.size()="+m_topics.size()+"]"; + } } *************** *** 1388,1394 **** /* * $Log$ ! * Revision 1.72 2006/03/07 15:36:35 lheuer ! * - Fixed bugs #1430090, #143009, #1430800, #1433530 ! * - Applied feature patches #1432895, #1432892, #1432888, #1432883, #1432880, #1432877, #1432872 * * Revision 1.71 2004/09/10 20:51:52 kal_ahmed --- 1391,1400 ---- /* * $Log$ ! * Revision 1.73 2007/04/17 05:04:33 mediumnet ! * Support for removing a topic from a merged topic in response to bug https://sourceforge.net/tracker/index.php?func=detail&aid=1698885&group_id=27895&atid=391879 . Also adds some diagnostics support. ! * ! * Revision 1.72 2006/03/07 15:36:35 lheuer ! * - Fixed bugs #1430090, #143009, #1430800, #1433530 ! * - Applied feature patches #1432895, #1432892, #1432888, #1432883, #1432880, #1432877, #1432872 * * Revision 1.71 2004/09/10 20:51:52 kal_ahmed |
From: Xuan B. <med...@us...> - 2007-04-17 05:04:34
|
Update of /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv29252/src/org/tm4j/topicmap Modified Files: Topic.java Log Message: Support for removing a topic from a merged topic in response to bug https://sourceforge.net/tracker/index.php?func=detail&aid=1698885&group_id=27895&atid=391879 . Also adds some diagnostics support. Index: Topic.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/Topic.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** Topic.java 27 Sep 2004 12:54:15 -0000 1.29 --- Topic.java 17 Apr 2007 05:04:33 -0000 1.30 *************** *** 390,393 **** --- 390,399 ---- */ public void addMergedTopic(Topic t) throws MergedTopicSubjectClashException; + + /* + protected void removeMergedTopic(Topic mergedTopic) { + throw new UnsupportedOperationException(); + } + */ /** *************** *** 459,462 **** --- 465,471 ---- /* * $Log$ + * Revision 1.30 2007/04/17 05:04:33 mediumnet + * Support for removing a topic from a merged topic in response to bug https://sourceforge.net/tracker/index.php?func=detail&aid=1698885&group_id=27895&atid=391879 . Also adds some diagnostics support. + * * Revision 1.29 2004/09/27 12:54:15 kal_ahmed * Added addMergedTopic() method to force the merge of two topics. |
From: Xuan B. <med...@us...> - 2007-04-17 04:48:21
|
Update of /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/cmd In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv22526/src/org/tm4j/topicmap/cmd Modified Files: TopicMapList.java Log Message: Support for delayed opening and early closing of streams in response to bug https://sourceforge.net/tracker/index.php?func=detail&aid=1698489&group_id=27895&atid=391879 . Index: TopicMapList.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/cmd/TopicMapList.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TopicMapList.java 26 Feb 2004 21:33:44 -0000 1.7 --- TopicMapList.java 17 Apr 2007 04:48:19 -0000 1.8 *************** *** 23,26 **** --- 23,28 ---- import java.io.IOException; import java.io.InputStream; + import java.io.FilterInputStream; + import java.io.EOFException; import java.net.MalformedURLException; *************** *** 48,51 **** --- 50,56 ---- private String m_shortArg; private String m_longArg; + + /** to minimize filedescriptor usage */ + protected final static boolean useOnDemandInputStreams = true; public TopicMapList(char shortArg, String longArg) { *************** *** 104,108 **** if (sourceFile.exists()) { try { ! tmStream = new FileInputStream(sourceFile); if (tmBase == null) { --- 109,117 ---- if (sourceFile.exists()) { try { ! if (useOnDemandInputStreams) { ! tmStream = new OnDemandFileInputStream(sourceFile); ! } else { ! tmStream = new FileInputStream(sourceFile); ! } if (tmBase == null) { *************** *** 127,131 **** try { URL url = new URL(source); ! tmStream = url.openStream(); if (tmBase == null) { --- 136,144 ---- try { URL url = new URL(source); ! if (useOnDemandInputStreams) { ! tmStream = new OnDemandURLInputStream(url); ! } else { ! tmStream = url.openStream(); ! } if (tmBase == null) { *************** *** 134,138 **** } catch (MalformedURLException ex) { throw new ParseException("Could not convert '" + source + ! "' to a local file name or to a URL."); } catch (IOException ex) { throw new ParseException("Error opening URL '" + source + --- 147,151 ---- } catch (MalformedURLException ex) { throw new ParseException("Could not convert '" + source + ! "' to a local file name or to a URL.",ex); } catch (IOException ex) { throw new ParseException("Error opening URL '" + source + *************** *** 161,164 **** --- 174,293 ---- super(msg); } + + ParseException(String msg,Exception cause) { + super(msg,cause); + } + } + + public class OnDemandURLInputStream extends OnDemandInputStream { + URL url; + + public OnDemandURLInputStream(URL url) { + this.url = url; + } + + protected InputStream internalOpen() throws IOException { + return url.openStream(); + } + + } + + public class OnDemandFileInputStream extends OnDemandInputStream { + File file; + + public OnDemandFileInputStream(File file) { + this.file = file; + } + + protected InputStream internalOpen() throws IOException { + return new FileInputStream(file); + } + } + + public abstract class OnDemandInputStream extends FilterInputStream { + boolean alreadyOpened; + boolean alreadyClosed; + + public OnDemandInputStream() { + super(null); + } + + protected void ensureOpen() throws IOException { + if (!alreadyOpened&&!alreadyClosed) { + in = internalOpen(); + alreadyOpened = true; + } + } + + protected abstract InputStream internalOpen() throws IOException; + + protected void internalClose() throws IOException { + if (alreadyOpened) { + if (!alreadyClosed) { + alreadyClosed = true; + in.close(); + } + } + } + + protected void handlePossibleEOF(int readReturn) throws IOException { + if (readReturn==-1) { + handleEOF(); + } + } + + protected void handleEOF() throws IOException { + internalClose(); + } + + public int available() throws IOException { + ensureOpen(); + return super.available(); + } + + public long skip(long n) throws IOException { + ensureOpen(); + return super.skip(n); + } + + public int read() throws IOException { + ensureOpen(); + try { + int result = super.read(); + handlePossibleEOF(result); + return result; + } catch (EOFException e) { + handleEOF(); + throw e; + } + } + + public int read(byte[] b,int off,int len) throws IOException { + ensureOpen(); + try { + int result = super.read(b,off,len); + handlePossibleEOF(result); + return result; + } catch (EOFException e) { + handleEOF(); + throw e; + } + } + + public boolean markSupported() { + return false; + } + + public void mark() { + } + + public void reset() throws IOException { + throw new IOException("mark() not supported."); + } + + public void close() throws IOException { + internalClose(); + } + } } *************** *** 167,170 **** --- 296,302 ---- /* * $Log$ + * Revision 1.8 2007/04/17 04:48:19 mediumnet + * Support for delayed opening and early closing of streams in response to bug https://sourceforge.net/tracker/index.php?func=detail&aid=1698489&group_id=27895&atid=391879 . + * * Revision 1.7 2004/02/26 21:33:44 kal_ahmed * Updated license text and reformatted source with Jalopy. |
From: Xuan B. <med...@us...> - 2007-04-17 04:02:58
|
Update of /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/cmd In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv3533/src/org/tm4j/topicmap/cmd Modified Files: AppBase.java Log Message: Support for reading arguments from standard input (instead from argument line) in response to feature request https://sourceforge.net/tracker/index.php?func=detail&aid=1698486&group_id=27895&atid=391882 . This is still a hack, but achieves the objective to support unlimited arguments. Index: AppBase.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/cmd/AppBase.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** AppBase.java 26 Feb 2004 21:33:44 -0000 1.6 --- AppBase.java 17 Apr 2007 04:02:55 -0000 1.7 *************** *** 24,29 **** --- 24,32 ---- import java.io.IOException; import java.io.OutputStream; + import java.io.BufferedReader; + import java.io.InputStreamReader; import java.util.List; + import java.util.ArrayList; *************** *** 166,169 **** --- 169,190 ---- setupBasicArgs(parser); setupApplicationArgs(parser); + + // Hack to allow a greater number of arguments + if ((args.length==1)&&args[0].equals("--@")) { + try { + BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); + ArrayList<String> argsList = new ArrayList<String>(); + String s; + + while ((s = in.readLine())!=null) { + argsList.add(s); + } + + args = argsList.toArray(new String[0]); + } catch (IOException e) { + throw new RuntimeException("Could not read System.in.",e); + } + } + parser.parse(args); run(parser); *************** *** 270,273 **** --- 291,297 ---- /* * $Log$ + * Revision 1.7 2007/04/17 04:02:55 mediumnet + * Support for reading arguments from standard input (instead from argument line) in response to feature request https://sourceforge.net/tracker/index.php?func=detail&aid=1698486&group_id=27895&atid=391882 . This is still a hack, but achieves the objective to support unlimited arguments. + * * Revision 1.6 2004/02/26 21:33:44 kal_ahmed * Updated license text and reformatted source with Jalopy. |
From: Xuan B. <med...@us...> - 2007-04-17 03:53:40
|
Update of /cvsroot/tm4j/tmnav/lib In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv32071 Added Files: BrowserLauncher2-10.jar Removed Files: browserLauncher.jar Log Message: Update BrowserLauncher in response to feature request http://sourceforge.net/tracker/index.php?func=detail&aid=1699114&group_id=27895&atid=391882 --- browserLauncher.jar DELETED --- --- NEW FILE: BrowserLauncher2-10.jar --- (This appears to be a binary file; contents omitted.) |
From: Xuan B. <med...@us...> - 2007-04-13 15:06:57
|
Update of /cvsroot/tm4j/tm4j/docs In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv18799/docs Modified Files: TMDM-support.html Log Message: Change due to valueable comments from Lars Heuer. Index: TMDM-support.html =================================================================== RCS file: /cvsroot/tm4j/tm4j/docs/TMDM-support.html,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TMDM-support.html 13 Apr 2007 02:08:31 -0000 1.1 --- TMDM-support.html 13 Apr 2007 15:06:53 -0000 1.2 *************** *** 20,25 **** <li>name type optional (added in TMDM, is simulated by a "default" name type)</li> ! <li>topic type (removed in TMDM, replaced by a <code>http://psi.topicmaps.org/iso13250/model/type-instance</code> ! association)</li> <li>multiple subject locators (added in TMDM)</li> <li>new names for items (Name instead of BaseName, Value instead of --- 20,26 ---- <li>name type optional (added in TMDM, is simulated by a "default" name type)</li> ! <li>topic type (specially implemented in current TM4j 0.9.x, to be ! made "unspecial" as a normal association (however, the special API for ! topic types should be kept))</li> <li>multiple subject locators (added in TMDM)</li> <li>new names for items (Name instead of BaseName, Value instead of |
From: Xuan B. <med...@us...> - 2007-04-13 02:08:37
|
Update of /cvsroot/tm4j/tm4j/docs In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv16186/docs Added Files: TMDM-support.html Log Message: Add a 'green paper' on how to support TMDM. --- NEW FILE: TMDM-support.html --- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> <title>TMDM support</title> </head> <body> <h2>Current plans on how to support TMDM</h2> The basic idea is to implement a superset of the current TM4J (0.9.x) and the TMDM. Following issues need to be addressed:<br> <ul> <li>multiple role players per role (removed in TMDM)</li> <li>occurence type mandatory (added in TMDM, can be simulated by a "default" occurence type)</li> <li>association type mandatory (added in TMDM, can be simulated by a "default" association type)</li> <li>role type mandatory (added in TMDM, can be simulated by a "default" role type)</li> <li>name type optional (added in TMDM, is simulated by a "default" name type)</li> <li>topic type (removed in TMDM, replaced by a <code>http://psi.topicmaps.org/iso13250/model/type-instance</code> association)</li> <li>multiple subject locators (added in TMDM)</li> <li>new names for items (Name instead of BaseName, Value instead of BaseNameString, Role instead of Member, ...)</li> <ul> <li>can be simulated by creating new classes with the new name inheriting from the classes with the old name. Fortunately, no such class has a public constructor, so we can always construct objects of the new classes when being asked to create objects the old classes.</li> </ul> <li>Automatic and implied merging of</li> <ul> <li>topics items (currently implemented)</li> <li>topic name items</li> <li>variant items</li> <li>occurence items</li> <li>association items</li> <li>association role items<br> </li> </ul> </ul> The idea how to deal with this is:<br> <ul> <li>Rework TM4J under the hood to implement TMDM+multiple players per role.</li> <li>Keep the old 0.9.x-API, but let the 0.9.x-API methods translate from the TMDM representation to the old representation.</li> <li>On the creation (or usage?) of a topic map, each topic map gets a TopicMapFlavour attached to it.</li> <ul> <li>TopicMapFlavour.TM4J1: behave like TM4J 1 (for example, throw exceptions if we have multiple subject locators, do not automatically merge associations?)</li> <li>TopicMapFlavour.COMPATIBLE: behave like TMDM+multiple players per role</li> <li>TopicMapFlavour.TMDM: behave as TMDM expects (for example, throw exceptions if there will be multiple players per role introduced by using the old API)<br> </li> </ul> </ul> <br> Author: <a href="mailto:xua...@ba...">Xuân Baldauf</a>.<br> </body> </html> |
From: Xuan B. <med...@us...> - 2007-04-12 13:58:16
|
Update of /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/utils In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv30530/src/org/tm4j/topicmap/utils Modified Files: XTMBuilder.java XTMParser.java XTMWriter.java Log Message: Tabs->Spaces for some files. Also make indentation rules explicit (at least to jEdit). Index: XTMParser.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/utils/XTMParser.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** XTMParser.java 12 Apr 2007 12:57:48 -0000 1.20 --- XTMParser.java 12 Apr 2007 13:58:12 -0000 1.21 *************** *** 1,3 **** ! /* Copyright (c) 2000-2004 The TM4J Project. All rights reserved. --- 1,3 ---- ! /* :indentSize=4:tabSize=4: Copyright (c) 2000-2004 The TM4J Project. All rights reserved. *************** *** 56,72 **** public static final String XLINK_NS_URI = "http://www.w3.org/1999/xlink"; ! public static final String XTM2_NS_URI = "http://www.topicmaps.org/xtm/"; ! public static final String SUBJECTIDENTIFIER = "subjectIdentifier"; ! public static final String NAME = "name"; ! public static final String VALUE = "value"; ! public static final String TYPE = "type"; ! public static final String ROLE = "role"; /** ! XTM 2.0 support is a quick&dirty kludge and it is incomplete. ! Shall it be replaced by something better. ! But as long nothing better is there... */ ! protected final static boolean enableXTM2support = true; private static Stack m_classStack; --- 56,72 ---- public static final String XLINK_NS_URI = "http://www.w3.org/1999/xlink"; ! public static final String XTM2_NS_URI = "http://www.topicmaps.org/xtm/"; ! public static final String SUBJECTIDENTIFIER = "subjectIdentifier"; ! public static final String NAME = "name"; ! public static final String VALUE = "value"; ! public static final String TYPE = "type"; ! public static final String ROLE = "role"; /** ! XTM 2.0 support is a quick&dirty kludge and it is incomplete. ! Shall it be replaced by something better. ! But as long nothing better is there... */ ! protected final static boolean enableXTM2support = true; private static Stack m_classStack; *************** *** 462,479 **** public void parseTypeEnd() throws TopicMapProcessingException { ! switch (((XTMBuilder) m_builder).peekPurpose()) { ! case XTMBuilder.ROLESPEC: m_builder.endRoleSpec(); ! break; ! case XTMBuilder.INSTANCEOF: ! m_builder.endInstanceOf(); ! break; ! default: ! throw new UnsupportedOperationException(); } } public void parseRoleStart(Attributes atts) throws TopicMapProcessingException { ! parseMember(atts); } --- 462,479 ---- public void parseTypeEnd() throws TopicMapProcessingException { ! switch (((XTMBuilder) m_builder).peekPurpose()) { ! case XTMBuilder.ROLESPEC: m_builder.endRoleSpec(); ! break; ! case XTMBuilder.INSTANCEOF: ! m_builder.endInstanceOf(); ! break; ! default: ! throw new UnsupportedOperationException(); } } public void parseRoleStart(Attributes atts) throws TopicMapProcessingException { ! parseMember(atts); } *************** *** 512,524 **** String ret = atts.getValue(XLINK_NS_URI, localName); ! if (enableXTM2support&&(ret==null)) { ! ret = atts.getValue(XTM2_NS_URI, localName); ! ! if (ret==null) { ! ret = atts.getValue(localName); ! } ! } ! ! return ret; } --- 512,524 ---- String ret = atts.getValue(XLINK_NS_URI, localName); ! if (enableXTM2support&&(ret==null)) { ! ret = atts.getValue(XTM2_NS_URI, localName); ! ! if (ret==null) { ! ret = atts.getValue(localName); ! } ! } ! ! return ret; } *************** *** 536,547 **** } ! private void warn(String detail) { ! StringBuffer msg = new StringBuffer(); ! msg.append(m_currentLine); ! msg.append(":"); ! msg.append(m_currentCol); ! msg.append(":"); ! msg.append(detail); ! } } --- 536,547 ---- } ! private void warn(String detail) { ! StringBuffer msg = new StringBuffer(); ! msg.append(m_currentLine); ! msg.append(":"); ! msg.append(m_currentCol); ! msg.append(":"); ! msg.append(detail); ! } } Index: XTMBuilder.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/utils/XTMBuilder.java,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** XTMBuilder.java 12 Apr 2007 12:57:48 -0000 1.73 --- XTMBuilder.java 12 Apr 2007 13:58:12 -0000 1.74 *************** *** 1,3 **** ! /* Copyright (c) 2000-2004 The TM4J Project. All rights reserved. --- 1,3 ---- ! /* :indentSize=4:tabSize=4: Copyright (c) 2000-2004 The TM4J Project. All rights reserved. *************** *** 383,387 **** //URL u = ClassLoader.getSystemResource( // "org/tm4j/topicmap/xtm1.dtd"); ! URL u = TopicMapProvider.class.getResource("xtm1.dtd"); Vector args = new Vector(); args.add(XTM_1_0_PUBLIC); --- 383,387 ---- //URL u = ClassLoader.getSystemResource( // "org/tm4j/topicmap/xtm1.dtd"); ! URL u = TopicMapProvider.class.getResource("xtm1.dtd"); Vector args = new Vector(); args.add(XTM_1_0_PUBLIC); *************** *** 1759,1762 **** --- 1759,1765 ---- /* * $Log$ + * Revision 1.74 2007/04/12 13:58:12 mediumnet + * Tabs->Spaces for some files. Also make indentation rules explicit (at least to jEdit). + * * Revision 1.73 2007/04/12 12:57:48 mediumnet * Some XTM 2.0 reading support, applying to the current data model. Some XTM 2.0 features are still unsupported. This change should be very compatible, thus applying this change before branching into a release 1.0 branch and a more advanced branch. Index: XTMWriter.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/utils/XTMWriter.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** XTMWriter.java 15 Dec 2004 09:31:13 -0000 1.42 --- XTMWriter.java 12 Apr 2007 13:58:12 -0000 1.43 *************** *** 1,3 **** ! /* Copyright (c) 2000-2004 The TM4J Project. All rights reserved. --- 1,3 ---- ! /* :indentSize=4:tabSize=4: Copyright (c) 2000-2004 The TM4J Project. All rights reserved. *************** *** 587,595 **** return true; } else { ! if (m_writeStubs) { ! startTopic(getID(t)); ! return true; ! } ! return false; } } --- 587,595 ---- return true; } else { ! if (m_writeStubs) { ! startTopic(getID(t)); ! return true; ! } ! return false; } } *************** *** 853,893 **** */ protected String getResourceID(TopicMapObject tmo, Locator srcLoc) { ! if (!(srcLoc instanceof URILocator)) return null; ! String ret = null; ! Iterator srcLocs = tmo.getSourceLocators().iterator(); ! while ((ret == null) && srcLocs.hasNext()) { ! Locator tmoResLoc = (Locator)srcLocs.next(); ! Locator tmResLoc = srcLoc; ! if ((tmoResLoc == null) || (tmResLoc == null) || !(tmoResLoc instanceof URILocator) || !(tmResLoc instanceof URILocator)) { ! continue; ! } ! URILocator uTmoResLoc = (URILocator) tmoResLoc; ! URILocator uTmResLoc = (URILocator) tmResLoc; ! String tmAddress = getDocumentPart(uTmResLoc.getAddress()); ! ! if (getDocumentPart(uTmoResLoc.getAddress()).equals(tmAddress)) { ! return uTmoResLoc.getFragment(); ! } ! ! if (tmo instanceof Topic) { ! Iterator it = ((Topic) tmo).getSubjectIndicators().iterator(); ! ! while (it.hasNext()) { ! Object o = it.next(); ! ! if (o instanceof URILocator) { ! URILocator l = (URILocator) o; ! ! if (getDocumentPart(l.getAddress()).equals(tmAddress)) { ! return l.getFragment(); ! } ! } ! } ! } ! } return ret; } --- 853,893 ---- */ protected String getResourceID(TopicMapObject tmo, Locator srcLoc) { ! if (!(srcLoc instanceof URILocator)) return null; ! String ret = null; ! Iterator srcLocs = tmo.getSourceLocators().iterator(); ! while ((ret == null) && srcLocs.hasNext()) { ! Locator tmoResLoc = (Locator)srcLocs.next(); ! Locator tmResLoc = srcLoc; ! if ((tmoResLoc == null) || (tmResLoc == null) || !(tmoResLoc instanceof URILocator) || !(tmResLoc instanceof URILocator)) { ! continue; ! } ! URILocator uTmoResLoc = (URILocator) tmoResLoc; ! URILocator uTmResLoc = (URILocator) tmResLoc; ! String tmAddress = getDocumentPart(uTmResLoc.getAddress()); ! ! if (getDocumentPart(uTmoResLoc.getAddress()).equals(tmAddress)) { ! return uTmoResLoc.getFragment(); ! } ! ! if (tmo instanceof Topic) { ! Iterator it = ((Topic) tmo).getSubjectIndicators().iterator(); ! ! while (it.hasNext()) { ! Object o = it.next(); ! ! if (o instanceof URILocator) { ! URILocator l = (URILocator) o; ! ! if (getDocumentPart(l.getAddress()).equals(tmAddress)) { ! return l.getFragment(); ! } ! } ! } ! } ! } return ret; } *************** *** 922,928 **** if (m_exportResourceIDs) { Collection tmSrcLocs = tmo.getTopicMap().getSourceLocators(); ! if ((m_resourceIDBase == null) && (!tmSrcLocs.isEmpty())) { ! m_resourceIDBase = (Locator) tmSrcLocs.iterator().next(); ! } String resID = getResourceID(tmo, m_resourceIDBase); --- 922,928 ---- if (m_exportResourceIDs) { Collection tmSrcLocs = tmo.getTopicMap().getSourceLocators(); ! if ((m_resourceIDBase == null) && (!tmSrcLocs.isEmpty())) { ! m_resourceIDBase = (Locator) tmSrcLocs.iterator().next(); ! } String resID = getResourceID(tmo, m_resourceIDBase); *************** *** 947,950 **** --- 947,953 ---- /* * $Log$ + * Revision 1.43 2007/04/12 13:58:12 mediumnet + * Tabs->Spaces for some files. Also make indentation rules explicit (at least to jEdit). + * * Revision 1.42 2004/12/15 09:31:13 kal_ahmed * Added property to allow export of subjectIndicatorRef references instead of topicRef references. |
From: Xuan B. <med...@us...> - 2007-04-12 13:20:12
|
Update of /cvsroot/tm4j/tm4j/src/org/tm4j/net In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv13735/src/org/tm4j/net Modified Files: LocatorBase.java Log Message: A little bit more debuggability for LocatorBase. Index: LocatorBase.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/net/LocatorBase.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** LocatorBase.java 26 Feb 2004 21:33:41 -0000 1.8 --- LocatorBase.java 12 Apr 2007 13:20:10 -0000 1.9 *************** *** 105,108 **** --- 105,112 ---- return m_notation; } + + public String toString() { + return "LocatorBase[notation="+getNotation()+",address="+getAddress()+"]"; + } /** |
From: Xuan B. <med...@us...> - 2007-04-12 12:57:56
|
Update of /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/utils In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv3702/src/org/tm4j/topicmap/utils Modified Files: TopicMapHandler.java XTMBuilder.java XTMParser.java Log Message: Some XTM 2.0 reading support, applying to the current data model. Some XTM 2.0 features are still unsupported. This change should be very compatible, thus applying this change before branching into a release 1.0 branch and a more advanced branch. Index: XTMBuilder.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/utils/XTMBuilder.java,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** XTMBuilder.java 27 Sep 2004 19:14:24 -0000 1.72 --- XTMBuilder.java 12 Apr 2007 12:57:48 -0000 1.73 *************** *** 94,97 **** --- 94,98 ---- * @author <a href="mailto:ka...@te...">Kal Ahmed</a> * @author <a href="har...@we...">Harald Kuhn</a> (support for Reader) + * @author <a href="mailto:xua...@ba...">Xuan Baldauf</a> (some XTM2 support) */ public class XTMBuilder implements TopicMapHandler, TopicMapBuilder { *************** *** 985,988 **** --- 986,990 ---- case REFTYPE_SUBJECTINDICATOR: + case REFTYPE_SUBJECTIDENTIFIER: if (purpose != SUBJECTIDENTITY) { *************** *** 993,997 **** case REFTYPE_TOPIC: ! refTopic = getTopicBySourceLocator(expandedRef); break; --- 995,1003 ---- case REFTYPE_TOPIC: ! if (purpose != SUBJECTIDENTITY) { // This has side-effects for XTM 1.0, but this is considered correct. ! refTopic = getTopicBySubjectIndicator(expandedRef.getAddress()); ! } else { ! refTopic = getTopicBySourceLocator(expandedRef); ! } break; *************** *** 1092,1095 **** --- 1098,1106 ---- m_currScope.add(refTopic); + case 0: + if (refType == REFTYPE_SUBJECTIDENTIFIER) { + m_currTopic.addSubjectIndicator(m_locatorFactory.createLocator("URI", expandedRef.getAddress())); + } + break; } *************** *** 1748,1751 **** --- 1759,1765 ---- /* * $Log$ + * Revision 1.73 2007/04/12 12:57:48 mediumnet + * Some XTM 2.0 reading support, applying to the current data model. Some XTM 2.0 features are still unsupported. This change should be very compatible, thus applying this change before branching into a release 1.0 branch and a more advanced branch. + * * Revision 1.72 2004/09/27 19:14:24 kal_ahmed * Builder now handles out-of-order scope elements better. Index: XTMParser.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/utils/XTMParser.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** XTMParser.java 7 Oct 2004 16:29:33 -0000 1.19 --- XTMParser.java 12 Apr 2007 12:57:48 -0000 1.20 *************** *** 25,28 **** --- 25,32 ---- + /** + * @author unknown <!-- please fix --> + * @author <a href="mailto:xua...@ba...">Xuan Baldauf</a> (some XTM2 support) + */ public class XTMParser extends DefaultHandler implements ContentHandler, ErrorHandler { *************** *** 51,54 **** --- 55,73 ---- public static final String XTM_NS_URI = "http://www.topicmaps.org/xtm/1.0/"; public static final String XLINK_NS_URI = "http://www.w3.org/1999/xlink"; + + public static final String XTM2_NS_URI = "http://www.topicmaps.org/xtm/"; + public static final String SUBJECTIDENTIFIER = "subjectIdentifier"; + public static final String NAME = "name"; + public static final String VALUE = "value"; + public static final String TYPE = "type"; + public static final String ROLE = "role"; + + /** + XTM 2.0 support is a quick&dirty kludge and it is incomplete. + Shall it be replaced by something better. + But as long nothing better is there... + */ + protected final static boolean enableXTM2support = true; + private static Stack m_classStack; private static Stack m_xmlBaseStack; *************** *** 58,63 **** private TopicMapHandler m_builder; ! private Log m_log = LogFactory.getLog(XTMParser.class); ! // optional XML catalog resolver private CatalogResolver m_catalogResolver = null; --- 77,82 ---- private TopicMapHandler m_builder; ! private Log m_log = LogFactory.getLog(XTMParser.class); ! // optional XML catalog resolver private CatalogResolver m_catalogResolver = null; *************** *** 163,166 **** --- 182,195 ---- } else if (xtmClass.equals(MERGEMAP)) { parseMergeMap(atts); + } else if (enableXTM2support&&xtmClass.equals(SUBJECTIDENTIFIER)) { + parseSubjectIdentifier(atts); + } else if (enableXTM2support&&xtmClass.equals(NAME)) { + parseNameStart(atts); + } else if (enableXTM2support&&xtmClass.equals(VALUE)) { + parseValueStart(atts); + } else if (enableXTM2support&&xtmClass.equals(TYPE)) { + parseTypeStart(atts); + } else if (enableXTM2support&&xtmClass.equals(ROLE)) { + parseRoleStart(atts); } else if (nsURI.equals(XTM_NS_URI)) { throw new TopicMapProcessingException( *************** *** 220,223 **** --- 249,264 ---- } else if (xtmClass.equals(MERGEMAP)) { m_builder.endMergeMap(); + } else if (xtmClass.equals(SUBJECTIDENTITY)) { + m_builder.endSubjectIdentity(); + } else if (enableXTM2support&&xtmClass.equals(SUBJECTIDENTIFIER)) { + /* do nothing special */ + } else if (enableXTM2support&&xtmClass.equals(NAME)) { + parseNameEnd(); + } else if (enableXTM2support&&xtmClass.equals(VALUE)) { + parseValueEnd(); + } else if (enableXTM2support&&xtmClass.equals(TYPE)) { + parseTypeEnd(); + } else if (enableXTM2support&&xtmClass.equals(ROLE)) { + parseRoleEnd(); } } catch (TopicMapProcessingException ex) { *************** *** 274,278 **** (String) m_xmlBaseStack.peek()); } else { ! warn("Encoutered topicRef element with no xlink:href attribute value. This element will be ignored."); } } --- 315,319 ---- (String) m_xmlBaseStack.peek()); } else { ! warn("Encoutered topicRef element with no xlink:href attribute value. This element will be ignored."); } } *************** *** 287,291 **** (String) m_xmlBaseStack.peek()); } else { ! warn("Encoutered resourceRef element with no xlink:href attribute value. This element will be ignored."); } } --- 328,332 ---- (String) m_xmlBaseStack.peek()); } else { ! warn("Encoutered resourceRef element with no xlink:href attribute value. This element will be ignored."); } } *************** *** 300,304 **** (String) m_xmlBaseStack.peek()); } else { ! warn("Encountered a subjectIndicatorRef element with no xlink:href attribute. This element will be ignored."); } } --- 341,345 ---- (String) m_xmlBaseStack.peek()); } else { ! warn("Encountered a subjectIndicatorRef element with no xlink:href attribute. This element will be ignored."); } } *************** *** 374,378 **** --- 415,485 ---- m_builder.startMergeMap(id, ref, (String) m_xmlBaseStack.peek()); } + + + + + public void parseSubjectIdentifier(Attributes atts) + throws TopicMapProcessingException { + String id = getXTMAttribute(ID, atts); + String ref = getXTMAttribute(HREF, atts); + if (ref != null) { + m_builder.ref(id, TopicMapHandler.REFTYPE_SUBJECTIDENTIFIER, ref, (String) m_xmlBaseStack.peek()); + } else { + warn("Encountered a subjectIdentifier element with no href attribute. This element will be ignored."); + } + } + + public void parseNameStart(Attributes atts) throws TopicMapProcessingException { + // FIXME: need to process type + parseBaseName(atts); + } + + public void parseValueStart(Attributes atts) throws TopicMapProcessingException { + // FIXME: need to process type + parseBaseNameString(atts); + } + + public void parseValueEnd() throws TopicMapProcessingException { + m_builder.baseNameString(m_id, m_data.toString()); + m_data = null; + m_getData = false; + } + + public void parseNameEnd() throws TopicMapProcessingException { + m_builder.endBaseName(); + } + + public void parseTypeStart(Attributes atts) throws TopicMapProcessingException { + switch (((XTMBuilder) m_builder).peekPurpose()) { + case XTMBuilder.MEMBER: + parseRoleSpec(atts); + break; + default: + parseInstanceOf(atts); + } + } + + public void parseTypeEnd() throws TopicMapProcessingException { + switch (((XTMBuilder) m_builder).peekPurpose()) { + case XTMBuilder.ROLESPEC: + m_builder.endRoleSpec(); + break; + case XTMBuilder.INSTANCEOF: + m_builder.endInstanceOf(); + break; + default: + throw new UnsupportedOperationException(); + } + } + + public void parseRoleStart(Attributes atts) throws TopicMapProcessingException { + parseMember(atts); + } + + public void parseRoleEnd() throws TopicMapProcessingException { + m_builder.endMember(); + } + protected String getXTMAttribute(String localName, Attributes atts) { String ret = atts.getValue(XTM_NS_URI, localName); *************** *** 403,407 **** protected String getXLinkAttribute(String localName, Attributes atts) { ! return atts.getValue(XLINK_NS_URI, localName); } --- 510,524 ---- protected String getXLinkAttribute(String localName, Attributes atts) { ! String ret = atts.getValue(XLINK_NS_URI, localName); ! ! if (enableXTM2support&&(ret==null)) { ! ret = atts.getValue(XTM2_NS_URI, localName); ! ! if (ret==null) { ! ret = atts.getValue(localName); ! } ! } ! ! return ret; } Index: TopicMapHandler.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/utils/TopicMapHandler.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** TopicMapHandler.java 26 Feb 2004 21:33:50 -0000 1.9 --- TopicMapHandler.java 12 Apr 2007 12:57:48 -0000 1.10 *************** *** 16,19 **** --- 16,21 ---- public static final int REFTYPE_TOPIC = 2; + public static final int REFTYPE_SUBJECTIDENTIFIER = 3; + public void startTopicMap(String id, String xmlBase) throws TopicMapProcessingException; |
From: Lars H. <lh...@us...> - 2007-02-16 17:27:46
|
Update of /cvsroot/tm4j/tm4j In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv8129 Modified Files: RELEASE.txt Log Message: Documentation of changes against 0.9.8 Index: RELEASE.txt =================================================================== RCS file: /cvsroot/tm4j/tm4j/RELEASE.txt,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** RELEASE.txt 15 Dec 2004 10:23:42 -0000 1.35 --- RELEASE.txt 16 Feb 2007 17:27:46 -0000 1.36 *************** *** 1,2 **** --- 1,44 ---- + TM4J 0.9.x Release Notes + ------------------------ + + Changes In This Release + ----------------------- + + - A number of bug fixes to the TMAPI implementation. + + - Updated the TMAPI libs to 1.0sp1 + + - Memory backend: Replaced unnecessary initialization of empty + collections with the static collection constants provided + by the java.util.Collections class + + - Memory TopicMapObjectImpl: Renamed field "resourceLocators" to + "sourceLocators". Removed System.out.println commands + (Patch #1432892) + + - Memory TopicMapImpl: Renamed field "objectsByResourceLocator" to + "objectsBySourceLocator". Removed deprecated method invocation + (Patch #1432888) + + - Memory ScopedObjectImpl: Avoid expensive update of scope if the + the theme is already in the scope (for adding themes) or if the + theme is not in the scope (for removing themes) + (Patch #1432883) + + - Memory TopicImpl: Several memory / performance improvements + (Patch #1432877) + + - Memory MemberImpl: Set id earlier to calculate the correct hashCode + (Bug #1501213). Thanks to Xuan Baldauf + + - TopicMapCopier: Removed unnecessary array creation, + Added support for VariantName copying. + + + + -------------------------------------------------------------------------------- + HISTORICAL RELEASE NOTES: + ------------------------- + TM4J 0.9.8 Release Notes ------------------------ *************** *** 19,27 **** The default behaviour as before - i.e. to always use a <topicRef> element. ! ! -------------------------------------------------------------------------------- ! HISTORICAL RELEASE NOTES: ! ------------------------- ! TM4J 0.9.7 Release Notes ------------------------ --- 61,66 ---- The default behaviour as before - i.e. to always use a <topicRef> element. ! ! TM4J 0.9.7 Release Notes ------------------------ |
From: Lars H. <lh...@us...> - 2007-02-16 16:20:00
|
Update of /cvsroot/tm4j/tm4j/lib In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv11513/lib Added Files: tmapi-1_0SP1.jar tmapi-test-1_0SP1.jar Removed Files: tmapi-1_0.jar tmapi-test-1_0.jar Log Message: - Replaced TMAPI 1.0 with TMAPI 1.0 SP1 release --- tmapi-test-1_0.jar DELETED --- --- NEW FILE: tmapi-1_0SP1.jar --- (This appears to be a binary file; contents omitted.) --- tmapi-1_0.jar DELETED --- --- NEW FILE: tmapi-test-1_0SP1.jar --- (This appears to be a binary file; contents omitted.) |
From: Lars H. <lh...@us...> - 2007-02-15 14:57:23
|
Update of /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/memory In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv13244/src/org/tm4j/topicmap/memory Modified Files: MemberImpl.java Log Message: Fixed bug 1501213 "MemberImpl.hashCode() is not consistent with equals()" thanks to Xuan Baldauf for the patch Index: MemberImpl.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/memory/MemberImpl.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** MemberImpl.java 7 Mar 2006 15:36:35 -0000 1.24 --- MemberImpl.java 15 Feb 2007 14:57:14 -0000 1.25 *************** *** 54,60 **** --- 54,64 ---- DuplicateResourceLocatorException { super(parent.getTopicMap()); + m_roleSpec = roleSpec; m_players = new ArrayList(players); + setID(id); + if (resourceLoc != null) addSourceLocator(resourceLoc); + for (Iterator it = m_players.iterator(); it.hasNext();) { TopicImpl t = (TopicImpl) it.next(); *************** *** 63,68 **** } - if (resourceLoc != null) addSourceLocator(resourceLoc); - setID(id); parent.addMember(this); } --- 67,70 ---- *************** *** 309,312 **** --- 311,318 ---- /* * $Log$ + * Revision 1.25 2007/02/15 14:57:14 lheuer + * Fixed bug 1501213 "MemberImpl.hashCode() is not consistent with equals()" + * thanks to Xuan Baldauf for the patch + * * Revision 1.24 2006/03/07 15:36:35 lheuer * - Fixed bugs #1430090, #143009, #1430800, #1433530 |
From: Lars H. <lh...@us...> - 2007-02-14 14:39:51
|
Update of /cvsroot/tm4j/tm4j/src/org/tm4j/tmapi/helpers In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv9852/src/org/tm4j/tmapi/helpers Modified Files: Wrapper.java Log Message: Made error msg for "unwrapping" vs. "wrapping" more explicit Index: Wrapper.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/tmapi/helpers/Wrapper.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** Wrapper.java 14 Feb 2007 13:58:45 -0000 1.15 --- Wrapper.java 14 Feb 2007 14:39:39 -0000 1.16 *************** *** 33,38 **** if (!(obj instanceof org.tm4j.tmapi.core.TMAPILocatorImpl)) { ! throw new RuntimeException( ! "Cannot unwrap TMAPI objects from a foreign implementation"); } --- 33,37 ---- if (!(obj instanceof org.tm4j.tmapi.core.TMAPILocatorImpl)) { ! foreignImplementation(obj); } *************** *** 316,322 **** } ! foreignImplementation(obj); ! ! return null; } --- 315,319 ---- } ! throw new RuntimeException("Cannot wrap object of class: " + obj.getClass().getName()); } |
From: Lars H. <lh...@us...> - 2007-02-14 13:58:49
|
Update of /cvsroot/tm4j/tm4j/src/org/tm4j/tmapi/helpers In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv24232/src/org/tm4j/tmapi/helpers Modified Files: Wrapper.java Log Message: Made excplicit that wrapping a native TM4J TopicMap is not possible without providing a TopicMapSystem Index: Wrapper.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/tmapi/helpers/Wrapper.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** Wrapper.java 7 Mar 2006 15:14:19 -0000 1.14 --- Wrapper.java 14 Feb 2007 13:58:45 -0000 1.15 *************** *** 276,280 **** if (obj instanceof org.tm4j.topicmap.TopicMap) { ! return wrap((org.tm4j.topicmap.TopicMap) obj, tm); } --- 276,283 ---- if (obj instanceof org.tm4j.topicmap.TopicMap) { ! throw new RuntimeException("Wrapping a TopicMap object is currently not possible. A TopicMapSystem instance must be provided"); ! // The following line causes a stack overflow because the ! // Topic Map System is not provided ! //return wrap((org.tm4j.topicmap.TopicMap) obj, tm); } |
From: maca k. <mar...@ya...> - 2006-12-23 10:13:04
|
<HTML> <BODY> Dakota Fanning Film "HoundDog" Selected For<BR> Largest 2007 Sundance Film Festal Ever!<BR><BR> <b>Company: The Motion Picture Group<BR> Symbol: MPRG<BR> Price: $0.15<BR> 5 Day Target: $0.38<BR><BR></b> January 18-28, 2007 brings another Sundance film festival. This Year <BR> MPRG's Dramatic film "HoundDog" starring Dakota Fanning has been <BR> selected to compete at the festival.<BR><BR> This is one the film industries more prestigious events. With 82 world <BR> premiers of the 122 feature titles from 25 countries, the selection of <BR> "HoundDog" is a great honor.<BR><BR> <b>The last news we had like this pushed MPRG up over 100% and we are told <BR> there will be a big news release next week. It is at $0.15 now, we can <BR> easily see going over $0.34. Make this Christmas even better, grab <BR> MPRG first thing Friday morning.<BR></b><BR><BR><BR><BR><BR><BR><BR><BR>It's more of a reference book ("How do I...?" type book) than a <br> read-beginning-to-end. However, for a <br> self-starter it's great: pick a task you want to achieve<br> ("How do i send TCP/IP messages back and forth") and <br> there are questions with answers which do <br>what you want. <br>that I need to keep in mind when I'm applying it to VB <br>Express? Thanks! <br> </BODY> </HTML> |
From: Dionne C. <Dio...@al...> - 2006-12-19 00:37:56
|
Steffen superidee, texte lustig weiterso chrischris markus drngt angeklickt! Agentbased monitoring, hybrid approach bmc bsm, embracing platforms standards. Bearshare reaction, confusion external software mediaedit. Easter engagement everyday fathers, communion friendship halloween, hanukkah. Udells context capstat dcstat jons. Get FPMC First Thing tomorrow. This Is Going To Explode! Check out for HOT NEWS!!! The alert is ON!! FLAIR PETROLEUM CORP (FPMC.PK) CURRENT_PRICE: $0.27 GET IT N0W! TARGET PRICE IN 1 WEEK: 0.73$ Please use your brokerage site to read the full news on this exciting company. Go FPMC! Angaben adressen regelmig aktuellen laufenden halten liste! Generally kad reliance, pure capability allowing high id? Libya north korea serbia! Thumbnail talkgoogle flash, mozilla maker cd, bulk. Looked page shortcuts set keywords character when shortcut appears. Henning hb drcke erscheint spielraum figur linken. Segments completes throughout ease websites, checksums. Favoritos versiones opinar valorar, facilidad apariencia avisar, recomendar. Cfab daab dbab dcab ddab. Document pdf must printed signed returned within three. Ehrensenf tv haufen glck oktober, wmv gpdatei. Fritz leaves halffull bar back burt. Supernodes sourced additional bundled softwares installer. Allows videos antipiracy warning riaa seem. Arbeite seit, stunden habe! |
From: Lars H. <lh...@us...> - 2006-03-07 15:36:48
|
Update of /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/memory In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1664/src/org/tm4j/topicmap/memory Modified Files: AssociationImpl.java MemberImpl.java ScopedObjectImpl.java TopicImpl.java TopicMapImpl.java TopicMapObjectImpl.java VariantContainerImpl.java Log Message: - Fixed bugs #1430090, #143009, #1430800, #1433530 - Applied feature patches #1432895, #1432892, #1432888, #1432883, #1432880, #1432877, #1432872 Index: TopicImpl.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/memory/TopicImpl.java,v retrieving revision 1.71 retrieving revision 1.72 diff -C2 -d -r1.71 -r1.72 *** TopicImpl.java 8 Dec 2004 10:50:57 -0000 1.71 --- TopicImpl.java 7 Mar 2006 15:36:35 -0000 1.72 *************** *** 1,2028 **** ! /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! /* ! * $Header$ ! */ [...3932 lines suppressed...] ! * Revision 1.8 2000/12/22 16:47:01 kal ! * Restructuring for XTM support ! * ! * Revision 1.7 2000/12/13 16:50:20 kal ! * Update from kermit repository ! * ! * Revision 1.2 2000/08/29 05:47:54 kal ! * Added convenience constructors ! * ! * Revision 1.1.1.1 2000/08/24 06:02:50 kal ! * Imported sources - Release 0.3 ! * ! * Revision 1.4 2000/08/01 08:01:55 kal ! * Fixed creation of scope ! * ! * Revision 1.3 2000/07/05 22:11:28 kal ! * Standardised on Collection for returning sets of objects. ! * Added CVS Header and Log comments. ! * ! */ Index: ScopedObjectImpl.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/memory/ScopedObjectImpl.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** ScopedObjectImpl.java 26 May 2004 18:27:02 -0000 1.22 --- ScopedObjectImpl.java 7 Mar 2006 15:36:35 -0000 1.23 *************** *** 1,290 **** ! /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! /* ! * $Header$ ! */ ! package org.tm4j.topicmap.memory; ! ! import org.tm4j.topicmap.IntegrityViolationException; ! import org.tm4j.topicmap.ScopedObject; ! import org.tm4j.topicmap.Topic; ! import org.tm4j.topicmap.TopicMap; ! import org.tm4j.topicmap.TopicMapRuntimeException; ! ! import java.beans.PropertyChangeEvent; ! import java.beans.PropertyChangeListener; ! import java.beans.PropertyVetoException; ! ! import java.util.Arrays; ! import java.util.Collections; ! import java.util.HashSet; ! import java.util.Set; ! ! ! /** ! * Base class for all topic map objects which have a validity scope. ! */ ! public abstract class ScopedObjectImpl extends TopicMapObjectImpl ! implements ScopedObject, PropertyChangeListener { ! private Set m_scope; ! ! ScopedObjectImpl(TopicMap tm) { ! this(tm, null); // changed by Elmar, calls other construcotr to ensure a valid scope ! ! /* ! try ! { ! m_scope = new ScopeImpl(tm, (String)null); ! } ! catch(DuplicateObjectIDException ex) ! { ! // Shouldn't end up here ! throw new TopicMapRuntimeException("INTERNAL ERROR: DuplicateObjectIDException thrown for id = null!"); ! } ! */ ! } ! ! /** ! * This constructor ensures that the scope is never null. If no scope is provided a new Unconstrained scope is attached ! * ! */ ! ScopedObjectImpl(TopicMap tm, Topic[] scopingTopics) { ! super(tm); ! ! if (scopingTopics != null) { ! try { ! setScope(scopingTopics); ! } catch (PropertyVetoException e) { ! throw new TopicMapRuntimeException("Setting of scope for object was vetoed.", ! e); ! } ! } else { ! m_scope = new HashSet(); ! } ! } ! ! /** ! * Clears contained scope references. ! */ ! public void dispose() { ! m_scope.clear(); ! } ! ! /** ! * Defines the scope of validity of this scoped object. ! * @param themes An array of Topics defining the scope for this scoped object. ! * @throws PropertyVetoException if the update of the scope for this object is vetoed by a listener. ! */ ! public void setScope(Topic[] themes) throws PropertyVetoException { ! Set newScope = new HashSet(); ! ! if (themes != null) { ! newScope.addAll(Arrays.asList(themes)); ! } ! ! fireVetoableChange("scope", m_scope, newScope); ! ! Set oldScope = m_scope; ! m_scope = newScope; ! firePropertyChange("scope", oldScope, m_scope); ! } ! ! public Set getScope() { ! return Collections.unmodifiableSet(m_scope); ! } ! ! // Add/Remove themes from scope: ! public void addTheme(Topic theme) throws PropertyVetoException { ! if (theme == null) { ! throw new IllegalArgumentException("Cannot add a null theme to the scope of an object."); ! } ! HashSet newScope = new HashSet(m_scope); ! newScope.add(theme); ! setScope((Topic[]) newScope.toArray(new Topic[newScope.size()])); ! } ! ! public void removeTheme(Topic theme) throws PropertyVetoException { ! HashSet newScope = new HashSet(m_scope); ! newScope.remove(theme); ! ! if (newScope.isEmpty()) { ! setScope(null); ! } else { ! setScope((Topic[]) newScope.toArray(new Topic[newScope.size()])); ! } ! } ! ! /** ! * @return True if the specified theme is in the scope of this object. ! * @deprecated from 0.9.0 use {@link org.tm4j.topicmap.utils.tester.InScopeTester} ! */ ! public boolean inScope(Topic theme) { ! if (m_scope == null) { ! return true; ! } ! ! return m_scope.contains(theme); ! } ! ! /** ! * @return True if the one or more of the specified themes are in the scope of this object. ! * @deprecated from 0.9.0 use {@link org.tm4j.topicmap.utils.tester.InScopeTester} ! */ ! public boolean inScope(Topic[] themes) { ! if (m_scope == null) { ! return true; ! } ! ! if (themes == null) { ! return false; ! } ! ! for (int i = 0; i < themes.length; i++) { ! if (m_scope.contains(themes[i])) { ! return true; ! } ! } ! ! return false; ! } ! ! /** ! * Handling of property change events from contained scope. ! * This handler should be overriden by derived classes. ! */ ! public void propertyChange(PropertyChangeEvent ev) { ! return; ! } ! ! /** ! * A ScopedObject can always be destroyed if the ! * derived class can be destroyed. However, ! * client applications should never call this method ! * directly but use the destroy() method provided on the ! * derived class instead. ! */ ! public void destroy() ! throws IntegrityViolationException, PropertyVetoException { ! // Notify listeners that the scope is being reset ! firePropertyChange("scope", m_scope, null); ! ! if (m_scope != null) { ! m_scope.clear(); ! } ! ! super.destroy(); ! } ! ! protected void _destroy() { ! m_scope = null; ! super._destroy(); ! } ! } ! ! ! /* * $Log$ ! * Revision 1.22 2004/05/26 18:27:02 kal_ahmed ! * Fixed addTheme(Topic) to prevent null being added to themes. ! * ! * Revision 1.21 2004/02/26 21:33:47 kal_ahmed ! * Updated license text and reformatted source with Jalopy. ! * ! * Revision 1.20 2003/08/31 15:08:41 kal_ahmed ! * Reformatted source code to Sun code style. ! * ! * Revision 1.19 2003/07/10 08:01:00 kal_ahmed ! * Updates to remove the Scope interface and implementations. ! * ! * Revision 1.18 2003/05/20 21:11:42 kal_ahmed ! * ScopedObject implementations now initialise scope in their own constructors to maintain a consistent ordering of event notifications. ! * ! * Revision 1.17 2003/05/10 16:15:56 kal_ahmed ! * Removed IntegrityViolationExceptions thrown when attempting to delete Occurrence and BaseName children of a Topic. Refactored handling of PropertyVetoExceptions during destroy() operations. Fixes bug #727539 ! * ! * Revision 1.16 2003/05/01 15:52:54 kal_ahmed ! * Reorganised import statements. ! * ! * Revision 1.15 2003/04/26 18:24:57 esomaniac ! * Constructor changed. Scope will never be null. Also the setScope ensures that scope is not null ! * ! * Revision 1.14 2003/03/11 20:35:21 kal_ahmed ! * Old scope is now correctly deregistered from this object in setScope(). ! * ! * Revision 1.13 2003/01/11 13:42:54 kal_ahmed ! * Updated ScopedObject.getScope() to return null for unscoped objects. ! * ! * Revision 1.12 2002/12/16 09:06:25 kal_ahmed ! * Moved constructors and setParent() methods into package scope in memory back-end implementation. ! * ! * Revision 1.11 2002/12/14 19:00:42 kal_ahmed ! * Moved constructor into package scope ! * ! * Revision 1.10 2002/04/09 19:56:59 kal_ahmed ! * Updated to support vetoable change notifications. ! * ! * Revision 1.9 2002/03/24 15:49:46 kal_ahmed ! * Implemented destroy() interface. ! * ! * Revision 1.8 2002/03/22 16:52:40 kal_ahmed ! * Added registration of object with scope to setScope() ! * ! * Revision 1.7 2002/02/09 19:37:39 kal_ahmed ! * Updated license text ! * ! * Revision 1.6 2002/01/26 19:32:50 kal_ahmed ! * Now throws a DuplicateObjectIDException if the ID value passed to the ! * constructor already exists in the parent topic map. ! * ! * Revision 1.5 2002/01/10 11:41:35 kal_ahmed ! * Updated license text ! * ! * Revision 1.4 2001/11/20 23:58:33 kal_ahmed ! * Updated constructor as required by base class changes. ! * ! * Revision 1.3 2001/11/04 00:47:22 kal_ahmed ! * Updated to match updated interfaces ! * ! * Revision 1.2 2001/09/28 21:29:36 kal_ahmed ! * Changed package declarations, imports and other occurrences of com.techquila.topicmap to org.tm4j.topicmap ! * ! * Revision 1.1 2001/09/28 20:54:06 kal_ahmed ! * Moved com/techquila/topicmap/* to org/tm4j/topicmap/* ! * ! * Revision 1.2 2001/07/26 17:11:52 kal_ahmed ! * Updated license text ! * ! * Revision 1.1 2001/07/26 14:01:20 kal_ahmed ! * Moved into new package for in-memory implementation ! * ! * Revision 1.1.1.1 2001/05/23 21:37:09 kal_ahmed ! * Initial import into SourceForge ! * ! * Revision 1.10 2001/01/07 20:11:11 kal ! * Updates to support navigation application ! * ! * Revision 1.9 2000/12/28 15:44:54 kal ! * Changes for XTM processing model ! * ! * Revision 1.8 2000/12/22 16:47:01 kal ! * Restructuring for XTM support ! * ! * Revision 1.7 2000/12/13 16:50:20 kal ! * Update from kermit repository ! * ! * Revision 1.1.1.1 2000/08/24 06:02:50 kal ! * Imported sources - Release 0.3 ! * ! * Revision 1.4 2000/08/01 07:59:04 kal ! * Fixed null pointer returned from getScope() when no scope defined for object. ! * ! * Revision 1.3 2000/07/05 22:08:59 kal ! * Standardised on Collection for returning sets of objects. ! * Added CVS Header and Log comments. ! * ! */ --- 1,302 ---- ! /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! /* ! * $Header$ ! */ ! package org.tm4j.topicmap.memory; ! ! import org.tm4j.topicmap.IntegrityViolationException; ! import org.tm4j.topicmap.ScopedObject; ! import org.tm4j.topicmap.Topic; ! import org.tm4j.topicmap.TopicMap; ! import org.tm4j.topicmap.TopicMapRuntimeException; ! ! import java.beans.PropertyChangeEvent; ! import java.beans.PropertyChangeListener; ! import java.beans.PropertyVetoException; ! ! import java.util.Arrays; ! import java.util.Collections; ! import java.util.HashSet; ! import java.util.Set; ! ! ! /** ! * Base class for all topic map objects which have a validity scope. ! */ ! public abstract class ScopedObjectImpl extends TopicMapObjectImpl ! implements ScopedObject, PropertyChangeListener { ! private Set m_scope; ! ! ScopedObjectImpl(TopicMap tm) { ! this(tm, null); // changed by Elmar, calls other construcotr to ensure a valid scope ! ! /* ! try ! { ! m_scope = new ScopeImpl(tm, (String)null); ! } ! catch(DuplicateObjectIDException ex) ! { ! // Shouldn't end up here ! throw new TopicMapRuntimeException("INTERNAL ERROR: DuplicateObjectIDException thrown for id = null!"); ! } ! */ ! } ! ! /** ! * This constructor ensures that the scope is never null. If no scope is provided a new Unconstrained scope is attached ! * ! */ ! ScopedObjectImpl(TopicMap tm, Topic[] scopingTopics) { ! super(tm); ! ! if (scopingTopics != null) { ! try { ! setScope(scopingTopics); ! } catch (PropertyVetoException e) { ! throw new TopicMapRuntimeException("Setting of scope for object was vetoed.", ! e); ! } ! } else { ! m_scope = new HashSet(); ! } ! } ! ! /** ! * Clears contained scope references. ! */ ! public void dispose() { ! m_scope.clear(); ! } ! ! /** ! * Defines the scope of validity of this scoped object. ! * @param themes An array of Topics defining the scope for this scoped object. ! * @throws PropertyVetoException if the update of the scope for this object is vetoed by a listener. ! */ ! public void setScope(Topic[] themes) throws PropertyVetoException { ! Set newScope = new HashSet(); ! ! if (themes != null) { ! newScope.addAll(Arrays.asList(themes)); ! } ! ! fireVetoableChange("scope", m_scope, newScope); ! ! Set oldScope = m_scope; ! m_scope = newScope; ! firePropertyChange("scope", oldScope, m_scope); ! } ! ! public Set getScope() { ! return Collections.unmodifiableSet(m_scope); ! } ! ! // Add/Remove themes from scope: ! public void addTheme(Topic theme) throws PropertyVetoException { ! if (theme == null) { ! throw new IllegalArgumentException("Cannot add a null theme to the scope of an object."); ! } ! if (m_scope.contains(theme)) { ! return; ! } ! // TODO: Optimize this, don't call setScope ! HashSet newScope = new HashSet(m_scope); ! newScope.add(theme); ! setScope((Topic[]) newScope.toArray(new Topic[newScope.size()])); ! } ! ! public void removeTheme(Topic theme) throws PropertyVetoException { ! if (!m_scope.contains(theme)) { ! return; ! } ! // TODO: Optimize this, don't call setScope ! HashSet newScope = new HashSet(m_scope); ! newScope.remove(theme); ! ! if (newScope.isEmpty()) { ! setScope(null); ! } else { ! setScope((Topic[]) newScope.toArray(new Topic[newScope.size()])); ! } ! } ! ! /** ! * @return True if the specified theme is in the scope of this object. ! * @deprecated from 0.9.0 use {@link org.tm4j.topicmap.utils.tester.InScopeTester} ! */ ! public boolean inScope(Topic theme) { ! if (m_scope == null) { ! return true; ! } ! ! return m_scope.contains(theme); ! } ! ! /** ! * @return True if the one or more of the specified themes are in the scope of this object. ! * @deprecated from 0.9.0 use {@link org.tm4j.topicmap.utils.tester.InScopeTester} ! */ ! public boolean inScope(Topic[] themes) { ! if (m_scope == null) { ! return true; ! } ! ! if (themes == null) { ! return false; ! } ! ! for (int i = 0; i < themes.length; i++) { ! if (m_scope.contains(themes[i])) { ! return true; ! } ! } ! ! return false; ! } ! ! /** ! * Handling of property change events from contained scope. ! * This handler should be overriden by derived classes. ! */ ! public void propertyChange(PropertyChangeEvent ev) { ! return; ! } ! ! /** ! * A ScopedObject can always be destroyed if the ! * derived class can be destroyed. However, ! * client applications should never call this method ! * directly but use the destroy() method provided on the ! * derived class instead. ! */ ! public void destroy() ! throws IntegrityViolationException, PropertyVetoException { ! // Notify listeners that the scope is being reset ! firePropertyChange("scope", m_scope, null); ! ! if (m_scope != null) { ! m_scope.clear(); ! } ! ! super.destroy(); ! } ! ! protected void _destroy() { ! m_scope = null; ! super._destroy(); ! } ! } ! ! ! /* * $Log$ ! * Revision 1.23 2006/03/07 15:36:35 lheuer ! * - Fixed bugs #1430090, #143009, #1430800, #1433530 ! * - Applied feature patches #1432895, #1432892, #1432888, #1432883, #1432880, #1432877, #1432872 ! * ! * Revision 1.22 2004/05/26 18:27:02 kal_ahmed ! * Fixed addTheme(Topic) to prevent null being added to themes. ! * ! * Revision 1.21 2004/02/26 21:33:47 kal_ahmed ! * Updated license text and reformatted source with Jalopy. ! * ! * Revision 1.20 2003/08/31 15:08:41 kal_ahmed ! * Reformatted source code to Sun code style. ! * ! * Revision 1.19 2003/07/10 08:01:00 kal_ahmed ! * Updates to remove the Scope interface and implementations. ! * ! * Revision 1.18 2003/05/20 21:11:42 kal_ahmed ! * ScopedObject implementations now initialise scope in their own constructors to maintain a consistent ordering of event notifications. ! * ! * Revision 1.17 2003/05/10 16:15:56 kal_ahmed ! * Removed IntegrityViolationExceptions thrown when attempting to delete Occurrence and BaseName children of a Topic. Refactored handling of PropertyVetoExceptions during destroy() operations. Fixes bug #727539 ! * ! * Revision 1.16 2003/05/01 15:52:54 kal_ahmed ! * Reorganised import statements. ! * ! * Revision 1.15 2003/04/26 18:24:57 esomaniac ! * Constructor changed. Scope will never be null. Also the setScope ensures that scope is not null ! * ! * Revision 1.14 2003/03/11 20:35:21 kal_ahmed ! * Old scope is now correctly deregistered from this object in setScope(). ! * ! * Revision 1.13 2003/01/11 13:42:54 kal_ahmed ! * Updated ScopedObject.getScope() to return null for unscoped objects. ! * ! * Revision 1.12 2002/12/16 09:06:25 kal_ahmed ! * Moved constructors and setParent() methods into package scope in memory back-end implementation. ! * ! * Revision 1.11 2002/12/14 19:00:42 kal_ahmed ! * Moved constructor into package scope ! * ! * Revision 1.10 2002/04/09 19:56:59 kal_ahmed ! * Updated to support vetoable change notifications. ! * ! * Revision 1.9 2002/03/24 15:49:46 kal_ahmed ! * Implemented destroy() interface. ! * ! * Revision 1.8 2002/03/22 16:52:40 kal_ahmed ! * Added registration of object with scope to setScope() ! * ! * Revision 1.7 2002/02/09 19:37:39 kal_ahmed ! * Updated license text ! * ! * Revision 1.6 2002/01/26 19:32:50 kal_ahmed ! * Now throws a DuplicateObjectIDException if the ID value passed to the ! * constructor already exists in the parent topic map. ! * ! * Revision 1.5 2002/01/10 11:41:35 kal_ahmed ! * Updated license text ! * ! * Revision 1.4 2001/11/20 23:58:33 kal_ahmed ! * Updated constructor as required by base class changes. ! * ! * Revision 1.3 2001/11/04 00:47:22 kal_ahmed ! * Updated to match updated interfaces ! * ! * Revision 1.2 2001/09/28 21:29:36 kal_ahmed ! * Changed package declarations, imports and other occurrences of com.techquila.topicmap to org.tm4j.topicmap ! * ! * Revision 1.1 2001/09/28 20:54:06 kal_ahmed ! * Moved com/techquila/topicmap/* to org/tm4j/topicmap/* ! * ! * Revision 1.2 2001/07/26 17:11:52 kal_ahmed ! * Updated license text ! * ! * Revision 1.1 2001/07/26 14:01:20 kal_ahmed ! * Moved into new package for in-memory implementation ! * ! * Revision 1.1.1.1 2001/05/23 21:37:09 kal_ahmed ! * Initial import into SourceForge ! * ! * Revision 1.10 2001/01/07 20:11:11 kal ! * Updates to support navigation application ! * ! * Revision 1.9 2000/12/28 15:44:54 kal ! * Changes for XTM processing model ! * ! * Revision 1.8 2000/12/22 16:47:01 kal ! * Restructuring for XTM support ! * ! * Revision 1.7 2000/12/13 16:50:20 kal ! * Update from kermit repository ! * ! * Revision 1.1.1.1 2000/08/24 06:02:50 kal ! * Imported sources - Release 0.3 ! * ! * Revision 1.4 2000/08/01 07:59:04 kal ! * Fixed null pointer returned from getScope() when no scope defined for object. ! * ! * Revision 1.3 2000/07/05 22:08:59 kal ! * Standardised on Collection for returning sets of objects. ! * Added CVS Header and Log comments. ! * ! */ Index: AssociationImpl.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/memory/AssociationImpl.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** AssociationImpl.java 25 May 2004 09:41:12 -0000 1.38 --- AssociationImpl.java 7 Mar 2006 15:36:35 -0000 1.39 *************** *** 1,587 **** ! /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! /* ! * $Header$ ! */ [...1139 lines suppressed...] ! * Revision 1.9 2001/01/07 20:11:11 kal ! * Updates to support navigation application ! * ! * Revision 1.8 2000/12/28 15:43:17 kal ! * Changes to match XTM processing model ! * ! * Revision 1.7 2000/12/22 16:47:01 kal ! * Restructuring for XTM support ! * ! * Revision 1.6 2000/12/13 16:50:20 kal ! * Update from kermit repository ! * ! * Revision 1.1.1.1 2000/08/24 06:02:50 kal ! * Imported sources - Release 0.3 ! * ! * Revision 1.3 2000/07/05 21:58:45 kal ! * Standardised on Collection for returning sets of objects. ! * Added CVS Header and Log comments. ! * ! */ Index: MemberImpl.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/memory/MemberImpl.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** MemberImpl.java 12 Jul 2004 19:13:03 -0000 1.23 --- MemberImpl.java 7 Mar 2006 15:36:35 -0000 1.24 *************** *** 1,398 **** ! /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! /* ! * $Header$ ! */ ! package org.tm4j.topicmap.memory; ! ! import org.tm4j.net.Locator; ! ! import org.tm4j.topicmap.Association; ! import org.tm4j.topicmap.DuplicateObjectIDException; ! import org.tm4j.topicmap.DuplicateResourceLocatorException; ! import org.tm4j.topicmap.IntegrityViolationException; ! import org.tm4j.topicmap.Member; ! import org.tm4j.topicmap.TMTypes; ! import org.tm4j.topicmap.Topic; ! import org.tm4j.topicmap.TopicMapRuntimeException; ! ! import java.beans.PropertyChangeEvent; ! import java.beans.PropertyVetoException; ! ! import java.util.ArrayList; ! import java.util.Arrays; ! import java.util.Collection; ! import java.util.Collections; ! import java.util.Iterator; ! import java.util.List; ! ! ! /** ! * Implements the Member interface for TM4J's in-memory storage model ! */ ! public class MemberImpl extends ScopedObjectImpl implements Member { ! protected Association m_parent; ! protected Topic m_roleSpec; ! protected ArrayList m_players; ! ! MemberImpl(Association parent, String id) ! throws DuplicateObjectIDException, PropertyVetoException { ! super(parent.getTopicMap()); ! setID(id); ! parent.addMember(this); ! } ! ! public MemberImpl(AssociationImpl parent, String id, Locator resourceLoc, ! Topic roleSpec, Collection players) ! throws DuplicateObjectIDException, PropertyVetoException, ! DuplicateResourceLocatorException { ! super(parent.getTopicMap()); ! m_roleSpec = roleSpec; ! m_players = new ArrayList(players); ! ! Iterator it = m_players.iterator(); ! ! while (it.hasNext()) { ! TopicImpl t = (TopicImpl) it.next(); ! ! if (t.m_rolesPlayed == null) { ! t.m_rolesPlayed = new ArrayList(); ! } ! ! t.m_rolesPlayed.add(this); ! } ! ! if (resourceLoc != null) addSourceLocator(resourceLoc); ! setID(id); ! parent.addMember(this); ! } ! ! /** ! * Applications should not call this function directly. ! * It is called indirectly from Association.addMember(), Association.removeMember() and Association.setMembers() ! */ ! void setParent(Association parent) throws PropertyVetoException { ! if ((parent != null) && (!parent.getTopicMap().equals(getTopicMap()))) { ! throw new TopicMapRuntimeException( ! "Attempt to move object to a different topic map."); ! } ! ! fireVetoableChange("parent", m_parent, parent); ! ! Association oldParent = m_parent; ! m_parent = parent; ! firePropertyChange("parent", oldParent, m_parent); ! } ! ! public Association getParent() { ! return m_parent; ! } ! ! public void setRoleSpec(Topic roleSpec) throws PropertyVetoException { ! fireVetoableChange("roleSpec", m_roleSpec, roleSpec); ! ! Topic oldRoleSpec = m_roleSpec; ! ! m_roleSpec = roleSpec; ! ! firePropertyChange("roleSpec", oldRoleSpec, m_roleSpec); ! } ! ! public Topic getRoleSpec() { ! return m_roleSpec; ! } ! ! /** ! * Adds a player to this Member. ! * Calling this function will result in Topic.addRolePlayed() ! * being invoked on <i>player</i> with <i>this</i> as a parameter, to ! * allow the player Topic to update its list of roles played. ! */ ! public void addPlayer(Topic player) throws PropertyVetoException { ! if ((m_players == null) || (!m_players.contains(player))) { ! ArrayList oldPlayers = (m_players == null) ? new ArrayList() ! : new ArrayList(m_players); ! ArrayList newPlayers = new ArrayList(oldPlayers); ! newPlayers.add(player); ! ! fireVetoableChange("players", ! Collections.unmodifiableCollection(oldPlayers), ! Collections.unmodifiableCollection(newPlayers)); ! ! ((TopicImpl) player).addRolePlayed(this); ! ! // _addPlayer() will fire post-change notification. ! } ! } ! ! /** ! * Adds a player to this Member. ! * CAlling this function will not notify the <i>player</i> object ! * that it has a new Member role played. ! * This function should only be invoked by the Topic.addRolePlayed() ! * function. ! */ ! protected void _addPlayer(Topic player) { ! ArrayList oldPlayers = null; ! ! if (m_players != null) { ! oldPlayers = new ArrayList(m_players); ! } ! ! if (m_players == null) { ! m_players = new ArrayList(); ! } ! ! m_players.add(player); ! firePropertyChange("players", oldPlayers, m_players); ! } ! ! public void removePlayer(Topic player) throws PropertyVetoException { ! if (m_players == null) { ! // No players, so nothing can be removed. ! return; ! } ! ! ArrayList oldPlayers = new ArrayList(m_players); ! ! if (m_players.contains(player)) { ! ArrayList newPlayers = new ArrayList(oldPlayers); ! newPlayers.remove(player); ! fireVetoableChange("players", ! Collections.unmodifiableCollection(oldPlayers), ! Collections.unmodifiableCollection(newPlayers)); ! ! ArrayList newRoles = new ArrayList(player.getRolesPlayed()); ! newRoles.remove(this); ! fireVetoableChange(new PropertyChangeEvent(player, "rolesPlayed", ! Collections.unmodifiableCollection(player.getRolesPlayed()), ! Collections.unmodifiableCollection(newRoles))); ! _removePlayer(player); ! ((TopicImpl) player).removeRolePlayed(this); ! firePropertyChange("players", oldPlayers, m_players); ! } ! } ! ! protected void _removePlayer(Topic player) { ! if (m_players == null) { ! return; ! } ! ! if (m_players.contains(player)) { ! m_players.remove(player); ! } ! } ! ! public void setPlayers(Topic[] players) throws PropertyVetoException { ! List newPlayers = (players == null) ? new ArrayList() ! : Arrays.asList(players); ! ! // Fire all vetoable change notifications before proceeding: ! fireVetoableChange("players", ! Collections.unmodifiableCollection((m_players == null) ! ? new ArrayList() : m_players), ! Collections.unmodifiableCollection(newPlayers)); ! ! // Vetoable notification of removal of role from old players ! if (m_players != null) { ! Iterator it = m_players.iterator(); ! ! while (it.hasNext()) { ! Topic t = (Topic) it.next(); ! ! if (!newPlayers.contains(t)) { ! ArrayList newRoles = new ArrayList(t.getRolesPlayed()); ! newRoles.remove(this); ! fireVetoableChange(new PropertyChangeEvent(t, ! "rolesPlayed", ! Collections.unmodifiableCollection( ! t.getRolesPlayed()), ! Collections.unmodifiableCollection(newRoles))); ! } ! } ! } ! ! if (players != null) { ! Iterator it = Arrays.asList(players).iterator(); ! ! while (it.hasNext()) { ! Topic t = (Topic) it.next(); ! ! if (!newPlayers.contains(t)) { ! ArrayList newRoles = new ArrayList(t.getRolesPlayed()); ! newRoles.add(this); ! fireVetoableChange("rolesPlayed", ! Collections.unmodifiableCollection(t.getRolesPlayed()), ! Collections.unmodifiableCollection(newRoles)); ! } ! } ! } ! ! ArrayList oldPlayers = null; ! ! if (m_players != null) { ! oldPlayers = new ArrayList(m_players); ! ! Iterator it = oldPlayers.iterator(); ! ! while (it.hasNext()) { ! Topic player = (Topic) it.next(); ! ! if (!newPlayers.contains(player)) { ! ((TopicImpl) player).removeRolePlayed(this); ! } ! } ! } ! ! if ((players == null) || (players.length == 0)) { ! m_players = null; ! } else { ! if (m_players == null) { ! m_players = new ArrayList(); ! } ! ! for (int i = 0; i < players.length; i++) { ! if (!m_players.contains(players[i])) { ! ((TopicImpl) players[i]).addRolePlayed(this); ! } ! } ! } ! ! firePropertyChange("players", oldPlayers, m_players); ! } ! ! public Collection getPlayers() { ! if (m_players == null) { ! return Collections.unmodifiableCollection(new ArrayList()); ! } ! ! return Collections.unmodifiableCollection(m_players); ! } ! ! public int getObjectType() { ! return TMTypes.TM_MEMBER; ! } ! ! public void destroy() ! throws IntegrityViolationException, PropertyVetoException { ! if (getParent() != null) { ! if (getParent().getMembers().contains(this)) { ! throw new IntegrityViolationException( ! "Member is still part of an Association."); ! } ! } ! ! removeChangeListeners(); ! ! try { ! setPlayers(null); ! } catch (PropertyVetoException ex) { ! // Vetos are ignored during destroy() ! } ! ! super.destroy(); ! } ! ! public void _destroy() { ! if (m_players != null) { ! m_players.clear(); ! m_players = null; ! } ! ! m_roleSpec = null; ! m_parent = null; ! super._destroy(); ! } ! } ! ! ! /* * $Log$ ! * Revision 1.23 2004/07/12 19:13:03 kal_ahmed ! * Fixed event notification on removePlayer(). ! * ! * Revision 1.22 2004/05/25 10:10:55 kal_ahmed ! * Fixed NPE if constructor called with null for resourceLoc parameter. ! * ! * Revision 1.21 2004/02/26 21:33:46 kal_ahmed ! * Updated license text and reformatted source with Jalopy. ! * ! * Revision 1.20 2004/01/25 20:51:49 kal_ahmed ! * Optimised creation of Associations and Members during XTM parsing. ! * ! * Revision 1.19 2003/08/31 15:08:41 kal_ahmed ! * Reformatted source code to Sun code style. ! * ! * Revision 1.18 2003/08/27 20:22:09 kal_ahmed ! * Removal of deprecated methods from the Topic interface ! * ! * Revision 1.17 2003/05/10 16:42:44 kal_ahmed ! * New Member object is no longer left attached to the parent Association if the creation throws an exception for some reason. Fixes bug#715293 ! * ! * Revision 1.16 2003/05/10 16:15:56 kal_ahmed ! * Removed IntegrityViolationExceptions thrown when attempting to delete Occurrence and BaseName children of a Topic. Refactored handling of PropertyVetoExceptions during destroy() operations. Fixes bug #727539 ! * ! * Revision 1.15 2003/05/01 15:52:52 kal_ahmed ! * Reorganised import statements. ! * ! * Revision 1.14 2002/12/14 18:49:14 kal_ahmed ! * Made constructors and setParent() method package scope as they are no longer exposed to API users. ! * ! * Revision 1.13 2002/09/02 17:04:13 kal_ahmed ! * Fixed integrity violation checking ! * ! * Revision 1.12 2002/06/20 15:19:06 kal_ahmed ! * Fixed VetoableChange events to use unmodifiable collections ! * ! * Revision 1.11 2002/04/21 19:01:25 kal_ahmed ! * Disconnet change listeners before trying to destroy self. ! * ! * Revision 1.10 2002/04/02 16:08:11 kal_ahmed ! * Added implementation of vetoable property change notifications ! * ! * Revision 1.9 2002/04/02 08:21:44 kal_ahmed ! * Created new vetoable change event notification infrastructure. Added vetoable change notification to Association properties. ! * ! * Revision 1.8 2002/03/26 19:05:54 kal_ahmed ! * Improved robustness of _destroy() method ! * ! * Revision 1.7 2002/03/24 15:49:46 kal_ahmed ! * Implemented destroy() interface. ! * ! * Revision 1.6 2002/02/09 19:37:39 kal_ahmed ! * Updated license text ! * ! * Revision 1.5 2002/01/26 19:32:50 kal_ahmed ! * Now throws a DuplicateObjectIDException if the ID value passed to the ! * constructor already exists in the parent topic map. ! * ! * Revision 1.4 2002/01/10 11:41:35 kal_ahmed ! * Updated license text ! * ! * Revision 1.3 2001/11/20 23:36:12 kal_ahmed ! * Updated constructor as required by base class changes. ! * ! * Revision 1.2 2001/09/28 21:29:36 kal_ahmed ! * Changed package declarations, imports and other occurrences of com.techquila.topicmap to org.tm4j.topicmap ! * ! * Revision 1.1 2001/09/28 20:54:06 kal_ahmed ! * Moved com/techquila/topicmap/* to org/tm4j/topicmap/* ! * ! * Revision 1.4 2001/09/26 19:17:45 kal_ahmed ! * Fixed to notify players when they are removed from the member. ! * ! * Revision 1.3 2001/07/31 13:04:31 kal_ahmed ! * Fixed bug causing Topics to be added twice in a single addPlayer() call ! * ! * Revision 1.2 2001/07/26 17:11:52 kal_ahmed ! * Updated license text ! * ! * Revision 1.1 2001/07/26 14:01:20 kal_ahmed ! * Moved into new package for in-memory implementation ! * ! */ --- 1,397 ---- ! /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! /* ! * $Header$ ! */ ! package org.tm4j.topicmap.memory; ! ! import org.tm4j.net.Locator; ! ! import org.tm4j.topicmap.Association; ! import org.tm4j.topicmap.DuplicateObjectIDException; ! import org.tm4j.topicmap.DuplicateResourceLocatorException; ! import org.tm4j.topicmap.IntegrityViolationException; ! import org.tm4j.topicmap.Member; ! import org.tm4j.topicmap.TMTypes; ! import org.tm4j.topicmap.Topic; ! import org.tm4j.topicmap.TopicMapRuntimeException; ! ! import java.beans.PropertyChangeEvent; ! import java.beans.PropertyVetoException; ! ! import java.util.ArrayList; ! import java.util.Arrays; ! import java.util.Collection; ! import java.util.Collections; ! import java.util.HashSet; ! import java.util.Iterator; ! import java.util.List; ! ! ! /** ! * Implements the Member interface for TM4J's in-memory storage model ! */ ! public class MemberImpl extends ScopedObjectImpl implements Member { ! protected Association m_parent; ! protected Topic m_roleSpec; ! protected Collection m_players; ! ! MemberImpl(Association parent, String id) ! throws DuplicateObjectIDException, PropertyVetoException { ! super(parent.getTopicMap()); ! setID(id); ! parent.addMember(this); ! } ! ! MemberImpl(AssociationImpl parent, String id, Locator resourceLoc, ! Topic roleSpec, Collection players) ! throws DuplicateObjectIDException, PropertyVetoException, ! DuplicateResourceLocatorException { ! super(parent.getTopicMap()); ! m_roleSpec = roleSpec; ! m_players = new ArrayList(players); ! ! for (Iterator it = m_players.iterator(); it.hasNext();) { ! TopicImpl t = (TopicImpl) it.next(); ! // TODO: Avoid the access of the Topic.m_rolesPlayed field ! t.m_rolesPlayed.add(this); ! } ! ! if (resourceLoc != null) addSourceLocator(resourceLoc); ! setID(id); ! parent.addMember(this); ! } ! ! /** ! * Applications should not call this function directly. ! * It is called indirectly from Association.addMember(), Association.removeMember() and Association.setMembers() ! */ ! void setParent(Association parent) throws PropertyVetoException { ! if ((parent != null) && (!parent.getTopicMap().equals(getTopicMap()))) { ! throw new TopicMapRuntimeException( ! "Attempt to move object to a different topic map."); ! } ! ! fireVetoableChange("parent", m_parent, parent); ! ! Association oldParent = m_parent; ! m_parent = parent; ! firePropertyChange("parent", oldParent, m_parent); ! } ! ! public Association getParent() { ! return m_parent; ! } ! ! public void setRoleSpec(Topic roleSpec) throws PropertyVetoException { ! fireVetoableChange("roleSpec", m_roleSpec, roleSpec); ! ! Topic oldRoleSpec = m_roleSpec; ! ! m_roleSpec = roleSpec; ! ! firePropertyChange("roleSpec", oldRoleSpec, m_roleSpec); ! } ! ! public Topic getRoleSpec() { ! return m_roleSpec; ! } ! ! /** ! * Adds a player to this Member. ! * Calling this function will result in Topic.addRolePlayed() ! * being invoked on <i>player</i> with <i>this</i> as a parameter, to ! * allow the player Topic to update its list of roles played. ! */ ! public void addPlayer(Topic player) throws PropertyVetoException { ! if ((m_players == null) || (!m_players.contains(player))) { ! ArrayList oldPlayers = (m_players == null) ? new ArrayList() ! : new ArrayList(m_players); ! ArrayList newPlayers = new ArrayList(oldPlayers); ! newPlayers.add(player); ! ! fireVetoableChange("players", ! Collections.unmodifiableCollection(oldPlayers), ! Collections.unmodifiableCollection(newPlayers)); ! ! ((TopicImpl) player).addRolePlayed(this); ! ! // _addPlayer() will fire post-change notification. ! } ! } ! ! /** ! * Adds a player to this Member. ! * CAlling this function will not notify the <i>player</i> object ! * that it has a new Member role played. ! * This function should only be invoked by the Topic.addRolePlayed() ! * function. ! */ ! protected void _addPlayer(Topic player) { ! ArrayList oldPlayers = null; ! ! if (m_players != null) { ! oldPlayers = new ArrayList(m_players); ! } ! ! if (m_players == null) { ! m_players = new ArrayList(); ! } ! ! m_players.add(player); ! firePropertyChange("players", oldPlayers, m_players); ! } ! ! public void removePlayer(Topic player) throws PropertyVetoException { ! if (m_players == null) { ! // No players, so nothing can be removed. ! return; ! } ! ! ArrayList oldPlayers = new ArrayList(m_players); ! ! if (m_players.contains(player)) { ! ArrayList newPlayers = new ArrayList(oldPlayers); ! newPlayers.remove(player); ! fireVetoableChange("players", ! Collections.unmodifiableCollection(oldPlayers), ! Collections.unmodifiableCollection(newPlayers)); ! ! ArrayList newRoles = new ArrayList(player.getRolesPlayed()); ! newRoles.remove(this); ! fireVetoableChange(new PropertyChangeEvent(player, "rolesPlayed", ! Collections.unmodifiableCollection(player.getRolesPlayed()), ! Collections.unmodifiableCollection(newRoles))); ! _removePlayer(player); ! ((TopicImpl) player).removeRolePlayed(this); ! firePropertyChange("players", oldPlayers, m_players); ! } ! } ! ! protected void _removePlayer(Topic player) { ! if (m_players == null) { ! return; ! } ! ! if (m_players.contains(player)) { ! m_players.remove(player); ! } ! } ! ! public void setPlayers(Topic[] players) throws PropertyVetoException { ! List newPlayers = (players == null) ? new ArrayList() ! : Arrays.asList(players); ! ! // Fire all vetoable change notifications before proceeding: ! fireVetoableChange("players", ! Collections.unmodifiableCollection((m_players == null) ! ? new ArrayList() : m_players), ! Collections.unmodifiableCollection(newPlayers)); ! ! // Vetoable notification of removal of role from old players ! if (m_players != null) { ! Iterator it = m_players.iterator(); ! ! while (it.hasNext()) { ! Topic t = (Topic) it.next(); ! ! if (!newPlayers.contains(t)) { ! ArrayList newRoles = new ArrayList(t.getRolesPlayed()); ! newRoles.remove(this); ! fireVetoableChange(new PropertyChangeEvent(t, ! "rolesPlayed", ! Collections.unmodifiableCollection( ! t.getRolesPlayed()), ! Collections.unmodifiableCollection(newRoles))); ! } ! } ! } ! ! if (players != null) { ! Iterator it = Arrays.asList(players).iterator(); ! ! while (it.hasNext()) { ! Topic t = (Topic) it.next(); ! ! if (!newPlayers.contains(t)) { ! ArrayList newRoles = new ArrayList(t.getRolesPlayed()); ! newRoles.add(this); ! fireVetoableChange("rolesPlayed", ! Collections.unmodifiableCollection(t.getRolesPlayed()), ! Collections.unmodifiableCollection(newRoles)); ! } ! } ! } ! ! ArrayList oldPlayers = null; ! ! if (m_players != null) { ! oldPlayers = new ArrayList(m_players); ! ! Iterator it = oldPlayers.iterator(); ! ! while (it.hasNext()) { ! Topic player = (Topic) it.next(); ! ! if (!newPlayers.contains(player)) { ! ((TopicImpl) player).removeRolePlayed(this); ! } ! } ! } ! ! if ((players == null) || (players.length == 0)) { ! m_players = null; ! } else { ! if (m_players == null) { ! m_players = new ArrayList(); ! } ! ! for (int i = 0; i < players.length; i++) { ! if (!m_players.contains(players[i])) { ! ((TopicImpl) players[i]).addRolePlayed(this); ! } ! } ! } ! ! firePropertyChange("players", oldPlayers, m_players); ! } ! ! public Collection getPlayers() { ! if (m_players == null) { ! return Collections.unmodifiableCollection(new ArrayList()); ! } ! ! return Collections.unmodifiableCollection(m_players); ! } ! ! public int getObjectType() { ! return TMTypes.TM_MEMBER; ! } ! ! public void destroy() ! throws IntegrityViolationException, PropertyVetoException { ! if (getParent() != null) { ! if (getParent().getMembers().contains(this)) { ! throw new IntegrityViolationException( ! "Member is still part of an Association."); ! } ! } ! ! removeChangeListeners(); ! ! try { ! setPlayers(null); ! } catch (PropertyVetoException ex) { ! // Vetos are ignored during destroy() ! } ! ! super.destroy(); ! } ! ! public void _destroy() { ! if (m_players != null) { ! m_players.clear(); ! m_players = null; ! } ! ! m_roleSpec = null; ! m_parent = null; ! super._destroy(); ! } ! } ! ! ! /* * $Log$ ! * Revision 1.24 2006/03/07 15:36:35 lheuer ! * - Fixed bugs #1430090, #143009, #1430800, #1433530 ! * - Applied feature patches #1432895, #1432892, #1432888, #1432883, #1432880, #1432877, #1432872 ! * ! * Revision 1.23 2004/07/12 19:13:03 kal_ahmed ! * Fixed event notification on removePlayer(). ! * ! * Revision 1.22 2004/05/25 10:10:55 kal_ahmed ! * Fixed NPE if constructor called with null for resourceLoc parameter. ! * ! * Revision 1.21 2004/02/26 21:33:46 kal_ahmed ! * Updated license text and reformatted source with Jalopy. ! * ! * Revision 1.20 2004/01/25 20:51:49 kal_ahmed ! * Optimised creation of Associations and Members during XTM parsing. ! * ! * Revision 1.19 2003/08/31 15:08:41 kal_ahmed ! * Reformatted source code to Sun code style. ! * ! * Revision 1.18 2003/08/27 20:22:09 kal_ahmed ! * Removal of deprecated methods from the Topic interface ! * ! * Revision 1.17 2003/05/10 16:42:44 kal_ahmed ! * New Member object is no longer left attached to the parent Association if the creation throws an exception for some reason. Fixes bug#715293 ! * ! * Revision 1.16 2003/05/10 16:15:56 kal_ahmed ! * Removed IntegrityViolationExceptions thrown when attempting to delete Occurrence and BaseName children of a Topic. Refactored handling of PropertyVetoExceptions during destroy() operations. Fixes bug #727539 ! * ! * Revision 1.15 2003/05/01 15:52:52 kal_ahmed ! * Reorganised import statements. ! * ! * Revision 1.14 2002/12/14 18:49:14 kal_ahmed ! * Made constructors and setParent() method package scope as they are no longer exposed to API users. ! * ! * Revision 1.13 2002/09/02 17:04:13 kal_ahmed ! * Fixed integrity violation checking ! * ! * Revision 1.12 2002/06/20 15:19:06 kal_ahmed ! * Fixed VetoableChange events to use unmodifiable collections ! * ! * Revision 1.11 2002/04/21 19:01:25 kal_ahmed ! * Disconnet change listeners before trying to destroy self. ! * ! * Revision 1.10 2002/04/02 16:08:11 kal_ahmed ! * Added implementation of vetoable property change notifications ! * ! * Revision 1.9 2002/04/02 08:21:44 kal_ahmed ! * Created new vetoable change event notification infrastructure. Added vetoable change notification to Association properties. ! * ! * Revision 1.8 2002/03/26 19:05:54 kal_ahmed ! * Improved robustness of _destroy() method ! * ! * Revision 1.7 2002/03/24 15:49:46 kal_ahmed ! * Implemented destroy() interface. ! * ! * Revision 1.6 2002/02/09 19:37:39 kal_ahmed ! * Updated license text ! * ! * Revision 1.5 2002/01/26 19:32:50 kal_ahmed ! * Now throws a DuplicateObjectIDException if the ID value passed to the ! * constructor already exists in the parent topic map. ! * ! * Revision 1.4 2002/01/10 11:41:35 kal_ahmed ! * Updated license text ! * ! * Revision 1.3 2001/11/20 23:36:12 kal_ahmed ! * Updated constructor as required by base class changes. ! * ! * Revision 1.2 2001/09/28 21:29:36 kal_ahmed ! * Changed package declarations, imports and other occurrences of com.techquila.topicmap to org.tm4j.topicmap ! * ! * Revision 1.1 2001/09/28 20:54:06 kal_ahmed ! * Moved com/techquila/topicmap/* to org/tm4j/topicmap/* ! * ! * Revision 1.4 2001/09/26 19:17:45 kal_ahmed ! * Fixed to notify players when they are removed from the member. ! * ! * Revision 1.3 2001/07/31 13:04:31 kal_ahmed ! * Fixed bug causing Topics to be added twice in a single addPlayer() call ! * ! * Revision 1.2 2001/07/26 17:11:52 kal_ahmed ! * Updated license text ! * ! * Revision 1.1 2001/07/26 14:01:20 kal_ahmed ! * Moved into new package for in-memory implementation ! * ! */ Index: TopicMapObjectImpl.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/memory/TopicMapObjectImpl.java,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** TopicMapObjectImpl.java 22 Apr 2004 20:45:56 -0000 1.36 --- TopicMapObjectImpl.java 7 Mar 2006 15:36:35 -0000 1.37 *************** *** 1,637 **** ! /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! /* ! * $Header$ ! */ [...1250 lines suppressed...] ! * ! * Revision 1.2 2001/09/28 21:29:36 kal_ahmed ! * Changed package declarations, imports and other occurrences of com.techquila.topicmap to org.tm4j.topicmap ! * ! * Revision 1.1 2001/09/28 20:54:06 kal_ahmed ! * Moved com/techquila/topicmap/* to org/tm4j/topicmap/* ! * ! * Revision 1.4 2001/09/26 19:26:46 kal_ahmed ! * Removed Log4J logging...for now ! * ! * Revision 1.3 2001/09/08 19:16:09 kal_ahmed ! * Added check to prevent modification of an object's ID after it has been assigned. ! * ! * Revision 1.2 2001/07/26 17:11:52 kal_ahmed ! * Updated license text ! * ! * Revision 1.1 2001/07/26 14:01:20 kal_ahmed ! * Moved into new package for in-memory implementation ! * ! */ Index: VariantContainerImpl.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/memory/VariantContainerImpl.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** VariantContainerImpl.java 26 Feb 2004 21:33:47 -0000 1.18 --- VariantContainerImpl.java 7 Mar 2006 15:36:35 -0000 1.19 *************** *** 1,162 **** ! /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! package org.tm4j.topicmap.memory; ! ! import org.tm4j.topicmap.DuplicateObjectIDException; ! import org.tm4j.topicmap.IntegrityViolationException; ! import org.tm4j.topicmap.TopicMap; ! import org.tm4j.topicmap.TopicMapRuntimeException; ! import org.tm4j.topicmap.Variant; ! import org.tm4j.topicmap.VariantContainer; ! ! import java.beans.PropertyVetoException; ! ! import java.util.ArrayList; ! import java.util.Arrays; ! import java.util.Collection; ! import java.util.Collections; ! import java.util.Iterator; ! import java.util.List; ! ! ! public class VariantContainerImpl extends ScopedObjectImpl ! implements VariantContainer { ! protected ArrayList m_variants; ! ! VariantContainerImpl(TopicMap tm) { ! super(tm); ! m_variants = null; ! } ! ! VariantContainerImpl(TopicMap tm, String id) ! throws DuplicateObjectIDException { ! super(tm); ! setID(id); ! m_variants = null; ! } ! ! public void setVariants(Variant[] variants) throws PropertyVetoException { ! ArrayList oldVariants = (m_variants == null) ? new ArrayList() ! : new ArrayList(m_variants); ! List newVariants = (variants == null) ? new ArrayList() ! : Arrays.asList(variants); ! fireVetoableChange("variants", oldVariants, newVariants); ! ! if ((variants == null) || (variants.length == 0)) { ! m_variants = null; ! } else { ! m_variants = new ArrayList(Arrays.asList(variants)); ! } ! ! // Update parent pointers: ! if (oldVariants != null) { ! Iterator it = oldVariants.iterator(); ! ! while (it.hasNext()) { ! ((VariantImpl) it.next()).setParent(null); ! } ! } ! ! if (m_variants != null) { ! Iterator it = m_variants.iterator(); ! ! while (it.hasNext()) { ! ((VariantImpl) it.next()).setParent(this); ! } ! } ! ! firePropertyChange("variants", oldVariants, m_variants); ! } ! ! public void addVariant(Variant v) throws PropertyVetoException { ! ArrayList oldVariants = (m_variants == null) ? new ArrayList() ! : new ArrayList(m_variants); ! ArrayList newVariants = new ArrayList(oldVariants); ! newVariants.add(v); ! fireVetoableChange("variants", oldVariants, newVariants); ! ! if (m_variants == null) { ! m_variants = new ArrayList(); ! } ! ! m_variants.add(v); ! ((VariantImpl) v).setParent(this); ! ! firePropertyChange("variants", oldVariants, m_variants); ! } ! ! public Variant createVariant(String id) ! throws DuplicateObjectIDException, PropertyVetoException { ! try { ! Variant ret = ((TopicMapFactoryImpl) getTopicMap().getFactory()).createVariant(this, ! id); ! ! return ret; ! } catch (IntegrityViolationException ex) { ! // Should not happen ! throw new TopicMapRuntimeException("INTERNAL ERROR: Unexpected IntegrityViolationException while in VariantContainer.createVariant(String)", ! ex); ! } ! } ! ! /** ! * Package-scope method for notifying the destruction of a child Variant. This method ! * removes the child from the list of variants of the parent. ! * @param v the Variant to be removed. ! */ ! void removeVariant(Variant v) { ! ArrayList oldVariants = new ArrayList(m_variants); ! m_variants.remove(v); ! firePropertyChange("variants", ! Collections.unmodifiableCollection(oldVariants), ! Collections.unmodifiableCollection(m_variants)); ! } ! ! public Collection getVariants() { ! if (m_variants == null) { ! return Collections.unmodifiableCollection(new ArrayList()); ! } else { ! return Collections.unmodifiableCollection(m_variants); ! } ! } ! ! /** ! * A VariantContainer can always be destroyed. However, ! * clients should never call this method directly, it ! * should only be called via Variant.destroy() or ! * BaseName.destroy() ! */ ! public void destroy() ! throws IntegrityViolationException, PropertyVetoException { ! ArrayList variants = new ArrayList(getVariants()); ! ! try { ! setVariants(null); ! } catch (PropertyVetoException ex) { ! // Ignored during destroy ! } ! ! Iterator it = variants.iterator(); ! ! while (it.hasNext()) { ! Variant v = (Variant) it.next(); ! v.destroy(); ! } ! ! super.destroy(); ! } ! ! protected void _destroy() { ! if (m_variants != null) { ! m_variants.clear(); ! m_variants = null; ! } ! ! super._destroy(); ! } ! } --- 1,157 ---- ! /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! package org.tm4j.topicmap.memory; ! ! import org.tm4j.topicmap.DuplicateObjectIDException; ! import org.tm4j.topicmap.IntegrityViolationException; ! import org.tm4j.topicmap.TopicMap; ! import org.tm4j.topicmap.TopicMapRuntimeException; ! import org.tm4j.topicmap.Variant; ! import org.tm4j.topicmap.VariantContainer; ! ! import java.beans.PropertyVetoException; ! ! import java.util.ArrayList; ! import java.util.Arrays; ! import java.util.Collection; ! import java.util.Collections; ! import java.util.Iterator; ! import java.util.List; ! ! ! public class VariantContainerImpl extends ScopedObjectImpl ! implements VariantContainer { ! protected Collection m_variants; ! ! VariantContainerImpl(TopicMap tm) { ! super(tm); ! m_variants = null; ! } ! ! VariantContainerImpl(TopicMap tm, String id) ! throws DuplicateObjectIDException { ! super(tm); ! setID(id); ! m_variants = null; ! } ! ! public void setVariants(Variant[] variants) throws PropertyVetoException { ! Collection oldVariants = (m_variants == null) ? Collections.EMPTY_LIST ! : m_variants; ! Collection newVariants = (variants == null) ? Collections.EMPTY_LIST ! : Arrays.asList(variants); ! fireVetoableChange("variants", Collections.unmodifiableCollection(oldVariants), ! Collections.unmodifiableCollection(newVariants)); ! ! m_variants = (newVariants.isEmpty()) ? null : newVariants; ! ... [truncated message content] |
From: Lars H. <lh...@us...> - 2006-03-07 15:36:44
|
Update of /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/utils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1664/src/org/tm4j/topicmap/utils Modified Files: TopicMapCopier.java Log Message: - Fixed bugs #1430090, #143009, #1430800, #1433530 - Applied feature patches #1432895, #1432892, #1432888, #1432883, #1432880, #1432877, #1432872 Index: TopicMapCopier.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/topicmap/utils/TopicMapCopier.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TopicMapCopier.java 28 Apr 2004 20:13:49 -0000 1.7 --- TopicMapCopier.java 7 Mar 2006 15:36:35 -0000 1.8 *************** *** 1,482 **** ! /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ ! */ ! package org.tm4j.topicmap.utils; ! ! import org.tm4j.net.Locator; ! import org.tm4j.net.LocatorFactory; ! import org.tm4j.net.LocatorFactoryException; ! ! import org.tm4j.topicmap.Association; ! import org.tm4j.topicmap.BaseName; ! import org.tm4j.topicmap.Member; ! import org.tm4j.topicmap.Occurrence; ! import org.tm4j.topicmap.ScopedObject; ! import org.tm4j.topicmap.Topic; ! import org.tm4j.topicmap.TopicMap; ! import org.tm4j.topicmap.TopicMapObject; ! import org.tm4j.topicmap.TopicMapProcessingException; ! import org.tm4j.topicmap.Variant; ! import org.tm4j.topicmap.VariantContainer; ! ! import java.beans.PropertyVetoException; ! ! import java.util.Collection; ! import java.util.HashMap; ! import java.util.Iterator; ! import java.util.Set; ! ! ! /** ! * Encapsulates an algorithm for copying topics and associations between topic ! * maps while ensuring that copied references do not result in multiple topic copies. ! * For complex copying operations, the operations in this class should be preferred ! * to the TopicMapFactory copy() methods. ! * @author Kal Ahmed (ka...@te...) ! */ ! public class TopicMapCopier { ! private TopicMap m_tm; ! private LocatorFactory m_locFactory; ! ! public TopicMapCopier(TopicMap destTM) { ! m_tm = destTM; ! m_locFactory = m_tm.getLocatorFactory(); ! } ! ! public Topic copy(Topic src, boolean deep, String idPrefix, ! String idSuffix, HashMap copied) ! throws TopicMapProcessingException, LocatorFactoryException { ! if (copied.containsKey(src.getID())) { ! return (Topic) copied.get(src.getID()); ! } ! ! Topic ret = null; ! ! try { ! ret = m_tm.createTopic(copyID(src, idPrefix, idSuffix)); ! ! // KA: Record this new copy to prevent looping when ! // copying other topic references ! copied.put(src.getID(), ret); ! ! if (deep) { ! // copy baseNames ! Iterator it = src.getNames().iterator(); ! int i = 0; ! BaseName[] cpNames = new BaseName[src.getNames().size()]; ! ! while (it.hasNext()) { ! cpNames[i++] = copy((BaseName) it.next(), ret, deep, ! idPrefix, idSuffix, copied); ! } ! ! ret.setNames(cpNames); ! ! // copy occurrences (deep) ! it = src.getOccurrences().iterator(); ! i = 0; ! ! Occurrence[] cpOccs = new Occurrence[src.getOccurrences().size()]; ! ! while (it.hasNext()) { ! cpOccs[i++] = copy((Occurrence) it.next(), ret, deep, ! idPrefix, idSuffix, copied); ! } ! ! // copy types (shallow copies) ! it = src.getTypes().iterator(); ! i = 0; ! ! Topic[] cpTypes = new Topic[src.getTypes().size()]; ! ! while (it.hasNext()) { ! Topic srcTopic = (Topic) it.next(); ! ! if (copied.containsKey(srcTopic.getID())) { ! cpTypes[i++] = (Topic) copied.get(srcTopic.getID()); ! } else { ! cpTypes[i++] = copy(srcTopic, deep, idPrefix, idSuffix, ! copied); ! } ! } ! ! ret.setTypes(cpTypes); ! ! // subject & subjectIndicators ! if (src.getSubject() != null) { ! ret.setSubject(copy(src.getSubject())); ! } ! ! Collection si = src.getSubjectIndicators(); ! ! if (!si.isEmpty()) { ! it = si.iterator(); ! i = 0; ! ! Locator[] inds = new Locator[si.size()]; ! ! while (it.hasNext()) { ! Locator lsrc = (Locator) it.next(); ! ret.addSubjectIndicator(copy((Locator) lsrc)); ! } ! } ! ! // Finally, add the source topic's resource address(es) ! // as subject indicators ! it = src.getSourceLocators().iterator(); ! while (it.hasNext()) { ! Locator lsrc = (Locator)it.next(); ! ret.addSubjectIndicator(copy(lsrc)); ! } ! } else { ! boolean willMerge = false; ! ! if (src.getSubject() != null) { ! ret.setSubject(copy(src.getSubject())); ! willMerge = true; ! } ! ! if (!src.getSubjectIndicators().isEmpty()) { ! Iterator it = src.getSubjectIndicators().iterator(); ! ! while (it.hasNext()) { ! ret.addSubjectIndicator(copy((Locator) it.next())); ! } ! ! willMerge = true; ! } ! ! if (!src.getNames().isEmpty()) { ! // copy baseNames ! Iterator it = src.getNames().iterator(); ! int i = 0; ! BaseName[] cpNames = new BaseName[src.getNames().size()]; ! ! while (it.hasNext()) { ! cpNames[i++] = copy((BaseName) it.next(), ret, deep, ! idPrefix, idSuffix, copied); ! } ! ! willMerge = true; ! } ! ! if (!willMerge) { ! // Last ditch attempt - use the topic address as a subject indicator for the copy ! Iterator srcLocs = src.getSourceLocators().iterator(); ! ! if (srcLocs.hasNext()) { ! ret.addSubjectIndicator(copy((Locator) srcLocs.next())); ! } ! } ! } ! ! copied.put(src.getID(), ret); ! ! return ret; ! } catch (PropertyVetoException ex) { ! if (ret != null) { ! copied.remove(src.getID()); ! } ! ! destroyAndRaisePVE(ret, ex); ! ! return null; ! } ! } ! ! public Association copy(Association src, boolean deep, String idPrefix, ! String idSuffix, HashMap copied) ! throws TopicMapProcessingException, LocatorFactoryException { ! try { ! Association ret = m_tm.createAssociation(copyID(src, idPrefix, ! idSuffix)); ! ! // Note: Members are copied before the association type ! // to prevent the XTMTypeInstanceValidator rejecting ! // incomplete type-instance associations. ! Collection m = src.getMembers(); ! ! if (!m.isEmpty()) { ! Member[] cpMembers = new Member[m.size()]; ! Iterator it = m.iterator(); ! int i = 0; ! ! while (it.hasNext()) { ! cpMembers[i++] = copy((Member) it.next(), ret, false, ! idPrefix, idSuffix, copied); ! } ! } ! ! if (src.getType() != null) { ! String typeId = src.getType().getID(); ! ! if (copied.containsKey(typeId)) { ! ret.setType((Topic) copied.get(typeId)); ! } else { ! ret.setType(copy(src.getType(), false, idPrefix, idSuffix, ! copied)); ! } ! } ! ! return ret; ! } catch (PropertyVetoException ex) { ! throw new TopicMapProcessingException("Copy was vetoed: " + ! ex.toString()); ! } ! } ! ! protected BaseName copy(BaseName src, Topic destParent, boolean deep, ! String idPrefix, String idSuffix, HashMap copied) ! throws TopicMapProcessingException, LocatorFactoryException { ! BaseName ret = null; ! ! try { ! ret = destParent.createName(copyID(src, idPrefix, idSuffix)); ! copyScopedObject(src, ret, deep, idPrefix, idSuffix, copied); ! ! if (deep && (src.getData() != null)) { ! ret.setData(new String(src.getData())); ! } else { ! ret.setData(src.getData()); ! } ! ! Collection vars = src.getVariants(); ! ! if (!vars.isEmpty()) { ! Variant[] cpVars = new Variant[vars.size()]; ! Iterator it = vars.iterator(); ! int i = 0; ! ! while (it.hasNext()) { ! cpVars[i++] = copy((Variant) it.next(), ret, deep, ! idPrefix, idSuffix, copied); ! } ! } ! ! return ret; ! } catch (PropertyVetoException ex) { ! destroyAndRaisePVE(ret, ex); ! ! return null; ! } ! } ! ! protected Variant copy(Variant src, VariantContainer destParent, ! boolean deep, String idPrefix, String idSuffix, HashMap copied) ! throws TopicMapProcessingException, LocatorFactoryException { ! Variant ret = null; ! ! try { ! ret = destParent.createVariant(copyID(src, idPrefix, idSuffix)); ! ! Collection params = src.getParameters(); ! ! if (!params.isEmpty()) { ! Topic[] cpParams = new Topic[params.size()]; ! Iterator it = params.iterator(); ! int i = 0; ! ! while (it.hasNext()) { ! Topic srcParam = (Topic) it.next(); ! ! if (copied.containsKey(srcParam.getID())) { ! cpParams[i++] = (Topic) copied.get(srcParam.getID()); ! } else { ! cpParams[i++] = copy(srcParam, false, idPrefix, ! idSuffix, copied); ! } ! } ! ! ret.setParameters(cpParams); ! } ! ! Collection vars = src.getVariants(); ! ! if (!vars.isEmpty()) { ! Variant[] cpVars = new Variant[vars.size()]; ! Iterator it = vars.iterator(); ! int i = 0; ! ! while (it.hasNext()) { ! cpVars[i++] = copy((Variant) it.next(), ret, deep, ! idPrefix, idSuffix, copied); ! } ! } ! ! return ret; ! } catch (PropertyVetoException ex) { ! destroyAndRaisePVE(ret, ex); ! ! return null; ! } ! } ! ! protected Occurrence copy(Occurrence src, Topic destParent, boolean deep, ! String idPrefix, String idSuffix, HashMap copied) ! throws TopicMapProcessingException, LocatorFactoryException { ! Occurrence ret = null; ! ! try { ! ret = destParent.createOccurrence(copyID(src, idPrefix, idSuffix)); ! copyScopedObject(src, ret, deep, idPrefix, idSuffix, copied); ! ! if (src.getType() != null) { ! if (copied.containsKey(src.getType().getID())) { ! ret.setType((Topic) copied.get(src.getType().getID())); ! } else { ! ret.setType(copy(src.getType(), deep, idPrefix, idSuffix, ! copied)); ! } ! } ! ! if (src.getDataLocator() != null) { ! if (deep) { ! ret.setDataLocator(src.getDataLocator().copy()); ! } else { ! ret.setDataLocator(src.getDataLocator()); ! } ! } else if (src.getData() != null) { ! if (deep) { ! ret.setData(new String(src.getData())); ! } else { ! ret.setData(src.getData()); ! } ! } ! ! return ret; ! } catch (PropertyVetoException ex) { ! destroyAndRaisePVE(ret, ex); ! ! return null; ! } ! } ! ! protected Member copy(Member src, Association destParent, boolean deep, ! String idPrefix, String idSuffix, HashMap copied) ! throws TopicMapProcessingException, LocatorFactoryException { ! Member ret = null; ! ! try { ! ret = destParent.createMember(copyID(src, idPrefix, idSuffix)); ! ! if (src.getRoleSpec() != null) { ! if (copied.containsKey(src.getRoleSpec().getID())) { ! ret.setRoleSpec((Topic) copied.get( ! src.getRoleSpec().getID())); ! } else { ! ret.setRoleSpec(copy(src.getRoleSpec(), false, idPrefix, ! idSuffix, copied)); ! } ! } ! ! Collection players = src.getPlayers(); ! ! if (!players.isEmpty()) { ! Topic[] cpPlayers = new Topic[players.size()]; ! int i = 0; ! Iterator it = players.iterator(); ! ! while (it.hasNext()) { ! Topic srcTopic = (Topic) it.next(); ! ! if (copied.containsKey(srcTopic.getID())) { ! cpPlayers[i++] = (Topic) copied.get(srcTopic.getID()); ! } else { ! cpPlayers[i++] = copy(srcTopic, deep, idPrefix, ! idSuffix, copied); ! } ! } ! ! ret.setPlayers(cpPlayers); ! } ! ! return ret; ! } catch (PropertyVetoException ex) { ! destroyAndRaisePVE(ret, ex); ! ! return null; ! } ! } ! ! protected void copyScopedObject(ScopedObject src, ScopedObject dest, ! boolean deep, String idPrefix, String idSuffix, HashMap copied) ! throws TopicMapProcessingException, PropertyVetoException, ! LocatorFactoryException { ! if (src.getScope() != null) { ! Set srcScope = src.getScope(); ! Topic[] cpScope = null; ! ! if (!srcScope.isEmpty()) { ! cpScope = (Topic[]) srcScope.toArray(new Topic[srcScope.size()]); ! } ! ! dest.setScope(cpScope); ! } ! ! return; ! } ! ! protected String copyID(TopicMapObject src, String prefix, String suffix) { ! if (src.getID() == null) { ! return null; ! } ! ! if (prefix == null) { ! prefix = ""; ! } ! ! if (suffix == null) { ! suffix = ""; ! } ! ! return prefix + src.getID() + suffix; ! } ! ! protected Locator copy(Locator src) throws LocatorFactoryException { ! return m_locFactory.createLocator(src.getNotation(), src.getAddress()); ! } ! ! /** ! * Called when a copy has been vetoed. If <code>ret</code> is not null, ! * then it will be destroyed. ! * @param ret the copy created before a PropertyVetoException was caught ! * @param srcEx the PropertyVetoException raised during the copy ! * @throws TopicMapProcessingException ! */ ! private void destroyAndRaisePVE(TopicMapObject ret, ! PropertyVetoException srcEx) throws TopicMapProcessingException { ! try { ! if (ret != null) { ! ret.destroy(); ! } ! } catch (Exception ex) { ! } ! ! throw new TopicMapProcessingException("Object copy was vetoed: " + ! srcEx.toString()); ! } ! } ! ! ! /* * $Log$ ! * Revision 1.7 2004/04/28 20:13:49 kal_ahmed ! * Now copies all source locators of src topic as subject indicators of the destination topic. ! * ! * Revision 1.6 2004/02/26 21:33:50 kal_ahmed ! * Updated license text and reformatted source with Jalopy. ! * ! * Revision 1.5 2003/11/10 21:23:36 kal_ahmed ! * Code reformatting with Jalopy ! * ! * Revision 1.4 2003/10/23 08:08:23 kal_ahmed ! * Reinstated helper class for complex topic map object copying. ! * ! */ --- 1,507 ---- ! /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! /* ! *$Header$ ! */ ! package org.tm4j.topicmap.utils; ! ! import org.tm4j.net.Locator; ! import org.tm4j.net.LocatorFactory; ! import org.tm4j.net.LocatorFactoryException; ! ! import org.tm4j.topicmap.Association; ! import org.tm4j.topicmap.BaseName; ! import org.tm4j.topicmap.Member; ! import org.tm4j.topicmap.Occurrence; ! import org.tm4j.topicmap.ScopedObject; ! import org.tm4j.topicmap.Topic; ! import org.tm4j.topicmap.TopicMap; ! import org.tm4j.topicmap.TopicMapObject; ! import org.tm4j.topicmap.TopicMapProcessingException; ! import org.tm4j.topicmap.Variant; ! import org.tm4j.topicmap.VariantContainer; ! import org.tm4j.topicmap.VariantName; ! ! import java.beans.PropertyVetoException; ! ! import java.util.Collection; ! import java.util.HashMap; ! import java.util.Iterator; ! import java.util.Set; ! ! ! /** ! * Encapsulates an algorithm for copying topics and associations between topic ! * maps while ensuring that copied references do not result in multiple topic copies. ! * For complex copying operations, the operations in this class should be preferred ! * to the TopicMapFactory copy() methods. ! * @author Kal Ahmed (ka...@te...) ! */ ! public class TopicMapCopier { ! private TopicMap m_tm; ! private LocatorFactory m_locFactory; ! ! public TopicMapCopier(TopicMap destTM) { ! m_tm = destTM; ! m_locFactory = m_tm.getLocatorFactory(); ! } ! ! public Topic copy(Topic src, boolean deep, String idPrefix, ! String idSuffix, HashMap copied) ! throws TopicMapProcessingException, LocatorFactoryException { ! if (copied.containsKey(src.getID())) { ! return (Topic) copied.get(src.getID()); ! } ! ! Topic ret = null; ! ! try { ! ret = m_tm.createTopic(copyID(src, idPrefix, idSuffix)); ! ! // KA: Record this new copy to prevent looping when ! // copying other topic references ! copied.put(src.getID(), ret); ! ! if (deep) { ! // copy baseNames ! Iterator it = src.getNames().iterator(); ! // int i = 0; ! // BaseName[] cpNames = new BaseName[src.getNames().size()]; ! ! while (it.hasNext()) { ! // cpNames[i++] = copy((BaseName) it.next(), ret, deep, ! // idPrefix, idSuffix, copied); ! copy((BaseName) it.next(), ret, deep, ! idPrefix, idSuffix, copied); ! } ! ! // ret.setNames(cpNames); ! ! // copy occurrences (deep) ! it = src.getOccurrences().iterator(); ! // i = 0; ! ! // Occurrence[] cpOccs = new Occurrence[src.getOccurrences().size()]; ! ! while (it.hasNext()) { ! // cpOccs[i++] = copy((Occurrence) it.next(), ret, deep, ! // idPrefix, idSuffix, copied); ! copy((Occurrence) it.next(), ret, deep, ! idPrefix, idSuffix, copied); ! } ! ! // copy types (shallow copies) ! it = src.getTypes().iterator(); ! int i = 0; ! ! Topic[] cpTypes = new Topic[src.getTypes().size()]; ! ! while (it.hasNext()) { ! Topic srcTopic = (Topic) it.next(); ! ! if (copied.containsKey(srcTopic.getID())) { ! cpTypes[i++] = (Topic) copied.get(srcTopic.getID()); ! } else { ! cpTypes[i++] = copy(srcTopic, deep, idPrefix, idSuffix, ! copied); ! } ! } ! ! ret.setTypes(cpTypes); ! ! // subject & subjectIndicators ! if (src.getSubject() != null) { ! ret.setSubject(copy(src.getSubject())); ! } ! ! Collection si = src.getSubjectIndicators(); ! ! if (!si.isEmpty()) { ! it = si.iterator(); ! i = 0; ! ! Locator[] inds = new Locator[si.size()]; ! ! while (it.hasNext()) { ! Locator lsrc = (Locator) it.next(); ! ret.addSubjectIndicator(copy((Locator) lsrc)); ! } ! } ! ! // Finally, add the source topic's resource address(es) ! // as subject indicators ! it = src.getSourceLocators().iterator(); ! while (it.hasNext()) { ! Locator lsrc = (Locator)it.next(); ! ret.addSubjectIndicator(copy(lsrc)); ! } ! } else { ! boolean willMerge = false; ! ! if (src.getSubject() != null) { ! ret.setSubject(copy(src.getSubject())); ! willMerge = true; ! } ! ! if (!src.getSubjectIndicators().isEmpty()) { ! Iterator it = src.getSubjectIndicators().iterator(); ! ! while (it.hasNext()) { ! ret.addSubjectIndicator(copy((Locator) it.next())); ! } ! ! willMerge = true; ! } ! ! if (!src.getNames().isEmpty()) { ! // copy baseNames ! Iterator it = src.getNames().iterator(); ! // int i = 0; ! // BaseName[] cpNames = new BaseName[src.getNames().size()]; ! ! while (it.hasNext()) { ! // cpNames[i++] = copy((BaseName) it.next(), ret, deep, ! // idPrefix, idSuffix, copied); ! copy((BaseName) it.next(), ret, deep, ! idPrefix, idSuffix, copied); ! } ! ! willMerge = true; ! } ! ! if (!willMerge) { ! // Last ditch attempt - use the topic address as a subject indicator for the copy ! Iterator srcLocs = src.getSourceLocators().iterator(); ! ! if (srcLocs.hasNext()) { ! ret.addSubjectIndicator(copy((Locator) srcLocs.next())); ! } ! } ! } ! ! copied.put(src.getID(), ret); ! ! return ret; ! } catch (PropertyVetoException ex) { ! if (ret != null) { ! copied.remove(src.getID()); ! } ! ! destroyAndRaisePVE(ret, ex); ! ! return null; ! } ! } ! ! public Association copy(Association src, boolean deep, String idPrefix, ! String idSuffix, HashMap copied) ! throws TopicMapProcessingException, LocatorFactoryException { ! try { ! Association ret = m_tm.createAssociation(copyID(src, idPrefix, ! idSuffix)); ! ! // Note: Members are copied before the association type ! // to prevent the XTMTypeInstanceValidator rejecting ! // incomplete type-instance associations. ! Collection m = src.getMembers(); ! ! if (!m.isEmpty()) { ! Member[] cpMembers = new Member[m.size()]; ! Iterator it = m.iterator(); ! int i = 0; ! ! while (it.hasNext()) { ! cpMembers[i++] = copy((Member) it.next(), ret, false, ! idPrefix, idSuffix, copied); ! } ! } ! ! if (src.getType() != null) { ! String typeId = src.getType().getID(); ! ! if (copied.containsKey(typeId)) { ! ret.setType((Topic) copied.get(typeId)); ! } else { ! ret.setType(copy(src.getType(), false, idPrefix, idSuffix, ! copied)); ! } ! } ! ! return ret; ! } catch (PropertyVetoException ex) { ! throw new TopicMapProcessingException("Copy was vetoed: " + ! ex.toString()); ! } ! } ! ! protected BaseName copy(BaseName src, Topic destParent, boolean deep, ! String idPrefix, String idSuffix, HashMap copied) ! throws TopicMapProcessingException, LocatorFactoryException { ! BaseName ret = null; ! ! try { ! ret = destParent.createName(copyID(src, idPrefix, idSuffix)); ! copyScopedObject(src, ret, deep, idPrefix, idSuffix, copied); ! ! if (deep && (src.getData() != null)) { ! ret.setData(new String(src.getData())); ! } else { ! ret.setData(src.getData()); ! } ! ! Collection vars = src.getVariants(); ! ! if (!vars.isEmpty()) { ! //Variant[] cpVars = new Variant[vars.size()]; ! Iterator it = vars.iterator(); ! //int i = 0; ! ! while (it.hasNext()) { ! // cpVars[i++] = copy((Variant) it.next(), ret, deep, ! // idPrefix, idSuffix, copied); ! copy((Variant) it.next(), ret, deep, idPrefix, idSuffix, copied); ! } ! } ! ! return ret; ! } catch (PropertyVetoException ex) { ! destroyAndRaisePVE(ret, ex); ! ! return null; ! } ! } ! ! protected Variant copy(Variant src, VariantContainer destParent, ! boolean deep, String idPrefix, String idSuffix, HashMap copied) ! throws TopicMapProcessingException, LocatorFactoryException { ! Variant ret = null; ! ! try { ! ret = destParent.createVariant(copyID(src, idPrefix, idSuffix)); ! ! Collection params = src.getParameters(); ! ! if (!params.isEmpty()) { ! Topic[] cpParams = new Topic[params.size()]; ! Iterator it = params.iterator(); ! int i = 0; ! ! while (it.hasNext()) { ! Topic srcParam = (Topic) it.next(); ! ! if (copied.containsKey(srcParam.getID())) { ! cpParams[i++] = (Topic) copied.get(srcParam.getID()); ! } else { ! cpParams[i++] = copy(srcParam, false, idPrefix, ! idSuffix, copied); ! } ! } ! ! ret.setParameters(cpParams); ! } ! ! VariantName srcVarName = src.getVariantName(); ! ! VariantName destVarName = ret.createVariantName(null); ! ! if (srcVarName.getData() != null) { ! destVarName.setData(srcVarName.getData()); ! } ! else { ! destVarName.setDataLocator(srcVarName.getDataLocator()); ! } ! ! Collection vars = src.getVariants(); ! ! if (!vars.isEmpty()) { ! // Variant[] cpVars = new Variant[vars.size()]; ! Iterator it = vars.iterator(); ! // int i = 0; ! ! while (it.hasNext()) { ! // cpVars[i++] = copy((Variant) it.next(), ret, deep, ! // idPrefix, idSuffix, copied); ! copy((Variant) it.next(), ret, deep, ! idPrefix, idSuffix, copied); ! } ! } ! ! return ret; ! } catch (PropertyVetoException ex) { ! destroyAndRaisePVE(ret, ex); ! ! return null; ! } ! } ! ! protected Occurrence copy(Occurrence src, Topic destParent, boolean deep, ! String idPrefix, String idSuffix, HashMap copied) ! throws TopicMapProcessingException, LocatorFactoryException { ! Occurrence ret = null; ! ! try { ! ret = destParent.createOccurrence(copyID(src, idPrefix, idSuffix)); ! copyScopedObject(src, ret, deep, idPrefix, idSuffix, copied); ! ! if (src.getType() != null) { ! if (copied.containsKey(src.getType().getID())) { ! ret.setType((Topic) copied.get(src.getType().getID())); ! } else { ! ret.setType(copy(src.getType(), deep, idPrefix, idSuffix, ! copied)); ! } ! } ! ! if (src.getDataLocator() != null) { ! if (deep) { ! ret.setDataLocator(src.getDataLocator().copy()); ! } else { ! ret.setDataLocator(src.getDataLocator()); ! } ! } else if (src.getData() != null) { ! if (deep) { ! ret.setData(new String(src.getData())); ! } else { ! ret.setData(src.getData()); ! } ! } ! ! return ret; ! } catch (PropertyVetoException ex) { ! destroyAndRaisePVE(ret, ex); ! ! return null; ! } ! } ! ! protected Member copy(Member src, Association destParent, boolean deep, ! String idPrefix, String idSuffix, HashMap copied) ! throws TopicMapProcessingException, LocatorFactoryException { ! Member ret = null; ! ! try { ! ret = destParent.createMember(copyID(src, idPrefix, idSuffix)); ! ! if (src.getRoleSpec() != null) { ! if (copied.containsKey(src.getRoleSpec().getID())) { ! ret.setRoleSpec((Topic) copied.get( ! src.getRoleSpec().getID())); ! } else { ! ret.setRoleSpec(copy(src.getRoleSpec(), false, idPrefix, ! idSuffix, copied)); ! } ! } ! ! Collection players = src.getPlayers(); ! ! if (!players.isEmpty()) { ! Topic[] cpPlayers = new Topic[players.size()]; ! int i = 0; ! Iterator it = players.iterator(); ! ! while (it.hasNext()) { ! Topic srcTopic = (Topic) it.next(); ! ! if (copied.containsKey(srcTopic.getID())) { ! cpPlayers[i++] = (Topic) copied.get(srcTopic.getID()); ! } else { ! cpPlayers[i++] = copy(srcTopic, deep, idPrefix, ! idSuffix, copied); ! } ! } ! ! ret.setPlayers(cpPlayers); ! } ! ! return ret; ! } catch (PropertyVetoException ex) { ! destroyAndRaisePVE(ret, ex); ! ! return null; ! } ! } ! ! protected void copyScopedObject(ScopedObject src, ScopedObject dest, ! boolean deep, String idPrefix, String idSuffix, HashMap copied) ! throws TopicMapProcessingException, PropertyVetoException, ! LocatorFactoryException { ! if (src.getScope() != null) { ! Set srcScope = src.getScope(); ! Topic[] cpScope = null; ! ! if (!srcScope.isEmpty()) { ! cpScope = (Topic[]) srcScope.toArray(new Topic[srcScope.size()]); ! } ! ! dest.setScope(cpScope); ! } ! ! return; ! } ! ! protected String copyID(TopicMapObject src, String prefix, String suffix) { ! if (src.getID() == null) { ! return null; ! } ! ! if (prefix == null) { ! prefix = ""; ! } ! ! if (suffix == null) { ! suffix = ""; ! } ! ! return prefix + src.getID() + suffix; ! } ! ! protected Locator copy(Locator src) throws LocatorFactoryException { ! return m_locFactory.createLocator(src.getNotation(), src.getAddress()); ! } ! ! /** ! * Called when a copy has been vetoed. If <code>ret</code> is not null, ! * then it will be destroyed. ! * @param ret the copy created before a PropertyVetoException was caught ! * @param srcEx the PropertyVetoException raised during the copy ! * @throws TopicMapProcessingException ! */ ! private void destroyAndRaisePVE(TopicMapObject ret, ! PropertyVetoException srcEx) throws TopicMapProcessingException { ! try { ! if (ret != null) { ! ret.destroy(); ! } ! } catch (Exception ex) { ! } ! ! throw new TopicMapProcessingException("Object copy was vetoed: " + ! srcEx.toString()); ! } ! } ! ! ! /* * $Log$ ! * Revision 1.8 2006/03/07 15:36:35 lheuer ! * - Fixed bugs #1430090, #143009, #1430800, #1433530 ! * - Applied feature patches #1432895, #1432892, #1432888, #1432883, #1432880, #1432877, #1432872 ! * ! * Revision 1.7 2004/04/28 20:13:49 kal_ahmed ! * Now copies all source locators of src topic as subject indicators of the destination topic. ! * ! * Revision 1.6 2004/02/26 21:33:50 kal_ahmed ! * Updated license text and reformatted source with Jalopy. ! * ! * Revision 1.5 2003/11/10 21:23:36 kal_ahmed ! * Code reformatting with Jalopy ! * ! * Revision 1.4 2003/10/23 08:08:23 kal_ahmed ! * Reinstated helper class for complex topic map object copying. ! * ! */ |
Update of /cvsroot/tm4j/tm4j/src/org/tm4j/tmapi/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23449/src/org/tm4j/tmapi/core Modified Files: TMAPIAssociationImpl.java TMAPIBaseNameImpl.java TMAPILocatorImpl.java TMAPIMemberImpl.java TMAPIOccurrenceImpl.java TMAPIScopedObjectImpl.java TMAPITopicImpl.java TMAPITopicMapImpl.java TMAPITopicMapObjectImpl.java TMAPITopicMapSystemFactoryImpl.java TMAPITopicMapSystemImpl.java TMAPIVariantImpl.java Log Message: Fixed all known TMAPI impl. related bugs (see #1434160, #1435978) Index: TMAPIScopedObjectImpl.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/tmapi/core/TMAPIScopedObjectImpl.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** TMAPIScopedObjectImpl.java 8 Dec 2004 12:11:39 -0000 1.12 --- TMAPIScopedObjectImpl.java 7 Mar 2006 15:14:19 -0000 1.13 *************** *** 1,46 **** ! /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! package org.tm4j.tmapi.core; ! ! import org.tm4j.tmapi.helpers.Wrapper; ! ! import java.util.Set; ! ! ! public abstract class TMAPIScopedObjectImpl extends TMAPITopicMapObjectImpl { ! private org.tm4j.topicmap.ScopedObject m_obj; ! ! public TMAPIScopedObjectImpl(org.tm4j.topicmap.ScopedObject obj, ! TMAPITopicMapImpl tm) ! { ! super(obj, tm); ! m_obj = obj; ! } ! ! public Set getScope() { ! return Wrapper.wrap(m_obj.getScope(), m_tm); ! } ! ! public void addScopingTopic(org.tmapi.core.Topic topic) { ! checkUpdateAllowed(); ! try { ! m_obj.addTheme(Wrapper.unwrap(topic)); ! } catch (Exception ex) { ! throw new RuntimeException(ex.toString()); ! } ! } ! ! public void removeScopingTopic(org.tmapi.core.Topic topic) { ! checkUpdateAllowed(); ! try { ! m_obj.removeTheme(Wrapper.unwrap(topic)); ! } catch (Exception ex) { ! throw new RuntimeException(ex.toString()); ! } ! } ! } --- 1,57 ---- ! /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! package org.tm4j.tmapi.core; ! ! import org.tm4j.tmapi.helpers.Wrapper; ! import org.tmapi.core.ScopedObject; ! ! import java.util.Set; ! ! ! public abstract class TMAPIScopedObjectImpl extends TMAPITopicMapObjectImpl ! implements ScopedObject { ! private org.tm4j.topicmap.ScopedObject m_obj; ! ! public TMAPIScopedObjectImpl(org.tm4j.topicmap.ScopedObject obj, ! TMAPITopicMapImpl tm) ! { ! super(obj, tm); ! m_obj = obj; ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.ScopedObject#getScope() ! */ ! public Set getScope() { ! return Wrapper.wrap(m_obj.getScope(), m_tm); ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.ScopedObject#addScopingTopic(org.tmapi.core.Topic) ! */ ! public void addScopingTopic(org.tmapi.core.Topic topic) { ! checkUpdateAllowed(); ! try { ! m_obj.addTheme(Wrapper.unwrap(topic)); ! } catch (Exception ex) { ! throw new RuntimeException(ex.toString()); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.ScopedObject#removeScopingTopic(org.tmapi.core.Topic) ! */ ! public void removeScopingTopic(org.tmapi.core.Topic topic) { ! checkUpdateAllowed(); ! try { ! m_obj.removeTheme(Wrapper.unwrap(topic)); ! } catch (Exception ex) { ! throw new RuntimeException(ex.toString()); ! } ! } ! } Index: TMAPIBaseNameImpl.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/tmapi/core/TMAPIBaseNameImpl.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** TMAPIBaseNameImpl.java 8 Dec 2004 12:11:38 -0000 1.14 --- TMAPIBaseNameImpl.java 7 Mar 2006 15:14:19 -0000 1.15 *************** *** 1,164 **** ! /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! package org.tm4j.tmapi.core; ! ! import org.tm4j.tmapi.helpers.Wrapper; ! ! import org.tm4j.topicmap.IntegrityViolationException; ! import org.tm4j.topicmap.TopicMapFactory; ! import org.tm4j.topicmap.TopicMapProcessingException; ! ! import org.tmapi.core.Locator; ! import org.tmapi.core.Topic; ! ! import java.util.ArrayList; ! import java.util.Collection; ! import java.util.Collections; ! import java.util.HashSet; ! import java.util.Iterator; ! import java.util.Set; ! ! ! public class TMAPIBaseNameImpl extends TMAPIScopedObjectImpl ! implements org.tmapi.core.TopicName { ! private org.tm4j.topicmap.BaseName m_obj; ! ! public TMAPIBaseNameImpl(org.tm4j.topicmap.BaseName obj, TMAPITopicMapImpl tm) { ! super(obj, tm); ! m_obj = obj; ! } ! ! public org.tm4j.topicmap.BaseName getWrapped() { ! return m_obj; ! } ! ! public org.tmapi.core.Topic getTopic() { ! return Wrapper.wrap(m_obj.getParent(), m_tm); ! } ! ! public String getValue() { ! return m_obj.getData(); ! } ! ! public void setValue(String data) { ! checkUpdateAllowed(); ! try { ! m_obj.setData(data); ! } catch (Exception ex) { ! throw new RuntimeException(ex.toString()); ! } ! } ! ! public Set getVariants() { ! return Collections.unmodifiableSet(buildVariants()); ! } ! ! public org.tmapi.core.Variant createVariant(String nameString, ! Collection params) { ! checkUpdateAllowed(); ! try { ! org.tm4j.topicmap.Variant var = m_obj.createVariant(null); ! org.tm4j.topicmap.VariantName varName = var.createVariantName(null); ! varName.setData(nameString); ! setParams(var, params); ! return Wrapper.wrap(var, varName, m_tm); ! } catch (TopicMapProcessingException ex) { ! throw Wrapper.wrap(ex); ! } catch (java.beans.PropertyVetoException ex) { ! throw Wrapper.wrap(ex); ! } ! } ! ! public org.tmapi.core.Variant createVariant(Locator resourceRef, ! Collection params) { ! checkUpdateAllowed(); ! try { ! org.tm4j.topicmap.Variant var = m_obj.createVariant(null); ! org.tm4j.topicmap.VariantName varName = var.createVariantName(null); ! varName.setDataLocator(Wrapper.unwrap(resourceRef)); ! setParams(var, params); ! return Wrapper.wrap(var, varName, m_tm); ! } catch (TopicMapProcessingException ex) { ! throw Wrapper.wrap(ex); ! } catch (java.beans.PropertyVetoException ex) { ! throw Wrapper.wrap(ex); ! } ! } ! ! private void setParams(org.tm4j.topicmap.Variant var, Collection params) ! throws java.beans.PropertyVetoException { ! checkUpdateAllowed(); ! if ((params != null) && (params.size() > 0)) { ! org.tm4j.topicmap.Topic[] _params = new org.tm4j.topicmap.Topic[params.size()]; ! int ix = 0; ! Iterator it = params.iterator(); ! ! while (it.hasNext()) { ! _params[ix++] = Wrapper.unwrap((org.tmapi.core.Topic) it.next()); ! } ! ! var.setParameters(_params); ! } ! } ! ! protected Set buildVariants() { ! Set variants = new HashSet(); ! TopicMapFactory factory = m_obj.getTopicMap().getFactory(); ! ! Iterator it = m_obj.getVariants().iterator(); ! ! while (it.hasNext()) { ! addVariants(variants, (org.tm4j.topicmap.Variant) it.next()); ! } ! ! return variants; ! } ! ! protected void addVariants(Collection variants, ! org.tm4j.topicmap.Variant var) { ! org.tmapi.core.Variant wrapped = Wrapper.wrap(var, var.getVariantName(), m_tm); ! variants.add(wrapped); ! ! Iterator it = var.getVariants().iterator(); ! ! while (it.hasNext()) { ! addVariants(variants, (org.tm4j.topicmap.Variant) it.next()); ! } ! } ! ! public Topic getType() { ! return null; ! } ! ! public void setType(Topic nameType) { ! checkUpdateAllowed(); ! throw new UnsupportedOperationException("TM4J does not support XTM 1.1 constructs (yet!)."); ! } ! ! public void remove() { ! checkUpdateAllowed(); ! try { ! org.tm4j.topicmap.Topic t = m_obj.getParent(); ! ArrayList names = new ArrayList(t.getNames()); ! names.remove(m_obj); ! ! if (names.isEmpty()) { ! t.setNames(null); ! } else { ! t.setNames((org.tm4j.topicmap.BaseName[]) names.toArray( ! new org.tm4j.topicmap.BaseName[1])); ! } ! ! m_obj.destroy(); ! } catch (java.beans.PropertyVetoException ex) { ! throw Wrapper.wrap(ex); ! } catch (IntegrityViolationException ex) { ! throw Wrapper.wrap(ex); ! } ! } ! } --- 1,167 ---- ! /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! package org.tm4j.tmapi.core; ! ! import org.tm4j.tmapi.helpers.Wrapper; ! ! import org.tm4j.topicmap.TopicMapProcessingException; ! ! import org.tmapi.core.Locator; ! import org.tmapi.core.Topic; ! ! import java.util.Collection; ! import java.util.Collections; ! import java.util.HashSet; ! import java.util.Iterator; ! import java.util.Set; ! ! ! public class TMAPIBaseNameImpl extends TMAPIScopedObjectImpl ! implements org.tmapi.core.TopicName { ! private org.tm4j.topicmap.BaseName m_obj; ! ! public TMAPIBaseNameImpl(org.tm4j.topicmap.BaseName obj, TMAPITopicMapImpl tm) { ! super(obj, tm); ! m_obj = obj; ! } ! ! public org.tm4j.topicmap.BaseName getWrapped() { ! return m_obj; ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.TopicName#getTopic() ! */ ! public org.tmapi.core.Topic getTopic() { ! return Wrapper.wrap(m_obj.getParent(), m_tm); ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.TopicName#getValue() ! */ ! public String getValue() { ! return m_obj.getData(); ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.TopicName#setValue(java.lang.String) ! */ ! public void setValue(String data) { ! checkUpdateAllowed(); ! try { ! m_obj.setData(data); ! } catch (Exception ex) { ! throw new RuntimeException(ex.toString()); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.TopicName#getVariants() ! */ ! public Set getVariants() { ! Set variants = new HashSet(); ! for (Iterator iter = m_obj.getVariants().iterator(); iter.hasNext();) { ! addVariants(variants, (org.tm4j.topicmap.Variant) iter.next()); ! } ! return Collections.unmodifiableSet(variants); ! } ! ! /** ! * Used to collect the variants of the underlying native base name. ! * ! * The native TM4J base name supports hierarchical variants, the TMAPI ! * variants are "flat" ! * ! * @param variants ! * @param var ! */ ! private void addVariants(Collection variants, org.tm4j.topicmap.Variant var) { ! org.tmapi.core.Variant wrapped = Wrapper.wrap(var, var.getVariantName(), m_tm); ! variants.add(wrapped); ! ! for (Iterator iter = var.getVariants().iterator(); iter.hasNext();) { ! addVariants(variants, (org.tm4j.topicmap.Variant) iter.next()); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.TopicName#createVariant(java.lang.String, java.util.Collection) ! */ ! public org.tmapi.core.Variant createVariant(String nameString, ! Collection params) { ! checkUpdateAllowed(); ! try { ! org.tm4j.topicmap.Variant var = m_obj.createVariant(null); ! org.tm4j.topicmap.VariantName varName = var.createVariantName(null); ! varName.setData(nameString); ! setParams(var, params); ! return Wrapper.wrap(var, varName, m_tm); ! } catch (TopicMapProcessingException ex) { ! throw Wrapper.wrap(ex); ! } catch (java.beans.PropertyVetoException ex) { ! throw Wrapper.wrap(ex); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.TopicName#createVariant(org.tmapi.core.Locator, java.util.Collection) ! */ ! public org.tmapi.core.Variant createVariant(Locator resourceRef, ! Collection params) { ! checkUpdateAllowed(); ! try { ! org.tm4j.topicmap.Variant var = m_obj.createVariant(null); ! org.tm4j.topicmap.VariantName varName = var.createVariantName(null); ! varName.setDataLocator(Wrapper.unwrap(resourceRef)); ! setParams(var, params); ! return Wrapper.wrap(var, varName, m_tm); ! } catch (TopicMapProcessingException ex) { ! throw Wrapper.wrap(ex); ! } catch (java.beans.PropertyVetoException ex) { ! throw Wrapper.wrap(ex); ! } ! } ! ! /** ! * Sets the scope of a variant. ! * ! * @param var ! * @param params ! * @throws java.beans.PropertyVetoException ! */ ! private void setParams(org.tm4j.topicmap.Variant var, Collection params) ! throws java.beans.PropertyVetoException { ! if ((params != null) && (params.size() > 0)) { ! org.tm4j.topicmap.Topic[] _params = new org.tm4j.topicmap.Topic[params.size()]; ! int ix = 0; ! Iterator it = params.iterator(); ! ! while (it.hasNext()) { ! _params[ix++] = Wrapper.unwrap((org.tmapi.core.Topic) it.next()); ! } ! ! var.setParameters(_params); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.TopicName#getType() ! */ ! public Topic getType() { ! return null; ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.TopicName#setType(org.tmapi.core.Topic) ! */ ! public void setType(Topic nameType) { ! checkUpdateAllowed(); ! throw new UnsupportedOperationException("TM4J does not support XTM 1.1 constructs (yet!)."); ! } ! ! } Index: TMAPITopicImpl.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/tmapi/core/TMAPITopicImpl.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** TMAPITopicImpl.java 8 Dec 2004 12:11:39 -0000 1.22 --- TMAPITopicImpl.java 7 Mar 2006 15:14:19 -0000 1.23 *************** *** 1,331 **** ! /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! package org.tm4j.tmapi.core; ! ! import java.beans.PropertyVetoException; ! import java.util.ArrayList; ! import java.util.Collection; ! import java.util.Collections; ! import java.util.HashSet; ! import java.util.Iterator; ! import java.util.Set; ! ! import org.tm4j.net.Locator; ! import org.tm4j.tmapi.helpers.Wrapper; ! import org.tm4j.topicmap.IntegrityViolationException; ! import org.tm4j.topicmap.Member; ! import org.tm4j.topicmap.MergedTopicSubjectClashException; ! import org.tmapi.core.ModelConstraintException; ! import org.tmapi.core.SubjectLocatorClashException; ! import org.tmapi.core.TMAPIRuntimeException; ! import org.tmapi.core.Topic; ! import org.tmapi.core.TopicName; ! ! ! public class TMAPITopicImpl extends TMAPITopicMapObjectImpl ! implements org.tmapi.core.Topic { ! private org.tm4j.topicmap.Topic m_obj; ! ! public TMAPITopicImpl(org.tm4j.topicmap.Topic obj, TMAPITopicMapImpl tm) { ! super(obj, tm); ! m_obj = obj; ! } ! ! public org.tm4j.topicmap.Topic getWrapped() { ! return m_obj; ! } ! ! public Set getTopicNames() { ! return Wrapper.wrap(m_obj.getNames(), m_tm); ! } ! ! public TopicName createTopicName( ! String baseNameString, ! Topic type, ! Collection scope) ! { ! throw new UnsupportedOperationException("TM4J does not support typed topic names."); ! } ! ! public TopicName createTopicName(String baseNameString, ! Collection scope) { ! checkUpdateAllowed(); ! try { ! org.tm4j.topicmap.BaseName bn; ! bn = m_obj.createName(null); ! bn.setData(baseNameString); ! ! if ((scope != null) && !scope.isEmpty()) { ! org.tm4j.topicmap.Topic[] themes = new org.tm4j.topicmap.Topic[scope.size()]; ! int ix = 0; ! Iterator it = scope.iterator(); ! ! while (it.hasNext()) { ! themes[ix++] = Wrapper.unwrap((org.tmapi.core.Topic) it.next()); ! } ! ! bn.setScope(themes); ! } ! ! //m_obj.addName(bn); ! return Wrapper.wrap(bn, m_tm); ! } catch (Exception ex) { ! throw new RuntimeException(ex.toString()); ! } ! } ! ! /* ! public void removeBaseName(org.tmapi.core.BaseName _bn) ! { ! org.tm4j.topicmap.BaseName bn = Wrapper.unwrap(_bn); ! ArrayList names = new ArrayList(m_obj.getNames()); ! names.remove(bn); ! org.tm4j.topicmap.BaseName [] _names = new org.tm4j.topicmap.BaseName[names.size()]; ! try ! { ! m_obj.setNames((org.tm4j.topicmap.BaseName[])names.toArray(_names)); ! } ! catch(Exception ex) ! { ! throw new RuntimeException(ex.toString()); ! } ! } ! */ ! public Set getOccurrences() { ! return Wrapper.wrap(m_obj.getOccurrences(), m_tm); ! } ! ! public org.tmapi.core.Occurrence createOccurrence( ! org.tmapi.core.Locator resourceRef, ! org.tmapi.core.Topic type, ! Collection scope) { ! ! checkUpdateAllowed(); ! try { ! org.tm4j.topicmap.Occurrence occ = m_obj.createOccurrence(null); ! ! if (type != null) { ! occ.setType(Wrapper.unwrap(type)); ! } ! ! if (resourceRef != null) { ! occ.setDataLocator(Wrapper.unwrap(resourceRef)); ! } ! ! if ((scope != null) && !scope.isEmpty()) { ! //org.tm4j.topicmap.Scope sc = m_obj.getTopicMap().createScope(null); ! Wrapper.setScopeThemes(occ, scope); ! } ! ! //m_obj.addOccurrence(occ); ! return Wrapper.wrap(occ, m_tm); ! } catch (Exception ex) { ! throw new RuntimeException(ex.toString()); ! } ! } ! ! public org.tmapi.core.Occurrence createOccurrence( ! String resourceData, ! org.tmapi.core.Topic type, ! Collection scope) { ! checkUpdateAllowed(); ! try { ! org.tm4j.topicmap.Occurrence occ = m_obj.createOccurrence(null); ! ! if (type != null) { ! occ.setType(Wrapper.unwrap(type)); ! } ! ! if (resourceData != null) { ! occ.setData(resourceData); ! } ! ! if ((scope != null) && !scope.isEmpty()) { ! Wrapper.setScopeThemes(occ, scope); ! } ! ! //m_obj.addOccurrence(occ); ! return Wrapper.wrap(occ, m_tm); ! } catch (Exception ex) { ! throw new RuntimeException(ex.toString()); ! } ! } ! ! /* ! public void removeOccurrence(org.tmapi.core.Occurrence _obj) ! { ! org.tm4j.topicmap.Occurrence obj = Wrapper.unwrap(_obj); ! ArrayList objlist = new ArrayList(m_obj.getOccurrences()); ! objlist.remove(obj); ! org.tm4j.topicmap.Occurrence [] objarry = new org.tm4j.topicmap.Occurrence[objlist.size()]; ! try ! { ! m_obj.setOccurrences((org.tm4j.topicmap.Occurrence[])objlist.toArray(objarry)); ! } ! catch(Exception ex) ! { ! throw new RuntimeException(ex.toString()); ! } ! } ! */ ! public Set getSubjectLocators() { ! Locator rawLoc = m_obj.getSubject(); ! if (rawLoc == null) { ! return new HashSet(0); ! } else { ! Set ret = new HashSet(1); ! ret.add(Wrapper.wrap(m_obj.getSubject())); ! return Collections.unmodifiableSet(ret); ! } ! } ! ! public void addSubjectLocator(org.tmapi.core.Locator loc) { ! checkUpdateAllowed(); ! Locator currLoc = m_obj.getSubject(); ! Locator rawLoc = Wrapper.unwrap(loc); ! ! if (currLoc != null) { ! if (currLoc.equals(rawLoc)) { ! return; ! } else { ! throw new ModelConstraintException(this, "Topics can only have one subject locator under XTM 1.0"); ! } ! } ! try { ! m_obj.setSubject(Wrapper.unwrap(loc)); ! } catch (PropertyVetoException e) { ! throw new TMAPIRuntimeException("Addition of subject locator " + loc.getReference() + " was vetoed.", e); ! } ! } ! ! public Set getSubjectIdentifiers() { ! return Wrapper.wrap(m_obj.getSubjectIndicators(), m_tm); ! } ! ! public void addSubjectIdentifier(org.tmapi.core.Locator loc) { ! checkUpdateAllowed(); ! try { ! m_obj.addSubjectIndicator(Wrapper.unwrap(loc)); ! } catch (Exception ex) { ! throw new RuntimeException(ex.toString()); ! } ! } ! ! public void removeSubjectIdentifier(org.tmapi.core.Locator _obj) { ! checkUpdateAllowed(); ! org.tm4j.net.Locator obj = Wrapper.unwrap(_obj); ! ArrayList objlist = new ArrayList(m_obj.getSubjectIndicators()); ! objlist.remove(obj); ! ! org.tm4j.net.Locator[] objarry = new org.tm4j.net.Locator[objlist.size()]; ! ! try { ! m_obj.setSubjectIndicators((org.tm4j.net.Locator[]) objlist.toArray( ! objarry)); ! } catch (Exception ex) { ! throw new RuntimeException(ex.toString()); ! } ! } ! ! public org.tmapi.core.TopicMap getTopicMap() { ! return m_tm; ! } ! ! public Set getTypes() { ! return Wrapper.wrap(m_obj.getTypes(), m_tm); ! } ! ! public void addType(org.tmapi.core.Topic type) { ! checkUpdateAllowed(); ! try { ! m_obj.addType(Wrapper.unwrap(type)); ! } catch (java.beans.PropertyVetoException ex) { ! throw Wrapper.wrap(ex); ! } ! } ! ! public void removeType(org.tmapi.core.Topic _obj) { ! checkUpdateAllowed(); ! org.tm4j.topicmap.Topic obj = Wrapper.unwrap(_obj); ! ArrayList objlist = new ArrayList(m_obj.getTypes()); ! objlist.remove(obj); ! ! org.tm4j.topicmap.Topic[] objarry = new org.tm4j.topicmap.Topic[objlist.size()]; ! ! try { ! m_obj.setTypes((org.tm4j.topicmap.Topic[]) objlist.toArray(objarry)); ! } catch (java.beans.PropertyVetoException ex) { ! throw Wrapper.wrap(ex); ! } ! } ! ! public Set getRolesPlayed() { ! Set ret = new HashSet(); ! Iterator it = m_obj.getRolesPlayed().iterator(); ! while(it.hasNext()) { ! Member m = (Member)it.next(); ! ret.add(Wrapper.wrap(m, m_obj, m_tm)); ! } ! return ret; ! } ! ! public void remove() { ! checkUpdateAllowed(); ! try { ! m_obj.destroy(); ! } catch (IntegrityViolationException ex) { ! throw Wrapper.wrap(ex); ! } catch (PropertyVetoException ex) { ! throw Wrapper.wrap(ex); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Topic#mergeIn(org.tmapi.core.Topic) ! */ ! public void mergeIn(Topic t) ! { ! checkUpdateAllowed(); ! org.tm4j.topicmap.Topic toMerge = Wrapper.unwrap(t); ! try { ! m_obj.addMergedTopic(toMerge); ! } catch (MergedTopicSubjectClashException e) { ! throw new SubjectLocatorClashException(this, t, "Cannot merge topics with different non-null subject locators."); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Topic#getReified() ! */ ! public Set getReified() { ! HashSet ret = new HashSet(); ! Iterator it = m_obj.getSubjectIndicators().iterator(); ! while (it.hasNext()) { ! ret.add(m_obj.getTopicMap().getObjectBySourceLocator((org.tm4j.net.Locator)it.next())); ! } ! return Wrapper.wrap(ret, m_tm); ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Topic#removeSubjectLocator(org.tmapi.core.Locator) ! */ ! public void removeSubjectLocator(org.tmapi.core.Locator loc) { ! checkUpdateAllowed(); ! if (m_obj.getSubject() == null) return; ! Locator rawLoc = Wrapper.unwrap(loc); ! if (rawLoc.equals(m_obj.getSubject())) { ! try { ! m_obj.setSubject(null); ! } catch (PropertyVetoException e) { ! throw new TMAPIRuntimeException("Removal of subject locator was vetoed.", e); ! } ! } ! return; ! } ! ! } --- 1,351 ---- ! /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! package org.tm4j.tmapi.core; ! ! import java.beans.PropertyVetoException; ! import java.util.ArrayList; ! import java.util.Collection; ! import java.util.Collections; ! import java.util.HashSet; ! import java.util.Iterator; ! import java.util.Set; ! ! import org.tm4j.net.Locator; ! import org.tm4j.tmapi.helpers.Wrapper; ! import org.tm4j.topicmap.DuplicateObjectIDException; ! import org.tm4j.topicmap.Member; ! import org.tm4j.topicmap.MergedTopicSubjectClashException; ! import org.tmapi.core.ModelConstraintException; ! import org.tmapi.core.SubjectLocatorClashException; ! import org.tmapi.core.TMAPIRuntimeException; ! import org.tmapi.core.Topic; ! import org.tmapi.core.TopicName; ! ! ! public class TMAPITopicImpl extends TMAPITopicMapObjectImpl ! implements org.tmapi.core.Topic { ! private org.tm4j.topicmap.Topic m_obj; ! ! public TMAPITopicImpl(org.tm4j.topicmap.Topic obj, TMAPITopicMapImpl tm) { ! super(obj, tm); ! m_obj = obj; ! } ! ! public org.tm4j.topicmap.Topic getWrapped() { ! return m_obj; ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Topic#getTopicNames() ! */ ! public Set getTopicNames() { ! return Wrapper.wrap(m_obj.getNames(), m_tm); ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Topic#createTopicName(java.lang.String, org.tmapi.core.Topic, java.util.Collection) ! */ ! public TopicName createTopicName(String baseNameString, ! Topic type, ! Collection scope) { ! if (type != null) { ! throw new UnsupportedOperationException("TM4J does not support typed topic names."); ! } ! else { ! return createTopicName(baseNameString, scope); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Topic#createTopicName(java.lang.String, java.util.Collection) ! */ ! public TopicName createTopicName(String baseNameString, Collection scope) { ! checkUpdateAllowed(); ! try { ! org.tm4j.topicmap.BaseName bn = m_obj.createName(null); ! bn.setData(baseNameString); ! if ((scope != null) && !scope.isEmpty()) { ! Wrapper.setScopeThemes(bn, scope); ! } ! return Wrapper.wrap(bn, m_tm); ! } catch (Exception ex) { ! throw new RuntimeException(ex.toString()); ! } ! } ! ! /* ! public void removeBaseName(org.tmapi.core.BaseName _bn) ! { ! org.tm4j.topicmap.BaseName bn = Wrapper.unwrap(_bn); ! ArrayList names = new ArrayList(m_obj.getNames()); ! names.remove(bn); ! org.tm4j.topicmap.BaseName [] _names = new org.tm4j.topicmap.BaseName[names.size()]; ! try ! { ! m_obj.setNames((org.tm4j.topicmap.BaseName[])names.toArray(_names)); ! } ! catch(Exception ex) ! { ! throw new RuntimeException(ex.toString()); ! } ! } ! */ ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Topic#getOccurrences() ! */ ! public Set getOccurrences() { ! return Wrapper.wrap(m_obj.getOccurrences(), m_tm); ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Topic#createOccurrence(org.tmapi.core.Locator, org.tmapi.core.Topic, java.util.Collection) ! */ ! public org.tmapi.core.Occurrence createOccurrence( ! org.tmapi.core.Locator resourceRef, ! org.tmapi.core.Topic type, ! Collection scope) { ! ! try { ! org.tm4j.topicmap.Occurrence occ = createOccurrence(type, scope); ! if (resourceRef != null) { ! occ.setDataLocator(Wrapper.unwrap(resourceRef)); ! } ! return Wrapper.wrap(occ, m_tm); ! } catch (Exception ex) { ! throw new RuntimeException(ex.toString()); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Topic#createOccurrence(java.lang.String, org.tmapi.core.Topic, java.util.Collection) ! */ ! public org.tmapi.core.Occurrence createOccurrence(String resourceData, ! org.tmapi.core.Topic type, ! Collection scope) { ! try { ! org.tm4j.topicmap.Occurrence occ = createOccurrence(type, scope); ! if (resourceData != null) { ! occ.setData(resourceData); ! } ! return Wrapper.wrap(occ, m_tm); ! } catch (Exception ex) { ! throw new RuntimeException(ex.toString()); ! } ! } ! ! /** ! * @param type ! * @param scope ! * @return ! * @throws DuplicateObjectIDException ! * @throws PropertyVetoException ! */ ! private org.tm4j.topicmap.Occurrence createOccurrence(org.tmapi.core.Topic type, ! Collection scope) throws DuplicateObjectIDException, PropertyVetoException { ! checkUpdateAllowed(); ! org.tm4j.topicmap.Occurrence occ = m_obj.createOccurrence(null); ! ! if (type != null) { ! occ.setType(Wrapper.unwrap(type)); ! } ! if ((scope != null) && !scope.isEmpty()) { ! Wrapper.setScopeThemes(occ, scope); ! } ! return occ; ! } ! ! /* ! public void removeOccurrence(org.tmapi.core.Occurrence _obj) ! { ! org.tm4j.topicmap.Occurrence obj = Wrapper.unwrap(_obj); ! ArrayList objlist = new ArrayList(m_obj.getOccurrences()); ! objlist.remove(obj); ! org.tm4j.topicmap.Occurrence [] objarry = new org.tm4j.topicmap.Occurrence[objlist.size()]; ! try ! { ! m_obj.setOccurrences((org.tm4j.topicmap.Occurrence[])objlist.toArray(objarry)); ! } ! catch(Exception ex) ! { ! throw new RuntimeException(ex.toString()); ! } ! } ! */ ! ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Topic#getSubjectLocators() ! */ ! public Set getSubjectLocators() { ! Locator rawLoc = m_obj.getSubject(); ! return rawLoc == null ? Collections.EMPTY_SET ! : Collections.singleton(Wrapper.wrap(rawLoc, m_tm)); ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Topic#addSubjectLocator(org.tmapi.core.Locator) ! */ ! public void addSubjectLocator(org.tmapi.core.Locator loc) { ! checkUpdateAllowed(); ! Locator currLoc = m_obj.getSubject(); ! Locator rawLoc = Wrapper.unwrap(loc); ! ! if (currLoc != null) { ! if (currLoc.equals(rawLoc)) { ! return; ! } else { ! throw new ModelConstraintException(this, "Topics can only have one subject locator under XTM 1.0"); ! } ! } ! try { ! m_obj.setSubject(Wrapper.unwrap(loc)); ! } catch (PropertyVetoException e) { ! throw new TMAPIRuntimeException("Addition of subject locator " + loc.getReference() + " was vetoed.", e); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Topic#getSubjectIdentifiers() ! */ ! public Set getSubjectIdentifiers() { ! return Wrapper.wrap(m_obj.getSubjectIndicators(), m_tm); ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Topic#addSubjectIdentifier(org.tmapi.core.Locator) ! */ ! public void addSubjectIdentifier(org.tmapi.core.Locator loc) { ! checkUpdateAllowed(); ! try { ! m_obj.addSubjectIndicator(Wrapper.unwrap(loc)); ! } catch (Exception ex) { ! throw new RuntimeException(ex.toString()); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Topic#removeSubjectIdentifier(org.tmapi.core.Locator) ! */ ! public void removeSubjectIdentifier(org.tmapi.core.Locator _obj) { ! checkUpdateAllowed(); ! org.tm4j.net.Locator obj = Wrapper.unwrap(_obj); ! ArrayList objlist = new ArrayList(m_obj.getSubjectIndicators()); ! if (!objlist.remove(obj)) { ! return; // Avoid the expensive setSubjectIndicators operation ! } ! ! try { ! m_obj.setSubjectIndicators((org.tm4j.net.Locator[]) objlist.toArray(new org.tm4j.net.Locator[objlist.size()])); ! } catch (Exception ex) { ! throw new RuntimeException(ex.toString()); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Topic#getTypes() ! */ ! public Set getTypes() { ! return Wrapper.wrap(m_obj.getTypes(), m_tm); ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Topic#addType(org.tmapi.core.Topic) ! */ ! public void addType(org.tmapi.core.Topic type) { ! checkUpdateAllowed(); ! try { ! m_obj.addType(Wrapper.unwrap(type)); ! } catch (java.beans.PropertyVetoException ex) { ! throw Wrapper.wrap(ex); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Topic#removeType(org.tmapi.core.Topic) ! */ ! public void removeType(org.tmapi.core.Topic _obj) { ! checkUpdateAllowed(); ! org.tm4j.topicmap.Topic obj = Wrapper.unwrap(_obj); ! ArrayList objlist = new ArrayList(m_obj.getTypes()); ! if (!objlist.remove(obj)) { ! return; // Avoid the expensive setTypes operation ! } ! ! try { ! m_obj.setTypes((org.tm4j.topicmap.Topic[]) objlist.toArray(new org.tm4j.topicmap.Topic[objlist.size()])); ! } catch (java.beans.PropertyVetoException ex) { ! throw Wrapper.wrap(ex); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Topic#getRolesPlayed() ! */ ! public Set getRolesPlayed() { ! Set ret = new HashSet(); ! Iterator it = m_obj.getRolesPlayed().iterator(); ! while(it.hasNext()) { ! Member m = (Member)it.next(); ! ret.add(Wrapper.wrap(m, m_obj, m_tm)); ! } ! return ret; ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Topic#mergeIn(org.tmapi.core.Topic) ! */ ! public void mergeIn(Topic t) { ! checkUpdateAllowed(); ! org.tm4j.topicmap.Topic toMerge = Wrapper.unwrap(t); ! try { ! m_obj.addMergedTopic(toMerge); ! } catch (MergedTopicSubjectClashException e) { ! throw new SubjectLocatorClashException(this, t, "Cannot merge topics with different non-null subject locators."); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Topic#getReified() ! */ ! public Set getReified() { ! HashSet ret = new HashSet(); ! Iterator it = m_obj.getSubjectIndicators().iterator(); ! while (it.hasNext()) { ! ret.add(m_obj.getTopicMap().getObjectBySourceLocator((org.tm4j.net.Locator)it.next())); ! } ! return Wrapper.wrap(ret, m_tm); ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Topic#removeSubjectLocator(org.tmapi.core.Locator) ! */ ! public void removeSubjectLocator(org.tmapi.core.Locator loc) { ! checkUpdateAllowed(); ! if (m_obj.getSubject() == null) return; ! Locator rawLoc = Wrapper.unwrap(loc); ! if (rawLoc.equals(m_obj.getSubject())) { ! return; ! } ! try { ! m_obj.setSubject(null); ! } catch (PropertyVetoException e) { ! throw new TMAPIRuntimeException("Removal of subject locator was vetoed.", e); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tm4j.tmapi.core.TMAPITopicMapObjectImpl#getReifier() ! */ ! public Topic getReifier() { ! // Under normal circumstances the user cannot call this method. ! throw new UnsupportedOperationException("A topic cannot reify a topic"); ! } ! ! ! } Index: TMAPIOccurrenceImpl.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/tmapi/core/TMAPIOccurrenceImpl.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** TMAPIOccurrenceImpl.java 8 Dec 2004 12:11:38 -0000 1.12 --- TMAPIOccurrenceImpl.java 7 Mar 2006 15:14:19 -0000 1.13 *************** *** 1,96 **** ! /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! package org.tm4j.tmapi.core; ! ! import org.tm4j.tmapi.helpers.Wrapper; ! ! import org.tm4j.topicmap.IntegrityViolationException; ! ! import java.beans.PropertyVetoException; ! ! import java.util.ArrayList; ! ! ! public class TMAPIOccurrenceImpl extends TMAPIScopedObjectImpl ! implements org.tmapi.core.Occurrence { ! org.tm4j.topicmap.Occurrence m_obj; ! ! public TMAPIOccurrenceImpl(org.tm4j.topicmap.Occurrence occ, TMAPITopicMapImpl tm) { ! super(occ, tm); ! m_obj = occ; ! } ! ! public org.tm4j.topicmap.Occurrence getWrapped() { ! return m_obj; ! } ! ! public org.tmapi.core.Topic getTopic() { ! return Wrapper.wrap(m_obj.getParent(), m_tm); ! } ! ! public org.tmapi.core.Topic getType() { ! return Wrapper.wrap(m_obj.getType(), m_tm); ! } ! ! public void setType(org.tmapi.core.Topic type) { ! checkUpdateAllowed(); ! try { ! m_obj.setType(Wrapper.unwrap(type)); ! } catch (PropertyVetoException ex) { ! throw new RuntimeException(ex.toString()); ! } ! } ! ! public String getValue() { ! return m_obj.getData(); ! } ! ! public void setValue(String data) { ! checkUpdateAllowed(); ! try { ! m_obj.setData(data); ! } catch (PropertyVetoException ex) { ! throw new RuntimeException(ex.toString()); ! } ! } ! ! public org.tmapi.core.Locator getResource() { ! return Wrapper.wrap(m_obj.getDataLocator()); ! } ! ! public void setResource(org.tmapi.core.Locator loc) { ! checkUpdateAllowed(); ! try { ! m_obj.setDataLocator(Wrapper.unwrap(loc)); ! } catch (PropertyVetoException ex) { ! throw new RuntimeException(ex.toString()); ! } ! } ! ! public void remove() { ! checkUpdateAllowed(); ! try { ! org.tm4j.topicmap.Topic t = m_obj.getParent(); ! ArrayList occs = new ArrayList(t.getOccurrences()); ! occs.remove(m_obj); ! ! if (occs.isEmpty()) { ! t.setOccurrences(null); ! } else { ! t.setOccurrences((org.tm4j.topicmap.Occurrence[]) occs.toArray( ! new org.tm4j.topicmap.Occurrence[1])); ! } ! ! m_obj.destroy(); ! } catch (PropertyVetoException ex) { ! throw Wrapper.wrap(ex); ! } catch (IntegrityViolationException ex) { ! throw Wrapper.wrap(ex); ! } ! } ! } --- 1,92 ---- ! /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! package org.tm4j.tmapi.core; ! ! import org.tm4j.tmapi.helpers.Wrapper; ! ! import java.beans.PropertyVetoException; ! ! ! public class TMAPIOccurrenceImpl extends TMAPIScopedObjectImpl ! implements org.tmapi.core.Occurrence { ! org.tm4j.topicmap.Occurrence m_obj; ! ! public TMAPIOccurrenceImpl(org.tm4j.topicmap.Occurrence occ, TMAPITopicMapImpl tm) { ! super(occ, tm); ! m_obj = occ; ! } ! ! public org.tm4j.topicmap.Occurrence getWrapped() { ! return m_obj; ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Occurrence#getTopic() ! */ ! public org.tmapi.core.Topic getTopic() { ! return Wrapper.wrap(m_obj.getParent(), m_tm); ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Occurrence#getType() ! */ ! public org.tmapi.core.Topic getType() { ! return Wrapper.wrap(m_obj.getType(), m_tm); ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Occurrence#setType(org.tmapi.core.Topic) ! */ ! public void setType(org.tmapi.core.Topic type) { ! checkUpdateAllowed(); ! try { ! m_obj.setType(Wrapper.unwrap(type)); ! } catch (PropertyVetoException ex) { ! throw new RuntimeException(ex.toString()); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Occurrence#getValue() ! */ ! public String getValue() { ! return m_obj.getData(); ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Occurrence#setValue(java.lang.String) ! */ ! public void setValue(String data) { ! checkUpdateAllowed(); ! try { ! m_obj.setData(data); ! } catch (PropertyVetoException ex) { ! throw new RuntimeException(ex.toString()); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Occurrence#getResource() ! */ ! public org.tmapi.core.Locator getResource() { ! return Wrapper.wrap(m_obj.getDataLocator()); ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.Occurrence#setResource(org.tmapi.core.Locator) ! */ ! public void setResource(org.tmapi.core.Locator loc) { ! checkUpdateAllowed(); ! try { ! m_obj.setDataLocator(Wrapper.unwrap(loc)); ! } catch (PropertyVetoException ex) { ! throw new RuntimeException(ex.toString()); ! } ! } ! ! } Index: TMAPITopicMapObjectImpl.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/tmapi/core/TMAPITopicMapObjectImpl.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** TMAPITopicMapObjectImpl.java 8 Dec 2004 12:11:39 -0000 1.17 --- TMAPITopicMapObjectImpl.java 7 Mar 2006 15:14:19 -0000 1.18 *************** *** 1,109 **** ! /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! package org.tm4j.tmapi.core; ! ! import java.util.HashSet; ! import java.util.Iterator; ! import java.util.Set; ! ! import org.tm4j.tmapi.helpers.Wrapper; ! import org.tm4j.topicmap.DuplicateResourceLocatorException; ! import org.tmapi.core.FeatureNotRecognizedException; ! ! ! public abstract class TMAPITopicMapObjectImpl ! implements org.tmapi.core.TopicMapObject { ! org.tm4j.topicmap.TopicMapObject m_obj; ! TMAPITopicMapImpl m_tm; ! ! public TMAPITopicMapObjectImpl(org.tm4j.topicmap.TopicMapObject obj, TMAPITopicMapImpl tm) ! { ! m_obj = obj; ! m_tm = tm; ! } ! ! public org.tmapi.core.TopicMap getTopicMap() { ! return m_tm; ! } ! ! public void addSourceLocator(org.tmapi.core.Locator loc) { ! checkUpdateAllowed(); ! try { ! m_obj.addSourceLocator(Wrapper.unwrap(loc)); ! } catch (DuplicateResourceLocatorException ex) { ! throw Wrapper.wrap(ex); ! } ! } ! ! public Set getSourceLocators() { ! Set ret = new HashSet(); ! ret.addAll(Wrapper.wrap(m_obj.getSourceLocators(), m_tm)); ! ! return ret; ! } ! ! public void removeSourceLocator(org.tmapi.core.Locator loc) { ! checkUpdateAllowed(); ! m_obj.removeSourceLocator(Wrapper.unwrap(loc)); ! } ! ! ! /* (non-Javadoc) ! * @see org.tmapi.core.TopicMapObject#getObjectId() ! */ ! public String getObjectId() { ! return m_obj.getID(); ! } ! ! public boolean equals(Object other) { ! // TODO: Validate this algorithm against TMAPI expectations ! if (other == null) { ! return false; ! } ! ! if (other.getClass().equals(getClass())) { ! return ((TMAPITopicMapObjectImpl) other).getObjectId().equals(m_obj.getID()); ! } else if (other instanceof TMAPITopicMapObjectStub) { ! return ((TMAPITopicMapObjectStub) other).equals(this); ! } ! ! return false; ! } ! ! public int hashCode() { ! // TODO: Validate this algorithm against TMAPI expectations ! if (getObjectId() == null) { ! // This should only happen for removed objects ! return super.hashCode(); ! } ! return getObjectId().hashCode(); ! } ! ! public org.tmapi.core.Topic getReifier() { ! Iterator it = m_obj.getSourceLocators().iterator(); ! while (it.hasNext()) { ! org.tm4j.topicmap.Topic rawReifier = m_obj.getTopicMap().getTopicBySubjectIndicator((org.tm4j.net.Locator)it.next()); ! if (rawReifier != null) { ! return Wrapper.wrap(rawReifier, m_tm); ! } ! } ! return null; ! } ! ! public void checkUpdateAllowed() { ! try { ! if (getTopicMap().getTopicMapSystem().getFeature("http://tmapi.org/features/readOnly/")) { ! throw new UnsupportedOperationException("Update operations are not allowed on a read-only topic map."); ! } ! } catch (FeatureNotRecognizedException e) { ! return; ! } ! } ! ! ! } --- 1,134 ---- ! /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! package org.tm4j.tmapi.core; ! ! import java.util.Iterator; ! import java.util.Set; ! ! import org.tm4j.tmapi.helpers.Wrapper; ! import org.tm4j.topicmap.DuplicateResourceLocatorException; ! import org.tm4j.topicmap.IntegrityViolationException; ! import org.tmapi.core.FeatureNotRecognizedException; ! ! ! public abstract class TMAPITopicMapObjectImpl ! implements org.tmapi.core.TopicMapObject { ! org.tm4j.topicmap.TopicMapObject m_obj; ! TMAPITopicMapImpl m_tm; ! ! public TMAPITopicMapObjectImpl(org.tm4j.topicmap.TopicMapObject obj, TMAPITopicMapImpl tm) ! { ! m_obj = obj; ! m_tm = tm; ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.TopicMapObject#getTopicMap() ! */ ! public org.tmapi.core.TopicMap getTopicMap() { ! return m_tm; ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.TopicMapObject#addSourceLocator(org.tmapi.core.Locator) ! */ ! public void addSourceLocator(org.tmapi.core.Locator loc) { ! checkUpdateAllowed(); ! try { ! m_obj.addSourceLocator(Wrapper.unwrap(loc)); ! } catch (DuplicateResourceLocatorException ex) { ! throw Wrapper.wrap(ex); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.TopicMapObject#getSourceLocators() ! */ ! public Set getSourceLocators() { ! return Wrapper.wrap(m_obj.getSourceLocators(), m_tm); ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.TopicMapObject#removeSourceLocator(org.tmapi.core.Locator) ! */ ! public void removeSourceLocator(org.tmapi.core.Locator loc) { ! checkUpdateAllowed(); ! m_obj.removeSourceLocator(Wrapper.unwrap(loc)); ! } ! ! ! /* (non-Javadoc) ! * @see org.tmapi.core.TopicMapObject#getObjectId() ! */ ! public String getObjectId() { ! return m_obj.getID(); ! } ! ! /* (non-Javadoc) ! * @see java.lang.Object#equals(java.lang.Object) ! */ ! public boolean equals(Object other) { ! // TODO: Validate this algorithm against TMAPI expectations ! if (other == null) { ! return false; ! } ! ! if (other.getClass().equals(getClass())) { ! return ((TMAPITopicMapObjectImpl) other).getObjectId().equals(m_obj.getID()); ! } ! ! return false; ! } ! ! /* (non-Javadoc) ! * @see java.lang.Object#hashCode() ! */ ! public int hashCode() { ! return getObjectId().hashCode(); ! } ! ! public org.tmapi.core.Topic getReifier() { ! Iterator it = m_obj.getSourceLocators().iterator(); ! while (it.hasNext()) { ! org.tm4j.topicmap.Topic rawReifier = m_obj.getTopicMap().getTopicBySubjectIndicator((org.tm4j.net.Locator)it.next()); ! if (rawReifier != null) { ! return Wrapper.wrap(rawReifier, m_tm); ! } ! } ! return null; ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.TopicMapObject#remove() ! */ ! public void remove() { ! checkUpdateAllowed(); ! try { ! m_obj.destroy(); ! } catch (java.beans.PropertyVetoException ex) { ! throw Wrapper.wrap(ex); ! } catch (IntegrityViolationException ex) { ! throw Wrapper.wrap(ex); ! } ! } ! ! /** ! * Throws an an UnsupportedOperationException if topic map is read-only. ! */ ! protected void checkUpdateAllowed() { ! try { ! if (getTopicMap().getTopicMapSystem().getFeature("http://tmapi.org/features/readOnly/")) { ! throw new UnsupportedOperationException("Update operations are not allowed on a read-only topic map."); ! } ! } catch (FeatureNotRecognizedException e) { ! return; ! } ! } ! ! ! } Index: TMAPITopicMapImpl.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/tmapi/core/TMAPITopicMapImpl.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** TMAPITopicMapImpl.java 8 Dec 2004 12:11:39 -0000 1.22 --- TMAPITopicMapImpl.java 7 Mar 2006 15:14:19 -0000 1.23 *************** *** 1,249 **** ! /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! package org.tm4j.tmapi.core; ! ! import java.beans.PropertyVetoException; ! import java.util.Arrays; ! import java.util.HashMap; ! import java.util.HashSet; ! import java.util.Iterator; ! import java.util.Set; ! ! import org.tm4j.net.LocatorFactoryException; ! import org.tm4j.tmapi.helpers.HelperObjectMap; ! import org.tm4j.tmapi.helpers.Wrapper; ! import org.tm4j.topicmap.DuplicateObjectIDException; ! import org.tm4j.topicmap.IntegrityViolationException; ! import org.tm4j.topicmap.MergedTopicSubjectClashException; ! import org.tm4j.topicmap.ProviderTransaction; ! import org.tm4j.topicmap.Topic; ! import org.tm4j.topicmap.TopicMapProcessingException; ! import org.tm4j.topicmap.utils.IDGenerator; ! import org.tm4j.topicmap.utils.IDGeneratorFactory; ! import org.tm4j.topicmap.utils.TopicMapCopier; ! import org.tm4j.topicmap.utils.XTMUtils; ! import org.tmapi.core.HelperObjectConfigurationException; ! import org.tmapi.core.HelperObjectInstantiationException; ! import org.tmapi.core.SubjectLocatorClashException; ! import org.tmapi.core.TMAPIRuntimeException; ! import org.tmapi.core.TopicMap; ! import org.tmapi.core.TopicMapObject; ! import org.tmapi.core.TopicMapSystem; ! import org.tmapi.core.UnsupportedHelperObjectException; ! ! ! public class TMAPITopicMapImpl extends TMAPITopicMapObjectImpl ! implements org.tmapi.core.TopicMap { ! private TopicMapSystem m_tmSystem; ! private org.tm4j.topicmap.TopicMap m_obj; ! private IDGenerator m_idGen = IDGeneratorFactory.newIDGenerator(); ! ! public TMAPITopicMapImpl( ! org.tm4j.topicmap.TopicMap topicMap, ! TMAPITopicMapSystemImpl tmSystem) ! { ! super(topicMap, null); ! m_obj = topicMap; ! m_tmSystem = tmSystem; ! } ! ! public TopicMap getTopicMap() { ! return this; ! } ! ! public org.tm4j.topicmap.TopicMap getWrapped() { ! return m_obj; ! } ! ! public TopicMapSystem getTopicMapSystem() { ! return m_tmSystem; ! } ! ! public Set getAssociations() { ! return Wrapper.wrap(m_obj.getAssociations(), this); ! } ! ! public org.tmapi.core.Association createAssociation() { ! checkUpdateAllowed(); ! try { ! org.tm4j.topicmap.Association assoc = m_obj.createAssociation(null); ! ! return Wrapper.wrap(assoc, this); ! } catch (DuplicateObjectIDException ex) { ! throw Wrapper.wrap(ex); ! } catch (java.beans.PropertyVetoException ex) { ! throw Wrapper.wrap(ex); ! } ! } ! ! public void removeAssociation(org.tmapi.core.Association assoc) { ! checkUpdateAllowed(); ! try { ! Wrapper.unwrap(assoc).destroy(); ! ! //m_obj.removeAssociation(Wrapper.unwrap(assoc)); ! } catch (IntegrityViolationException ex) { ! throw Wrapper.wrap(ex); ! } catch (PropertyVetoException ex) { ! throw Wrapper.wrap(ex); ! } ! } ! ! public org.tmapi.core.Locator getBaseLocator() { ! return Wrapper.wrap(m_obj.getBaseLocator()); ! } ! ! public Set getTopics() { ! return Wrapper.wrap(m_obj.getTopics(), this); ! } ! ! public org.tmapi.core.Topic createTopic() { ! checkUpdateAllowed(); ! try { ! org.tm4j.topicmap.Topic topic = m_obj.createTopic(m_idGen.getID()); ! ! return Wrapper.wrap(topic, this); ! } catch (PropertyVetoException ex) { ! throw Wrapper.wrap(ex); ! } catch (DuplicateObjectIDException ex) { ! throw Wrapper.wrap(ex); ! } ! } ! ! public void removeTopic(org.tmapi.core.Topic topic) { ! checkUpdateAllowed(); ! try { ! //m_obj.removeTopic(Wrapper.unwrap(topic)); ! Wrapper.unwrap(topic).destroy(); ! } catch (TopicMapProcessingException ex) { ! throw Wrapper.wrap(ex); ! } catch (PropertyVetoException ex) { ! throw Wrapper.wrap(ex); ! } ! } ! ! public org.tmapi.core.Locator createLocator(String address) { ! checkUpdateAllowed(); ! return createLocator(address, "URI"); ! } ! ! public org.tmapi.core.Locator createLocator(String address, String notation) { ! checkUpdateAllowed(); ! try { ! org.tm4j.net.Locator loc = m_obj.getLocatorFactory().createLocator(notation, ! address); ! ! return Wrapper.wrap(loc); ! } catch (org.tm4j.net.LocatorFactoryException ex) { ! throw Wrapper.wrap(ex); ! } ! } ! ! public void remove() { ! checkUpdateAllowed(); ! try { ! m_obj.destroy(); ! } catch (IntegrityViolationException ex) { ! throw new TMAPIRuntimeException("Unable to remove topic map.", ex); ! } catch (PropertyVetoException ex) { ! throw new TMAPIRuntimeException("Unable to remove topic map.", ex); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.TopicMap#getObjectById(java.lang.String) ! */ ! public TopicMapObject getObjectById(String id) { ! return (TopicMapObject) Wrapper.wrap(m_obj.getObjectByID(id), this); ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.TopicMap#mergeIn(org.tmapi.core.TopicMap) ! */ ! public void mergeIn(TopicMap tm) ! { ! TopicMapCopier copier = new TopicMapCopier(m_obj); ! HashMap copyMap = new HashMap(); ! try { ! org.tm4j.topicmap.TopicMap _tm = Wrapper.unwrap(tm); ! ProviderTransaction txn = null; ! if (_tm.getProvider().isTransactional()) { ! txn = _tm.getProvider().openTransaction(); ! } ! try { ! Iterator it = Wrapper.unwrap(tm).getTopicsIterator(); ! while (it.hasNext()) { ! copier.copy((org.tm4j.topicmap.Topic)it.next(), true, "", "", copyMap); ! } ! } finally { ! if (txn != null) txn.commit(); ! } ! ! if (_tm.getProvider().isTransactional()) { ! txn = _tm.getProvider().openTransaction(); ! } ! try { ! Iterator it = Wrapper.unwrap(tm).getAssociationsIterator(); ! while (it.hasNext()) { ! copier.copy((org.tm4j.topicmap.Association)it.next(), true, "", "", copyMap); ! } ! } finally { ! if (txn != null) txn.commit(); ! } ! ! XTMUtils.makeConsistent(m_obj); ! } catch (TopicMapProcessingException ex) { ! ... [truncated message content] |
From: Lars H. <lh...@us...> - 2006-03-07 15:14:29
|
Update of /cvsroot/tm4j/tm4j/src/org/tm4j/tmapi/helpers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23449/src/org/tm4j/tmapi/helpers Modified Files: Wrapper.java Log Message: Fixed all known TMAPI impl. related bugs (see #1434160, #1435978) Index: Wrapper.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/tmapi/helpers/Wrapper.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Wrapper.java 28 Dec 2005 19:18:03 -0000 1.13 --- Wrapper.java 7 Mar 2006 15:14:19 -0000 1.14 *************** *** 1,348 **** ! /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! package org.tm4j.tmapi.helpers; ! ! import java.util.Collection; ! import java.util.Iterator; ! import java.util.Set; ! ! import org.tm4j.net.LocatorFactoryException; ! import org.tm4j.tmapi.core.TMAPIAssociationImpl; ! import org.tm4j.tmapi.core.TMAPIBaseNameImpl; ! import org.tm4j.tmapi.core.TMAPIMemberImpl; ! import org.tm4j.tmapi.core.TMAPIOccurrenceImpl; ! import org.tm4j.tmapi.core.TMAPITopicImpl; ! import org.tm4j.tmapi.core.TMAPITopicMapImpl; ! import org.tm4j.tmapi.core.TMAPITopicMapSystemImpl; ! import org.tm4j.tmapi.core.TMAPIVariantImpl; ! import org.tm4j.topicmap.Topic; ! import org.tm4j.topicmap.TopicMapProcessingException; ! ! ! public class Wrapper { ! ! public static org.tm4j.net.Locator unwrap(org.tmapi.core.Locator obj) { ! if (obj == null) { ! return null; ! } ! ! if (!(obj instanceof org.tm4j.tmapi.core.TMAPILocatorImpl)) { ! throw new RuntimeException( ! "Cannot unwrap TMAPI objects from a foreign implementation"); ! } ! ! return ((org.tm4j.tmapi.core.TMAPILocatorImpl) obj).getWrapped(); ! } ! ! public static org.tmapi.core.Locator wrap(org.tm4j.net.Locator obj) { ! if (obj == null) { ! return null; ! } ! ! return new org.tm4j.tmapi.core.TMAPILocatorImpl(obj); ! } ! ! public static org.tmapi.core.TopicMap wrap(org.tm4j.topicmap.TopicMap obj, ! TMAPITopicMapSystemImpl tmSystem) { ! return new TMAPITopicMapImpl(obj, tmSystem); ! } ! ! public static org.tm4j.topicmap.TopicMap unwrap(org.tmapi.core.TopicMap obj) { ! if (obj == null) { ! return null; ! } ! ! if (!(obj instanceof TMAPITopicMapImpl)) { ! foreignImplementation(obj); ! } ! ! return (org.tm4j.topicmap.TopicMap) ((TMAPITopicMapImpl) obj).getWrapped(); ! } ! ! // Topic ! public static org.tmapi.core.Topic wrap(org.tm4j.topicmap.Topic obj, ! TMAPITopicMapImpl tm) ! { ! if (obj == null) { ! return null; ! } ! ! return new TMAPITopicImpl(obj, tm); ! } ! ! public static org.tm4j.topicmap.Topic unwrap(org.tmapi.core.Topic obj) { ! if (obj == null) { ! return null; ! } ! ! if (!(obj instanceof TMAPITopicImpl)) { ! foreignImplementation(obj); ! } ! ! return (org.tm4j.topicmap.Topic) ((TMAPITopicImpl) obj).getWrapped(); ! } ! ! // Association ! public static org.tmapi.core.Association wrap( ! org.tm4j.topicmap.Association obj, ! TMAPITopicMapImpl tm) { ! if (obj == null) { ! return null; ! } ! ! return new TMAPIAssociationImpl(obj, tm); ! } ! ! public static org.tm4j.topicmap.Association unwrap( ! org.tmapi.core.Association obj) { ! if (obj == null) { ! return null; ! } ! ! if (!(obj instanceof TMAPIAssociationImpl)) { ! foreignImplementation(obj); ! } ! ! return (org.tm4j.topicmap.Association) ((TMAPIAssociationImpl) obj).getWrapped(); ! } ! ! // Occurrence ! public static org.tmapi.core.Occurrence wrap( ! org.tm4j.topicmap.Occurrence obj, ! TMAPITopicMapImpl tm) ! { ! if (obj == null) { ! return null; ! } ! ! return new TMAPIOccurrenceImpl(obj, tm); ! } ! ! public static org.tm4j.topicmap.Occurrence unwrap( ! org.tmapi.core.Occurrence obj) { ! if (obj == null) { ! return null; ! } ! ! if (!(obj instanceof TMAPIOccurrenceImpl)) { ! foreignImplementation(obj); ! } ! ! return (org.tm4j.topicmap.Occurrence) ((TMAPIOccurrenceImpl) obj).getWrapped(); ! } ! ! // BaseName ! public static org.tmapi.core.TopicName wrap(org.tm4j.topicmap.BaseName obj, TMAPITopicMapImpl tm) ! { ! if (obj == null) { ! return null; ! } ! ! return new TMAPIBaseNameImpl(obj, tm); ! } ! ! public static org.tm4j.topicmap.BaseName unwrap(org.tmapi.core.TopicName obj) { ! if (obj == null) { ! return null; ! } ! ! if (!(obj instanceof TMAPIBaseNameImpl)) { ! foreignImplementation(obj); ! } ! ! return (org.tm4j.topicmap.BaseName) ((TMAPIBaseNameImpl) obj).getWrapped(); ! } ! ! // Member ! public static org.tmapi.core.AssociationRole wrap(org.tm4j.topicmap.Member obj, ! org.tm4j.topicmap.Topic player, ! TMAPITopicMapImpl tm) { ! if (obj == null) { ! return null; ! } ! ! return new TMAPIMemberImpl(obj, player, tm); ! } ! ! public static org.tm4j.topicmap.Member unwrap(org.tmapi.core.AssociationRole obj) { ! if (obj == null) { ! return null; ! } ! ! if (obj instanceof TMAPIMemberImpl) { ! return (org.tm4j.topicmap.Member) ((TMAPIMemberImpl) obj).getWrapped(); ! } ! /* ! else if (obj instanceof TMAPIMemberStub) ! { ! TMAPIMemberImpl impl = (TMAPIMemberImpl)((TMAPIMemberStub)obj).getImplementation(); ! if (impl != null) ! { ! return impl.getWrapped(); ! } ! else ! { ! // Cannot unwrap object that is still a stub. ! // Throw runtime exception instead ? ! return null; ! } ! } ! */ ! else { ! foreignImplementation(obj); ! } ! ! // Should never get here. ! return null; ! } ! ! // Variant ! public static org.tmapi.core.Variant wrap(org.tm4j.topicmap.Variant var, ! org.tm4j.topicmap.VariantName vn, ! TMAPITopicMapImpl tm) { ! if (var == null) { ! System.out.println("NULL passed for object to wrap!"); ! ! return null; ! } ! ! return new TMAPIVariantImpl(var, vn, tm); ! } ! ! public static org.tm4j.topicmap.Variant unwrap(org.tmapi.core.Variant obj) { ! if (obj == null) { ! return null; ! } ! ! if (obj instanceof TMAPIVariantImpl) { ! return (org.tm4j.topicmap.Variant) ((TMAPIVariantImpl) obj).getWrappedVariant(); ! } ! /* ! else if (obj instanceof TMAPIVariantStub) ! { ! TMAPIVariantStub stub = (TMAPIVariantStub)obj; ! if (stub.getImplementation() != null) ! { ! return Wrapper.unwrap(stub.getImplementation()); ! } ! else ! { ! // Cannot unwrap a stub ! // Perhaps a runtime exception should get thrown here ? ! return null; ! } ! } ! */ ! else { ! foreignImplementation(obj); ! } ! ! // Shouldn't ever get here ! return null; ! } ! ! // Set/Collection ! public static Set wrap(Collection col, TMAPITopicMapImpl tm) { ! return new LazySet(col, tm); ! } ! ! // Runtime / Processing exception ! public static RuntimeException wrap(TopicMapProcessingException ex) { ! return new RuntimeException(ex.toString()); ! } ! ! // Property Veto Exception ! public static RuntimeException wrap(java.beans.PropertyVetoException ex) { ! return new RuntimeException(ex.toString()); ! } ! ! // LocatorFactoryException ! public static RuntimeException wrap(LocatorFactoryException ex) { ! return new RuntimeException(ex.toString()); ! } ! ! // Catch-all wrapper ! public static Object wrap(Object obj, TMAPITopicMapImpl tm) { ! if (obj == null) { ! return null; ! } ! ! if (obj instanceof org.tm4j.net.Locator) { ! return wrap((org.tm4j.net.Locator) obj); ! } ! ! if (obj instanceof org.tm4j.topicmap.TopicMap) { ! return wrap((org.tm4j.topicmap.TopicMap) obj, tm); ! } ! ! if (obj instanceof org.tm4j.topicmap.Topic) { ! return wrap((org.tm4j.topicmap.Topic) obj, tm); ! } ! ! if (obj instanceof org.tm4j.topicmap.Association) { ! return wrap((org.tm4j.topicmap.Association) obj, tm); ! } ! ! if (obj instanceof org.tm4j.topicmap.Occurrence) { ! return wrap((org.tm4j.topicmap.Occurrence) obj, tm); ! } ! ! if (obj instanceof org.tm4j.topicmap.Member) { ! org.tm4j.topicmap.Member m = (org.tm4j.topicmap.Member)obj; ! Collection players = m.getPlayers(); ! if (players.size() == 1) { ! return wrap(m, (Topic)m.getPlayers().iterator().next(), tm); ! } else if (players.size() > 1) { ! // Wrapper can only wrap a single player ! throw new org.tmapi.core.TMAPIRuntimeException("TMAPI Wrapper does not support TM4J Member objects with > 1 role player."); ! } else { ! return wrap(m, null, tm); ! } ! } ! ! if (obj instanceof org.tm4j.topicmap.BaseName) { ! return wrap((org.tm4j.topicmap.BaseName) obj, tm); ! } ! ! foreignImplementation(obj); ! ! return null; ! } ! ! /** ! * Utility method to convert a Collection of org.tmapi.core.Topic objects ! * into the themes on the org.tm4j.topicmap.Scope object <code>scope</code> ! * ! * @param scope The Scope object to populate ! * @param themes The collection of topics to be set as the themes. ! * @return The updated Scope object. ! */ ! public static org.tm4j.topicmap.ScopedObject setScopeThemes( ! org.tm4j.topicmap.ScopedObject scopedObject, Collection themes) { ! try { ! org.tm4j.topicmap.Topic[] _themes = new org.tm4j.topicmap.Topic[themes.size()]; ! int ix = 0; ! Iterator it = themes.iterator(); ! ! while (it.hasNext()) { ! _themes[ix++] = unwrap((org.tmapi.core.Topic) it.next()); ! } ! ! scopedObject.setScope(_themes); ! ! return scopedObject; ! } catch (java.beans.PropertyVetoException ex) { ! throw wrap(ex); ! } ! } ! ! private static void foreignImplementation(Object obj) { ! throw new RuntimeException("Cannot unwrap object of class: " + ! obj.getClass().getName()); ! } ! } --- 1,351 ---- ! /* ! Copyright (c) 2000-2004 The TM4J Project. All rights reserved. ! ! This software is licensed under a modified version of the ! Apache Software License. The full license text can be found ! at http://tm4j.org/LICENSE.txt ! */ ! package org.tm4j.tmapi.helpers; ! ! import java.util.Collection; ! import java.util.Iterator; ! import java.util.Set; ! ! import org.tm4j.net.LocatorFactoryException; ! import org.tm4j.tmapi.core.TMAPIAssociationImpl; ! import org.tm4j.tmapi.core.TMAPIBaseNameImpl; ! import org.tm4j.tmapi.core.TMAPIMemberImpl; ! import org.tm4j.tmapi.core.TMAPIOccurrenceImpl; ! import org.tm4j.tmapi.core.TMAPITopicImpl; ! import org.tm4j.tmapi.core.TMAPITopicMapImpl; ! import org.tm4j.tmapi.core.TMAPITopicMapSystemImpl; ! import org.tm4j.tmapi.core.TMAPIVariantImpl; ! import org.tm4j.topicmap.Topic; ! import org.tm4j.topicmap.TopicMapProcessingException; ! ! ! public class Wrapper { ! ! public static org.tm4j.net.Locator unwrap(org.tmapi.core.Locator obj) { ! if (obj == null) { ! return null; ! } ! ! if (!(obj instanceof org.tm4j.tmapi.core.TMAPILocatorImpl)) { ! throw new RuntimeException( ! "Cannot unwrap TMAPI objects from a foreign implementation"); ! } ! ! return ((org.tm4j.tmapi.core.TMAPILocatorImpl) obj).getWrapped(); ! } ! ! public static org.tmapi.core.Locator wrap(org.tm4j.net.Locator obj) { ! if (obj == null) { ! return null; ! } ! ! return new org.tm4j.tmapi.core.TMAPILocatorImpl(obj); ! } ! ! public static org.tmapi.core.TopicMap wrap(org.tm4j.topicmap.TopicMap obj, ! TMAPITopicMapSystemImpl tmSystem) { ! return new TMAPITopicMapImpl(obj, tmSystem); ! } ! ! public static org.tm4j.topicmap.TopicMap unwrap(org.tmapi.core.TopicMap obj) { ! if (obj == null) { ! return null; ! } ! ! if (!(obj instanceof TMAPITopicMapImpl)) { ! foreignImplementation(obj); ! } ! ! return (org.tm4j.topicmap.TopicMap) ((TMAPITopicMapImpl) obj).getWrapped(); ! } ! ! // Topic ! public static org.tmapi.core.Topic wrap(org.tm4j.topicmap.Topic obj, ! TMAPITopicMapImpl tm) ! { ! if (obj == null) { ! return null; ! } ! ! return new TMAPITopicImpl(obj, tm); ! } ! ! public static org.tm4j.topicmap.Topic unwrap(org.tmapi.core.Topic obj) { ! if (obj == null) { ! return null; ! } ! ! if (!(obj instanceof TMAPITopicImpl)) { ! foreignImplementation(obj); ! } ! ! return (org.tm4j.topicmap.Topic) ((TMAPITopicImpl) obj).getWrapped(); ! } ! ! // Association ! public static org.tmapi.core.Association wrap( ! org.tm4j.topicmap.Association obj, ! TMAPITopicMapImpl tm) { ! if (obj == null) { ! return null; ! } ! ! return new TMAPIAssociationImpl(obj, tm); ! } ! ! public static org.tm4j.topicmap.Association unwrap( ! org.tmapi.core.Association obj) { ! if (obj == null) { ! return null; ! } ! ! if (!(obj instanceof TMAPIAssociationImpl)) { ! foreignImplementation(obj); ! } ! ! return (org.tm4j.topicmap.Association) ((TMAPIAssociationImpl) obj).getWrapped(); ! } ! ! // Occurrence ! public static org.tmapi.core.Occurrence wrap( ! org.tm4j.topicmap.Occurrence obj, ! TMAPITopicMapImpl tm) ! { ! if (obj == null) { ! return null; ! } ! ! return new TMAPIOccurrenceImpl(obj, tm); ! } ! ! public static org.tm4j.topicmap.Occurrence unwrap( ! org.tmapi.core.Occurrence obj) { ! if (obj == null) { ! return null; ! } ! ! if (!(obj instanceof TMAPIOccurrenceImpl)) { ! foreignImplementation(obj); ! } ! ! return (org.tm4j.topicmap.Occurrence) ((TMAPIOccurrenceImpl) obj).getWrapped(); ! } ! ! // BaseName ! public static org.tmapi.core.TopicName wrap(org.tm4j.topicmap.BaseName obj, TMAPITopicMapImpl tm) ! { ! if (obj == null) { ! return null; ! } ! ! return new TMAPIBaseNameImpl(obj, tm); ! } ! ! public static org.tm4j.topicmap.BaseName unwrap(org.tmapi.core.TopicName obj) { ! if (obj == null) { ! return null; ! } ! ! if (!(obj instanceof TMAPIBaseNameImpl)) { ! foreignImplementation(obj); ! } ! ! return (org.tm4j.topicmap.BaseName) ((TMAPIBaseNameImpl) obj).getWrapped(); ! } ! ! // Member ! public static org.tmapi.core.AssociationRole wrap(org.tm4j.topicmap.Member obj, ! org.tm4j.topicmap.Topic player, ! TMAPITopicMapImpl tm) { ! if (obj == null) { ! return null; ! } ! ! return new TMAPIMemberImpl(obj, player, tm); ! } ! ! public static org.tm4j.topicmap.Member unwrap(org.tmapi.core.AssociationRole obj) { ! if (obj == null) { ! return null; ! } ! ! if (obj instanceof TMAPIMemberImpl) { ! return (org.tm4j.topicmap.Member) ((TMAPIMemberImpl) obj).getWrapped(); ! } ! /* ! else if (obj instanceof TMAPIMemberStub) ! { ! TMAPIMemberImpl impl = (TMAPIMemberImpl)((TMAPIMemberStub)obj).getImplementation(); ! if (impl != null) ! { ! return impl.getWrapped(); ! } ! else ! { ! // Cannot unwrap object that is still a stub. ! // Throw runtime exception instead ? ! return null; ! } ! } ! */ ! else { ! foreignImplementation(obj); ! } ! ! // Should never get here. ! return null; ! } ! ! // Variant ! public static org.tmapi.core.Variant wrap(org.tm4j.topicmap.Variant var, ! org.tm4j.topicmap.VariantName vn, ! TMAPITopicMapImpl tm) { ! if (var == null || vn == null) { ! return null; ! } ! ! return new TMAPIVariantImpl(var, vn, tm); ! } ! ! public static org.tm4j.topicmap.Variant unwrap(org.tmapi.core.Variant obj) { ! if (obj == null) { ! return null; ! } ! ! if (obj instanceof TMAPIVariantImpl) { ! return (org.tm4j.topicmap.Variant) ((TMAPIVariantImpl) obj).getWrappedVariant(); ! } ! /* ! else if (obj instanceof TMAPIVariantStub) ! { ! TMAPIVariantStub stub = (TMAPIVariantStub)obj; ! if (stub.getImplementation() != null) ! { ! return Wrapper.unwrap(stub.getImplementation()); ! } ! else ! { ! // Cannot unwrap a stub ! // Perhaps a runtime exception should get thrown here ? ! return null; ! } ! } ! */ ! else { ! foreignImplementation(obj); ! } ! ! // Shouldn't ever get here ! return null; ! } ! ! // Set/Collection ! public static Set wrap(Collection col, TMAPITopicMapImpl tm) { ! return new LazySet(col, tm); ! } ! ! // Runtime / Processing exception ! public static RuntimeException wrap(TopicMapProcessingException ex) { ! return new RuntimeException(ex.toString()); ! } ! ! // Property Veto Exception ! public static RuntimeException wrap(java.beans.PropertyVetoException ex) { ! return new RuntimeException(ex.toString()); ! } ! ! // LocatorFactoryException ! public static RuntimeException wrap(LocatorFactoryException ex) { ! return new RuntimeException(ex.toString()); ! } ! ! // Catch-all wrapper ! public static Object wrap(Object obj, TMAPITopicMapImpl tm) { ! if (obj == null) { ! return null; ! } ! ! if (obj instanceof org.tm4j.net.Locator) { ! return wrap((org.tm4j.net.Locator) obj); ! } ! ! if (obj instanceof org.tm4j.topicmap.TopicMap) { ! return wrap((org.tm4j.topicmap.TopicMap) obj, tm); ! } ! ! if (obj instanceof org.tm4j.topicmap.Topic) { ! return wrap((org.tm4j.topicmap.Topic) obj, tm); ! } ! ! if (obj instanceof org.tm4j.topicmap.Association) { ! return wrap((org.tm4j.topicmap.Association) obj, tm); ! } ! ! if (obj instanceof org.tm4j.topicmap.Occurrence) { ! return wrap((org.tm4j.topicmap.Occurrence) obj, tm); ! } ! ! if (obj instanceof org.tm4j.topicmap.Member) { ! org.tm4j.topicmap.Member m = (org.tm4j.topicmap.Member)obj; ! Collection players = m.getPlayers(); ! if (players.size() == 1) { ! return wrap(m, (Topic)m.getPlayers().iterator().next(), tm); ! } else if (players.size() > 1) { ! // Wrapper can only wrap a single player ! throw new org.tmapi.core.TMAPIRuntimeException("TMAPI Wrapper does not support TM4J Member objects with > 1 role player."); ! } else { ! return wrap(m, null, tm); ! } ! } ! ! if (obj instanceof org.tm4j.topicmap.BaseName) { ! return wrap((org.tm4j.topicmap.BaseName) obj, tm); ! } ! ! if (obj instanceof org.tm4j.topicmap.VariantName) { ! org.tm4j.topicmap.VariantName varName = (org.tm4j.topicmap.VariantName) obj; ! return wrap(varName.getParent(), varName, tm); ! } ! ! foreignImplementation(obj); ! ! return null; ! } ! ! /** ! * Utility method to convert a Collection of org.tmapi.core.Topic objects ! * into the themes on the org.tm4j.topicmap.Scope object <code>scope</code> ! * ! * @param scope The Scope object to populate ! * @param themes The collection of topics to be set as the themes. ! * @return The updated Scope object. ! */ ! public static org.tm4j.topicmap.ScopedObject setScopeThemes( ! org.tm4j.topicmap.ScopedObject scopedObject, Collection themes) { ! try { ! org.tm4j.topicmap.Topic[] _themes = new org.tm4j.topicmap.Topic[themes.size()]; ! int ix = 0; ! Iterator it = themes.iterator(); ! ! while (it.hasNext()) { ! _themes[ix++] = unwrap((org.tmapi.core.Topic) it.next()); ! } ! ! scopedObject.setScope(_themes); ! ! return scopedObject; ! } catch (java.beans.PropertyVetoException ex) { ! throw wrap(ex); ! } ! } ! ! private static void foreignImplementation(Object obj) { ! throw new RuntimeException("Cannot unwrap object of class: " + ! obj.getClass().getName()); ! } ! } |
From: Lars H. <lh...@us...> - 2006-03-07 15:14:27
|
Update of /cvsroot/tm4j/tm4j/src/org/tm4j/tmapi/index/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23449/src/org/tm4j/tmapi/index/core Modified Files: TMAPITopicNamesIndexImpl.java Log Message: Fixed all known TMAPI impl. related bugs (see #1434160, #1435978) Index: TMAPITopicNamesIndexImpl.java =================================================================== RCS file: /cvsroot/tm4j/tm4j/src/org/tm4j/tmapi/index/core/TMAPITopicNamesIndexImpl.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TMAPITopicNamesIndexImpl.java 5 May 2004 17:38:26 -0000 1.2 --- TMAPITopicNamesIndexImpl.java 7 Mar 2006 15:14:19 -0000 1.3 *************** *** 1,132 **** ! /* ! * $Header$ ! */ ! package org.tm4j.tmapi.index.core; ! ! import java.util.ArrayList; ! import java.util.Collection; ! import java.util.Collections; ! ! import org.tm4j.tmapi.core.TMAPITopicMapImpl; ! import org.tm4j.tmapi.helpers.Wrapper; ! import org.tm4j.tmapi.index.TMAPIIndexFlagsImpl; ! import org.tm4j.topicmap.index.IndexException; ! import org.tm4j.topicmap.index.IndexManager; ! import org.tm4j.topicmap.index.basic.BaseNameDataIndex; ! import org.tmapi.core.HelperObjectConfigurationException; ! import org.tmapi.core.TopicMap; ! import org.tmapi.core.TopicMapSystem; ! import org.tmapi.core.Topic; ! import org.tmapi.index.IndexFlags; ! import org.tmapi.index.TMAPIIndexException; ! import org.tmapi.index.core.TopicNamesIndex; ! ! /** ! * Wrapper implementation of the TMAPI TopicNamesIndex. ! */ ! public class TMAPITopicNamesIndexImpl implements TopicNamesIndex, TopicMapSystem.ConfigurableHelperObject ! { ! private TMAPITopicMapImpl m_tm; ! private BaseNameDataIndex m_bdi; ! private IndexFlags m_flags; ! ! /* (non-Javadoc) ! * @see org.tmapi.index.core.TopicNamesIndex#getTopicNamesByValue(java.lang.String) ! */ ! public Collection getTopicNamesByValue(String value) { ! return Wrapper.wrap(m_bdi.getBaseNamesByData(value), m_tm); ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.index.core.TopicNamesIndex#getTopicNameTypes() ! */ ! public Collection getTopicNameTypes() { ! return Collections.unmodifiableCollection(new ArrayList()); ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.index.core.TopicNamesIndex#getTopicNamesByType(org.tmapi.core.Topic) ! */ ! public Collection getTopicNamesByType(Topic arg0) { ! return Collections.unmodifiableCollection(new ArrayList()); ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.index.Index#open() ! */ ! public void open() throws TMAPIIndexException { ! if (!m_bdi.isOpen()) try { ! m_bdi.open(); ! } catch (IndexException e) { ! throw new TMAPIIndexException("Unable to open underlying index. " + e.getMessage()); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.index.Index#close() ! */ ! public void close() throws TMAPIIndexException { ! if (m_bdi.isOpen()) try { ! m_bdi.close(); ! } catch (IndexException e) { ! throw new TMAPIIndexException("Unable to close underlying index. " + e.getMessage()); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.index.Index#isOpen() ! */ ! public boolean isOpen() throws TMAPIIndexException { ! return m_bdi.isOpen(); ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.index.Index#reindex() ! */ ! public void reindex() throws TMAPIIndexException { ! try { ! m_bdi.reindex(); ! } catch (IndexException e) { ! throw new TMAPIIndexException("Unable to reindex underlying index. " + e.getMessage()); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.index.Index#getFlags() ! */ ! public IndexFlags getFlags() throws TMAPIIndexException { ! return m_flags; ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.TopicMapSystem.ConfigurableHelperObject#configure(org.tmapi.core.TopicMap) ! */ ! public void configure(TopicMap tm) throws HelperObjectConfigurationException { ! if (tm instanceof TMAPITopicMapImpl) { ! try { ! m_tm = (TMAPITopicMapImpl)tm; ! org.tm4j.topicmap.TopicMap _tm = m_tm.getWrapped(); ! IndexManager im = _tm.getIndexManager(); ! m_bdi = (BaseNameDataIndex) im.getIndex(BaseNameDataIndex.class); ! m_flags = new TMAPIIndexFlagsImpl(im.getIndexMeta(BaseNameDataIndex.class).isAutomaticallyUpdated()); ! } catch (Exception ex) { ! throw new HelperObjectConfigurationException("Unable to initialise underlying index.", ex); ! } ! } else { ! throw new HelperObjectConfigurationException("TM4J TopicNamesIndex implementation cannot index a TopicMap that is not a TM4J TopicMap implementation."); ! } ! } ! ! } ! /* * $Log$ ! * Revision 1.2 2004/05/05 17:38:26 kal_ahmed ! * Refactored code to enable getTopicMap() and getTopicMapSystem() to work correctly when there are multiple TopicMapSystem instances in the same JVM. ! * ! * Revision 1.1 2004/04/15 12:24:59 kal_ahmed ! * Renamed file for consistency with other index implementations. ! * ! * Revision 1.1 2004/04/13 19:43:02 kal_ahmed ! * Completed implementation of TMAPI core indexes. ! * */ \ No newline at end of file --- 1,148 ---- ! /* ! * $Header$ ! */ ! package org.tm4j.tmapi.index.core; ! ! import java.util.ArrayList; ! import java.util.Collection; ! import java.util.Collections; ! import java.util.Iterator; ! ! import org.tm4j.tmapi.core.TMAPITopicMapImpl; ! import org.tm4j.tmapi.helpers.Wrapper; ! import org.tm4j.tmapi.index.TMAPIIndexFlagsImpl; ! import org.tm4j.topicmap.index.IndexException; ! import org.tm4j.topicmap.index.IndexManager; ! import org.tm4j.topicmap.index.basic.BaseNameDataIndex; ! import org.tmapi.core.HelperObjectConfigurationException; ! import org.tmapi.core.TopicMap; ! import org.tmapi.core.TopicMapSystem; ! import org.tmapi.core.Topic; ! import org.tmapi.index.IndexFlags; ! import org.tmapi.index.TMAPIIndexException; ! import org.tmapi.index.core.TopicNamesIndex; ! ! /** ! * Wrapper implementation of the TMAPI TopicNamesIndex. ! */ ! public class TMAPITopicNamesIndexImpl implements TopicNamesIndex, TopicMapSystem.ConfigurableHelperObject ! { ! private TMAPITopicMapImpl m_tm; ! private BaseNameDataIndex m_bdi; ! private IndexFlags m_flags; ! ! /* (non-Javadoc) ! * @see org.tmapi.index.core.TopicNamesIndex#getTopicNamesByValue(java.lang.String) ! */ ! public Collection getTopicNamesByValue(String value) { ! return Wrapper.wrap(m_bdi.getBaseNamesByData(value), m_tm); ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.index.core.TopicNamesIndex#getTopicNameTypes() ! */ ! public Collection getTopicNameTypes() { ! return Collections.EMPTY_SET; ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.index.core.TopicNamesIndex#getTopicNamesByType(org.tmapi.core.Topic) ! */ ! public Collection getTopicNamesByType(Topic type) { ! if (type != null) { ! return Collections.EMPTY_SET; // No support for typed names, yet ! } ! else { ! // TODO: Optimize this, we need to collect all names, since all names are untyped ! Collection names = new ArrayList(); ! org.tm4j.topicmap.Topic topic = null; ! for (Iterator iter = m_tm.getWrapped().getTopicsIterator(); iter.hasNext();) { ! topic = (org.tm4j.topicmap.Topic) iter.next(); ! names.addAll(topic.getNames()); ! } ! return Wrapper.wrap(names, m_tm); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.index.Index#open() ! */ ! public void open() throws TMAPIIndexException { ! if (!m_bdi.isOpen()) try { ! m_bdi.open(); ! } catch (IndexException e) { ! throw new TMAPIIndexException("Unable to open underlying index. " + e.getMessage()); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.index.Index#close() ! */ ! public void close() throws TMAPIIndexException { ! if (m_bdi.isOpen()) try { ! m_bdi.close(); ! } catch (IndexException e) { ! throw new TMAPIIndexException("Unable to close underlying index. " + e.getMessage()); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.index.Index#isOpen() ! */ ! public boolean isOpen() throws TMAPIIndexException { ! return m_bdi.isOpen(); ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.index.Index#reindex() ! */ ! public void reindex() throws TMAPIIndexException { ! try { ! m_bdi.reindex(); ! } catch (IndexException e) { ! throw new TMAPIIndexException("Unable to reindex underlying index. " + e.getMessage()); ! } ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.index.Index#getFlags() ! */ ! public IndexFlags getFlags() throws TMAPIIndexException { ! return m_flags; ! } ! ! /* (non-Javadoc) ! * @see org.tmapi.core.TopicMapSystem.ConfigurableHelperObject#configure(org.tmapi.core.TopicMap) ! */ ! public void configure(TopicMap tm) throws HelperObjectConfigurationException { ! if (tm instanceof TMAPITopicMapImpl) { ! try { ! m_tm = (TMAPITopicMapImpl)tm; ! org.tm4j.topicmap.TopicMap _tm = m_tm.getWrapped(); ! IndexManager im = _tm.getIndexManager(); ! m_bdi = (BaseNameDataIndex) im.getIndex(BaseNameDataIndex.class); ! m_flags = new TMAPIIndexFlagsImpl(im.getIndexMeta(BaseNameDataIndex.class).isAutomaticallyUpdated()); ! } catch (Exception ex) { ! throw new HelperObjectConfigurationException("Unable to initialise underlying index.", ex); ! } ! } else { ! throw new HelperObjectConfigurationException("TM4J TopicNamesIndex implementation cannot index a TopicMap that is not a TM4J TopicMap implementation."); ! } ! } ! ! } ! /* * $Log$ ! * Revision 1.3 2006/03/07 15:14:19 lheuer ! * Fixed all known TMAPI impl. related bugs (see #1434160, #1435978) ! * ! * Revision 1.2 2004/05/05 17:38:26 kal_ahmed ! * Refactored code to enable getTopicMap() and getTopicMapSystem() to work correctly when there are multiple TopicMapSystem instances in the same JVM. ! * ! * Revision 1.1 2004/04/15 12:24:59 kal_ahmed ! * Renamed file for consistency with other index implementations. ! * ! * Revision 1.1 2004/04/13 19:43:02 kal_ahmed ! * Completed implementation of TMAPI core indexes. ! * */ \ No newline at end of file |