Assigning a basic type like string to any
type is absolutely legal. Problem is somewhere else.
Since you're not passing a string in the form used for event files, it is giving error. Decoding the error message becomes really simple once you look at one example where parseType
method is used. That gives some hint why does it really look for the opening quote in the argument.
Your problem simply put:
package com.apama.test;
event Evt{}
monitor Foo {
action onload() {
Evt e1;
// handleResponse(any.parseType("string", "World!")); // #1 Invalid argument. Doesn't work
handleResponse(any.parseType("com.apama.test.Evt", "com.apama.test.Evt()")); // #2
handleResponse("World!"); // #3
}
action handleResponse(any response){
log "Hello " + response.toString() ;
}
}
prints:
com.apama.test.Foo [1] Hello any(com.apama.test.Evt,com.apama.test.Evt())
com.apama.test.Foo [1] Hello any(string,"World!")
while uncommenting #1
gives error as shown below:
ParseException - Error in parseType() method: Unable to parse string: missing opening quote
Further, if you pass a properly-formed-but-a-non-existing-event to parseType
method, it will throw an error stating that the type couldn't be found.
ParseException - Error in parseType() method: Unable to find type 'com.apama.test.Evt2'