There is my actual solution to add a value to a hashmap
private HashMap<String,Sexpr> contexte = new HashMap<String,Sexpr>();
...
this.putVariable("car",Car.CAR);
this.putVariable("cdr",Cdr.CDR);
I want to do the same thing from a XML by using SAX
<root>
<!-- Les types prédéfinis -->
<type symbole="car" type="expr" class="Car.CAR"/>
<type symbole="cdr" type="expr" class="Cdr.CDR"/>
</root>
I can get theses values from my handler (with Sax) by using
attributes.getValue(i).toString(), i’d like to convert my string to Java Code for the second part of my request to access my class Car or Cdr in this example
X.putVariable(attributes.getValue(0).toString, attributes.getValue(2).? );
Thank you for your help
It looks like you will have to use reflection to retrieve the static member (called a
Fieldin the Java reflection APIs) named in the “class” attribute. For example (untested):Now you can use it as: