Comment sérialiser HashTable<String, String> XML en utilisant JAXB?

Je suis en train d'utiliser JAXB pour sérialiser un HashTable<String, String> à XML. Je suis très nouveau à Java (est venu à partir de C#), donc je suis un peu perplexe par cette tâche.

J'ai vu le code suivant:

public static <T> String ObjectToXml(T object, Class<T> classType) throws JAXBException
{
  JAXBContext jaxbContext = JAXBContext.newInstance(classType);
  StringWriter writerTo = new StringWriter();
  Marshaller marshaller = jaxbContext.createMarshaller();
  marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); 
  marshaller.marshal(object, writerTo); //create xml string from the input object
  return writerTo.toString();
}

Qui est invoquée comme suit: ObjectToXml(o, ClassOfO.class), mais HashTable<String, String>.class est mal (que je connais déjà).

Pouvez Java gourous là me montrer comment appeler ce code? Proposer une simplification de la mise en œuvre (avec une invocation exemple, bien sûr) n'est plus la bienvenue.

Grâce.

InformationsquelleAutor mark | 2011-09-23