public class XStream2
extends com.thoughtworks.xstream.XStream
XStream
customized in various ways for Jenkins’ needs.
Most importantly, integrates RobustReflectionConverter
.Modifier and Type | Class and Description |
---|---|
static class |
XStream2.PassthruConverter<T>
Create a nested
ConverterImpl subclass that extends this class to run some
callback code just after a type is unmarshalled by RobustReflectionConverter. |
Constructor and Description |
---|
XStream2() |
XStream2(com.thoughtworks.xstream.io.HierarchicalStreamDriver hierarchicalStreamDriver) |
Modifier and Type | Method and Description |
---|---|
void |
addCompatibilityAlias(String oldClassName,
Class newClass)
Adds an alias in case class names change.
|
void |
addCriticalField(Class<?> clazz,
String field)
Specifies that a given field of a given class should not be treated with laxity by
RobustCollectionConverter . |
static com.thoughtworks.xstream.io.HierarchicalStreamDriver |
getDefaultDriver()
Convenience method so we only have to change the driver in one place
if we switch to something new in the future
|
com.thoughtworks.xstream.mapper.Mapper |
getMapperInjectionPoint() |
void |
setMapper(com.thoughtworks.xstream.mapper.Mapper m)
This method allows one to insert additional mappers after
XStream2 was created,
but because of the way XStream works internally, this needs to be done carefully. |
protected void |
setupConverters() |
void |
toXML(Object obj,
OutputStream out)
Deprecated.
Uses default encoding yet fails to write an encoding header. Prefer
toXMLUTF8(java.lang.Object, java.io.OutputStream) . |
void |
toXMLUTF8(Object obj,
OutputStream out)
Serializes to a byte stream.
|
Object |
unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader reader,
Object root,
com.thoughtworks.xstream.converters.DataHolder dataHolder) |
Object |
unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader reader,
Object root,
com.thoughtworks.xstream.converters.DataHolder dataHolder,
boolean nullOut)
Variant of
unmarshal(HierarchicalStreamReader, Object, DataHolder) that nulls out non-transient instance fields not defined in the source when unmarshaling into an existing object. |
protected com.thoughtworks.xstream.mapper.MapperWrapper |
wrapMapper(com.thoughtworks.xstream.mapper.MapperWrapper next) |
addDefaultImplementation, addImmutableType, addImmutableType, addImplicitArray, addImplicitArray, addImplicitArray, addImplicitCollection, addImplicitCollection, addImplicitCollection, addImplicitMap, addImplicitMap, addPermission, alias, alias, aliasAttribute, aliasAttribute, aliasField, aliasPackage, aliasSystemAttribute, aliasType, allowTypeHierarchy, allowTypes, allowTypes, allowTypesByRegExp, allowTypesByRegExp, allowTypesByWildcard, autodetectAnnotations, createObjectInputStream, createObjectInputStream, createObjectInputStream, createObjectInputStream, createObjectOutputStream, createObjectOutputStream, createObjectOutputStream, createObjectOutputStream, createObjectOutputStream, createObjectOutputStream, createObjectOutputStream, denyPermission, denyTypeHierarchy, denyTypes, denyTypes, denyTypesByRegExp, denyTypesByRegExp, denyTypesByWildcard, fromXML, fromXML, fromXML, fromXML, fromXML, fromXML, fromXML, fromXML, fromXML, fromXML, getClassLoader, getClassLoaderReference, getConverterLookup, getMapper, getReflectionProvider, ignoreUnknownElements, ignoreUnknownElements, ignoreUnknownElements, marshal, marshal, newDataHolder, omitField, processAnnotations, processAnnotations, registerConverter, registerConverter, registerConverter, registerConverter, registerLocalConverter, registerLocalConverter, setClassLoader, setMarshallingStrategy, setMode, setupAliases, setupDefaultImplementations, setupDefaultSecurity, setupImmutableTypes, setupSecurity, toXML, toXML, unmarshal, unmarshal, useAttributeFor, useAttributeFor, useAttributeFor, useXStream11XmlFriendlyMapper
public XStream2()
public XStream2(com.thoughtworks.xstream.io.HierarchicalStreamDriver hierarchicalStreamDriver)
public static com.thoughtworks.xstream.io.HierarchicalStreamDriver getDefaultDriver()
public Object unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, Object root, com.thoughtworks.xstream.converters.DataHolder dataHolder)
unmarshal
in class com.thoughtworks.xstream.XStream
public Object unmarshal(com.thoughtworks.xstream.io.HierarchicalStreamReader reader, Object root, com.thoughtworks.xstream.converters.DataHolder dataHolder, boolean nullOut)
unmarshal(HierarchicalStreamReader, Object, DataHolder)
that nulls out non-transient
instance fields not defined in the source when unmarshaling into an existing object.
Typically useful when loading user-supplied XML files in place (non-null root
)
where some reference-valued fields of the root object may have legitimate reasons for being null.
Without this mode, it is impossible to clear such fields in an existing instance,
since XStream has no notation for a null field value.
Even for primitive-valued fields, it is useful to guarantee
that unmarshaling will produce the same result as creating a new instance.
Do not use in cases where the root objects defines fields (typically final
)
which it expects to be NonNull
unless you are prepared to restore default values for those fields.
nullOut
- whether to perform this special behavior;
false to use the stock XStream behavior of leaving unmentioned root
fields untouchedXmlFile.unmarshalNullingOut(java.lang.Object)
,
JENKINS-21017protected void setupConverters()
setupConverters
in class com.thoughtworks.xstream.XStream
public void addCriticalField(Class<?> clazz, String field)
RobustCollectionConverter
.clazz
- a class which we expect to hold a non-transient
fieldfield
- a field name in that classprotected com.thoughtworks.xstream.mapper.MapperWrapper wrapMapper(com.thoughtworks.xstream.mapper.MapperWrapper next)
wrapMapper
in class com.thoughtworks.xstream.XStream
public com.thoughtworks.xstream.mapper.Mapper getMapperInjectionPoint()
@Deprecated public void toXML(Object obj, OutputStream out)
toXMLUTF8(java.lang.Object, java.io.OutputStream)
.toXML
in class com.thoughtworks.xstream.XStream
public void toXMLUTF8(Object obj, OutputStream out) throws IOException
IOException
public void setMapper(com.thoughtworks.xstream.mapper.Mapper m)
XStream2
was created,
but because of the way XStream works internally, this needs to be done carefully.
Namely,
getMapperInjectionPoint()
wrap it, then put that back into setMapper(Mapper)
.
public void addCompatibilityAlias(String oldClassName, Class newClass)
XStream.alias(String, Class)
, which uses the registered alias name for writing XML,
this method registers an alias to be used only for the sake of reading from XML. This makes
this method usable for the situation when class names change.oldClassName
- Fully qualified name of the old class name.newClass
- New class that's field-compatible with the given old class name.Copyright © 2004–2021. All rights reserved.