title: Convert a member of a structure of type char * to java.lang.Object in Java using SWIG
body: <p>I’m trying to convert a member of a structure of type char * to java.lang.Object in Java generated class. I want to do that because I want to pass to it objects of type Integer and String. Is it possible to do that?</p>
  
  <p>For example I have the following structure: </p>
  
  <pre><code>typedef struct Foo
  {
      int type;
      char * data;
  } Foo;
  </code></pre>
  
  <p>The <code>type</code> member is for determining the data type of the <code>data</code> member - Integer or String.</p>
  
  <p>In the generated Java class of the Foo structure I want to have a set method (for the <code>data</code> member) on which I can pass arguments of type String and Integer. I can convert the String and Integer objects to some convenient data type for example byte[] before I pass them to the set method. I want only set method not get method. Then in the C code I have to use the passed Integer or String value according to the <code>type</code> member.</p>