From: <lh...@us...> - 2008-04-20 11:44:16
|
Revision: 9 http://tinytim.svn.sourceforge.net/tinytim/?rev=9&view=rev Author: lheuer Date: 2008-04-20 04:44:19 -0700 (Sun, 20 Apr 2008) Log Message: ----------- Initial import of the libs Added Paths: ----------- tinytim/trunk/lib/ tinytim/trunk/lib/LICENSE.tmapi-test.txt tinytim/trunk/lib/LICENSE.tmapi.txt tinytim/trunk/lib/LICENSE.trove.txt tinytim/trunk/lib/tmapi-1_0SP1.jar tinytim/trunk/lib/tmapi-test-1_0SP1.jar tinytim/trunk/lib/trove-2.0.3.jar Added: tinytim/trunk/lib/LICENSE.tmapi-test.txt =================================================================== --- tinytim/trunk/lib/LICENSE.tmapi-test.txt (rev 0) +++ tinytim/trunk/lib/LICENSE.tmapi-test.txt 2008-04-20 11:44:19 UTC (rev 9) @@ -0,0 +1,21 @@ +TMAPI 1.0 + + Version 1.0 of the Topic Maps API (TMAPI), created collectively by + the membership of the tmapi-discuss mailing list + (http://lists.sourceforge.net/mailman/listinfo/tmapi-discuss), + is hereby released into the public domain. + + No one owns TMAPI: you may use it freely in both commercial and + non-commercial applications, bundle it with your software + distribution, include it on a CD-ROM, list the source code in a + book, mirror the documentation at your own web site, or use it in + any other way you see fit. + + Kal Ahmed (kal at techquila.com) + Lars Marius Garshol (larsga at users.sourceforge.net) + Geir Ove Gr\xF8nmo (grove at users.sourceforge.net) + Lars Heuer (lheuer at users.sourceforge.net) + Stefan Lischke (lischke2 at users.sourceforge.net) + Graham Moore (gra_moore at users.sourceforge.net) + + 08 April 2004 Added: tinytim/trunk/lib/LICENSE.tmapi.txt =================================================================== --- tinytim/trunk/lib/LICENSE.tmapi.txt (rev 0) +++ tinytim/trunk/lib/LICENSE.tmapi.txt 2008-04-20 11:44:19 UTC (rev 9) @@ -0,0 +1,21 @@ +TMAPI 1.0 + + Version 1.0 of the Topic Maps API (TMAPI), created collectively by + the membership of the tmapi-discuss mailing list + (http://lists.sourceforge.net/mailman/listinfo/tmapi-discuss), + is hereby released into the public domain. + + No one owns TMAPI: you may use it freely in both commercial and + non-commercial applications, bundle it with your software + distribution, include it on a CD-ROM, list the source code in a + book, mirror the documentation at your own web site, or use it in + any other way you see fit. + + Kal Ahmed (kal at techquila.com) + Lars Marius Garshol (larsga at users.sourceforge.net) + Geir Ove Gr\xF8nmo (grove at users.sourceforge.net) + Lars Heuer (lheuer at users.sourceforge.net) + Stefan Lischke (lischke2 at users.sourceforge.net) + Graham Moore (gra_moore at users.sourceforge.net) + + 08 April 2004 Added: tinytim/trunk/lib/LICENSE.trove.txt =================================================================== --- tinytim/trunk/lib/LICENSE.trove.txt (rev 0) +++ tinytim/trunk/lib/LICENSE.trove.txt 2008-04-20 11:44:19 UTC (rev 9) @@ -0,0 +1,528 @@ +The Trove library is licensed under the Lesser GNU Public License, +which is included with the distribution in a file called LICENSE.txt. + +Other license arrangements are possible, for a fee: contact +e...@us... for terms/pricing. + +The PrimeFinder and HashFunctions classes in Trove are subject to the +following license restrictions: + +Copyright (c) 1999 CERN - European Organization for Nuclear Research. + +Permission to use, copy, modify, distribute and sell this software and +its documentation for any purpose is hereby granted without fee, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation. CERN makes no representations about the +suitability of this software for any purpose. It is provided "as is" +without expressed or implied warranty. + + + +Content of Trove's LICENSE.txt: + + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + <one line to give the library's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + <signature of Ty Coon>, 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + Added: tinytim/trunk/lib/tmapi-1_0SP1.jar =================================================================== (Binary files differ) Property changes on: tinytim/trunk/lib/tmapi-1_0SP1.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: tinytim/trunk/lib/tmapi-test-1_0SP1.jar =================================================================== (Binary files differ) Property changes on: tinytim/trunk/lib/tmapi-test-1_0SP1.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: tinytim/trunk/lib/trove-2.0.3.jar =================================================================== (Binary files differ) Property changes on: tinytim/trunk/lib/trove-2.0.3.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-04-20 12:06:28
|
Revision: 11 http://tinytim.svn.sourceforge.net/tinytim/?rev=11&view=rev Author: lheuer Date: 2008-04-20 05:06:28 -0700 (Sun, 20 Apr 2008) Log Message: ----------- Initial test case import Added Paths: ----------- tinytim/trunk/test/ tinytim/trunk/test/java/ tinytim/trunk/test/java/org/ tinytim/trunk/test/java/org/tinytim/ tinytim/trunk/test/java/org/tinytim/TMAPITestCase.java tinytim/trunk/test/java/org/tinytim/TestReifiable.java tinytim/trunk/test/java/org/tinytim/TestScoped.java tinytim/trunk/test/java/org/tinytim/TestSignatureGenerator.java tinytim/trunk/test/java/org/tinytim/TestTMAPICore.java tinytim/trunk/test/java/org/tinytim/TestTMAPIIndex.java tinytim/trunk/test/java/org/tinytim/TestTopicMapSystemFactoryImpl.java tinytim/trunk/test/java/org/tinytim/TestTopicMerge.java tinytim/trunk/test/java/org/tinytim/TestTopicMergeDetection.java tinytim/trunk/test/java/org/tinytim/TestTyped.java tinytim/trunk/test/java/org/tinytim/TinyTimTestCase.java Added: tinytim/trunk/test/java/org/tinytim/TMAPITestCase.java =================================================================== --- tinytim/trunk/test/java/org/tinytim/TMAPITestCase.java (rev 0) +++ tinytim/trunk/test/java/org/tinytim/TMAPITestCase.java 2008-04-20 12:06:28 UTC (rev 11) @@ -0,0 +1,36 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim; + +import junit.framework.TestCase; + +/** + * Base class for all TMAPI-related test cases. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public class TMAPITestCase extends TestCase { + + static { + System.setProperty("org.tmapi.core.TopicMapSystemFactory", "org.tinytim.TopicMapSystemFactoryImpl"); + } +} Property changes on: tinytim/trunk/test/java/org/tinytim/TMAPITestCase.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native Added: tinytim/trunk/test/java/org/tinytim/TestReifiable.java =================================================================== --- tinytim/trunk/test/java/org/tinytim/TestReifiable.java (rev 0) +++ tinytim/trunk/test/java/org/tinytim/TestReifiable.java 2008-04-20 12:06:28 UTC (rev 11) @@ -0,0 +1,151 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim; + +import org.tmapi.core.Association; +import org.tmapi.core.AssociationRole; +import org.tmapi.core.ModelConstraintException; +import org.tmapi.core.Occurrence; +import org.tmapi.core.Topic; +import org.tmapi.core.TopicMap; +import org.tmapi.core.TopicName; +import org.tmapi.core.Variant; + +/** + * Tests against the {@link org.tinytim.IReifiable} interface. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public class TestReifiable extends TinyTimTestCase { + + /** + * Tests if a Topic Maps construct is an instance of IReifiable. + */ + public void testInstanceOf() { + assertTrue(((TopicMap)_tm) instanceof IReifiable); + Topic topic = _tm.createTopic(); + assertFalse(topic instanceof IReifiable); + Association assoc = _tm.createAssociation(); + assertTrue(assoc instanceof IReifiable); + AssociationRole role = assoc.createAssociationRole(_tm.createTopic(), _tm.createTopic()); + assertTrue(role instanceof IReifiable); + Occurrence occ = topic.createOccurrence("tinyTiM", null, null); + assertTrue(occ instanceof IReifiable); + TopicName name = topic.createTopicName("tinyTiM", null); + assertTrue(name instanceof IReifiable); + Variant variant = name.createVariant("tinyTiM", null); + assertTrue(variant instanceof IReifiable); + } + + /** + * Tests setting and getting the reifier of a topic map. + */ + public void testTopicMap() { + _testSetGet((IReifiable)_tm); + } + + /** + * Tests setting and getting the reifier of an association. + */ + public void testAssociation() { + _testSetGet((IReifiable)_tm.createAssociation()); + } + + /** + * Tests setting and getting the reifier of a role. + */ + public void testRole() { + Association assoc = _tm.createAssociation(); + AssociationRole role = assoc.createAssociationRole(_tm.createTopic(), _tm.createTopic()); + _testSetGet((IReifiable)role); + } + + /** + * Tests setting and getting the reifier of an occurrence. + */ + public void testOccurrence() { + Topic topic = _tm.createTopic(); + Occurrence occ = topic.createOccurrence("tinyTiM", null, null); + _testSetGet((IReifiable)occ); + } + + /** + * Tests setting and getting the reifier of a name. + */ + public void testName() { + Topic topic = _tm.createTopic(); + TopicName name = topic.createTopicName("tinyTiM", null, null); + _testSetGet((IReifiable)name); + } + + /** + * Tests setting and getting the reifier of a variant. + */ + public void testVariant() { + Topic topic = _tm.createTopic(); + TopicName name = topic.createTopicName("tinyTiM", null, null); + Variant variant = name.createVariant("tinyTiM", null); + _testSetGet((IReifiable)variant); + } + + /** + * Tests setting and getting the reifier of a reifiable Topic Maps construct. + * + * @param reifiable The Topic Maps construct to test. + */ + private void _testSetGet(IReifiable reifiable) { + assertNull(reifiable.getReifier()); + TopicImpl reifier = (TopicImpl) _tm.createTopic(); + assertEquals(0, reifier.getReified().size()); + reifiable.setReifier(reifier); + assertEquals(reifier, reifiable.getReifier()); + assertEquals(reifiable, reifier._reified); + assertEquals(1, reifier.getReified().size()); + assertTrue(reifier.getReified().contains(reifiable)); + reifiable.setReifier(null); + assertNull(reifiable.getReifier()); + assertNull(reifier._reified); + assertEquals(0, reifier.getReified().size()); + + TopicImpl reifier2 = (TopicImpl) _tm.createTopic(); + IReifiable assoc = (IReifiable) _tm.createAssociation(); + assoc.setReifier(reifier2); + assertEquals(reifier2, assoc.getReifier()); + assertEquals(assoc, reifier2._reified); + try { + reifiable.setReifier(reifier2); + fail("Expected an exception. The reifier reifies another Topic Maps construct"); + } + catch (ModelConstraintException ex) { + // noop. + } + assoc.setReifier(null); + assertNull(assoc.getReifier()); + assertNull(reifier2._reified); + reifiable.setReifier(reifier); + assertEquals(reifier, reifiable.getReifier()); + assertEquals(reifiable, reifier._reified); + reifiable.setReifier(reifier2); + assertEquals(reifier2, reifiable.getReifier()); + assertEquals(reifiable, reifier2._reified); + } +} Property changes on: tinytim/trunk/test/java/org/tinytim/TestReifiable.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native Added: tinytim/trunk/test/java/org/tinytim/TestScoped.java =================================================================== --- tinytim/trunk/test/java/org/tinytim/TestScoped.java (rev 0) +++ tinytim/trunk/test/java/org/tinytim/TestScoped.java 2008-04-20 12:06:28 UTC (rev 11) @@ -0,0 +1,119 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim; + +import org.tmapi.core.Association; +import org.tmapi.core.AssociationRole; +import org.tmapi.core.Occurrence; +import org.tmapi.core.Topic; +import org.tmapi.core.TopicMap; +import org.tmapi.core.TopicName; +import org.tmapi.core.Variant; + +/** + * Tests against the {@link org.tinytim.IScoped} interface. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public class TestScoped extends TinyTimTestCase { + + /** + * Tests if a Topic Maps construct is an instance of IScoped. + */ + public void testInstanceOf() { + assertFalse(((TopicMap)_tm) instanceof IScoped); + Topic topic = _tm.createTopic(); + assertFalse(topic instanceof IScoped); + Association assoc = _tm.createAssociation(); + assertTrue(assoc instanceof IScoped); + AssociationRole role = assoc.createAssociationRole(_tm.createTopic(), _tm.createTopic()); + assertFalse(role instanceof IScoped); + Occurrence occ = topic.createOccurrence("tinyTiM", null, null); + assertTrue(occ instanceof IScoped); + TopicName name = topic.createTopicName("tinyTiM", null); + assertTrue(name instanceof IScoped); + Variant variant = name.createVariant("tinyTiM", null); + assertTrue(variant instanceof IScoped); + } + + /** + * Tests against an association. + */ + public void testAssociation() { + Association assoc = _tm.createAssociation(); + _testScoped((IScoped) assoc); + } + + /** + * Tests against an occurrence. + */ + public void testOccurrence() { + Topic topic = _tm.createTopic(); + Occurrence occ = topic.createOccurrence("tinyTiM", null, null); + _testScoped((IScoped) occ); + } + + /** + * Tests against a name. + */ + public void testName() { + Topic topic = _tm.createTopic(); + TopicName name = topic.createTopicName("tinyTiM", null, null); + _testScoped((IScoped) name); + } + + /** + * Tests against a variant. + */ + public void testVariant() { + Topic topic = _tm.createTopic(); + TopicName name = topic.createTopicName("tinyTiM", null, null); + Variant variant = name.createVariant("tinyTiM", null); + _testScoped((IScoped) variant); + } + + /** + * Tests adding / removing themes. + * + * @param scoped The scoped Topic Maps construct to test. + */ + private void _testScoped(IScoped scoped) { + //TODO: This may fail in the future for variants + assertEquals(0, scoped.getScope().size()); + Topic theme1 = _tm.createTopic(); + scoped.addTheme(theme1); + assertEquals(1, scoped.getScope().size()); + assertTrue(scoped.getScope().contains(theme1)); + Topic theme2 = _tm.createTopic(); + assertFalse(scoped.getScope().contains(theme2)); + scoped.addTheme(theme2); + assertEquals(2, scoped.getScope().size()); + assertTrue(scoped.getScope().contains(theme1)); + assertTrue(scoped.getScope().contains(theme2)); + scoped.removeTheme(theme2); + assertEquals(1, scoped.getScope().size()); + assertTrue(scoped.getScope().contains(theme1)); + assertFalse(scoped.getScope().contains(theme2)); + scoped.removeTheme(theme1); + assertEquals(0, scoped.getScope().size()); + } +} Property changes on: tinytim/trunk/test/java/org/tinytim/TestScoped.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native Added: tinytim/trunk/test/java/org/tinytim/TestSignatureGenerator.java =================================================================== --- tinytim/trunk/test/java/org/tinytim/TestSignatureGenerator.java (rev 0) +++ tinytim/trunk/test/java/org/tinytim/TestSignatureGenerator.java 2008-04-20 12:06:28 UTC (rev 11) @@ -0,0 +1,117 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim; + +import org.tinytim.SignatureGenerator; +import org.tmapi.core.Association; +import org.tmapi.core.AssociationRole; +import org.tmapi.core.Occurrence; +import org.tmapi.core.Topic; +import org.tmapi.core.TopicName; +import org.tmapi.core.Variant; + +/** + * Tests against the {@link org.tinytim.SignatureGenerator}. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public class TestSignatureGenerator extends TinyTimTestCase { + + /** + * Tests if an association with no initialized properties returns the same + * signature. + */ + public void testAssociationBasic() { + Association assoc = _tm.createAssociation(); + Association assoc2 = _tm.createAssociation(); + assertFalse(assoc.getObjectId().equals(assoc2.getObjectId())); + String sig = SignatureGenerator.generateSignature(assoc); + assertEquals(sig, SignatureGenerator.generateSignature(assoc2)); + } + + /** + * Tests if a role with no initialized properties returns the same + * signature. + */ + public void testRoleBasic() { + Association assoc = _tm.createAssociation(); + AssociationRole role = assoc.createAssociationRole(null, null); + AssociationRole role2 = assoc.createAssociationRole(null, null); + assertFalse(role.getObjectId().equals(role2.getObjectId())); + String sig = SignatureGenerator.generateSignature(role); + assertEquals(sig, SignatureGenerator.generateSignature(role2)); + } + + /** + * Tests if an occurrence with no initialized properties returns the same + * signature. + */ + public void testOccurrenceBasic() { + Topic topic = _tm.createTopic(); + Occurrence occ = topic.createOccurrence((String) null, null, null); + Occurrence occ2 = topic.createOccurrence((String) null, null, null); + assertFalse(occ.getObjectId().equals(occ2.getObjectId())); + String sig = SignatureGenerator.generateSignature(occ); + assertEquals(sig, SignatureGenerator.generateSignature(occ2)); + } + + /** + * Tests if a name with no initialized properties returns the same + * signature. + */ + public void testNameBasic() { + Topic topic = _tm.createTopic(); + TopicName name = topic.createTopicName(null, null); + TopicName name2 = topic.createTopicName(null, null); + assertFalse(name.getObjectId().equals(name2.getObjectId())); + String sig = SignatureGenerator.generateSignature(name); + assertEquals(sig, SignatureGenerator.generateSignature(name2)); + } + + /** + * Tests if a variant with no initialized properties returns the same + * signature. + */ + public void testVariantBasic() { + Topic topic = _tm.createTopic(); + TopicName name = topic.createTopicName("tinyTiM", null); + Variant variant = name.createVariant("tiny Topic Maps", null); + String sig = SignatureGenerator.generateSignature(variant); + assertEquals(sig, SignatureGenerator.generateSignature(variant)); + } + + /** + * Tests if associations with the same type return the same signature. + */ + public void testAssociationTyped() { + Association assoc = _tm.createAssociation(); + String sigBefore = SignatureGenerator.generateSignature(assoc); + Topic type = _tm.createTopic(); + assoc.setType(type); + String sigAfter = SignatureGenerator.generateSignature(assoc); + assertFalse(sigBefore.equals(sigAfter)); + Association assoc2 = _tm.createAssociation(); + assertEquals(sigBefore, SignatureGenerator.generateSignature(assoc2)); + assoc2.setType(type); + assertEquals(sigAfter, SignatureGenerator.generateSignature(assoc2)); + } +} Property changes on: tinytim/trunk/test/java/org/tinytim/TestSignatureGenerator.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native Added: tinytim/trunk/test/java/org/tinytim/TestTMAPICore.java =================================================================== --- tinytim/trunk/test/java/org/tinytim/TestTMAPICore.java (rev 0) +++ tinytim/trunk/test/java/org/tinytim/TestTMAPICore.java 2008-04-20 12:06:28 UTC (rev 11) @@ -0,0 +1,45 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim; + +import org.tmapi.core.test.AllTMAPITests; + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * Runs the TMAPI core test suite against tinyTiM. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public class TestTMAPICore extends TMAPITestCase { + + public static void main(String[] args) { + junit.textui.TestRunner.run(suite()); + } + + public static Test suite() { + TestSuite suite = new TestSuite(); + suite.addTest(AllTMAPITests.suite()); + return suite; + } +} Property changes on: tinytim/trunk/test/java/org/tinytim/TestTMAPICore.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native Added: tinytim/trunk/test/java/org/tinytim/TestTMAPIIndex.java =================================================================== --- tinytim/trunk/test/java/org/tinytim/TestTMAPIIndex.java (rev 0) +++ tinytim/trunk/test/java/org/tinytim/TestTMAPIIndex.java 2008-04-20 12:06:28 UTC (rev 11) @@ -0,0 +1,45 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim; + +import org.tmapi.index.core.test.AllTMAPIIndexTests; + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * Runs the TMAPI index test suite against tinyTiM. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public class TestTMAPIIndex extends TMAPITestCase { + + public static void main(String[] args) { + junit.textui.TestRunner.run(suite()); + } + + public static Test suite() { + TestSuite suite = new TestSuite(); + suite.addTest(AllTMAPIIndexTests.suite()); + return suite; + } +} Property changes on: tinytim/trunk/test/java/org/tinytim/TestTMAPIIndex.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native Added: tinytim/trunk/test/java/org/tinytim/TestTopicMapSystemFactoryImpl.java =================================================================== --- tinytim/trunk/test/java/org/tinytim/TestTopicMapSystemFactoryImpl.java (rev 0) +++ tinytim/trunk/test/java/org/tinytim/TestTopicMapSystemFactoryImpl.java 2008-04-20 12:06:28 UTC (rev 11) @@ -0,0 +1,179 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.tinytim.ICollectionFactory; +import org.tinytim.JavaCollectionFactory; +import org.tinytim.Property; +import org.tinytim.TMAPIFeature; +import org.tinytim.TopicMapSystemImpl; +import org.tmapi.core.FeatureNotRecognizedException; +import org.tmapi.core.FeatureNotSupportedException; + +/** + * Tests against the {@link org.tinytim.TopicMapSystemFactoryImpl}. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public class TestTopicMapSystemFactoryImpl extends TinyTimTestCase { + + /** + * Tests the default feature values. + * + * @throws Exception + */ + public void testDefaultFeatureValues() throws Exception { + assertTrue(_sysFactory.getFeature(TMAPIFeature.NOTATION_URI)); + assertTrue(_sysFactory.getFeature(TMAPIFeature.XTM_1_1)); + assertFalse(_sysFactory.getFeature(TMAPIFeature.XTM_1_0)); + assertFalse(_sysFactory.getFeature(TMAPIFeature.READ_ONLY)); + assertFalse(_sysFactory.getFeature(TMAPIFeature.AUTOMERGE)); + assertFalse(_sysFactory.getFeature(TMAPIFeature.TNC)); + } + + + private void _setFeatureToAcceptedValue(String featureName, boolean value) throws Exception { + try { + _sysFactory.setFeature(featureName, value); + } + catch (FeatureNotSupportedException ex) { + fail("Unexpected exception while setting '" + featureName + "' to '" + value + "'"); + } + } + + private void _setFeatureToUnacceptedValue(String featureName, boolean value) throws Exception { + try { + _sysFactory.setFeature(featureName, value); + fail("Expected exception while setting '" + featureName + "' to '" + value + "'"); + } + catch (FeatureNotSupportedException ex) { + // noop. + } + } + + /** + * Tests if enabling / disabling of various features delivers the expected + * results. + * + * @throws Exception + */ + public void testSetFeatureValues() throws Exception { + _setFeatureToAcceptedValue(TMAPIFeature.NOTATION_URI, true); + _setFeatureToUnacceptedValue(TMAPIFeature.NOTATION_URI, false); + _setFeatureToAcceptedValue(TMAPIFeature.XTM_1_0, false); + _setFeatureToUnacceptedValue(TMAPIFeature.XTM_1_0, true); + _setFeatureToAcceptedValue(TMAPIFeature.XTM_1_1, true); + _setFeatureToUnacceptedValue(TMAPIFeature.XTM_1_1, false); + _setFeatureToAcceptedValue(TMAPIFeature.READ_ONLY, false); + _setFeatureToUnacceptedValue(TMAPIFeature.READ_ONLY, true); + _setFeatureToAcceptedValue(TMAPIFeature.AUTOMERGE, false); + _setFeatureToUnacceptedValue(TMAPIFeature.AUTOMERGE, true); + _setFeatureToAcceptedValue(TMAPIFeature.TNC, false); + _setFeatureToUnacceptedValue(TMAPIFeature.TNC, true); + } + + /** + * Tests if an unknown feature throws the expected exception. + * + * @throws Exception + */ + public void testUnrecognizedFeature() throws Exception { + try { + String unknownFeatureName = "http://www.semagia.com/tinyTiM/unknownTMAPIFeature"; + _sysFactory.setFeature(unknownFeatureName, true); + fail("Expected an exception while setting a unknown feature"); + } + catch (FeatureNotRecognizedException ex) { + // noop. + } + } + + /** + * Tests if the collection factory property is set. + * + * @throws Exception + */ + public void testCollectionFactoryProperty() throws Exception { + boolean troveAvailable = false; + try { + Class.forName("gnu.trove.THashSet"); + troveAvailable = true; + } + catch (Exception ex) { + // noop. + } + if (troveAvailable) { + assertEquals("org.tinytim.TroveCollectionFactory", _sysFactory.getProperty(Property.COLLECTION_FACTORY)); + } + else { + assertEquals("org.tinytim.JavaCollectionFactory", _sysFactory.getProperty(Property.COLLECTION_FACTORY)); + assertTrue(((TopicMapSystemImpl) _sysFactory.newTopicMapSystem()).getCollectionFactory() instanceof JavaCollectionFactory); + } + } + + /** + * Tests if the TopicMapSystemFactory creates automatically a default + * CollectionFactory iff the class name in the property is invaild / + * not resolvable. + * + * @throws Exception + */ + public void testCollectionFactoryFallback() throws Exception { + _sysFactory.setProperty(Property.COLLECTION_FACTORY, "a.non.existent.CollectionFactory"); + TopicMapSystemImpl sys = (TopicMapSystemImpl) _sysFactory.newTopicMapSystem(); + assertTrue(sys.getCollectionFactory() instanceof JavaCollectionFactory); + } + + /** + * Sets the setting of a custom {@link ICollectionFactory}. + * + * @throws Exception + */ + public void testCustomCollectionFactory() throws Exception { + _sysFactory.setProperty(Property.COLLECTION_FACTORY, MyCollectionFactory.class.getName()); + TopicMapSystemImpl sys = (TopicMapSystemImpl) _sysFactory.newTopicMapSystem(); + assertTrue(sys.getCollectionFactory() instanceof MyCollectionFactory); + } + + /** + * {@link ICollectionFactory} implementation that uses the Java collections. + */ + public static final class MyCollectionFactory implements ICollectionFactory { + public <K, V> Map<K, V> createMap() { + return new HashMap<K, V>(); + } + public <K, V> Map<K, V> createMap(int size) { + return createMap(); + } + public <E> Set<E> createSet(int size) { + return createSet(); + } + public <E> Set<E> createSet() { + return new HashSet<E>(); + } + } +} Property changes on: tinytim/trunk/test/java/org/tinytim/TestTopicMapSystemFactoryImpl.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native Added: tinytim/trunk/test/java/org/tinytim/TestTopicMerge.java =================================================================== --- tinytim/trunk/test/java/org/tinytim/TestTopicMerge.java (rev 0) +++ tinytim/trunk/test/java/org/tinytim/TestTopicMerge.java 2008-04-20 12:06:28 UTC (rev 11) @@ -0,0 +1,159 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim; + +import org.tmapi.core.Association; +import org.tmapi.core.AssociationRole; +import org.tmapi.core.Locator; +import org.tmapi.core.ModelConstraintException; +import org.tmapi.core.Topic; +import org.tmapi.core.TopicName; + +/** + * Tests merging of topics. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public class TestTopicMerge extends TinyTimTestCase { + + /** + * If topics reify different Topic Maps constructs they cannot be merged. + */ + public void testReifiedClash() { + Topic topic1 = _tm.createTopic(); + Topic topic2 = _tm.createTopic(); + Association assoc1 = _tm.createAssociation(); + Association assoc2 = _tm.createAssociation(); + Topic type1 = _tm.createTopic(); + Topic type2 = _tm.createTopic(); + assoc1.setType(type1); + assoc2.setType(type2); + ((IReifiable) assoc1).setReifier(topic1); + ((IReifiable) assoc2).setReifier(topic2); + assertEquals(type1, assoc1.getType()); + assertEquals(type2, assoc2.getType()); + assertEquals(topic1, assoc1.getReifier()); + assertEquals(topic2, assoc2.getReifier()); + try { + topic1.mergeIn(topic2); + fail("The topics reify different Topic Maps constructs and cannot be merged"); + } + catch (ModelConstraintException ex) { + // noop. + } + } + + /** + * Tests if a topic overtakes all roles played of the other topic. + */ + public void testRolePlaying() { + Topic topic1 = _tm.createTopic(); + Topic topic2 = _tm.createTopic(); + Association assoc = _tm.createAssociation(); + assoc.setType(_tm.createTopic()); + AssociationRole role = assoc.createAssociationRole(topic2, _tm.createTopic()); + assertEquals(4, _tm.getTopics().size()); + assertFalse(topic1.getRolesPlayed().contains(role)); + assertTrue(topic2.getRolesPlayed().contains(role)); + topic1.mergeIn(topic2); + assertEquals(3, _tm.getTopics().size()); + assertTrue(topic1.getRolesPlayed().contains(role)); + } + + /** + * Tests if the subject identifiers are overtaken. + */ + public void testIdentitySubjectIdentifier() { + Topic topic1 = _tm.createTopic(); + Topic topic2 = _tm.createTopic(); + Locator sid1 = _tm.createLocator("http://psi.exmaple.org/sid-1"); + Locator sid2 = _tm.createLocator("http://psi.exmaple.org/sid-2"); + topic1.addSubjectIdentifier(sid1); + topic2.addSubjectIdentifier(sid2); + assertTrue(topic1.getSubjectIdentifiers().contains(sid1)); + assertFalse(topic1.getSubjectIdentifiers().contains(sid2)); + assertFalse(topic2.getSubjectIdentifiers().contains(sid1)); + assertTrue(topic2.getSubjectIdentifiers().contains(sid2)); + topic1.mergeIn(topic2); + assertEquals(2, topic1.getSubjectIdentifiers().size()); + assertTrue(topic1.getSubjectIdentifiers().contains(sid1)); + assertTrue(topic1.getSubjectIdentifiers().contains(sid2)); + } + + /** + * Tests if the subject locator are overtaken. + */ + public void testIdentitySubjectLocator() { + Topic topic1 = _tm.createTopic(); + Topic topic2 = _tm.createTopic(); + Locator slo1 = _tm.createLocator("http://tinytim.sf.net"); + Locator slo2 = _tm.createLocator("http://tinytim.sourceforge.net"); + topic1.addSubjectLocator(slo1); + topic2.addSubjectLocator(slo2); + assertTrue(topic1.getSubjectLocators().contains(slo1)); + assertFalse(topic1.getSubjectLocators().contains(slo2)); + assertFalse(topic2.getSubjectLocators().contains(slo1)); + assertTrue(topic2.getSubjectLocators().contains(slo2)); + topic1.mergeIn(topic2); + assertEquals(2, topic1.getSubjectLocators().size()); + assertTrue(topic1.getSubjectLocators().contains(slo1)); + assertTrue(topic1.getSubjectLocators().contains(slo2)); + } + + /** + * Tests if the item identifiers are overtaken. + */ + public void testIdentityItemIdentifier() { + Topic topic1 = _tm.createTopic(); + Topic topic2 = _tm.createTopic(); + Locator iid1 = _tm.createLocator("http://tinytim.sf.net/test#1"); + Locator iid2 = _tm.createLocator("http://tinytim.sf.net/test#2"); + topic1.addSourceLocator(iid1); + topic2.addSourceLocator(iid2); + assertTrue(topic1.getSourceLocators().contains(iid1)); + assertFalse(topic1.getSourceLocators().contains(iid2)); + assertFalse(topic2.getSourceLocators().contains(iid1)); + assertTrue(topic2.getSourceLocators().contains(iid2)); + topic1.mergeIn(topic2); + assertEquals(2, topic1.getSourceLocators().size()); + assertTrue(topic1.getSourceLocators().contains(iid1)); + assertTrue(topic1.getSourceLocators().contains(iid2)); + } + + /** + * Tests if merging detects duplicate names. + */ + public void testDuplicateSuppressionName() { + Topic topic1 = _tm.createTopic(); + Topic topic2 = _tm.createTopic(); + TopicName name1 = topic1.createTopicName("tinyTiM", null, null); + TopicName name2 = topic2.createTopicName("tinyTiM", null, null); + TopicName name3 = topic2.createTopicName("tiny Topic Maps engine", null, null); + assertEquals(1, topic1.getTopicNames().size()); + assertTrue(topic1.getTopicNames().contains(name1)); + assertEquals(2, topic2.getTopicNames().size()); + assertTrue(topic2.getTopicNames().contains(name2)); + assertTrue(topic2.getTopicNames().contains(name3)); + topic1.mergeIn(topic2); + assertEquals(2, topic1.getTopicNames().size()); + } +} Property changes on: tinytim/trunk/test/java/org/tinytim/TestTopicMerge.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native Added: tinytim/trunk/test/java/org/tinytim/TestTopicMergeDetection.java =================================================================== --- tinytim/trunk/test/java/org/tinytim/TestTopicMergeDetection.java (rev 0) +++ tinytim/trunk/test/java/org/tinytim/TestTopicMergeDetection.java 2008-04-20 12:06:28 UTC (rev 11) @@ -0,0 +1,141 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim; + +import org.tmapi.core.Locator; +import org.tmapi.core.Topic; +import org.tmapi.core.TopicsMustMergeException; + +/** + * Tests if merging situations are detected. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public class TestTopicMergeDetection extends TinyTimTestCase { + + /** + * Tests if adding a duplicate subject identifier is detected. + */ + public void testExistingSubjectIdentifier() { + Topic topic1 = _tm.createTopic(); + Topic topic2 = _tm.createTopic(); + Locator loc = _tm.createLocator("http://sf.net/projects/tinytim"); + topic1.addSubjectIdentifier(loc); + assertTrue(topic1.getSubjectIdentifiers().contains(loc)); + assertEquals(topic1, _tm.getTopicBySubjectIdentifier(loc)); + try { + topic2.addSubjectIdentifier(loc); + fail("The duplicate subject identifier '" + loc + "' is not detected"); + } + catch (TopicsMustMergeException ex) { + // noop. + } + } + + /** + * Tests if adding a duplicate subject identifier on the SAME topic is ignored. + */ + public void testExistingSubjectIdentifierLegal() { + Topic topic1 = _tm.createTopic(); + Locator loc = _tm.createLocator("http://sf.net/projects/tinytim"); + topic1.addSubjectIdentifier(loc); + assertEquals(1, topic1.getSubjectIdentifiers().size()); + assertTrue(topic1.getSubjectIdentifiers().contains(loc)); + assertEquals(topic1, _tm.getTopicBySubjectIdentifier(loc)); + topic1.addSubjectIdentifier(loc); + assertEquals(1, topic1.getSubjectIdentifiers().size()); + } + + /** + * Tests if adding a duplicate subject locator is detected. + */ + public void testExistingSubjectLocator() { + Topic topic1 = _tm.createTopic(); + Topic topic2 = _tm.createTopic(); + Locator loc = _tm.createLocator("http://sf.net/projects/tinytim"); + topic1.addSubjectLocator(loc); + assertTrue(topic1.getSubjectLocators().contains(loc)); + assertEquals(topic1, _tm.getTopicBySubjectLocator(loc)); + try { + topic2.addSubjectLocator(loc); + fail("The duplicate subject locator '" + loc + "' is not detected"); + } + catch (TopicsMustMergeException ex) { + // noop. + } + } + + /** + * Tests if adding a duplicate subject locator at the SAME topic is ignored. + */ + public void testExistingSubjectLocatorLegal() { + Topic topic1 = _tm.createTopic(); + Locator loc = _tm.createLocator("http://sf.net/projects/tinytim"); + topic1.addSubjectLocator(loc); + assertEquals(1, topic1.getSubjectLocators().size()); + assertTrue(topic1.getSubjectLocators().contains(loc)); + assertEquals(topic1, _tm.getTopicBySubjectLocator(loc)); + topic1.addSubjectLocator(loc); + assertEquals(1, topic1.getSubjectLocators().size()); + } + + /** + * Tests if adding a subject identifier equals to an item identifier is detected. + */ + public void testExistingSubjectIdentifierItemIdentifier() { + Topic topic1 = _tm.createTopic(); + Topic topic2 = _tm.createTopic(); + Locator loc = _tm.createLocator("http://sf.net/projects/tinytim"); + topic1.addSubjectIdentifier(loc); + assertTrue(topic1.getSubjectIdentifiers().contains(loc)); + assertEquals(topic1, _tm.getTopicBySubjectIdentifier(loc)); + try { + topic2.addSourceLocator(loc); + fail("A topic with a subject identifier equals to the item identifier '" + loc + "' exists."); + } + catch (TopicsMustMergeException ex) { + // noop. + } + } + + /** + * Tests if adding a subject identifier equals to an item identifier + * on the SAME topic is accepted + */ + public void testExistingSubjectIdentifierItemIdentifierLegal() { + Topic topic1 = _tm.createTopic(); + Locator loc = _tm.createLocator("http://sf.net/projects/tinytim"); + topic1.addSubjectIdentifier(loc); + assertEquals(1, topic1.getSubjectIdentifiers().size()); + assertEquals(0, topic1.getSourceLocators().size()); + assertTrue(topic1.getSubjectIdentifiers().contains(loc)); + assertEquals(topic1, _tm.getTopicBySubjectIdentifier(loc)); + assertNull(_tm.getObjectByItemIdentifier(loc)); + topic1.addSourceLocator(loc); + assertEquals(1, topic1.getSubjectIdentifiers().size()); + assertEquals(1, topic1.getSourceLocators().size()); + assertTrue(topic1.getSubjectIdentifiers().contains(loc)); + assertTrue(topic1.getSourceLocators().contains(loc)); + assertEquals(topic1, _tm.getTopicBySubjectIdentifier(loc)); + assertEquals(topic1, _tm.getObjectByItemIdentifier(loc)); + } +} Property changes on: tinytim/trunk/test/java/org/tinytim/TestTopicMergeDetection.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native Added: tinytim/trunk/test/java/org/tinytim/TestTyped.java =================================================================== --- tinytim/trunk/test/java/org/tinytim/TestTyped.java (rev 0) +++ tinytim/trunk/test/java/org/tinytim/TestTyped.java 2008-04-20 12:06:28 UTC (rev 11) @@ -0,0 +1,111 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim; + +import org.tmapi.core.Association; +import org.tmapi.core.AssociationRole; +import org.tmapi.core.Occurrence; +import org.tmapi.core.Topic; +import org.tmapi.core.TopicMap; +import org.tmapi.core.TopicName; +import org.tmapi.core.Variant; + +/** + * Tests against the {@link org.tinytim.ITyped} interface. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public class TestTyped extends TinyTimTestCase { + + /** + * Tests if a Topic Maps construct is an instance of ITyped. + */ + public void testInstanceOf() { + assertFalse(((TopicMap)_tm) instanceof ITyped); + Topic topic = _tm.createTopic(); + assertFalse(topic instanceof ITyped); + Association assoc = _tm.createAssociation(); + assertTrue(assoc instanceof ITyped); + AssociationRole role = assoc.createAssociationRole(_tm.createTopic(), _tm.createTopic()); + assertTrue(role instanceof ITyped); + Occurrence occ = topic.createOccurrence("tinyTiM", null, null); + assertTrue(occ instanceof ITyped); + TopicName name = topic.createTopicName("tinyTiM", null); + assertTrue(name instanceof ITyped); + Variant variant = name.createVariant("tinyTiM", null); + assertFalse(variant instanceof ITyped); + } + + /** + * Tests setting and getting the type of an association. + */ + public void testAssociation() { + _testSetGet((ITyped)_tm.createAssociation()); + } + + /** + * Tests setting and getting the type of a role. + */ + public void testRole() { + Association assoc = _tm.createAssociation(); + AssociationRole role = assoc.createAssociationRole(_tm.createTopic(), _tm.createTopic()); + _testSetGet((ITyped)role); + } + + /** + * Tests setting and getting the type of an occurrence. + */ + public void testOccurrence() { + Topic topic = _tm.createTopic(); + Occurrence occ = topic.createOccurrence("tinyTiM", null, null); + _testSetGet((ITyped)occ); + } + + /** + * Tests setting and getting the type of a name. + */ + public void testName() { + Topic topic = _tm.createTopic(); + TopicName name = topic.createTopicName("tinyTiM", null, null); + _testSetGet((ITyped)name); + } + + /** + * Tests setting and getting the type of a typed Topic Maps construct. + * + * @param typed The Topic Maps construct to test. + */ + private void _testSetGet(ITyped typed) { + Topic type = _tm.createTopic(); + Topic type2 = _tm.createTopic(); + assertFalse(type.equals(typed.getType())); + assertFalse(type2.equals(typed.getType())); + typed.setType(type); + assertTrue(type.equals(typed.getType())); + assertFalse(type2.equals(typed.getType())); + typed.setType(type2); + assertFalse(type.equals(typed.getType())); + assertTrue(type2.equals(typed.getType())); + typed.setType(null); + assertNull(typed.getType()); + } +} Property changes on: tinytim/trunk/test/java/org/tinytim/TestTyped.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native Added: tinytim/trunk/test/java/org/tinytim/TinyTimTestCase.java =================================================================== --- tinytim/trunk/test/java/org/tinytim/TinyTimTestCase.java (rev 0) +++ tinytim/trunk/test/java/org/tinytim/TinyTimTestCase.java 2008-04-20 12:06:28 UTC (rev 11) @@ -0,0 +1,71 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim; + +import org.tinytim.TopicMapImpl; +import org.tinytim.TopicMapSystemFactoryImpl; +import org.tinytim.TopicMapSystemImpl; +import org.tmapi.core.Locator; + +import junit.framework.TestCase; + +/** + * Base class of all tinyTiM-specific test cases. + * + * This class sets up a default {@link org.tinytim.TopicMapSystemFactoryImpl}, + * a {@link org.tinytim.TopicMapSystemImpl}, and a + * {@link org.tinytim.TopicMapImpl}. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public class TinyTimTestCase extends TestCase { + + protected static final String _IRI = "http://www.semagia.com/tinyTiM/testTopicMap/"; + protected Locator _base; + protected TopicMapImpl _tm; + protected TopicMapSystemImpl _sys; + protected TopicMapSystemFactoryImpl _sysFactory; + + /* (non-Javadoc) + * @see junit.framework.TestCase#setUp() + */ + @Override + protected void setUp() throws Exception { + super.setUp(); + _sysFactory = new TopicMapSystemFactoryImpl(); + _sys = (TopicMapSystemImpl) _sysFactory.newTopicMapSystem(); + _tm = (TopicMapImpl) _sys.createTopicMap(_IRI); + _base = _tm.getBaseLocator(); + } + + /* (non-Javadoc) + * @see junit.framework.TestCase#tearDown() + */ + @Override + protected void tearDown() throws Exception { + super.tearDown(); + _sysFactory = null; + _sys = null; + _tm = null; + } + +} Property changes on: tinytim/trunk/test/java/org/tinytim/TinyTimTestCase.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-04-20 13:37:15
|
Revision: 12 http://tinytim.svn.sourceforge.net/tinytim/?rev=12&view=rev Author: lheuer Date: 2008-04-20 06:23:18 -0700 (Sun, 20 Apr 2008) Log Message: ----------- Initial import of classes / interfaces which are considered as stable Added Paths: ----------- tinytim/trunk/main/ tinytim/trunk/main/java/ tinytim/trunk/main/java/org/ tinytim/trunk/main/java/org/tinytim/ tinytim/trunk/main/java/org/tinytim/Event.java tinytim/trunk/main/java/org/tinytim/ICollectionFactory.java tinytim/trunk/main/java/org/tinytim/IConstruct.java tinytim/trunk/main/java/org/tinytim/IEventHandler.java tinytim/trunk/main/java/org/tinytim/IEventPublisher.java tinytim/trunk/main/java/org/tinytim/IReifiable.java tinytim/trunk/main/java/org/tinytim/JavaCollectionFactory.java tinytim/trunk/main/java/org/tinytim/Property.java tinytim/trunk/main/java/org/tinytim/SignatureGenerator.java tinytim/trunk/main/java/org/tinytim/TMAPIFeature.java tinytim/trunk/main/java/org/tinytim/TroveCollectionFactory.java Added: tinytim/trunk/main/java/org/tinytim/Event.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/Event.java (rev 0) +++ tinytim/trunk/main/java/org/tinytim/Event.java 2008-04-20 13:23:18 UTC (rev 12) @@ -0,0 +1,156 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim; + +/** + * Event constants. + * + * All events are sent before a change happens. This allows to check + * some constraints. + * + * This class is not meant to be used outside of the tinyTiM package. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public enum Event { + + /** + * Notification that a topic should be added. + */ + ADD_TOPIC, + /** + * Notification that a topic should be removed. + */ + REMOVE_TOPIC, + /** + * Notification that an association should be added. + */ + ADD_ASSOCIATION, + /** + * Notification that an association should be removed. + */ + REMOVE_ASSOCIATION, + /** + * Notification that a role should be added. + */ + ADD_ROLE, + /** + * Notification that a role should be removed. + */ + REMOVE_ROLE, + /** + * Notification that an occurrence should be added. + */ + ADD_OCCURRENCE, + /** + * Notification that an occurrence should be removed. + */ + REMOVE_OCCURRENCE, + /** + * Notification that a name should be added. + */ + ADD_NAME, + /** + * Notification that a name should be removed. + */ + REMOVE_NAME, + /** + * Notification that a variant should be added. + */ + ADD_VARIANT, + /** + * Notification that a variant should be removed. + */ + REMOVE_VARIANT, + + /** + * Notification that a subject identifier should be added. + */ + ADD_SID, + /** + * Notification that a subject identifier should be removed. + */ + REMOVE_SID, + /** + * Notification that a subject locator should be added. + */ + ADD_SLO, + /** + * Notification that a subject locator should be removed. + */ + REMOVE_SLO, + /** + * Notification that an item identifier should be added. + */ + ADD_IID, + /** + * Notification that an item identifier should be removed. + */ + REMOVE_IID, + + /** + * Notification that a type should be added to a topic. + */ + ADD_TYPE, + /** + * Notification that a type should be removed from a topic. + */ + REMOVE_TYPE, + /** + * Notification that the type of a {@link ITyped} construct should be set. + */ + SET_TYPE, + + /** + * Notification that a theme should be added to a {@link IScoped} construct. + */ + ADD_THEME, + /** + * Notification that a theme should be removed from a + * {@link IScoped} construct. + */ + REMOVE_THEME, + + /** + * Notification that the value of a name, an occurrence or variant + * should be set. + */ + SET_VALUE, + + /** + * Notification that the player of a role should be set. + */ + SET_PLAYER, + + /** + * Notification that the reifier of a {@link IReifiable} construct + * should be set. + */ + SET_REIFIER, + + /** + * Notification that the "resource" of an occurrence or variant should be + * set. + */ + SET_LOCATOR; //TODO: Remove this once we have a TMDM-compatible version + +} Property changes on: tinytim/trunk/main/java/org/tinytim/Event.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native Added: tinytim/trunk/main/java/org/tinytim/ICollectionFactory.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/ICollectionFactory.java (rev 0) +++ tinytim/trunk/main/java/org/tinytim/ICollectionFactory.java 2008-04-20 13:23:18 UTC (rev 12) @@ -0,0 +1,72 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim; + +import java.util.Map; +import java.util.Set; + +/** + * Factory for collections. + * + * Implementations of this interface must provide a default constructor. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public interface ICollectionFactory { + + /** + * Creates a Set with the specified initial <code>size</code>. + * + * @param <E> + * @param size The initial capacity. + * @return + */ + <E> Set<E> createSet(int size); + + /** + * Creates a Set. + * + * @param <E> + * @return + */ + <E> Set<E> createSet(); + + /** + * Creates a Map. + * + * @param <K> + * @param <V> + * @return + */ + <K, V> Map<K, V> createMap(); + + /** + * Creates a Map with the specified initial <code>size</code>. + * + * @param <K> + * @param <V> + * @param size The initial capacity. + * @return + */ + <K, V> Map<K, V> createMap(int size); + +} Property changes on: tinytim/trunk/main/java/org/tinytim/ICollectionFactory.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native Added: tinytim/trunk/main/java/org/tinytim/IConstruct.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/IConstruct.java (rev 0) +++ tinytim/trunk/main/java/org/tinytim/IConstruct.java 2008-04-20 13:23:18 UTC (rev 12) @@ -0,0 +1,66 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim; + +import java.util.Set; + +import org.tmapi.core.Locator; +import org.tmapi.core.TopicMapObject; + +/** + * The Topic Maps construct. + * + * This interface is not meant to be used outside of the tinyTiM package. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public interface IConstruct extends TopicMapObject { + + /** + * Returns the parent of the Topic Maps construct. + * + * @return The parent of a Topic Maps construct or <code>null</code>. + */ + public IConstruct getParent(); + + /** + * Returns the item identifiers of the Topic Maps construct. + * + * @return A (maybe empty) immutable Set of item identifiers. + */ + public Set<Locator> getItemIdentifiers(); + + /** + * Adds an item identifier to the Topic Maps construct. + * + * @param itemIdentifier The item identifier to add. + */ + public void addItemIdentifier(Locator itemIdentifier); + + /** + * Removes an item identifier from the Topic Maps construct. + * + * @param itemIdentifier The item identifier to remove. + */ + public void removeItemIdentifier(Locator itemIdentifier); + +} Property changes on: tinytim/trunk/main/java/org/tinytim/IConstruct.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native Added: tinytim/trunk/main/java/org/tinytim/IEventHandler.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/IEventHandler.java (rev 0) +++ tinytim/trunk/main/java/org/tinytim/IEventHandler.java 2008-04-20 13:23:18 UTC (rev 12) @@ -0,0 +1,47 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim; + +/** + * Event handler that is able to handle Topic Maps events. + * + * This interface is not meant to be used outside of the tinyTiM package. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public interface IEventHandler { + + /** + * Callback method if a {@link IEventPublisher} sends an event to which + * this handler is subscribed to. + * + * @param evt The event. + * @param sender The sender of the event (this is not necessarily the + * publisher). + * @param oldValue The old value or <code>null</code> if the old value + * is not available or was <code>null</code>. + * @param newValue The new value or <code>null</code> if the new value + * is not available or should become <code>null</code>. + */ + public void handleEvent(Event evt, IConstruct sender, Object oldValue, Object newValue); + +} Property changes on: tinytim/trunk/main/java/org/tinytim/IEventHandler.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native Added: tinytim/trunk/main/java/org/tinytim/IEventPublisher.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/IEventPublisher.java (rev 0) +++ tinytim/trunk/main/java/org/tinytim/IEventPublisher.java 2008-04-20 13:23:18 UTC (rev 12) @@ -0,0 +1,48 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim; + +/** + * Publisher for Topic Maps events. + * + * This interface is not meant to be used outside of the tinyTiM package. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public interface IEventPublisher { + + /** + * Subscribes the handler for the specified event. + * + * @param event The event of interesst. + * @param handler The event handler. + */ + public void subscribe(Event event, IEventHandler handler); + + /** + * Removes the handler from the publisher. + * + * @param event The event. + * @param handler The event handler. + */ + public void unsubscribe(Event event, IEventHandler handler); +} Property changes on: tinytim/trunk/main/java/org/tinytim/IEventPublisher.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native Added: tinytim/trunk/main/java/org/tinytim/IReifiable.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/IReifiable.java (rev 0) +++ tinytim/trunk/main/java/org/tinytim/IReifiable.java 2008-04-20 13:23:18 UTC (rev 12) @@ -0,0 +1,52 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim; + +import org.tmapi.core.Topic; + +/** + * Reifiable Topic Maps construct. + * + * Every Topic Maps construct != topic is reifiable. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public interface IReifiable extends IConstruct { + + /** + * Returns the reifier of this construct. + * + * @return The topic that reifies this construct or <code>null</code> if + * this construct has no reifier. + */ + public Topic getReifier(); + + /** + * Sets the reifier of this construct. + * + * If the <code>reifier</code> reifies another Topic Maps construct, a + * {@link org.tmapi.core.ModelConstraintException} is thrown. + * + * @param reifier The reifier or <code>null</code>. + */ + public void setReifier(Topic reifier); +} Property changes on: tinytim/trunk/main/java/org/tinytim/IReifiable.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native Added: tinytim/trunk/main/java/org/tinytim/JavaCollectionFactory.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/JavaCollectionFactory.java (rev 0) +++ tinytim/trunk/main/java/org/tinytim/JavaCollectionFactory.java 2008-04-20 13:23:18 UTC (rev 12) @@ -0,0 +1,64 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * {@link ICollectionFactory} which uses the standard Java collections. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +final class JavaCollectionFactory implements ICollectionFactory { + + /* (non-Javadoc) + * @see org.tinytim.ICollectionFactory#createMap(int) + */ + public <K, V> Map<K, V> createMap(int size) { + return new HashMap<K, V>(size); + } + + /* (non-Javadoc) + * @see org.tinytim.ICollectionFactory#createMap() + */ + public <K, V> Map<K, V> createMap() { + return new HashMap<K, V>(); + } + + /* (non-Javadoc) + * @see org.tinytim.ICollectionFactory#createSet(int) + */ + public <E> Set<E> createSet(int size) { + return new HashSet<E>(size); + } + + /* (non-Javadoc) + * @see org.tinytim.ICollectionFactory#createSet() + */ + public <E> Set<E> createSet() { + return new HashSet<E>(); + } + +} Property changes on: tinytim/trunk/main/java/org/tinytim/JavaCollectionFactory.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native Added: tinytim/trunk/main/java/org/tinytim/Property.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/Property.java (rev 0) +++ tinytim/trunk/main/java/org/tinytim/Property.java 2008-04-20 13:23:18 UTC (rev 12) @@ -0,0 +1,44 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim; + +/** + * Provides constants for all tinyTiM-specific TMAPI properties. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public final class Property { + + private Property() { + // noop. + } + + /** + * Property which indicates the {@link org.tinytim.ICollectionFactory} to use. + * + * The default value of this property depends on the environment: If + * the <a href="http://trove4j.sourceforge.net/">Trove4J</a> lib is found, + * that lib used, otherwise a collection factory which depends on the + * default Java collections. + */ + public static final String COLLECTION_FACTORY = "org.tinytim.CollectionFactory"; +} Property changes on: tinytim/trunk/main/java/org/tinytim/Property.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native Added: tinytim/trunk/main/java/org/tinytim/SignatureGenerator.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/SignatureGenerator.java (rev 0) +++ tinytim/trunk/main/java/org/tinytim/SignatureGenerator.java 2008-04-20 13:23:18 UTC (rev 12) @@ -0,0 +1,199 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim; + +import java.util.Arrays; +import java.util.Set; + +import org.tmapi.core.Association; +import org.tmapi.core.AssociationRole; +import org.tmapi.core.Occurrence; +import org.tmapi.core.ScopedObject; +import org.tmapi.core.Topic; +import org.tmapi.core.TopicName; +import org.tmapi.core.Variant; + +/** + * Generates signatures for Topic Maps constructs. + * + * This class can be used to detect duplicates: If two Topic Maps constructs + * have the same signature, they should be merged (if they belong to the same + * parent). + * + * Neither the topic map, the parent, the reifier, nor item identifiers + * are taken into account. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +final class SignatureGenerator { + + private SignatureGenerator() { + // noop. + } + + /** + * Returns the signature of an association. + * + * Beside of the type and scope of the association, the roles are + * taken into account. + * The parent is not taken into account. + * + * @param assoc The association to generate the signature for. + * @return The association's signature. + */ + @SuppressWarnings("unchecked") + public static String generateSignature(Association assoc) { + StringBuilder sb = new StringBuilder(); + sb.append(_generateTypeSignature((ITyped)assoc)) + .append('s') + .append(_generateScopeSignature((IScoped)assoc)) + .append('.'); + Set<AssociationRole> roles = assoc.getAssociationRoles(); + String[] roleSigs = new String[roles.size()]; + int i = 0; + for (AssociationRole role : roles) { + roleSigs[i++] = generateSignature(role); + } + Arrays.sort(roleSigs); + for (String sig : roleSigs) { + sb.append(sig) + .append('.'); + } + return sb.toString(); + } + + /** + * Generates the signature of a role. + * + * @param role The role to generate the signature for. + * @return The role's signature. + */ + public static String generateSignature(AssociationRole role) { + StringBuilder sb = new StringBuilder(); + sb.append(_generateTypeSignature((ITyped)role)) + .append('p') + .append(role.getPlayer() == null ? "" : role.getPlayer().getObjectId()); + return sb.toString(); + } + + /** + * Generates the signature for an occurrence. + * + * @param occ The occurrence to create the signature for. + * @return The signature of the occurrence. + */ + public static String generateSignature(Occurrence occ) { + StringBuilder sb = new StringBuilder(); + sb.append(_generateTypeSignature((ITyped)occ)) + .append('s') + .append(_generateScopeSignature((IScoped)occ)) + .append('v') + .append(_generateDataSignature((IDatatypeAwareConstruct) occ)); + return sb.toString(); + } + + /** + * Generates a signature for the specified <code>name</code>. + * + * The parent and the variants are not taken into account. + * + * @param name The name to generate the signature for. + * @return A signature for the name. + */ + public static String generateSignature(TopicName name) { + StringBuilder sb = new StringBuilder(); + sb.append(_generateTypeSignature((ITyped)name)) + .append('s') + .append(_generateScopeSignature((IScoped)name)) + .append('v') + .append(name.getValue() == null ? "" : name.getValue()); + return sb.toString(); + } + + /** + * Generates a signature for the specified <code>variant</code>. + * + * @param variant The variant to generate the signature for. + * @return A signature for the variant. + */ + public static String generateSignature(Variant variant) { + StringBuilder sb = new StringBuilder(); + sb.append(_generateScopeSignature((IScoped)variant)) + .append('v') + .append(_generateDataSignature((IDatatypeAwareConstruct) variant)); + return sb.toString(); + } + + /** + * Returns a signature for a value/datatype pair. + * + * @param construct An occurrence or variant. + * @return The signature. + */ + private static String _generateDataSignature(IDatatypeAwareConstruct construct) { + StringBuilder sb = new StringBuilder(); + sb.append(construct.getValue2()) + .append('.') + .append(construct.getDatatype().getReference()); + return sb.toString(); + } + + /** + * Returns a signature for the type of a typed Topic Maps construct. + * + * @param typed The typed Topic Maps construct. + * @return The signature. + */ + private static String _generateTypeSignature(ITyped typed) { + Topic type = typed.getType(); + return type == null ? "" : type.getObjectId(); + } + + /** + * Returns a signature for the scope of a scoped Topic Maps construct. + * + * This function returns the signature for the scope, only! No other + * properties of the scoped Topic Maps construct are taken into account! + * + * @param scoped The scoped Topic Maps construct. + * @return The signature. + */ + private static String _generateScopeSignature(IScoped scoped) { + Set<Topic> scope = scoped.getScope(); + if (scope.isEmpty()) { + return ""; + } + String[] ids = new String[scope.size()]; + int i = 0; + for (Topic topic : scope) { + ids[i++] = topic.getObjectId(); + } + Arrays.sort(ids); + StringBuilder sb = new StringBuilder(); + for (String id : ids) { + sb.append(id) + .append('.'); + } + return sb.toString(); + } + +} Property changes on: tinytim/trunk/main/java/org/tinytim/SignatureGenerator.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native Added: tinytim/trunk/main/java/org/tinytim/TMAPIFeature.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/TMAPIFeature.java (rev 0) +++ tinytim/trunk/main/java/org/tinytim/TMAPIFeature.java 2008-04-20 13:23:18 UTC (rev 12) @@ -0,0 +1,92 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim; + +/** + * This class provides access to the feature strings that TMAPI-compatible + * Topic Maps processors must recognize (but not necessarily support). + * + * Copied from the TMAPIX-project. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +final class TMAPIFeature { + + private TMAPIFeature() { + // noop. + } + + private static final String _FEATURE_BASE = "http://tmapi.org/features/"; + + /** + * An implementation which supports this feature can process locator + * addresses in URI notation as defined by RFC 2396. + * + * An implementation that supports URI notation locators MUST support + * the expansion of relative URIs that use a hierarchical URI scheme to + * fully specified URIs against a specified base URI, and MAY support + * the expansion of relative URIs that use other scheme-specific mechansims + * for relative URI expansion. + */ + public static final String NOTATION_URI= _FEATURE_BASE + "notation/URI"; + + /** + * An implementation which supports this feature supports the Topic Maps + * data model defined by the XTM 1.0 specification. + */ + public static final String XTM_1_0 = _FEATURE_BASE + "model/xtm1.0"; + + /** + * An implementation which supports this feature supports the + * <a href="http://www.isotopicmaps.org/sam/sam-model/">Topic Maps + * Data Model (TMDM) ISO/IEC 13250-2</a>. + */ + public static final String XTM_1_1 = _FEATURE_BASE + "model/xtm1.1"; + + /** + * An implementation which supports this feature MUST detect when two + * topic instances have topic names which match both in the scope of the + * name and the value of the name string, and, if XTM 1.1 is supported, + * the types are equal. Topics which have matching names must either be + * merged or a {@link org.tmapi.core.TopicsMustMergeException} must be + * raised, depending on the value of the + * <a href="http://tmapi.org/features/automerge">http://tmapi.org/features/automerge</a> + * feature. + */ + public static final String TNC = _FEATURE_BASE + "merge/byTopicName"; + + /** + * This feature indicates that the underlying + * {@link org.tmapi.core.TopicMapSystem} cannot be modified. + */ + public static final String READ_ONLY = _FEATURE_BASE + "readOnly"; + + /** + * If an implementation supports this feature, then whenever the + * implementation detects that two Topics should be merged (by one or more + * of the merge features defined under + * <a href="http://tmapi.org/features/merge/">http://tmapi.org/features/merge/</a>), + * then the implementation MUST merge the properties of these two Topics + * automatically and transparently to the API client. + */ + public static final String AUTOMERGE = _FEATURE_BASE + "automerge"; +} Property changes on: tinytim/trunk/main/java/org/tinytim/TMAPIFeature.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native Added: tinytim/trunk/main/java/org/tinytim/TroveCollectionFactory.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/TroveCollectionFactory.java (rev 0) +++ tinytim/trunk/main/java/org/tinytim/TroveCollectionFactory.java 2008-04-20 13:23:18 UTC (rev 12) @@ -0,0 +1,66 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim; + +import gnu.trove.THashMap; +import gnu.trove.THashSet; + +import java.util.Map; +import java.util.Set; + +/** + * {@link ICollectionFactory} which uses the + * <a href="http://sourceforge.net/projects/trove4j/">Trove library </a>. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +final class TroveCollectionFactory implements ICollectionFactory { + + /* (non-Javadoc) + * @see org.tinytim.ICollectionFactory#createMap(int) + */ + public <K, V> Map<K, V> createMap(int size) { + return new THashMap<K,V>(size); + } + + /* (non-Javadoc) + * @see org.tinytim.ICollectionFactory#createMap() + */ + public <K, V> Map<K, V> createMap() { + return new THashMap<K, V>(); + } + + /* (non-Javadoc) + * @see org.tinytim.ICollectionFactory#createSet(int) + */ + public <E> Set<E> createSet(int size) { + return new THashSet<E>(size); + } + + /* (non-Javadoc) + * @see org.tinytim.ICollectionFactory#createSet() + */ + public <E> Set<E> createSet() { + return new THashSet<E>(); + } + +} Property changes on: tinytim/trunk/main/java/org/tinytim/TroveCollectionFactory.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-04-21 13:52:44
|
Revision: 21 http://tinytim.svn.sourceforge.net/tinytim/?rev=21&view=rev Author: lheuer Date: 2008-04-21 06:51:38 -0700 (Mon, 21 Apr 2008) Log Message: ----------- Moved main and test into the right directory Modified Paths: -------------- tinytim/trunk/src/main/java/org/tinytim/Event.java tinytim/trunk/src/main/java/org/tinytim/ICollectionFactory.java tinytim/trunk/src/main/java/org/tinytim/IConstruct.java tinytim/trunk/src/main/java/org/tinytim/IEventHandler.java tinytim/trunk/src/main/java/org/tinytim/IEventPublisher.java tinytim/trunk/src/main/java/org/tinytim/IRI.java tinytim/trunk/src/main/java/org/tinytim/IReifiable.java tinytim/trunk/src/main/java/org/tinytim/IScoped.java tinytim/trunk/src/main/java/org/tinytim/ITyped.java tinytim/trunk/src/main/java/org/tinytim/JavaCollectionFactory.java tinytim/trunk/src/main/java/org/tinytim/Property.java tinytim/trunk/src/main/java/org/tinytim/Scoped.java tinytim/trunk/src/main/java/org/tinytim/TMAPIFeature.java tinytim/trunk/src/main/java/org/tinytim/TopicMapSystemFactoryImpl.java tinytim/trunk/src/main/java/org/tinytim/TroveCollectionFactory.java tinytim/trunk/src/main/java/org/tinytim/Typed.java tinytim/trunk/src/main/java/org/tinytim/index/IIndex.java tinytim/trunk/src/main/java/org/tinytim/index/IScopedIndex.java tinytim/trunk/src/main/java/org/tinytim/index/ITypeInstanceIndex.java tinytim/trunk/src/main/java/org/tinytim/index/IndexFlagsImpl.java tinytim/trunk/src/test/java/org/tinytim/TMAPITestCase.java tinytim/trunk/src/test/java/org/tinytim/TestConstruct.java tinytim/trunk/src/test/java/org/tinytim/TestReifiable.java tinytim/trunk/src/test/java/org/tinytim/TestScoped.java tinytim/trunk/src/test/java/org/tinytim/TestSignatureGenerator.java tinytim/trunk/src/test/java/org/tinytim/TestTMAPICore.java tinytim/trunk/src/test/java/org/tinytim/TestTMAPIIndex.java tinytim/trunk/src/test/java/org/tinytim/TestTopicMapSystemFactoryImpl.java tinytim/trunk/src/test/java/org/tinytim/TestTopicMerge.java tinytim/trunk/src/test/java/org/tinytim/TestTopicMergeDetection.java tinytim/trunk/src/test/java/org/tinytim/TestTyped.java tinytim/trunk/src/test/java/org/tinytim/TinyTimTestCase.java Added Paths: ----------- tinytim/trunk/src/main/ tinytim/trunk/src/main/java/ tinytim/trunk/src/test/ tinytim/trunk/src/test/java/ Removed Paths: ------------- tinytim/trunk/main/ tinytim/trunk/src/main/java/ tinytim/trunk/src/test/java/ tinytim/trunk/test/ Copied: tinytim/trunk/src/main (from rev 12, tinytim/trunk/main) Copied: tinytim/trunk/src/main/java (from rev 20, tinytim/trunk/main/java) Modified: tinytim/trunk/src/main/java/org/tinytim/Event.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/Event.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/main/java/org/tinytim/Event.java 2008-04-21 13:51:38 UTC (rev 21) @@ -29,7 +29,7 @@ * This class is not meant to be used outside of the tinyTiM package. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public enum Event { Modified: tinytim/trunk/src/main/java/org/tinytim/ICollectionFactory.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/ICollectionFactory.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/main/java/org/tinytim/ICollectionFactory.java 2008-04-21 13:51:38 UTC (rev 21) @@ -29,7 +29,7 @@ * Implementations of this interface must provide a default constructor. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public interface ICollectionFactory { Modified: tinytim/trunk/src/main/java/org/tinytim/IConstruct.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/IConstruct.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/main/java/org/tinytim/IConstruct.java 2008-04-21 13:51:38 UTC (rev 21) @@ -31,7 +31,7 @@ * This interface is not meant to be used outside of the tinyTiM package. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public interface IConstruct extends TopicMapObject { Modified: tinytim/trunk/src/main/java/org/tinytim/IEventHandler.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/IEventHandler.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/main/java/org/tinytim/IEventHandler.java 2008-04-21 13:51:38 UTC (rev 21) @@ -26,7 +26,7 @@ * This interface is not meant to be used outside of the tinyTiM package. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public interface IEventHandler { Modified: tinytim/trunk/src/main/java/org/tinytim/IEventPublisher.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/IEventPublisher.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/main/java/org/tinytim/IEventPublisher.java 2008-04-21 13:51:38 UTC (rev 21) @@ -26,7 +26,7 @@ * This interface is not meant to be used outside of the tinyTiM package. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public interface IEventPublisher { Modified: tinytim/trunk/src/main/java/org/tinytim/IRI.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/IRI.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/main/java/org/tinytim/IRI.java 2008-04-21 13:51:38 UTC (rev 21) @@ -28,7 +28,7 @@ * Immutable representation of an IRI. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public final class IRI implements Locator { Modified: tinytim/trunk/src/main/java/org/tinytim/IReifiable.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/IReifiable.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/main/java/org/tinytim/IReifiable.java 2008-04-21 13:51:38 UTC (rev 21) @@ -28,7 +28,7 @@ * Every Topic Maps construct != topic is reifiable. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public interface IReifiable extends IConstruct { Modified: tinytim/trunk/src/main/java/org/tinytim/IScoped.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/IScoped.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/main/java/org/tinytim/IScoped.java 2008-04-21 13:51:38 UTC (rev 21) @@ -32,7 +32,7 @@ * constructs. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ interface IScoped extends IConstruct, ScopedObject { Modified: tinytim/trunk/src/main/java/org/tinytim/ITyped.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/ITyped.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/main/java/org/tinytim/ITyped.java 2008-04-21 13:51:38 UTC (rev 21) @@ -28,7 +28,7 @@ * Associations, roles, occurrences, and names are typed Topic Maps constructs. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ interface ITyped extends IConstruct { Modified: tinytim/trunk/src/main/java/org/tinytim/JavaCollectionFactory.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/JavaCollectionFactory.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/main/java/org/tinytim/JavaCollectionFactory.java 2008-04-21 13:51:38 UTC (rev 21) @@ -29,7 +29,7 @@ * {@link ICollectionFactory} which uses the standard Java collections. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ final class JavaCollectionFactory implements ICollectionFactory { Modified: tinytim/trunk/src/main/java/org/tinytim/Property.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/Property.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/main/java/org/tinytim/Property.java 2008-04-21 13:51:38 UTC (rev 21) @@ -24,7 +24,7 @@ * Provides constants for all tinyTiM-specific TMAPI properties. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public final class Property { Modified: tinytim/trunk/src/main/java/org/tinytim/Scoped.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/Scoped.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/main/java/org/tinytim/Scoped.java 2008-04-21 13:51:38 UTC (rev 21) @@ -32,7 +32,7 @@ * a {@link IReifiable} implementation. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ abstract class Scoped extends Construct implements IReifiable { Modified: tinytim/trunk/src/main/java/org/tinytim/TMAPIFeature.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/TMAPIFeature.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/main/java/org/tinytim/TMAPIFeature.java 2008-04-21 13:51:38 UTC (rev 21) @@ -27,7 +27,7 @@ * Copied from the TMAPIX-project. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ final class TMAPIFeature { Modified: tinytim/trunk/src/main/java/org/tinytim/TopicMapSystemFactoryImpl.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/TopicMapSystemFactoryImpl.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/main/java/org/tinytim/TopicMapSystemFactoryImpl.java 2008-04-21 13:51:38 UTC (rev 21) @@ -34,7 +34,7 @@ * {@link org.tmapi.core.TopicMapSystemFactory} implementation. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public final class TopicMapSystemFactoryImpl extends TopicMapSystemFactory { Modified: tinytim/trunk/src/main/java/org/tinytim/TroveCollectionFactory.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/TroveCollectionFactory.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/main/java/org/tinytim/TroveCollectionFactory.java 2008-04-21 13:51:38 UTC (rev 21) @@ -31,7 +31,7 @@ * <a href="http://sourceforge.net/projects/trove4j/">Trove library </a>. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ final class TroveCollectionFactory implements ICollectionFactory { Modified: tinytim/trunk/src/main/java/org/tinytim/Typed.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/Typed.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/main/java/org/tinytim/Typed.java 2008-04-21 13:51:38 UTC (rev 21) @@ -29,7 +29,7 @@ * property changes. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ abstract class Typed extends Scoped { Modified: tinytim/trunk/src/main/java/org/tinytim/index/IIndex.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/index/IIndex.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/main/java/org/tinytim/index/IIndex.java 2008-04-21 13:51:38 UTC (rev 21) @@ -26,7 +26,7 @@ * Copied from the TMAPIX-project. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public interface IIndex { Modified: tinytim/trunk/src/main/java/org/tinytim/index/IScopedIndex.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/index/IScopedIndex.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/main/java/org/tinytim/index/IScopedIndex.java 2008-04-21 13:51:38 UTC (rev 21) @@ -37,7 +37,7 @@ * implementations. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public interface IScopedIndex extends IIndex { Modified: tinytim/trunk/src/main/java/org/tinytim/index/ITypeInstanceIndex.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/index/ITypeInstanceIndex.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/main/java/org/tinytim/index/ITypeInstanceIndex.java 2008-04-21 13:51:38 UTC (rev 21) @@ -38,7 +38,7 @@ * implementations. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public interface ITypeInstanceIndex extends IIndex { Modified: tinytim/trunk/src/main/java/org/tinytim/index/IndexFlagsImpl.java =================================================================== --- tinytim/trunk/main/java/org/tinytim/index/IndexFlagsImpl.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/main/java/org/tinytim/index/IndexFlagsImpl.java 2008-04-21 13:51:38 UTC (rev 21) @@ -28,7 +28,7 @@ * Use {@link #AUTOUPDATED} or {@link #NOT_AUTOUPDATED} * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public class IndexFlagsImpl implements IndexFlags { Copied: tinytim/trunk/src/test (from rev 11, tinytim/trunk/test) Copied: tinytim/trunk/src/test/java (from rev 20, tinytim/trunk/test/java) Modified: tinytim/trunk/src/test/java/org/tinytim/TMAPITestCase.java =================================================================== --- tinytim/trunk/test/java/org/tinytim/TMAPITestCase.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/test/java/org/tinytim/TMAPITestCase.java 2008-04-21 13:51:38 UTC (rev 21) @@ -26,7 +26,7 @@ * Base class for all TMAPI-related test cases. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public class TMAPITestCase extends TestCase { Modified: tinytim/trunk/src/test/java/org/tinytim/TestConstruct.java =================================================================== --- tinytim/trunk/test/java/org/tinytim/TestConstruct.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/test/java/org/tinytim/TestConstruct.java 2008-04-21 13:51:38 UTC (rev 21) @@ -32,7 +32,7 @@ * Tests against {@link IConstruct}. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public class TestConstruct extends TinyTimTestCase { Modified: tinytim/trunk/src/test/java/org/tinytim/TestReifiable.java =================================================================== --- tinytim/trunk/test/java/org/tinytim/TestReifiable.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/test/java/org/tinytim/TestReifiable.java 2008-04-21 13:51:38 UTC (rev 21) @@ -33,7 +33,7 @@ * Tests against the {@link org.tinytim.IReifiable} interface. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public class TestReifiable extends TinyTimTestCase { Modified: tinytim/trunk/src/test/java/org/tinytim/TestScoped.java =================================================================== --- tinytim/trunk/test/java/org/tinytim/TestScoped.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/test/java/org/tinytim/TestScoped.java 2008-04-21 13:51:38 UTC (rev 21) @@ -32,7 +32,7 @@ * Tests against the {@link org.tinytim.IScoped} interface. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public class TestScoped extends TinyTimTestCase { Modified: tinytim/trunk/src/test/java/org/tinytim/TestSignatureGenerator.java =================================================================== --- tinytim/trunk/test/java/org/tinytim/TestSignatureGenerator.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/test/java/org/tinytim/TestSignatureGenerator.java 2008-04-21 13:51:38 UTC (rev 21) @@ -32,7 +32,7 @@ * Tests against the {@link org.tinytim.SignatureGenerator}. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public class TestSignatureGenerator extends TinyTimTestCase { Modified: tinytim/trunk/src/test/java/org/tinytim/TestTMAPICore.java =================================================================== --- tinytim/trunk/test/java/org/tinytim/TestTMAPICore.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/test/java/org/tinytim/TestTMAPICore.java 2008-04-21 13:51:38 UTC (rev 21) @@ -29,7 +29,7 @@ * Runs the TMAPI core test suite against tinyTiM. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public class TestTMAPICore extends TMAPITestCase { Modified: tinytim/trunk/src/test/java/org/tinytim/TestTMAPIIndex.java =================================================================== --- tinytim/trunk/test/java/org/tinytim/TestTMAPIIndex.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/test/java/org/tinytim/TestTMAPIIndex.java 2008-04-21 13:51:38 UTC (rev 21) @@ -29,7 +29,7 @@ * Runs the TMAPI index test suite against tinyTiM. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public class TestTMAPIIndex extends TMAPITestCase { Modified: tinytim/trunk/src/test/java/org/tinytim/TestTopicMapSystemFactoryImpl.java =================================================================== --- tinytim/trunk/test/java/org/tinytim/TestTopicMapSystemFactoryImpl.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/test/java/org/tinytim/TestTopicMapSystemFactoryImpl.java 2008-04-21 13:51:38 UTC (rev 21) @@ -37,7 +37,7 @@ * Tests against the {@link org.tinytim.TopicMapSystemFactoryImpl}. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public class TestTopicMapSystemFactoryImpl extends TinyTimTestCase { Modified: tinytim/trunk/src/test/java/org/tinytim/TestTopicMerge.java =================================================================== --- tinytim/trunk/test/java/org/tinytim/TestTopicMerge.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/test/java/org/tinytim/TestTopicMerge.java 2008-04-21 13:51:38 UTC (rev 21) @@ -31,7 +31,7 @@ * Tests merging of topics. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public class TestTopicMerge extends TinyTimTestCase { Modified: tinytim/trunk/src/test/java/org/tinytim/TestTopicMergeDetection.java =================================================================== --- tinytim/trunk/test/java/org/tinytim/TestTopicMergeDetection.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/test/java/org/tinytim/TestTopicMergeDetection.java 2008-04-21 13:51:38 UTC (rev 21) @@ -28,7 +28,7 @@ * Tests if merging situations are detected. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public class TestTopicMergeDetection extends TinyTimTestCase { Modified: tinytim/trunk/src/test/java/org/tinytim/TestTyped.java =================================================================== --- tinytim/trunk/test/java/org/tinytim/TestTyped.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/test/java/org/tinytim/TestTyped.java 2008-04-21 13:51:38 UTC (rev 21) @@ -32,7 +32,7 @@ * Tests against the {@link org.tinytim.ITyped} interface. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public class TestTyped extends TinyTimTestCase { Modified: tinytim/trunk/src/test/java/org/tinytim/TinyTimTestCase.java =================================================================== --- tinytim/trunk/test/java/org/tinytim/TinyTimTestCase.java 2008-04-21 13:42:04 UTC (rev 20) +++ tinytim/trunk/src/test/java/org/tinytim/TinyTimTestCase.java 2008-04-21 13:51:38 UTC (rev 21) @@ -35,7 +35,7 @@ * {@link org.tinytim.TopicMapImpl}. * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> - * @version $Rev:$ - $Date:$ + * @version $Rev$ - $Date$ */ public class TinyTimTestCase extends TestCase { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-04-25 20:19:56
|
Revision: 39 http://tinytim.svn.sourceforge.net/tinytim/?rev=39&view=rev Author: lheuer Date: 2008-04-25 13:20:01 -0700 (Fri, 25 Apr 2008) Log Message: ----------- - Added Ant build files, changes, and readme - License is added Added Paths: ----------- tinytim/trunk/CHANGES.txt tinytim/trunk/LICENSE.txt tinytim/trunk/README.txt tinytim/trunk/build.properties tinytim/trunk/build.xml Added: tinytim/trunk/CHANGES.txt =================================================================== --- tinytim/trunk/CHANGES.txt (rev 0) +++ tinytim/trunk/CHANGES.txt 2008-04-25 20:20:01 UTC (rev 39) @@ -0,0 +1,10 @@ +=========== +Changes Log +=========== + + +1.5.0 alpha1 (25.04.2008) +------------------------- +- Initial 1.5.x release +- New code base +- Java 1.5 Added: tinytim/trunk/LICENSE.txt =================================================================== --- tinytim/trunk/LICENSE.txt (rev 0) +++ tinytim/trunk/LICENSE.txt 2008-04-25 20:20:01 UTC (rev 39) @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + <one line to give the library's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + <signature of Ty Coon>, 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + Added: tinytim/trunk/README.txt =================================================================== --- tinytim/trunk/README.txt (rev 0) +++ tinytim/trunk/README.txt 2008-04-25 20:20:01 UTC (rev 39) @@ -0,0 +1,29 @@ +==================================== +tinyTiM - The tiny Topic Maps engine +==================================== + +What is tinyTiM? +---------------- +tinyTiM is a tiny Topic Maps engine which keeps topic maps in-memory. +This Topic Maps engine is meant to be used together with the TMAPI interfaces, +see <http://www.tmapi.org/> for details. + + +Installation +------------ +No real installation needed, simply put the ``tinytim-<VERSION>.jar`` and +``tmapi-1_0SP1.jar`` into your classpath. That's all. :) +Optionally, you can put the ``trove-<VERSION>.jar`` into your classpath which +makes tinyTiM slightly more memory efficient and faster. + + +Latest Version +-------------- +Visit tinyTiM's homepage <http://sourceforge.net/projects/tinytim> for the +latest version. + + +License +------- +tinyTiM is licensed under the GNU Lesser General Public License (LGPL) +Version 2.1, see LICENSE.txt for details. Added: tinytim/trunk/build.properties =================================================================== --- tinytim/trunk/build.properties (rev 0) +++ tinytim/trunk/build.properties 2008-04-25 20:20:01 UTC (rev 39) @@ -0,0 +1,4 @@ +version=1.5.0 +version_suffix=alpha1 +debug=off +optimize=on Added: tinytim/trunk/build.xml =================================================================== --- tinytim/trunk/build.xml (rev 0) +++ tinytim/trunk/build.xml 2008-04-25 20:20:01 UTC (rev 39) @@ -0,0 +1,189 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ==================================================================== + This is tinyTiM, a tiny Topic Maps engine. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + ==================================================================== + + $Rev:$ - $Date:$ +--> +<project name="tinyTiM" default="jar" basedir="."> + <property file="build.properties"/> + + <property name="dir.src" value="${basedir}/src/main/java"/> + <property name="dir.test" value="${basedir}/src/test/java"/> + <property name="dir.lib" value="${basedir}/lib"/> + <property name="dir.res" value="${basedir}/src/main/resources"/> + + <property name="lib.junit" value="${dir.lib}/junit-4.4.jar"/> + <property name="lib.trove" value="${dir.lib}/trove-2.0.3.jar"/> + <property name="lib.tmapi" value="${dir.lib}/tmapi-1_0SP1.jar"/> + <property name="lib.tmapi.tests" value="${dir.lib}/tmapi-test-1_0SP1.jar"/> + + <target name="help"> + <echo message="--------------------"/> + <echo message="tinyTiM - Build file"/> + <echo message="--------------------"/> + <echo message=""/> + <echo message="Available targets:"/> + <echo message=""/> + <echo message=" jar Creates the jar"/> + <echo message=" release Creates the jar and a distributable file"/> + </target> + + <target name="init"> + <property name="dist.version" value="${version}${version_suffix}"/> + <property name="dist.name" value="tinytim-${dist.version}"/> + + <property name="tinytim.jar" value="${dist.name}.jar"/> + <property name="tinytim.tar" value="${dist.name}.tar"/> + <property name="tinytim.tar.gz" value="${tinytim.tar}.gz"/> + <property name="tinytim.zip" value="${dist.name}.zip"/> + + <property name="dir.build" value="${basedir}/build"/> + <property name="dir.dist.root" value="${dir.build}/dist"/> + <property name="dir.dist" value="${dir.dist.root}/${dist.name}"/> + <property name="dir.build.classes" value="${dir.build}/classes"/> + <property name="dir.build.tests" value="${dir.build}/tests"/> + <property name="dir.javadocs" value="${basedir}/javadocs"/> + </target> + + <!-- =================================================================== --> + <!-- Clean targets --> + <!-- =================================================================== --> + <target name="clean" depends="init"> + <delete dir="${dir.build}"/> + <delete dir="${dir.javadocs}"/> + </target> + + <!-- =================================================================== --> + <!-- Prepares the build directory --> + <!-- =================================================================== --> + <target name="prepare" depends="init"> + <mkdir dir="${dir.build}"/> + <mkdir dir="${dir.build.classes}"/> + </target> + + <!-- =================================================================== --> + <!-- Tests --> + <!-- =================================================================== --> + <target name="test" depends="compile"> + <mkdir dir="${dir.build.tests}"/> + <javac destdir="${dir.build.tests}" + debug="${debug}" + optimize="${optimize}" + target="1.5"> + <classpath> + <pathelement location="${dir.build.classes}"/> + <pathelement location="${lib.junit}"/> + <pathelement location="${lib.tmapi}"/> + <pathelement location="${lib.tmapi.tests}"/> + <pathelement location="${lib.trove}"/> + </classpath> + <src path="${dir.test}"/> + </javac> + <junit printsummary="true" showoutput="false" + errorProperty="test.failed" failureProperty="test.failed"> + <classpath> + <pathelement location="${dir.build.classes}"/> + <pathelement location="${dir.build.tests}"/> + <pathelement location="${lib.junit}"/> + <pathelement location="${lib.tmapi}"/> + <pathelement location="${lib.tmapi.tests}"/> + <pathelement location="${lib.trove}"/> + </classpath> + <formatter type="brief" usefile="false"/> + <batchtest fork="no" todir="${dir.build}"> + <fileset dir="${dir.build.tests}/"> + <include name="**/Test**.class"/> + <exclude name="**/Test*$**.class"/> + </fileset> + </batchtest> + </junit> + <fail message="Tests failed. Check test output." if="test.failed"/> + </target> + + <!-- =================================================================== --> + <!-- Compile source files --> + <!-- =================================================================== --> + <target name="compile" depends="clean, prepare"> + <javac destdir="${dir.build.classes}" + debug="${debug}" + target="1.5"> + <classpath> + <pathelement location="${lib.tmapi}"/> + <pathelement location="${lib.trove}"/> + </classpath> + <src path="${dir.src}"/> + </javac> + </target> + + <!-- =================================================================== --> + <!-- Creates the jar --> + <!-- =================================================================== --> + <target name="jar" depends="compile"> + <jar destfile="${dir.build}/${tinytim.jar}"> + <fileset dir="${dir.build.classes}"> + <include name="**/*.*"/> + </fileset> + <fileset dir="${dir.res}"> + <include name="**/*.*"/> + </fileset> + <manifest> + <attribute name="Implementation-Title" value="tinyTiM"/> + <attribute name="Implementation-Version" value="${dist.version}"/> + <attribute name="Implementation-URL" value="http://sourceforge.net/projects/tinytim"/> + </manifest> + </jar> + </target> + + <!-- =================================================================== --> + <!-- Prepares a distribution --> + <!-- =================================================================== --> + <target name="dist" depends="jar"> + <mkdir dir="${dir.dist}"/> + + <copy todir="${dir.dist}" file="${dir.build}/${tinytim.jar}"/> + + <copy todir="${dir.dist}/src"> + <fileset dir="${dir.src}"/> + </copy> + <copy todir="${dir.dist}/test"> + <fileset dir="${dir.test}"/> + </copy> + <copy todir="${dir.dist}/lib"> + <fileset dir="${dir.lib}"/> + </copy> + + <copy todir="${dir.dist}" file="CHANGES.txt"/> + <copy todir="${dir.dist}" file="LICENSE.txt"/> + <copy todir="${dir.dist}" file="README.txt"/> + </target> + + <!-- =================================================================== --> + <!-- Creates the distribution files (.zip and .tar.gz) --> + <!-- --> + <!-- Won't create the distribution files if a test fails --> + <!-- =================================================================== --> + <target name="release" depends="jar, test, dist"> + <tar destfile="${dir.dist.root}/${tinytim.tar}" + basedir="${dir.dist.root}"/> + <gzip src="${dir.dist.root}/${tinytim.tar}" + destfile="${dir.build}/${tinytim.tar.gz}" /> + <delete file="${dir.dist.root}/${tinytim.tar}" /> + <zip destfile="${dir.build}/${tinytim.zip}" basedir="${dir.dist.root}"/> + </target> +</project> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lh...@us...> - 2008-05-05 12:37:34
|
Revision: 53 http://tinytim.svn.sourceforge.net/tinytim/?rev=53&view=rev Author: lheuer Date: 2008-05-05 05:37:18 -0700 (Mon, 05 May 2008) Log Message: ----------- - Preparing alpha 2 - DuplicateRemovalUtils added - voc package added - TypeInstanceConverter added - More tests - IIndexManager added - Additional tinyTiM specific property added Modified Paths: -------------- tinytim/trunk/CHANGES.txt tinytim/trunk/build.properties tinytim/trunk/build.xml tinytim/trunk/src/main/java/org/tinytim/IDatatypeAwareConstruct.java tinytim/trunk/src/main/java/org/tinytim/MergeUtils.java tinytim/trunk/src/main/java/org/tinytim/Property.java tinytim/trunk/src/main/java/org/tinytim/ReificationUtils.java tinytim/trunk/src/main/java/org/tinytim/TopicMapImpl.java tinytim/trunk/src/main/java/org/tinytim/TopicMapSystemFactoryImpl.java tinytim/trunk/src/main/java/org/tinytim/TopicUtils.java tinytim/trunk/src/main/java/org/tinytim/VariantImpl.java tinytim/trunk/src/main/java/org/tinytim/index/IndexManager.java tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndex.java tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AssociationRolesIndexImpl.java tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AssociationsIndexImpl.java tinytim/trunk/src/main/java/org/tinytim/index/tmapi/OccurrencesIndexImpl.java tinytim/trunk/src/main/java/org/tinytim/index/tmapi/ScopedObjectsIndexImpl.java tinytim/trunk/src/main/java/org/tinytim/index/tmapi/TopicNamesIndexImpl.java tinytim/trunk/src/main/java/org/tinytim/index/tmapi/VariantsIndexImpl.java tinytim/trunk/src/test/java/org/tinytim/AllTests.java tinytim/trunk/src/test/java/org/tinytim/TestSignatureGenerator.java tinytim/trunk/src/test/java/org/tinytim/index/TestScopedIndex.java Added Paths: ----------- tinytim/trunk/src/main/java/org/tinytim/DuplicateRemovalUtils.java tinytim/trunk/src/main/java/org/tinytim/TypeInstanceConverter.java tinytim/trunk/src/main/java/org/tinytim/index/IIndexManager.java tinytim/trunk/src/main/java/org/tinytim/voc/ tinytim/trunk/src/main/java/org/tinytim/voc/TMDM.java tinytim/trunk/src/main/java/org/tinytim/voc/XTM10.java tinytim/trunk/src/test/java/org/tinytim/TestDuplicateRemovalUtils.java Modified: tinytim/trunk/CHANGES.txt =================================================================== --- tinytim/trunk/CHANGES.txt 2008-05-02 10:49:55 UTC (rev 52) +++ tinytim/trunk/CHANGES.txt 2008-05-05 12:37:18 UTC (rev 53) @@ -2,7 +2,28 @@ Changes Log =========== +1.5.0 alpha2 (05.05.2008) +------------------------- +Features: +- ``voc`` package added which provides access to common PSIs. +- ``DuplicateRemovalUtils`` added. Used to remove + duplicate Topic Maps constructs from topic maps, topics, + associations, and names +- ``TypeInstanceConverter`` added. Used to convert + type-instance associations into the topic's [types] + property. +- ``tmapi.TopicNamesIndex``, ``tmapi.OccurrenceIndex`` + and ``tmapi.VarinatsIndex`` use an optimized reindex + algorithm. +- Property to let ``Variant`` instances return the union + of their 'own' scope and the parent's scope. +Bugfixes: +- ``DatatypeAwareConstruct`` sent wrong event. Fixed +- All indexes return copies of their collections to avoid + concurrent modification exceptions. + + 1.5.0 alpha1 (25.04.2008) ------------------------- - Initial 1.5.x release Modified: tinytim/trunk/build.properties =================================================================== --- tinytim/trunk/build.properties 2008-05-02 10:49:55 UTC (rev 52) +++ tinytim/trunk/build.properties 2008-05-05 12:37:18 UTC (rev 53) @@ -1,4 +1,4 @@ version=1.5.0 -version_suffix=alpha1 +version_suffix=alpha2 debug=off optimize=on Modified: tinytim/trunk/build.xml =================================================================== --- tinytim/trunk/build.xml 2008-05-02 10:49:55 UTC (rev 52) +++ tinytim/trunk/build.xml 2008-05-05 12:37:18 UTC (rev 53) @@ -41,6 +41,7 @@ <echo message="Available targets:"/> <echo message=""/> <echo message=" jar Creates the jar"/> + <echo message=" doc Creates the API documentation"/> <echo message=" release Creates the jar and a distributable file"/> </target> @@ -58,7 +59,7 @@ <property name="dir.dist" value="${dir.dist.root}/${dist.name}"/> <property name="dir.build.classes" value="${dir.build}/classes"/> <property name="dir.build.tests" value="${dir.build}/tests"/> - <property name="dir.javadocs" value="${basedir}/javadocs"/> + <property name="dir.javadocs" value="${dir.dist}/docs/api"/> </target> <!-- =================================================================== --> @@ -132,6 +133,32 @@ </target> <!-- =================================================================== --> + <!-- Creates the Java Docs --> + <!-- =================================================================== --> + <target name="doc" depends="init"> + <mkdir dir="${dir.javadocs}"/> + <javadoc destdir="${dir.javadocs}" + packagenames="org.tinytim.*" + author="true" + version="true" + use="true" + splitindex="true" + noindex="false" + windowtitle="tinyTiM API v${dist.version}" + doctitle="tinyTiM API v${dist.version}"> + <fileset dir="${dir.src}"> + <exclude name="**/*Impl.*"/> + <exclude name="org/tinytim/index/**"/> + <exclude name="org/tinytim/IConstruct*"/> + <exclude name="org/tinytim/IDatatypeAware*"/> + <exclude name="org/tinytim/IRI*"/> + <exclude name="org/tinytim/IEvent*"/> + <exclude name="org/tinytim/Event*"/> + </fileset> + </javadoc> + </target> + + <!-- =================================================================== --> <!-- Creates the jar --> <!-- =================================================================== --> <target name="jar" depends="compile"> @@ -153,7 +180,7 @@ <!-- =================================================================== --> <!-- Prepares a distribution --> <!-- =================================================================== --> - <target name="dist" depends="jar"> + <target name="dist" depends="jar, doc"> <mkdir dir="${dir.dist}"/> <copy todir="${dir.dist}" file="${dir.build}/${tinytim.jar}"/> Added: tinytim/trunk/src/main/java/org/tinytim/DuplicateRemovalUtils.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/DuplicateRemovalUtils.java (rev 0) +++ tinytim/trunk/src/main/java/org/tinytim/DuplicateRemovalUtils.java 2008-05-05 12:37:18 UTC (rev 53) @@ -0,0 +1,209 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import org.tinytim.index.ITypeInstanceIndex; +import org.tmapi.core.Association; +import org.tmapi.core.AssociationRole; +import org.tmapi.core.Occurrence; +import org.tmapi.core.Topic; +import org.tmapi.core.TopicMap; +import org.tmapi.core.TopicMapObject; +import org.tmapi.core.TopicName; +import org.tmapi.core.Variant; + +/** + * Removes duplicates from Topic Maps constructs. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public final class DuplicateRemovalUtils { + + private DuplicateRemovalUtils() { + // noop. + } + + /** + * Removes duplicate Topic Maps constructs from a topic map. + * + * @param topicMap The topic map to remove the duplicates from. + */ + public static void removeDuplicates(TopicMap topicMap) { + TopicMapImpl tm = (TopicMapImpl) topicMap; + for (Topic topic: tm.getTopics()) { + removeDuplicates(topic); + } + Map<String, Association> sig2Assoc = tm.getCollectionFactory().createMap(); + ITypeInstanceIndex typeInstanceIdx = tm.getIndexManager().getTypeInstanceIndex(); + if (!typeInstanceIdx.isAutoUpdated()) { + typeInstanceIdx.reindex(); + } + for (Topic type: typeInstanceIdx.getAssociationTypes()) { + _removeDuplicateAssociations(sig2Assoc, typeInstanceIdx.getAssociations(type)); + } + _removeDuplicateAssociations(sig2Assoc, typeInstanceIdx.getAssociations(null)); + } + + private static void _removeDuplicateAssociations(Map<String, Association> sig2Assoc, Collection<AssociationImpl> assocs) { + sig2Assoc.clear(); + Association existing = null; + String sig = null; + for (Association assoc: assocs) { + removeDuplicates(assoc); + sig = SignatureGenerator.generateSignature(assoc); + existing = sig2Assoc.get(sig); + if (existing != null) { + MergeUtils.moveRoleCharacteristics(assoc, existing); + _removeConstruct(assoc); + } + else { + sig2Assoc.put(sig, assoc); + } + } + } + + /** + * Removes duplicate occurrences and names from a topic. + * + * @param topic The topic from which duplicates should be removed from. + */ + @SuppressWarnings("unchecked") + public static void removeDuplicates(Topic topic) { + _removeDuplicateOccurrences(topic.getOccurrences()); + _removeDuplicateNames(topic.getTopicNames()); + } + + /** + * Removes duplicate variants from a name. + * + * @param name The name from which the duplicates should be removed. + */ + @SuppressWarnings("unchecked") + public static void removeDuplicates(TopicName name) { + Map<String, Variant> sigs = new HashMap<String, Variant>(); + for (Variant variant: new ArrayList<Variant>(name.getVariants())) { + String sig = SignatureGenerator.generateSignature(variant); + Variant existing = sigs.get(sig); + if (existing != null) { + _handleExistingConstruct(variant, existing); + _removeConstruct(variant); + } + else { + sigs.put(sig, variant); + } + } + } + + /** + * + * + * @param occs + */ + private static void _removeDuplicateOccurrences(Collection<Occurrence> occs) { + Map<String, Occurrence> sigs = new HashMap<String, Occurrence>(occs.size()); + Occurrence existing = null; + for (Occurrence occ: new ArrayList<Occurrence>(occs)) { + String sig = SignatureGenerator.generateSignature(occ); + existing = sigs.get(sig); + if (existing != null) { + _handleExistingConstruct(occ, existing); + _removeConstruct(occ); + } + else { + sigs.put(sig, occ); + } + } + } + + /** + * + * + * @param names + */ + private static void _removeDuplicateNames(Collection<TopicName> names) { + Map<String, TopicName> sigs = new HashMap<String, TopicName>(names.size()); + TopicName existing = null; + for (TopicName name: new ArrayList<TopicName>(names)) { + removeDuplicates(name); + String sig = SignatureGenerator.generateSignature(name); + existing = sigs.get(sig); + if (existing != null) { + _handleExistingConstruct(name, existing); + _moveVariants(name, existing); + _removeConstruct(name); + } + else { + sigs.put(sig, name); + } + } + } + + /** + * Removes duplicate roles from an association. + * + * @param assoc The association to remove duplicate roles from. + */ + @SuppressWarnings("unchecked") + public static void removeDuplicates(Association assoc) { + Map<String, AssociationRole> sig2Role = ((TopicMapImpl) assoc.getTopicMap()).getCollectionFactory().createMap(); + AssociationRole existing = null; + String sig = null; + for (AssociationRole role: new ArrayList<AssociationRole>(assoc.getAssociationRoles())) { + sig = SignatureGenerator.generateSignature(role); + existing = sig2Role.get(sig); + if (existing != null) { + _handleExistingConstruct(role, existing); + _removeConstruct(role); + } + else { + sig2Role.put(sig, role); + } + } + } + + /** + * @see {@link MergeUtils#moveVariants(TopicNameImpl, TopicNameImpl)} + */ + private static void _moveVariants(TopicName source, TopicName target) { + MergeUtils.moveVariants((TopicNameImpl)source, (TopicNameImpl)target); + } + + /** + * @see {@link MergeUtils#removeConstruct(IConstruct)} + */ + private static void _removeConstruct(TopicMapObject construct) { + MergeUtils.removeConstruct((IConstruct) construct); + } + + /** + * @see {@link MergeUtils#handleExistingConstruct(IReifiable, IReifiable)} + */ + private static void _handleExistingConstruct(TopicMapObject source, TopicMapObject target) { + MergeUtils.handleExistingConstruct((IReifiable) source, (IReifiable) target); + } + +} Property changes on: tinytim/trunk/src/main/java/org/tinytim/DuplicateRemovalUtils.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native Modified: tinytim/trunk/src/main/java/org/tinytim/IDatatypeAwareConstruct.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/IDatatypeAwareConstruct.java 2008-05-02 10:49:55 UTC (rev 52) +++ tinytim/trunk/src/main/java/org/tinytim/IDatatypeAwareConstruct.java 2008-05-05 12:37:18 UTC (rev 53) @@ -30,7 +30,7 @@ * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ */ -interface IDatatypeAwareConstruct extends IConstruct { +public interface IDatatypeAwareConstruct extends IConstruct { /** * The value of this Topic Maps construct. Modified: tinytim/trunk/src/main/java/org/tinytim/MergeUtils.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/MergeUtils.java 2008-05-02 10:49:55 UTC (rev 52) +++ tinytim/trunk/src/main/java/org/tinytim/MergeUtils.java 2008-05-05 12:37:18 UTC (rev 53) @@ -25,9 +25,9 @@ import java.util.List; import java.util.Map; +import org.tinytim.index.IIndexManager; import org.tinytim.index.IScopedIndex; import org.tinytim.index.ITypeInstanceIndex; -import org.tinytim.index.IndexManager; import org.tmapi.core.Association; import org.tmapi.core.AssociationRole; import org.tmapi.core.Locator; @@ -266,7 +266,7 @@ */ private static void _replaceTopics(Topic source, Topic replacement) { TopicMapImpl tm = (TopicMapImpl) replacement.getTopicMap(); - IndexManager idxMan = tm.getIndexManager(); + IIndexManager idxMan = tm.getIndexManager(); ITypeInstanceIndex typeInstanceIndex = idxMan.getTypeInstanceIndex(); if (!typeInstanceIndex.isAutoUpdated()) { typeInstanceIndex.reindex(); Modified: tinytim/trunk/src/main/java/org/tinytim/Property.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/Property.java 2008-05-02 10:49:55 UTC (rev 52) +++ tinytim/trunk/src/main/java/org/tinytim/Property.java 2008-05-05 12:37:18 UTC (rev 53) @@ -56,4 +56,14 @@ */ public static final String XTM10_REIFICATION = "org.tinytim.XTM10Reification"; + /** + * Property which indicates if the variant's parent scope is included + * in the {@link org.tmapi.core.Variant#getScope()} return value. + * + * This property is disabled by default. + * + * If enabled, the variants scope is the union of its own scope and + * the parent name's scope. + */ + public static final String INHERIT_NAME_SCOPE = "org.tinytim.InheritNameScope"; } Modified: tinytim/trunk/src/main/java/org/tinytim/ReificationUtils.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/ReificationUtils.java 2008-05-02 10:49:55 UTC (rev 52) +++ tinytim/trunk/src/main/java/org/tinytim/ReificationUtils.java 2008-05-05 12:37:18 UTC (rev 53) @@ -20,6 +20,7 @@ */ package org.tinytim; +import java.util.HashSet; import java.util.Iterator; import java.util.Set; @@ -44,7 +45,7 @@ */ public static Set<TopicMapObject> getReified(Topic reifier) { TopicMapImpl tm = (TopicMapImpl) reifier.getTopicMap(); - Set<TopicMapObject> reified = tm.getCollectionFactory().createSet(); + Set<TopicMapObject> reified = new HashSet<TopicMapObject>(); for (Locator sid: ((TopicImpl) reifier).getSubjectIdentifiers()) { TopicMapObject obj = tm.getObjectByItemIdentifier(sid); if (obj != null) { Modified: tinytim/trunk/src/main/java/org/tinytim/TopicMapImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/TopicMapImpl.java 2008-05-02 10:49:55 UTC (rev 52) +++ tinytim/trunk/src/main/java/org/tinytim/TopicMapImpl.java 2008-05-05 12:37:18 UTC (rev 53) @@ -29,6 +29,7 @@ import java.util.Set; import org.tinytim.index.IndexManager; +import org.tinytim.index.IIndexManager; import org.tmapi.core.Association; import org.tmapi.core.AssociationRole; import org.tmapi.core.HelperObjectConfigurationException; @@ -88,6 +89,7 @@ private EventMultiplier _eventMultiplier; private Map<String, Object> _helperObjects; boolean _oldReification; + boolean _inheritNameScope; TopicMapImpl(TopicMapSystemImpl sys, Locator locator) { super(null); @@ -100,9 +102,11 @@ _evtHandlers = _collectionFactory.createMap(); _helperObjects = _collectionFactory.createMap(); _identityManager = new IdentityManager(this); + //TODO: Makes this configurable _indexManager = new IndexManager(this, _collectionFactory); _eventMultiplier = new EventMultiplier(this); _oldReification = "true".equalsIgnoreCase(sys.getProperty(Property.XTM10_REIFICATION)); + _inheritNameScope = "true".equalsIgnoreCase(sys.getProperty(Property.INHERIT_NAME_SCOPE)); } ICollectionFactory getCollectionFactory() { @@ -407,7 +411,7 @@ } } - public IndexManager getIndexManager() { + public IIndexManager getIndexManager() { return _indexManager; } Modified: tinytim/trunk/src/main/java/org/tinytim/TopicMapSystemFactoryImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/TopicMapSystemFactoryImpl.java 2008-05-02 10:49:55 UTC (rev 52) +++ tinytim/trunk/src/main/java/org/tinytim/TopicMapSystemFactoryImpl.java 2008-05-05 12:37:18 UTC (rev 53) @@ -60,6 +60,7 @@ _features.put(feature.name, feature.defaultValue); } _properties.setProperty(Property.XTM10_REIFICATION, "true"); + _properties.setProperty(Property.INHERIT_NAME_SCOPE, "false"); _properties.setProperty(Property.COLLECTION_FACTORY, _COLL_FACTORY_JAVA); try { // Probe if Trove is available. Modified: tinytim/trunk/src/main/java/org/tinytim/TopicUtils.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/TopicUtils.java 2008-05-02 10:49:55 UTC (rev 52) +++ tinytim/trunk/src/main/java/org/tinytim/TopicUtils.java 2008-05-05 12:37:18 UTC (rev 53) @@ -20,9 +20,9 @@ */ package org.tinytim; +import org.tinytim.index.IIndexManager; import org.tinytim.index.IScopedIndex; import org.tinytim.index.ITypeInstanceIndex; -import org.tinytim.index.IndexManager; import org.tmapi.core.Topic; /** @@ -76,7 +76,7 @@ if (!topic.getRolesPlayed().isEmpty()) { return false; } - IndexManager idxMan = ((TopicMapImpl) topic.getTopicMap()).getIndexManager(); + IIndexManager idxMan = ((TopicMapImpl) topic.getTopicMap()).getIndexManager(); ITypeInstanceIndex typeInstanceIdx = idxMan.getTypeInstanceIndex(); if (!typeInstanceIdx.isAutoUpdated()) { typeInstanceIdx.reindex(); Added: tinytim/trunk/src/main/java/org/tinytim/TypeInstanceConverter.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/TypeInstanceConverter.java (rev 0) +++ tinytim/trunk/src/main/java/org/tinytim/TypeInstanceConverter.java 2008-05-05 12:37:18 UTC (rev 53) @@ -0,0 +1,171 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim; + +import java.util.Collection; +import java.util.logging.Logger; + +import org.tinytim.index.ITypeInstanceIndex; +import org.tinytim.voc.TMDM; +import org.tinytim.voc.XTM10; +import org.tmapi.core.Association; +import org.tmapi.core.AssociationRole; +import org.tmapi.core.Locator; +import org.tmapi.core.TMAPIException; +import org.tmapi.core.TMAPIRuntimeException; +import org.tmapi.core.Topic; +import org.tmapi.core.TopicMap; + +/** + * This class provides functions that can be used to convert the type-instance + * relationships that are modelled as associations into the [types] property + * of {@link org.tmapi.core.Topic}s. + * + * Copied from the TMAPIX-project. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public final class TypeInstanceConverter { + + //TODO: Implement types -> associations + + private static final Logger LOG = Logger.getLogger(TypeInstanceConverter.class.getName()); + + private TypeInstanceConverter() { + // noop. + } + + /** + * Converts type-instance relationships (TMDM 1.0) and class-instance + * relationships into the [types] property of the {@link org.tmapi.core.Topic}. + * + * @see #convertTMDMAssociationsToTypes(TopicMap) + * @see #convertXTMAssociationsToTypes(TopicMap) + * + * @param topicMap The topic map to convert. + */ + public static void convertAssociationsToTypes(TopicMap topicMap) { + convertTMDMAssociationsToTypes(topicMap); + convertXTMAssociationsToTypes(topicMap); + } + + /** + * Converts class-instance relationships (XTM 1.0) into the [types] property + * of {@link org.tmapi.core.Topic}s. The associations are removed from the + * topic map. + * + * @param topicMap The topic map to convert. + */ + public static void convertXTMAssociationsToTypes(TopicMap topicMap) { + _associationsToTypes(topicMap, XTM10.CLASS_INSTANCE, + XTM10.CLASS, XTM10.INSTANCE); + } + + /** + * Converts type-instance relationships (TMDM 1.0) into the [types] property + * of {@link org.tmapi.core.Topic}s. The associations are removed from the + * topic map. + * + * @param topicMap The topic map to convert. + */ + public static void convertTMDMAssociationsToTypes(TopicMap topicMap) { + _associationsToTypes(topicMap, TMDM.TYPE_INSTANCE, + TMDM.TYPE, TMDM.INSTANCE); + } + + private static void _associationsToTypes(TopicMap topicMap, + Locator typeInstance_, Locator type_, Locator instance_) { + TopicMapImpl tm = (TopicMapImpl) topicMap; + Topic typeInstance = tm.getTopicBySubjectIdentifier(typeInstance_); + if (typeInstance == null) { + return; + } + Topic type = tm.getTopicBySubjectIdentifier(type_); + if (type == null) { + return; + } + Topic instance = tm.getTopicBySubjectIdentifier(instance_); + if (instance == null) { + return; + } + ITypeInstanceIndex typeInstanceIdx = tm.getIndexManager().getTypeInstanceIndex(); + if (!typeInstanceIdx.isAutoUpdated()) { + typeInstanceIdx.reindex(); + } + for (Association assoc: typeInstanceIdx.getAssociations(typeInstance)) { + Topic[] pair = _getTypeInstancePair(assoc, type, instance); + if (pair == null) { + continue; + } + pair[1].addType(pair[0]); + try { + assoc.remove(); + } + catch (TMAPIException ex) { + throw new TMAPIRuntimeException(ex); + } + } + } + + private static void _info(Association assoc, String msg) { + LOG.info("The association (ID: '" + assoc.getObjectId() + "') cannot be converted into a type. Reason: " + msg); + } + + @SuppressWarnings("unchecked") + private static Topic[] _getTypeInstancePair(Association assoc, Topic type, Topic instance) { + Collection<AssociationRole> roles = assoc.getAssociationRoles(); + if (roles.size() != 2) { + _info(assoc, "Not a binary association."); + return null; + } + if (assoc.getReifier() != null) { + _info(assoc, "It is reified"); + return null; + } + if (!assoc.getSourceLocators().isEmpty()) { + _info(assoc, "It as item identifiers"); + return null; + } + if (!assoc.getScope().isEmpty()) { + _info(assoc, "The scope is not unconstrained"); + return null; + } + Topic[] pair = new Topic[2]; + for (AssociationRole role: roles) { + if (type.equals(role.getType())) { + pair[0] = role.getPlayer(); + } + else if (instance.equals(role.getType())) { + pair[1] = role.getPlayer(); + } + } + if (pair[0] == null) { + _info(assoc, "The type player is null."); + return null; + } + if (pair[1] == null) { + _info(assoc, "The instance player is null"); + return null; + } + return pair; + } +} Property changes on: tinytim/trunk/src/main/java/org/tinytim/TypeInstanceConverter.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native Modified: tinytim/trunk/src/main/java/org/tinytim/VariantImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/VariantImpl.java 2008-05-02 10:49:55 UTC (rev 52) +++ tinytim/trunk/src/main/java/org/tinytim/VariantImpl.java 2008-05-05 12:37:18 UTC (rev 53) @@ -21,6 +21,7 @@ package org.tinytim; import java.util.Collection; +import java.util.Set; import org.tmapi.core.Locator; import org.tmapi.core.TMAPIException; @@ -53,6 +54,22 @@ } /* (non-Javadoc) + * @see org.tinytim.Scoped#getScope() + */ + @Override + public Set<Topic> getScope() { + if (_tm == null || _parent == null || !_tm._inheritNameScope) { + return super.getScope(); + } + else { + Set<Topic> scope = _tm.getCollectionFactory().createSet(); + scope.addAll(super.getScope()); + scope.addAll(((IScoped) _parent).getScope()); + return scope; + } + } + + /* (non-Javadoc) * @see org.tinytim.IMovable#moveTo(java.lang.Object) */ public void moveTo(TopicName newParent) { Added: tinytim/trunk/src/main/java/org/tinytim/index/IIndexManager.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/index/IIndexManager.java (rev 0) +++ tinytim/trunk/src/main/java/org/tinytim/index/IIndexManager.java 2008-05-05 12:37:18 UTC (rev 53) @@ -0,0 +1,44 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim.index; + +/** + * The index manager provides access to the tinyTiM-specific indexes. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public interface IIndexManager { + + /** + * Returns the {@link ITypeInstanceIndex}. + * + * @return A {@link ITypeInstanceIndex} instance. + */ + public ITypeInstanceIndex getTypeInstanceIndex(); + + /** + * Returns the {@link IScopedIndex}. + * + * @return A {@link IScopedIndex} instance. + */ + public IScopedIndex getScopedIndex(); +} Property changes on: tinytim/trunk/src/main/java/org/tinytim/index/IIndexManager.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native Modified: tinytim/trunk/src/main/java/org/tinytim/index/IndexManager.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/index/IndexManager.java 2008-05-02 10:49:55 UTC (rev 52) +++ tinytim/trunk/src/main/java/org/tinytim/index/IndexManager.java 2008-05-05 12:37:18 UTC (rev 53) @@ -24,12 +24,13 @@ import org.tinytim.IEventPublisher; /** + * {@link IIndexManager} implementation which provides autoupdated default + * indexes. * - * * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> * @version $Rev$ - $Date$ */ -public final class IndexManager { +public final class IndexManager implements IIndexManager { private ITypeInstanceIndex _typeInstanceIndex; private IScopedIndex _scopedIndex; @@ -39,10 +40,16 @@ _scopedIndex = new ScopedIndex(publisher, collFactory); } + /* (non-Javadoc) + * @see org.tinytim.index.IIndexManager#getTypeInstanceIndex() + */ public ITypeInstanceIndex getTypeInstanceIndex() { return _typeInstanceIndex; } + /* (non-Javadoc) + * @see org.tinytim.index.IIndexManager#getScopedIndex() + */ public IScopedIndex getScopedIndex() { return _scopedIndex; } Modified: tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndex.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndex.java 2008-05-02 10:49:55 UTC (rev 52) +++ tinytim/trunk/src/main/java/org/tinytim/index/ScopedIndex.java 2008-05-05 12:37:18 UTC (rev 53) @@ -77,7 +77,7 @@ public Collection<AssociationImpl> getAssociationsByTheme(Topic theme) { List<AssociationImpl> assocs = _theme2Assocs.get(theme); return assocs == null ? Collections.<AssociationImpl>emptySet() - : Collections.unmodifiableCollection(assocs); + : new ArrayList<AssociationImpl>(assocs); } /* (non-Javadoc) @@ -95,7 +95,7 @@ public Collection<OccurrenceImpl> getOccurrencesByTheme(Topic theme) { List<OccurrenceImpl> occs = _theme2Occs.get(theme); return occs == null ? Collections.<OccurrenceImpl>emptySet() - : Collections.unmodifiableCollection(occs); + : new ArrayList<OccurrenceImpl>(occs); } /* (non-Javadoc) @@ -113,7 +113,7 @@ public Collection<TopicNameImpl> getNamesByTheme(Topic theme) { List<TopicNameImpl> names = _theme2Names.get(theme); return names == null ? Collections.<TopicNameImpl>emptySet() - : Collections.unmodifiableCollection(names); + : new ArrayList<TopicNameImpl>(names); } /* (non-Javadoc) @@ -131,7 +131,7 @@ public Collection<VariantImpl> getVariantsByTheme(Topic theme) { List<VariantImpl> vars = _theme2Variants.get(theme); return vars == null ? Collections.<VariantImpl>emptySet() - : Collections.unmodifiableCollection(vars); + : new ArrayList<VariantImpl>(vars); } /* (non-Javadoc) Modified: tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AssociationRolesIndexImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AssociationRolesIndexImpl.java 2008-05-02 10:49:55 UTC (rev 52) +++ tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AssociationRolesIndexImpl.java 2008-05-05 12:37:18 UTC (rev 53) @@ -39,9 +39,13 @@ public class AssociationRolesIndexImpl extends AbstractTMAPIIndex implements AssociationRolesIndex { + private final IndexFlags _indexFlags; + public AssociationRolesIndexImpl(TopicMapImpl topicMap, ICollectionFactory collFactory) { super(topicMap, collFactory); + _indexFlags = topicMap.getIndexManager().getTypeInstanceIndex().isAutoUpdated() ? + IndexFlagsImpl.AUTOUPDATED : IndexFlagsImpl.NOT_AUTOUPDATED; } /* (non-Javadoc) @@ -62,14 +66,16 @@ * @see org.tmapi.index.Index#getFlags() */ public IndexFlags getFlags() throws TMAPIIndexException { - return IndexFlagsImpl.AUTOUPDATED; + return _indexFlags; } /* (non-Javadoc) * @see org.tmapi.index.Index#reindex() */ public void reindex() throws TMAPIIndexException { - // noop. + if (_indexFlags != IndexFlagsImpl.AUTOUPDATED) { + _weakTopicMap.get().getIndexManager().getTypeInstanceIndex().reindex(); + } } } Modified: tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AssociationsIndexImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AssociationsIndexImpl.java 2008-05-02 10:49:55 UTC (rev 52) +++ tinytim/trunk/src/main/java/org/tinytim/index/tmapi/AssociationsIndexImpl.java 2008-05-05 12:37:18 UTC (rev 53) @@ -39,9 +39,13 @@ public class AssociationsIndexImpl extends AbstractTMAPIIndex implements AssociationsIndex { + private final IndexFlags _indexFlags; + public AssociationsIndexImpl(TopicMapImpl topicMap, ICollectionFactory collFactory) { super(topicMap, collFactory); + _indexFlags = topicMap.getIndexManager().getTypeInstanceIndex().isAutoUpdated() ? + IndexFlagsImpl.AUTOUPDATED : IndexFlagsImpl.NOT_AUTOUPDATED; } /* (non-Javadoc) @@ -62,14 +66,16 @@ * @see org.tmapi.index.Index#getFlags() */ public IndexFlags getFlags() throws TMAPIIndexException { - return IndexFlagsImpl.AUTOUPDATED; + return _indexFlags; } /* (non-Javadoc) * @see org.tmapi.index.Index#reindex() */ public void reindex() throws TMAPIIndexException { - // noop. + if (_indexFlags != IndexFlagsImpl.AUTOUPDATED) { + _weakTopicMap.get().getIndexManager().getTypeInstanceIndex().reindex(); + } } } Modified: tinytim/trunk/src/main/java/org/tinytim/index/tmapi/OccurrencesIndexImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/index/tmapi/OccurrencesIndexImpl.java 2008-05-02 10:49:55 UTC (rev 52) +++ tinytim/trunk/src/main/java/org/tinytim/index/tmapi/OccurrencesIndexImpl.java 2008-05-05 12:37:18 UTC (rev 53) @@ -23,7 +23,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.Map; @@ -107,29 +106,39 @@ public void reindex() throws TMAPIIndexException { _value2Occs.clear(); _loc2Occs.clear(); - for (Topic topic: _weakTopicMap.get().getTopics()) { - for (Iterator<Occurrence> iter = topic.getOccurrences().iterator(); iter.hasNext();) { - Occurrence occ = iter.next(); - if (occ.getValue() != null) { - String value = occ.getValue(); - List<Occurrence> occs = _value2Occs.get(value); - if (occs == null) { - occs = new ArrayList<Occurrence>(); - _value2Occs.put(value, occs); - } - occs.add(occ); - } - else if (occ.getResource() != null) { - Locator loc = occ.getResource(); - List<Occurrence> occs = _loc2Occs.get(loc); - if (occs == null) { - occs = new ArrayList<Occurrence>(); - _loc2Occs.put(loc, occs); - } - occs.add(occ); - } + ITypeInstanceIndex typeInstanceIdx = _weakTopicMap.get().getIndexManager().getTypeInstanceIndex(); + if (!typeInstanceIdx.isAutoUpdated()) { + typeInstanceIdx.reindex(); + } + for (Topic type: typeInstanceIdx.getOccurrenceTypes()) { + for (Occurrence occ: typeInstanceIdx.getOccurrences(type)) { + _index(occ); } } + for (Occurrence occ: typeInstanceIdx.getOccurrences(null)) { + _index(occ); + } } + private void _index(Occurrence occ) { + if (occ.getValue() != null) { + String value = occ.getValue(); + List<Occurrence> occs = _value2Occs.get(value); + if (occs == null) { + occs = new ArrayList<Occurrence>(); + _value2Occs.put(value, occs); + } + occs.add(occ); + } + else if (occ.getResource() != null) { + Locator loc = occ.getResource(); + List<Occurrence> occs = _loc2Occs.get(loc); + if (occs == null) { + occs = new ArrayList<Occurrence>(); + _loc2Occs.put(loc, occs); + } + occs.add(occ); + } + } + } Modified: tinytim/trunk/src/main/java/org/tinytim/index/tmapi/ScopedObjectsIndexImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/index/tmapi/ScopedObjectsIndexImpl.java 2008-05-02 10:49:55 UTC (rev 52) +++ tinytim/trunk/src/main/java/org/tinytim/index/tmapi/ScopedObjectsIndexImpl.java 2008-05-05 12:37:18 UTC (rev 53) @@ -44,9 +44,13 @@ public class ScopedObjectsIndexImpl extends AbstractTMAPIIndex implements ScopedObjectsIndex { + private final IndexFlags _indexFlags; + public ScopedObjectsIndexImpl(TopicMapImpl topicMap, ICollectionFactory collFactory) { super(topicMap, collFactory); + _indexFlags = topicMap.getIndexManager().getScopedIndex().isAutoUpdated() ? + IndexFlagsImpl.AUTOUPDATED : IndexFlagsImpl.NOT_AUTOUPDATED; } private IScopedIndex _getScopedIndex() { @@ -102,14 +106,16 @@ * @see org.tmapi.index.Index#getFlags() */ public IndexFlags getFlags() throws TMAPIIndexException { - return IndexFlagsImpl.AUTOUPDATED; + return _indexFlags; } /* (non-Javadoc) * @see org.tmapi.index.Index#reindex() */ public void reindex() throws TMAPIIndexException { - // noop. + if (_indexFlags != IndexFlagsImpl.AUTOUPDATED) { + _weakTopicMap.get().getIndexManager().getScopedIndex().reindex(); + } } } Modified: tinytim/trunk/src/main/java/org/tinytim/index/tmapi/TopicNamesIndexImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/index/tmapi/TopicNamesIndexImpl.java 2008-05-02 10:49:55 UTC (rev 52) +++ tinytim/trunk/src/main/java/org/tinytim/index/tmapi/TopicNamesIndexImpl.java 2008-05-05 12:37:18 UTC (rev 53) @@ -23,7 +23,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.Iterator; import java.util.List; import java.util.Map; @@ -94,18 +93,28 @@ @SuppressWarnings("unchecked") public void reindex() throws TMAPIIndexException { _value2Names.clear(); - for (Topic topic: _weakTopicMap.get().getTopics()) { - for (Iterator<TopicName> iter = topic.getTopicNames().iterator(); iter.hasNext();) { - TopicName name = iter.next(); - String value = name.getValue(); - List<TopicName> names = _value2Names.get(value); - if (names == null) { - names = new ArrayList<TopicName>(); - _value2Names.put(value, names); - } - names.add(name); + ITypeInstanceIndex typeInstanceIdx = _weakTopicMap.get().getIndexManager().getTypeInstanceIndex(); + if (!typeInstanceIdx.isAutoUpdated()) { + typeInstanceIdx.reindex(); + } + for (Topic type: typeInstanceIdx.getNameTypes()) { + for (TopicName name: typeInstanceIdx.getNames(type)) { + _index(name); } } + for (TopicName name: typeInstanceIdx.getNames(null)) { + _index(name); + } } + private void _index(TopicName name) { + String value = name.getValue(); + List<TopicName> names = _value2Names.get(value); + if (names == null) { + names = new ArrayList<TopicName>(); + _value2Names.put(value, names); + } + names.add(name); + } + } Modified: tinytim/trunk/src/main/java/org/tinytim/index/tmapi/VariantsIndexImpl.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/index/tmapi/VariantsIndexImpl.java 2008-05-02 10:49:55 UTC (rev 52) +++ tinytim/trunk/src/main/java/org/tinytim/index/tmapi/VariantsIndexImpl.java 2008-05-05 12:37:18 UTC (rev 53) @@ -29,6 +29,7 @@ import org.tinytim.ICollectionFactory; import org.tinytim.TopicMapImpl; +import org.tinytim.index.ITypeInstanceIndex; import org.tmapi.core.Locator; import org.tmapi.core.Topic; import org.tmapi.core.TopicName; @@ -88,31 +89,43 @@ public void reindex() throws TMAPIIndexException { _value2Variants.clear(); _loc2Variants.clear(); - for (Topic topic: _weakTopicMap.get().getTopics()) { - for (Iterator<TopicName> nameIter = topic.getTopicNames().iterator(); nameIter.hasNext();) { - for (Iterator<Variant> iter = nameIter.next().getVariants().iterator(); iter.hasNext();) { - Variant variant = iter.next(); - if (variant.getValue() != null) { - String value = variant.getValue(); - List<Variant> variants = _value2Variants.get(value); - if (variants == null) { - variants = new ArrayList<Variant>(); - _value2Variants.put(value, variants); - } - variants.add(variant); - } - else if (variant.getResource() != null) { - Locator loc = variant.getResource(); - List<Variant> variants = _loc2Variants.get(loc); - if (variants == null) { - variants = new ArrayList<Variant>(); - _loc2Variants.put(loc, variants); - } - variants.add(variant); - } + ITypeInstanceIndex typeInstanceIdx = _weakTopicMap.get().getIndexManager().getTypeInstanceIndex(); + if (!typeInstanceIdx.isAutoUpdated()) { + typeInstanceIdx.reindex(); + } + for (Topic type: typeInstanceIdx.getNameTypes()) { + for (TopicName name: typeInstanceIdx.getNames(type)) { + for (Iterator<Variant> iter = name.getVariants().iterator(); iter.hasNext();) { + _index(iter.next()); } } } + for (TopicName name: typeInstanceIdx.getNames(null)) { + for (Iterator<Variant> iter = name.getVariants().iterator(); iter.hasNext();) { + _index(iter.next()); + } + } } + private void _index(Variant variant) { + if (variant.getValue() != null) { + String value = variant.getValue(); + List<Variant> variants = _value2Variants.get(value); + if (variants == null) { + variants = new ArrayList<Variant>(); + _value2Variants.put(value, variants); + } + variants.add(variant); + } + else if (variant.getResource() != null) { + Locator loc = variant.getResource(); + List<Variant> variants = _loc2Variants.get(loc); + if (variants == null) { + variants = new ArrayList<Variant>(); + _loc2Variants.put(loc, variants); + } + variants.add(variant); + } + } + } Added: tinytim/trunk/src/main/java/org/tinytim/voc/TMDM.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/voc/TMDM.java (rev 0) +++ tinytim/trunk/src/main/java/org/tinytim/voc/TMDM.java 2008-05-05 12:37:18 UTC (rev 53) @@ -0,0 +1,86 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim.voc; + +import org.tinytim.IRI; +import org.tmapi.core.Locator; + +/** + * Constants for TMDM 1.0 (model) PSIs. + * + * Copied from the Semagia MIO project. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public final class TMDM { + + private static final String _BASE = "http://psi.topicmaps.org/iso13250/model/"; + + /** + * Core concept of type-instance relationships. + * Used as association type. + */ + public static final Locator TYPE_INSTANCE = new IRI(_BASE + "type-instance"); + + /** + * Core concept of type within a type-instance relationship. + * Used as role type. + */ + public static final Locator TYPE = new IRI(_BASE + "type"); + + /** + * Core concept of instance within a type-instance relationship. + * Used as role type. + */ + public static final Locator INSTANCE = new IRI(_BASE + "instance"); + + /** + * Core concept of supertype-subtype relationship. + * Used as association type. + */ + public static final Locator SUPERTYPE_SUBTYPE = new IRI(_BASE + "supertype-subtype"); + + /** + * Core concept of supertype within a supertype-subtype relationship. + * Used as role type. + */ + public static final Locator SUPERTYPE = new IRI(_BASE + "supertype"); + + /** + * Core concept of subtype within a supertype-subtype relationship. + * Used as role type. + */ + public static final Locator SUBTYPE = new IRI(_BASE + "subtype"); + + /** + * Core concept of a topic name. + * Used as topic name type. + */ + public static final Locator TOPIC_NAME = new IRI(_BASE + "topic-name"); + + /** + * Used to indicate that a variant can be used for sorting purposes. + * Used as variant theme. + */ + public static final Locator SORT = new IRI(_BASE + "sort"); +} + Property changes on: tinytim/trunk/src/main/java/org/tinytim/voc/TMDM.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native Added: tinytim/trunk/src/main/java/org/tinytim/voc/XTM10.java =================================================================== --- tinytim/trunk/src/main/java/org/tinytim/voc/XTM10.java (rev 0) +++ tinytim/trunk/src/main/java/org/tinytim/voc/XTM10.java 2008-05-05 12:37:18 UTC (rev 53) @@ -0,0 +1,105 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim.voc; + +import org.tinytim.IRI; +import org.tmapi.core.Locator; + +/** + * Constants for XTM 1.0 PSIs. + * + * The XTM 1.0 PSIs are outdated and have no relevance for the + * Topic Maps Data Model. These constants are provided for (de-)serializing + * topic maps which depend on the XTM 1.0 "model" but they should not be + * used for new topic maps, use {@link TMDM}. + * + * Copied from the Semagia MIO project. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public final class XTM10 { + + private static final String _BASE = "http://www.topicmaps.org/xtm/1.0/core.xtm#"; + + /** + * The core concept of class-instance; the class of association that + * represents class-instance relationships between topics, and that is + * semantically equivalent to the use of <instanceOf> subelements. + */ + public static final Locator CLASS_INSTANCE = new IRI(_BASE + "class-instance"); + + /** + * The core concept of class; the role of class as played by one of the + * members of a class-instance association. + */ + public static final Locator CLASS = new IRI(_BASE + "class"); + + /** + * The core concept of instance; the role of instance as played by one of + * the members of a class-instance association. + */ + public static final Locator INSTANCE = new IRI(_BASE + "instance"); + + /** + * The core concept of superclass-subclass; the class of association that + * represents superclass-subclass relationships between topics. + */ + public static final Locator SUPERCLASS_SUBCLASS = new IRI(_BASE + "superclass-subclass"); + + /** + * The core concept of superclass; the role of superclass as played by one + * of the members of a superclass-subclass association. + */ + public static final Locator SUPERCLASS = new IRI(_BASE + "superclass"); + + /** + * The core concept of subclass; the role of subclass as played by one of + * the members of a superclass-subclass association. + */ + public static final Locator SUBCLASS = new IRI(_BASE + "subclass"); + + /** + * The core concept of association; the generic class to which all + * associations belong unless otherwise specified. + */ + public static final Locator ASSOCIATION = new IRI(_BASE + "association"); + + /** + * The core concept of occurrence; the generic class to which all + * occurrences belong unless otherwise specified. + */ + public static final Locator OCCURRENCE = new IRI(_BASE + "occurrence"); + + /** + * Used to indicate that a variant can be used for sorting purposes. + * Used as variant theme. + */ + public static final Locator SORT = new IRI(_BASE + "sort"); + + /** + * Used to indicate that a variant can be used for displaying purposes. + * Used as variant theme. + */ + public static final Locator DISPLAY = new IRI(_BASE + "display"); + +} + Property changes on: tinytim/trunk/src/main/java/org/tinytim/voc/XTM10.java ___________________________________________________________________ Name: svn:keywords + Rev Date Id Name: svn:eol-style + native Modified: tinytim/trunk/src/test/java/org/tinytim/AllTests.java =================================================================== --- tinytim/trunk/src/test/java/org/tinytim/AllTests.java 2008-05-02 10:49:55 UTC (rev 52) +++ tinytim/trunk/src/test/java/org/tinytim/AllTests.java 2008-05-05 12:37:18 UTC (rev 53) @@ -41,6 +41,7 @@ public static Test suite() { TestSuite suite = new TestSuite(); suite.addTestSuite(TestConstruct.class); + suite.addTestSuite(TestDuplicateRemovalUtils.class); suite.addTestSuite(TestItemIdentifierConstraint.class); suite.addTestSuite(TestReifiable.class); suite.addTestSuite(TestScoped.class); Added: tinytim/trunk/src/test/java/org/tinytim/TestDuplicateRemovalUtils.java =================================================================== --- tinytim/trunk/src/test/java/org/tinytim/TestDuplicateRemovalUtils.java (rev 0) +++ tinytim/trunk/src/test/java/org/tinytim/TestDuplicateRemovalUtils.java 2008-05-05 12:37:18 UTC (rev 53) @@ -0,0 +1,107 @@ +/* + * This is tinyTiM, a tiny Topic Maps engine. + * + * Copyright (C) 2008 Lars Heuer (heuer[at]semagia.com) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ +package org.tinytim; + +import java.util.Arrays; +import java.util.Collection; + +import org.tmapi.core.Association; +import org.tmapi.core.Locator; +import org.tmapi.core.Topic; +import org.tmapi.core.TopicName; + +/** + * Tests against the {@link DuplicateRemovalUtils}. + * + * @author Lars Heuer (heuer[at]semagia.com) <a href="http://www.semagia.com/">Semagia</a> + * @version $Rev:$ - $Date:$ + */ +public class TestDuplicateRemovalUtils extends TinyTimTestCase { + + public void testTopicRemoveNames() { + Topic topic = _tm.createTopic(); + TopicName name1 = topic.createTopicName("tinyTiM", null); + TopicName name2 = topic.createTopicName("tinyTiM", null); + assertNull(name1.getType()); + assertTrue(name1.getScope().isEmpty()); + assertNull(name2.getType()); + assertTrue(name2.getScope().isEmpty()); + assertEquals(2, topic.getTopicNames().size()); + DuplicateRemovalUtils.removeDuplicates(topic); + assertEquals(1, topic.getTopicNames().size()); + TopicName name = (TopicName) topic.getTopicNames().iterator().next(); + assertEquals("tinyTiM", name.getValue()); + assertNull(name.getType()); + assertTrue(name.getScope().isEmpty()); + } + + public void testTopicRemoveNames2() { + Topic topic = _tm.createTopic(); + TopicName name1 = topic.createTopicName("tinyTiM", null); + TopicName name2 = topic.createTopicName("tinyTiM", null); + Locator iid1 = _tm.createLocator("http://example.org/iid-1"); + Locator iid2 = _tm.createLocator("http://example.org/iid-2"); + name1.addSourceLocator(iid1); + name2.addSourceLocator(iid2); + assertEquals(2, topic.getTopicNames().size()); + DuplicateRemovalUtils.removeDuplicates(topic); + assertEquals(1, topic.getTopicNames().size()); + TopicName name = (TopicName) topic.getTopicNames().iterator().next(); + assertEquals("tinyTiM", name.getValue()); + assertNull(name.getType()); + assertTrue(name.getScope().isEmpty()); + assertEquals(2, name.getSourceLocators().size()); + assertTrue(name.getSourceLocators().contains(iid1)); + assertTrue(name.getSourceLocators().contains(iid2)); + } + + public void testTopicRemoveNames3() { + Topic topic = _tm.createTopic(); + Topic theme1 = _tm.createTopic(); + Topic theme2 = _tm.createTopic(); + Collection<Topic> scope1 = Arrays.asList(new Topic[] {theme1, theme2}); + Collection<Topic> scope2 = Arrays.asList(new Topic[] {theme2, theme1}); + TopicName name1 = topic.createTopicName("tinyTiM", scope1); + TopicName name2 = topic.createTopicName("tinyTiM", scope2); + assertEquals(2, name1.getScope().size()); + assertEquals(2, name2.getScope().size()); + assertEquals(2, topic.getTopicNames().size()); + DuplicateRemovalUtils.removeDuplicates(topic); + assertEquals(1, topic.getTopicNames().size()); + TopicName name = (TopicNa... [truncated message content] |