Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7709015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:45:30+00:00 2026-06-01T00:45:30+00:00

There is my actual solution to add a value to a hashmap private HashMap<String,Sexpr>

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T00:45:31+00:00Added an answer on June 1, 2026 at 12:45 am

    It looks like you will have to use reflection to retrieve the static member (called a Field in the Java reflection APIs) named in the “class” attribute. For example (untested):

    public static Object lookupStaticMember(String name) /* throws many */ {
      String classField[] = name.split("\\.");
      Class<?> klass = Class.forName(classField[0]);
      Field field = klass.getField(classField[1]);
      int mods = field.getModifiers();
      if ((Modifier.PUBLIC & mods == 0) || (Modifier.STATIC & mods == 0)) {
        throw new IllegalArgumentException("field " + name + " is not public static");
      }
      return field.get(klass);
    }
    

    Now you can use it as:

    X.putVariable(attributes.getValue(0).toString(),
        (Sexpr) lookupStaticMember(attributes.getValue(2).toString()));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there an actual package in CPAN to convert such string: my $string =
Is there anyway to get the actual images used in resources? e.g., I want
Is there an easy way to see the actual SQL generated by a rails
Is there a way to determine if a image path leads to an actual
is there any way, how to determine actual allocated memory in Android application (in
When I get an email, there is a header From: in the actual MIME
I'm adding a new WPF project to an existing Visual Studio solution and would
Original I want to parse a string of html code and add newlines after
Solution I did some googling and found this forum post , and here is
I want to add a constant value onto an incoming bound integer. In fact

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.