当前位置: 首页>>代码示例>>Java>>正文


Java UnmarshallingContext类代码示例

本文整理汇总了Java中com.thoughtworks.xstream.converters.UnmarshallingContext的典型用法代码示例。如果您正苦于以下问题:Java UnmarshallingContext类的具体用法?Java UnmarshallingContext怎么用?Java UnmarshallingContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UnmarshallingContext类属于com.thoughtworks.xstream.converters包,在下文中一共展示了UnmarshallingContext类的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;
}
 
开发者ID:CIRDLES,项目名称:Squid,代码行数:35,代码来源:ExpressionXMLConverter.java

示例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;
}
 
开发者ID:CIRDLES,项目名称:Squid,代码行数:36,代码来源:ShrimpSpeciesNodeXMLConverter.java

示例3: unmarshal

import com.thoughtworks.xstream.converters.UnmarshallingContext; //导入依赖的package包/类
/**
 * reads a <code>spotFieldNode</code> from the XML file specified
 * through <code>reader</code>
 *
 * @pre     <code>reader</code> leads to a valid <code>spotFieldNode</code>
 * @post the <code>spotFieldNode</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>spotFieldNode</code> - <code>spotFieldNode</code>
 * read from file specified by <code>reader</code>
 */
@Override
public Object unmarshal(HierarchicalStreamReader reader,
        UnmarshallingContext context) {

    SpotFieldNode spotFieldNode = new SpotFieldNode();

    reader.moveDown();
    spotFieldNode.setName(reader.getValue());
    reader.moveUp();   
    
    reader.moveDown();
    spotFieldNode.setMethodNameForShrimpFraction(reader.getValue());
    reader.moveUp();

    return spotFieldNode;
}
 
开发者ID:CIRDLES,项目名称:Squid,代码行数:30,代码来源:SpotFieldNodeNodeXMLConverter.java

示例4: unmarshal

import com.thoughtworks.xstream.converters.UnmarshallingContext; //导入依赖的package包/类
/**
 * reads a <code>VariableNodeForSummary</code> from the XML file specified through
 * <code>reader</code>
 *
 * @pre     <code>reader</code> leads to a valid <code>Operation</code>
 * @post the <code>VariableNodeForSummary</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>VariableNodeForSummary</code> - <code>VariableNodeForSummary</code> read from file
 * specified by <code>reader</code>
 */
@Override
public Object unmarshal(HierarchicalStreamReader reader,
        UnmarshallingContext context) {

    ExpressionTreeInterface variable = null;
    String variableType = reader.getNodeName();
    reader.moveDown();
    String variableName = reader.getValue();
    reader.moveUp();
    switch (variableType) {
        case "VariableNodeForSummary":
            variable = new VariableNodeForSummary(variableName);
            break;
        case "VariableNodeForPerSpotTaskExpressions":
            variable = new VariableNodeForPerSpotTaskExpressions(variableName);
            break;
        case "VariableNodeForIsotopicRatios":
            variable = new VariableNodeForIsotopicRatios(variableName);
            break;
    }

    return variable;
}
 
开发者ID:CIRDLES,项目名称:Squid,代码行数:36,代码来源:VariableNodeForSummaryXMLConverter.java

示例5: 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;
}
 
开发者ID:CIRDLES,项目名称:Squid,代码行数:37,代码来源:TaskXMLConverter.java

示例6: unmarshal

