Converter that supports all classes, but throws exceptions for
(un)marshalling.
The main purpose of this class is to register this converter as a catch-all last converter with a normal or higher priority, in addition to converters that explicitly handle the domain classes that should be supported. As a result, default XStream converters with lower priorities and possible security vulnerabilities do not get invoked.
For instance:
XStreamMarshaller unmarshaller = new XStreamMarshaller(); unmarshaller.getXStream().registerConverter(new MyDomainClassConverter(), XStream.PRIORITY_VERY_HIGH); unmarshaller.getXStream().registerConverter(new CatchAllConverter(), XStream.PRIORITY_NORMAL); MyDomainClass myObject = unmarshaller.unmarshal(source);
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | canConvert(Class<T>
the Class representing the object type to be converted type)Implements com. Determines whether the converter can marshall a particular type. |
| public void | marshal(Object
The object to be marshalled. source, HierarchicalStreamWriter A stream to write to. writer, MarshallingContext A context that allows nested objects to be processed by XStream. context)Implements com. Convert an object to textual data. |
| public Object | unmarshal(HierarchicalStreamReader
The stream to read the text from. reader, UnmarshallingContext context)Implements com. Convert textual data back into an object. |
| CatchAllConverter | back to summary |
|---|---|
| public CatchAllConverter() | |
| canConvert | back to summary |
|---|---|
| public boolean canConvert(Class<T> type) Implements com. Doc from com. Determines whether the converter can marshall a particular type.
| |
| marshal | back to summary |
|---|---|
| public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) Implements com. Doc from com. Convert an object to textual data.
| |
| unmarshal | back to summary |
|---|---|
| public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) Implements com. Doc from com. Convert textual data back into an object.
| |