Grails Date unmarshalling

The cleanest way is probably to register a custom DataBinder for possible date formats. import java.beans.PropertyEditorSupport; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; import java.util.List; public class CustomDateBinder extends PropertyEditorSupport { private final List<String> formats; public CustomDateBinder(List formats) { List<String> formatList = new ArrayList<String>(formats.size()); for (Object format : formats) { formatList.add(format.toString()); // Force String … Read more

JAXB – Ignore element

Assuming your JAXB model looks like this: @XmlRootElement(name=”foo”) public class Foo { @XmlElement(name=”element1″) String element1; @XmlElement(name=”element2″) String element2; @XmlElement(name=”bar”) Bar bar; } then simply removing the bar field from Foo will skip the <bar/> element in the input document. Alternatively, annotated the field with @XmlTransient instead of @XmlElement, and it will also be skipped.

Android E/Parcel﹕ Class not found when unmarshalling (only on Samsung Tab3)

For some strange reason it looks like the class loader isn’t set up properly. Try one of the following in TestActivity.onCreate(): TestParcel cfgOptions = getIntent().getParcelableExtra(“cfgOptions”); Intent intent = getIntent(); intent.setExtrasClassLoader(TestParcel.class.getClassLoader()); TestParcel cfgOptions = intent.getParcelableExtra(“cfgOptions”); Bundle extras = getIntent().getExtras(); extras.setClassLoader(TestParcel.class.getClassLoader()); TestParcel cfgOptions = extras.getParcelable(“cfgOptions”); Alternatively, wrap the parcelable into a bundle: Bundle b = new Bundle(); … Read more

JAXB/Moxy Unmarshalling assigns all field values to Map rather than the specific field provided for it

I believe this is somewhat related to the issue: @XmlPath(“.”) conflicts with @XmlAdapter As per bug ticket: org.eclipse.persistence.internal.oxm.record.UnmarshalRecordImpl public XPathNode getNonAttributeXPathNode(String namespaceURI, String localName, String qName, Attributes attributes) { … Line 1279 if(null == resultNode && null == nonPredicateNode) { // ANY MAPPING resultNode = xPathNode.getAnyNode();// by default it return the EventAdapter returing a null … Read more