本文整理匯總了Java中com.thoughtworks.xstream.converters.UnmarshallingContext.convertAnother方法的典型用法代碼示例。如果您正苦於以下問題:Java UnmarshallingContext.convertAnother方法的具體用法?Java UnmarshallingContext.convertAnother怎麽用?Java UnmarshallingContext.convertAnother使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.thoughtworks.xstream.converters.UnmarshallingContext
的用法示例。
在下文中一共展示了UnmarshallingContext.convertAnother方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: unmarshal
import com.thoughtworks.xstream.converters.UnmarshallingContext; //導入方法依賴的package包/類
/**
* reads a <code>Expression</code> from the XML file specified through
* <code>reader</code>
*
* @pre <code>reader</code> leads to a valid <code>Expression</code>
* @post the <code>Expression</code> is read from the XML file and returned
* @param reader stream to read through
* @param context <code>UnmarshallingContext</code> used to store generic
* data
* @return <code>Expression</code> - <code>Expression</code> read from file
* specified by <code>reader</code>
*/
@Override
public Object unmarshal(HierarchicalStreamReader reader,
UnmarshallingContext context) {
Expression expression = new Expression();
reader.moveDown();
expression.setName(reader.getValue());
reader.moveUp();
reader.moveDown();
expression.setExcelExpressionString(reader.getValue());
reader.moveUp();
reader.moveDown();
ExpressionTreeInterface expressionTree = new ExpressionTree();
expressionTree = (ExpressionTreeInterface) context.convertAnother(expressionTree, ExpressionTree.class);
expression.setExpressionTree(expressionTree);
reader.moveUp();
return expression;
}
示例2: unmarshal
import com.thoughtworks.xstream.converters.UnmarshallingContext; //導入方法依賴的package包/類
/**
* reads a <code>shrimpSpeciesNode</code> from the XML file specified
* through <code>reader</code>
*
* @pre <code>reader</code> leads to a valid <code>ShrimpSpeciesNode</code>
* @post the <code>ShrimpSpeciesNode</code> is read from the XML file and
* returned
* @param reader stream to read through
* @param context <code>UnmarshallingContext</code> used to store generic
* data
* @return <code>ShrimpSpeciesNode</code> - <code>ShrimpSpeciesNode</code>
* read from file specified by <code>reader</code>
*/
@Override
public Object unmarshal(HierarchicalStreamReader reader,
UnmarshallingContext context) {
ShrimpSpeciesNode shrimpSpeciesNode = ShrimpSpeciesNode.buildEmptyShrimpSpeciesNode();
reader.moveDown();
shrimpSpeciesNode.setName(reader.getValue());
reader.moveUp();
reader.moveDown();
SquidSpeciesModel squidSpeciesModel = new SquidSpeciesModel();
squidSpeciesModel = (SquidSpeciesModel) context.convertAnother(squidSpeciesModel, SquidSpeciesModel.class);
shrimpSpeciesNode.setsquidSpeciesModel(squidSpeciesModel);
reader.moveUp();
reader.moveDown();
shrimpSpeciesNode.setMethodNameForShrimpFraction(reader.getValue());
reader.moveUp();
return shrimpSpeciesNode;
}
示例3: unmarshal
import com.thoughtworks.xstream.converters.UnmarshallingContext; //導入方法依賴的package包/類
/**
* reads a <code>Task</code> from the XML file specified through
* <code>reader</code>
*
* @pre <code>reader</code> leads to a valid <code>Task</code>
* @post the <code>Task</code> is read from the XML file and returned
* @param reader stream to read through
* @param context <code>UnmarshallingContext</code> used to store generic
* data
* @return <code>Task</code> - <code>Task</code> read from file specified by
* <code>reader</code>
*/
@Override
public Object unmarshal(HierarchicalStreamReader reader,
UnmarshallingContext context) {
TaskInterface task = new Task();
reader.moveDown();
task.setName(reader.getValue());
reader.moveUp();
SortedSet<ExpressionTree> taskExpressions = new TreeSet<>();
reader.moveDown();
while (reader.hasMoreChildren()) {
reader.moveDown();
ExpressionTreeInterface exp = new ExpressionTree();
exp = (ExpressionTreeInterface) context.convertAnother(exp, ExpressionTree.class);
taskExpressions.add((ExpressionTree)exp);
reader.moveUp();
}
task.setTaskExpressionTreesOrdered(taskExpressions);
return task;
}
示例4: unmarshalComparator
import com.thoughtworks.xstream.converters.UnmarshallingContext; //導入方法依賴的package包/類
protected Comparator<?> unmarshalComparator(final HierarchicalStreamReader reader,
final UnmarshallingContext context, final TreeMap<?, ?> result) {
final Comparator<?> comparator;
if (reader.hasMoreChildren()) {
reader.moveDown();
if (reader.getNodeName().equals("comparator")) {
final Class<?> comparatorClass = HierarchicalStreams.readClassType(reader, mapper());
comparator = (Comparator<?>)context.convertAnother(result, comparatorClass);
} else if (reader.getNodeName().equals("no-comparator")) { // pre 1.4 format
comparator = null;
} else {
// we are already within the first entry
return NULL_MARKER;
}
reader.moveUp();
} else {
comparator = null;
}
return comparator;
}
示例5: unmarshal
import com.thoughtworks.xstream.converters.UnmarshallingContext; //導入方法依賴的package包/類
@Override
public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
final List<Object> list = new ArrayList<Object>();
while (reader.hasMoreChildren()) {
reader.moveDown();
final Object item;
final String className = HierarchicalStreams.readClassAttribute(reader, mapper);
final Class<?> itemType = className == null ? arrayType.getComponentType() : mapper.realClass(className);
if (Mapper.Null.class.equals(itemType)) {
item = null;
} else {
item = context.convertAnother(null, itemType);
}
list.add(item);
reader.moveUp();
}
final Object array = Array.newInstance(arrayType.getComponentType(), list.size());
for (int i = 0; i < list.size(); ++i) {
Array.set(array, i, list.get(i));
}
return array;
}
示例6: unmarshal
import com.thoughtworks.xstream.converters.UnmarshallingContext; //導入方法依賴的package包/類
@Override
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
WxPayOrderNotifyResult obj = new WxPayOrderNotifyResult();
List<Field> fields = new ArrayList<>(Arrays.asList(obj.getClass().getDeclaredFields()));
fields.addAll(Arrays.asList(obj.getClass().getSuperclass().getDeclaredFields()));
Map<String, Field> fieldMap = getFieldMap(fields);
List<WxPayOrderNotifyCoupon> coupons = new ArrayList<>(10);
while (reader.hasMoreChildren()) {
reader.moveDown();
if (fieldMap.containsKey(reader.getNodeName())) {
Field field = fieldMap.get(reader.getNodeName());
setFieldValue(context, obj, field);
} else if (StringUtils.startsWith(reader.getNodeName(), "coupon_id_")) {
String id = (String) context.convertAnother(obj, String.class);
getIndex(coupons, reader.getNodeName()).setCouponId(id);
} else if (StringUtils.startsWith(reader.getNodeName(), "coupon_type_")) {
String type = (String) context.convertAnother(obj, String.class);
getIndex(coupons, reader.getNodeName()).setCouponType(type);
} else if (StringUtils.startsWith(reader.getNodeName(), "coupon_fee_")) {
Integer fee = (Integer) context.convertAnother(obj, Integer.class);
getIndex(coupons, reader.getNodeName()).setCouponFee(fee);
}
reader.moveUp();
}
obj.setCouponList(coupons);
return obj;
}
示例7: setFieldValue
import com.thoughtworks.xstream.converters.UnmarshallingContext; //導入方法依賴的package包/類
private void setFieldValue(UnmarshallingContext context, WxPayOrderNotifyResult obj, Field field) {
Object val = context.convertAnother(obj, field.getType());
try {
if (val != null) {
PropertyDescriptor pd = new PropertyDescriptor(field.getName(), obj.getClass());
pd.getWriteMethod().invoke(obj, val);
}
} catch (Exception e) {
}
}
示例8: getUnmarshalledValue
import com.thoughtworks.xstream.converters.UnmarshallingContext; //導入方法依賴的package包/類
@Override
protected Object getUnmarshalledValue(Object object, HierarchicalStreamReader reader, UnmarshallingContext context)
{
Class clazz2use = resolver.resolveClass(reader);
if( clazz2use == null )
{
clazz2use = clazz;
}
Object current = null;
// Collections Data test
if( name.length() > 0 )
{
// Allows fields to be pre-initialised
current = getField(object);
}
if( current == null )
{
current = object;
}
Object retobj = context.convertAnother(current, clazz2use);
if( retobj instanceof XMLDataChild )
{
((XMLDataChild) retobj).setParentObject(object);
}
return retobj;
}
示例9: readCallback
import com.thoughtworks.xstream.converters.UnmarshallingContext; //導入方法依賴的package包/類
private void readCallback(final HierarchicalStreamReader reader, final UnmarshallingContext context,
final List<Callback> callbacksToEnhance, final List<Callback> callbacks) {
final Callback callback = (Callback)context.convertAnother(null, mapper.realClass(reader.getNodeName()));
callbacks.add(callback);
if (callback == null) {
callbacksToEnhance.add(NoOp.INSTANCE);
} else {
callbacksToEnhance.add(callback);
}
}
示例10: unmarshal
import com.thoughtworks.xstream.converters.UnmarshallingContext; //導入方法依賴的package包/類
@Override
public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
final Object result = instantiateNewInstance(context);
final Set<FastField> seenProperties = new HashSet<FastField>() {
@Override
public boolean add(final FastField e) {
if (!super.add(e)) {
throw new DuplicatePropertyException(e.getName());
}
return true;
}
};
final Class<?> resultType = result.getClass();
while (reader.hasMoreChildren()) {
reader.moveDown();
final String propertyName = mapper.realMember(resultType, reader.getNodeName());
if (mapper.shouldSerializeMember(resultType, propertyName)) {
final boolean propertyExistsInClass = beanProvider.propertyDefinedInClass(propertyName, resultType);
if (propertyExistsInClass) {
final Class<?> type = determineType(reader, result, propertyName);
final Object value = context.convertAnother(result, type);
beanProvider.writeProperty(result, propertyName, value);
seenProperties.add(new FastField(resultType, propertyName));
} else {
throw new MissingFieldException(resultType.getName(), propertyName);
}
}
reader.moveUp();
}
return result;
}
示例11: readItem
import com.thoughtworks.xstream.converters.UnmarshallingContext; //導入方法依賴的package包/類
protected Object readItem(final Class<?> type, final HierarchicalStreamReader reader,
final UnmarshallingContext context, final Object current) {
final String className = HierarchicalStreams.readClassAttribute(reader, mapper());
final Class<?> itemType = className == null ? type : mapper().realClass(className);
if (Mapper.Null.class.equals(itemType)) {
return null;
} else {
return context.convertAnother(current, itemType);
}
}
示例12: readItem
import com.thoughtworks.xstream.converters.UnmarshallingContext; //導入方法依賴的package包/類
@Override
protected Object readItem(final HierarchicalStreamReader reader, final UnmarshallingContext context,
final Object current) {
final String className = HierarchicalStreams.readClassAttribute(reader, mapper());
final Class<?> itemType = className == null ? type : mapper().realClass(className);
if (Mapper.Null.class.equals(itemType)) {
return null;
} else {
return context.convertAnother(current, itemType);
}
}
示例13: unmarshal
import com.thoughtworks.xstream.converters.UnmarshallingContext; //導入方法依賴的package包/類
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
WritableValue<T> property = createProperty();
final T value = (T) context.convertAnother(null, readType(reader));
property.setValue(value);
return property;
}
示例14: convert
import com.thoughtworks.xstream.converters.UnmarshallingContext; //導入方法依賴的package包/類
public Object convert(String name, UnmarshallingContext context)
{
return context.convertAnother(context, xstream.getMapper().realClass(name));
}
示例15: unmarshal
import com.thoughtworks.xstream.converters.UnmarshallingContext; //導入方法依賴的package包/類
@Override
public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
final Enhancer enhancer = new Enhancer();
reader.moveDown();
enhancer.setSuperclass((Class<?>)context.convertAnother(null, Class.class));
reader.moveUp();
reader.moveDown();
final List<Class<?>> interfaces = new ArrayList<Class<?>>();
while (reader.hasMoreChildren()) {
reader.moveDown();
interfaces.add((Class<?>)context.convertAnother(null, mapper.realClass(reader.getNodeName())));
reader.moveUp();
}
enhancer.setInterfaces(interfaces.toArray(new Class[interfaces.size()]));
reader.moveUp();
reader.moveDown();
final boolean useFactory = Boolean.valueOf(reader.getValue()).booleanValue();
enhancer.setUseFactory(useFactory);
reader.moveUp();
final List<Callback> callbacksToEnhance = new ArrayList<Callback>();
final List<Callback> callbacks = new ArrayList<Callback>();
Map<Method, Integer> callbackIndexMap = null;
reader.moveDown();
if ("callbacks".equals(reader.getNodeName())) {
reader.moveDown();
@SuppressWarnings("unchecked")
final Map<Method, Integer> typedMap = (Map<Method, Integer>)context.convertAnother(null, HashMap.class);
callbackIndexMap = typedMap;
reader.moveUp();
while (reader.hasMoreChildren()) {
reader.moveDown();
readCallback(reader, context, callbacksToEnhance, callbacks);
reader.moveUp();
}
} else {
readCallback(reader, context, callbacksToEnhance, callbacks);
}
enhancer.setCallbacks(callbacksToEnhance.toArray(new Callback[callbacksToEnhance.size()]));
if (callbackIndexMap != null) {
enhancer.setCallbackFilter(new ReverseEngineeredCallbackFilter(callbackIndexMap));
}
reader.moveUp();
Object result = null;
while (reader.hasMoreChildren()) {
reader.moveDown();
if (reader.getNodeName().equals("serialVersionUID")) {
enhancer.setSerialVersionUID(Long.valueOf(reader.getValue()));
} else if (reader.getNodeName().equals("instance")) {
result = create(enhancer, callbacks, useFactory);
super.doUnmarshalConditionally(result, reader, context);
}
reader.moveUp();
}
if (result == null) {
result = create(enhancer, callbacks, useFactory);
}
return serializationMethodInvoker.callReadResolve(result);
}