Mauricio Pazos ha scritto:
> Hi Andrea, I was trying alternatives:
> 1-  Create an SuperClass of SimpleNode. The compiler uses the "node id" to 
> build the correspondent filter. The "id" is SimpleNode's instance variable, 
> the 
> generated SimpleNode has not any getter for id, that is the reason why we 
> need 
> customize it.  
> 
> 2- Provide a factory for node (using the NODE_FACTORY option) This have two 
> alternative setting: 
> a) "true" it generate a SimpleNode with the method jjCreate(int id) which 
> should be implemented. This is not the solution required (thinking in the 
> Mojo 
> issue) because we need to avoid a custom SimpleNode. 
> b) "MyFactory class" that implement jjCreate method. This could be the 
> solution because we could provide the required Node implementation, 
> unfortunately javacc doesn't generate the correspondent line to call the 
> factory. I have sent an email to javacc user list. 
> 
> Others ideas are welcome

Hum, as far as I understand the id is considered private in javacc
and the code is supposed to perform instanceof checks instead.
 From what I can see in the code, SimpleNode.getType() is used in
a couple of places as an alternative to an instanceof check against
the parsed node. So, either of the following could work:
- really do perform instanceof checks in the code instead of relying
   on getType
- implement a int getType(Node) utility method that does the instanceof
   needed and returns the type of the node
As a further alternative, you can use reflection to force your way into
the id field (you can access private fields by forcing their Field
visibility to true at runtime), this would only work in an enviroment
where the security manager is not set (or allowing that kind of 
trickery). For more information on this topic:
http://tutorials.jenkov.com/java-reflection/private-fields-and-methods.html

Hope this helps
Cheers
Andrea



-- 
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
_______________________________________________
Geotools-devel mailing list
Geotools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to