NTM - The Java Implementation
I strongly advice you look at the Example classes before looking at the Ntm
class.
CAUTION - I make no claims that this code is production
quality. If you decide to use it, verify that cursors are closed, exceptions
are trapped and the code does exactly what you want it to do so. While I'll
be happy to help you resolve any issues, I am not promising this code will
work in your environment or solve the business problem you're grappling
with.
- ConnectToDb - shows how to make a JDBC
connection. It's not part of the NTM code, but I keep it around
to remind myself how the Connection object is created.
- Example01 - Shows how to insert many nodes at a single level.
- Example02 - Shows how to indent nodes and use the get_ancestors method.
- Example03 - Shows how to insert node D as a sibling of node B.
- Ntm - Contains the methods that interact directly with the database.
- NtmException - Wraps exceptions for ease of trapping.
- NtmFk - The Ntm class allows nodes to have multiple
parents. However, many applications don't require multiple parents. This
class is incomplete. Let me know if you need help to add functionality.
- ToHex - This class helps the UUID class to make hex
strings.
- UUID - This class uses a crytographically secure method
to generate random 32-character strings. In theory, the strings generated
will never, ever be duplicated. Let me know if you find a flaw in its
algortihm.
- MySQL_JDBC.jar - I used MySQL
and Oracle to test these classes. This is the MySQL driver that I used.