I've had some unpredictable results using a Map where the lookup object is a custom type.
Let's say I have a custom type that looks like this:
Type CType (s1 as string, s2 as string)
dim M as map
dim C as CType
C.initialize
C.s1="somevalue"
C.s2="someothervalue1"
M.put("key",C)
1. File.WriteMap writes a string like this:
Key = [s1=somevalue, s2=someothervalue]
This works great, but File.Readmap reads it as a string and refuses to convert it to the source type. I get a java error indicating a type conversion error.
So I wrote my own routine to convert C to a delimited string and store the string map:
key = somevalue|someothervalue
Gets parsed back in to the map indicated above.
2. When I put map entries, they get corrupted. I end up with multiple map entries that are identical:
C.initialize
C.s1="bob"
C.s2="bob is cool"
M.put("key1",C)
C.initialize
C.s1="tim"
C.s2="tim sucks"
M.put("key2",C)
log(M)
Prints.....
(MyMap) {key1=[s1=tim, s2=tim sucks], key2=[s1=tim, s2=tim sucks]}
As you can see, both key1 and key2 are the same....
Any ideas about problems 1 and 2?
Thanks in advance,
-JP
Let's say I have a custom type that looks like this:
Type CType (s1 as string, s2 as string)
dim M as map
dim C as CType
C.initialize
C.s1="somevalue"
C.s2="someothervalue1"
M.put("key",C)
1. File.WriteMap writes a string like this:
Key = [s1=somevalue, s2=someothervalue]
This works great, but File.Readmap reads it as a string and refuses to convert it to the source type. I get a java error indicating a type conversion error.
So I wrote my own routine to convert C to a delimited string and store the string map:
key = somevalue|someothervalue
Gets parsed back in to the map indicated above.
2. When I put map entries, they get corrupted. I end up with multiple map entries that are identical:
C.initialize
C.s1="bob"
C.s2="bob is cool"
M.put("key1",C)
C.initialize
C.s1="tim"
C.s2="tim sucks"
M.put("key2",C)
log(M)
Prints.....
(MyMap) {key1=[s1=tim, s2=tim sucks], key2=[s1=tim, s2=tim sucks]}
As you can see, both key1 and key2 are the same....
Any ideas about problems 1 and 2?
Thanks in advance,
-JP
Last edited: