Questions tagged [xmladapter]

55 questions
1
vote
1 answer

JAXB and an XmlAdapter for base type mapped inside the Hash Map

I'm developing some JavaSE GUI application which has to store and load it's data from/to XML file (source code avaliable here: https://github.com/SP8EBC/MKS_JG) In some place of the data structure I've a HashMap which bond a base type to Short. In…
Mateusz L
  • 41
  • 1
  • 7
1
vote
1 answer

Overriding XmlAdapter for 3rd party library class

I am generating xml using jaxbMarshaller for a third party library class. Since library XmlAdapter which converts Calendar object to string is not using TimeZone field, so marshaller is generating wrong xml for every Calendar field of pojo…
Shashi Shankar
  • 859
  • 2
  • 8
  • 25
1
vote
0 answers

Is it possible to rename an @XmlPath annotated element while marshalling with MOXy to normalize the json representation?

I'm not sure if this is at all possible as it contradicts the semantics of @XmlPath itself, but if yes, please do help me with this. I'm getting this json by calling some external API from my API implementation { "title": "Forrest Gump", …
chetan choulwar
  • 305
  • 1
  • 14
1
vote
0 answers

Excluding default valued elements in XML output of Jersey RESTful API with JAXB

I'm using JAXB to serialize objects to XML. I want to exclude elements with default values in my response. While serializing objects to JSON i have used JsonSerialize.Inclusion.NON_DEFAULT in the ObjectMapper configuration to exclude default…
1
vote
0 answers

XML adapter is not called while marshaling with dynamicly created @XmlJavaTypeAdapter annotation

I have a simple XMLAdapter: public class CDataXMLAdapter extends XmlAdapter { @Override public String marshal(String arg0) throws Exception { return ""; } @Override public String unmarshal(String arg0)…
Goni
  • 36
  • 4
1
vote
1 answer

Using JAXB to unmarshal a xml string but get empty one

Problem solved After change the XmlElementRef annotation to @XmlElementRef(name = "Option", type = Option.class, required = false) and add @XmlRootElement(name = "Option") to Option.class Update: I have added two classes(Options and Option) as…
Bruce
  • 647
  • 2
  • 12
  • 30
1
vote
0 answers

java XmlAdapter, is it possible to find out which enums are using that adapter?

I've few of Java Enums which needs to mapped. I implement a XmlAdapter for marshalling and unmarshalling purpose. I would like to make the enums generic that I can call similar method of the enums from XmlAdapter. I also introduced an interface…
pijushcse
  • 510
  • 9
  • 31
1
vote
1 answer

Use EJB in XmlAdapters

How can I inject EJBs into the XmlAdapters? The idea is I want to get list of IDs by rest API and convert this array of IDs to List of Objects for Entity Object. For example: public class Post { List categories; ... } public class…
user1079877
  • 9,008
  • 4
  • 43
  • 54
1
vote
1 answer

JAXB - adapter for a library object

I want to read an integer (inside XML element) to a Semaphore instead of int, effectively calling Semaphore(int theInteger) . Problem is - Semaphore doesn't have a default constructor. If it was a class I wrote I could either make a no-arg private…
Michael
  • 112
  • 1
  • 1
  • 7
1
vote
0 answers

JaxB Annotations and Jackson- Empty List Response

Does anyone have example of JaxB Annotation @XmlJavaTypeAdapter working with Jackson? I can NOT make it work when trying to serialize List objects. My scenario is something like the following. I have to use the XML Annotations as the beans are auto…
1
vote
0 answers

How to use jackson + jaxb + xmladapter to serialize to java data type instead of string

I am using jackson 2.4 + JaxbAnnotationModule In some cases, I would like to apply an XMLJavaTypeAdapter to the jaxb object, for example the below: @XmlJavaTypeAdapter(IntegerAdapter.class) @XmlSchemaType(name = "int") protected Integer…
indybee
  • 1,507
  • 13
  • 17
1
vote
1 answer

How to apply a @XmlJavaTypeAdapter rule to all fields of a specific type at once in JAXB?

I want to change the way XML date format is written, but I don't want to put annotations in every getter of the entire project. Is there a way to set the XmlAdapter globally to all fields of a specific type? Or at least in each class and not in each…
Pedro Barros
  • 1,326
  • 1
  • 12
  • 19
1
vote
0 answers

JAXB forward references in wrapper class mapped via adapter

I have problem with mapping map of my objects to xml via JAXB. To get prety xml from marshaller I use @XmlJavaTypeAdapter which map Map.Entry to my class which has jaxb annotation to create nice xml, but the problem is that value in my wrapper class…
gandalfml
  • 908
  • 1
  • 10
  • 23
1
vote
1 answer

Extension of XmlAdapter to handle ArrayList encloses [ ... ] with quotes

In order to solve the bug in Jersey that fails to serialize correctly a list with (only) one element, to wit: "list":"thing" instead of "list": [ "thing" ] I've written the code below which very nearly solves it, but (infuriatingly) gives me no…
Russ Bateman
  • 18,333
  • 14
  • 49
  • 65
1
vote
0 answers

@XmlJavaTypeAdapter unmarshaled Object is null

My question is: how does jax-ws generate the unmarshal code associated with the @XmlJavaTypeAdapter? I don't see the adapter class(es) in the client code (instead they are broken out into their adapted objects). Thus, how does the client know how…
Bryan
  • 11
  • 1