import com.thoughtworks.xstream.converters.UnmarshallingContext; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)
{
	Class<? extends IdCloneable> idClass = context.getRequiredType();
	IdCloneable newIdType;
	try
	{
		newIdType = idClass.newInstance();
		reader.moveDown();
		String value = reader.getValue();
		newIdType.setId(Long.parseLong(value));
		reader.moveUp();
		return newIdType;
	}
	catch( Exception e )
	{
		throw Throwables.propagate(e);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:21,代码来源:IdOnlyConverter.java

示例7: getUnmarshalledValue

import com.thoughtworks.xstream.converters.UnmarshallingContext; //导入依赖的package包/类
@Override
protected Object getUnmarshalledValue(Object object, HierarchicalStreamReader reader, UnmarshallingContext context)
{
	Object value = super.getUnmarshalledValue(object, reader, context);
	try
	{
		if( value != null )
		{
			value = format.parseObject(value.toString());
		}
	}
	catch( ParseException e )
	{
		value = null;
	}
	return value;
}
 
开发者ID:equella,项目名称:Equella,代码行数:18,代码来源:DateMapping.java

示例8: unmarshal

import com.thoughtworks.xstream.converters.UnmarshallingContext; //导入依赖的package包/类
@Override
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)
{
	Object object = context.currentObject();
	if( object == null )
	{
		object = createDefaultInstance(context.getRequiredType());
	}

	XMLDataMappings mappings;
	synchronized( XMLDataConverter.class )
	{
		mappings = ((XMLData) object).getMappings();
	}
	recurseUnmarshal(object, reader, context, "", mappings);
	return object;
}
 
开发者ID:equella,项目名称:Equella,代码行数:18,代码来源:XMLDataConverter.java

示例9: recurseUnmarshal

import com.thoughtworks.xstream.converters.UnmarshallingContext; //导入依赖的package包/类
public void recurseUnmarshal(Object object, HierarchicalStreamReader reader, UnmarshallingContext context,
	String path, XMLDataMappings mappings)
{
	Collection<AbstractMapping> col = getMapping(mappings.getMappings(), path);
	for( AbstractMapping nodeMap : col )
	{
		nodeMap.unmarshal(reader, context, object);
		if( nodeMap instanceof ElementMapping )
		{
			return;
		}
	}

	for( ; reader.hasMoreChildren(); reader.moveUp() )
	{
		reader.moveDown();
		String thispath = path + SLASH + processNodeName(mappings, reader.getNodeName());
		recurseUnmarshal(object, reader, context, thispath, mappings);
	}

}
 
开发者ID:equella,项目名称:Equella,代码行数:22,代码来源:XMLDataConverter.java

示例10: unmarshal

import com.thoughtworks.xstream.converters.UnmarshallingContext; //导入依赖的package包/类
@Override
@SuppressWarnings({"unchecked", "nls"})
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)
{
	String classFromStream = reader.getAttribute("entityclass"); //$NON-NLS-1$
	String uuidFromStream = reader.getAttribute("uuid"); //$NON-NLS-1$
	try
	{
		AbstractEntityService<?, ? extends BaseEntity> service = registry
			.getServiceForClass((Class<? extends BaseEntity>) Class.forName(classFromStream));
		if( service == null )
		{
			throw new RuntimeException("Could not find service for class '" + classFromStream
				+ "' in entity registry!");
		}
		return service.getByUuid(uuidFromStream);
	}
	catch( ClassNotFoundException e )
	{
		throw new RuntimeException(e);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:23,代码来源:BaseEntityXmlConverter.java

示例11: unmarshal

import com.thoughtworks.xstream.converters.UnmarshallingContext; //导入依赖的package包/类
@SuppressWarnings("nls")
@Override
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)
{
	MetadataFormat format = new MetadataFormat();
	for( ; reader.hasMoreChildren(); reader.moveUp() )
	{
		reader.moveDown();
		String name = reader.getNodeName();
		String value = reader.getValue();
		if( name.equals("oai:metadataPrefix") || name.equals("metadataPrefix") )
		{
			format.setMetadataPrefix(value);
		}
		else if( name.equals("oai:schema") || name.equals("schema") )
		{
			format.setSchema(value);
		}
		else if( name.equals("oai:metadataNamespace") || name.equals("metadataNamespace") )
		{
			format.setMetadataNamespace(value);
		}
	}

	return format;
}
 
开发者ID:equella,项目名称:Equella,代码行数:27,代码来源:OAIMetadataFormatConverter.java

示例12: unmarshal

import com.thoughtworks.xstream.converters.UnmarshallingContext; //导入依赖的package包/类
@Override
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context)
{
	Record record = new Record();
	for( ; reader.hasMoreChildren(); reader.moveUp() )
	{
		reader.moveDown();
		String name = reader.getNodeName();
		if( name.equals("metadata") )
		{
			reader.moveDown();
			Object object = new OAIDOMConverter().unmarshal(reader, context);
			record.setMetadata(object);
			reader.moveUp();
		}
		else if( name.equals("header") )
		{
			Header header = (Header) convert(name, context);
			record.setHeader(header);
		}
	}

	return record;
}
 
开发者ID:equella,项目名称:Equella,代码行数:25,代码来源:OAIRecordConverter.java

示例13: 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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:TreeMapConverter.java

示例14: unmarshal

import com.thoughtworks.xstream.converters.UnmarshallingContext; //导入依赖的package包/类
@Override
public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
    Class<?> type = context.getRequiredType();
    if (type.getSuperclass() != Enum.class) {
        type = type.getSuperclass(); // polymorphic enums
    }
    final String name = reader.getValue();
    try {
        @SuppressWarnings("rawtypes")
        final Class rawType = type;
        @SuppressWarnings("unchecked")
        final Enum<?> enumValue = Enum.valueOf(rawType, name);
        return enumValue;
    } catch (final IllegalArgumentException e) {
        // failed to find it, do a case insensitive match
        for (final Enum<?> c : (Enum<?>[])type.getEnumConstants()) {
            if (c.name().equalsIgnoreCase(name)) {
                return c;
            }
        }
        // all else failed
        throw e;
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:EnumConverter.java

示例15: unmarshal

import com.thoughtworks.xstream.converters.UnmarshallingContext; //导入依赖的package包/类
@Override
public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
    String methodName = null;
    String declaringClassName = null;

    while ((methodName == null || declaringClassName == null) && reader.hasMoreChildren()) {
        reader.moveDown();

        if (reader.getNodeName().equals("name")) {
            methodName = reader.getValue();
        } else if (reader.getNodeName().equals("clazz")) {
            declaringClassName = reader.getValue();
        }
        reader.moveUp();
    }

    final Class<?> declaringClass = (Class<?>)javaClassConverter.fromString(declaringClassName);
    try {
        return declaringClass.getDeclaredField(mapper.realMember(declaringClass, methodName));
    } catch (final NoSuchFieldException e) {
        throw new ConversionException(e);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:JavaFieldConverter.java


注:本文中的com.thoughtworks.xstream.converters.UnmarshallingContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。