I would think you'd "intern" the components of the FQN rather than FQN
itself. FQN by their nature are unique and it's the name components that frequently
repeated. And then you wouldn't have to remove the constructors of FQN. And thanks to
having the pool "equals" could use object identity to compare elements. You also
wouldn't have to intern() Strings and many primitive types (like Boolean and integers
in a range) as there is already a pool for those.
For more storage efficiency, you could FQN to hold a reference to its parent and just the
leaf element rather than a list. The leaf element would be placed in the FQN component
pool. You can also optimize hashCode computation by basing the cached hashcode off of the
parent XOR'd by the child.
For encoding, you want the common case that "toString()" is the same as
"toEncodedString".
And so there would be four cases: 1. String encoded same as before, except you escape /
using \, and \ with \. 2. Java primitives, which would be prefixed with \ and the type,
e.g. \I123 for integer 123. 3. Types with registered java.bean.PropertyEditor, you'd
prefix with \C and the class and the String value, for instance:
\Cjava.net.URL"http://example.net"/ and escape internal quotes. 4. Unregistered,
regular Serializable types, where you use the type and value encoded as Base64 or
similar.
But there's probably a better system out there for encoding, and if you can locate it,
go for it.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4138583#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...