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


Java HierarchicalStreamReader类代码示例

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


HierarchicalStreamReader类属于com.thoughtworks.xstream.io包,在下文中一共展示了HierarchicalStreamReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: unmarshal

import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入依赖的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.io.HierarchicalStreamReader; //导入依赖的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.io.HierarchicalStreamReader; //导入依赖的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.io.HierarchicalStreamReader; //导入依赖的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.io.HierarchicalStreamReader; //导入依赖的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.io.HierarchicalStreamReader; //导入依赖的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: resolveClass

import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入依赖的package包/类
@Override
public Class resolveClass(HierarchicalStreamReader reader)
{
	String xclass = reader.getAttribute(XCLASS);
	Class clazz2use = null;
	if( xclass != null )
	{
		try
		{
			clazz2use = Class.forName(xclass, false, Thread.currentThread().getContextClassLoader());
		}
		catch( ClassNotFoundException e )
		{
			throw new RuntimeException(e);
		}
	}
	return clazz2use;
}
 
开发者ID:equella,项目名称:Equella,代码行数:19,代码来源:DataMapping.java

示例8: getUnmarshalledValue

import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入依赖的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

示例9: unmarshal

import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入依赖的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

示例10: recurseUnmarshal

import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入依赖的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

示例11: unmarshal

import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入依赖的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

示例12: copy

import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入依赖的package包/类
public void copy(HierarchicalStreamReader source, HierarchicalStreamWriter destination) {
    destination.startNode(source.getNodeName());
    int attributeCount = source.getAttributeCount();
    for (int i = 0; i < attributeCount; i++) {
        destination.addAttribute(source.getAttributeName(i), source.getAttribute(i));
    }
    String value = source.getValue();
    if (value != null && value.length() > 0) {
        destination.setValue(value);
    }
    while (source.hasMoreChildren()) {
        source.moveDown();
        copy(source, destination);
        source.moveUp();
    }
    destination.endNode();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:HierarchicalStreamCopier.java

示例13: unmarshal

import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入依赖的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

示例14: unmarshal

import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入依赖的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

示例15: unmarshal

import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入依赖的package包/类
@Override
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
    Object result = defaultConverter.unmarshal(reader, context);
    if (result != null) {
	String className = result.getClass().getName();
	// During deserialize XML file into object, it will save file node into fileNodes
	for (NameInfo name : fileHandleClassList) {
	    if (name.className.equals(className)) {
		fileNodes.add(ExportToolContentService.this.new ValueInfo(name, result));
		break;
	    }
	}
    }

    return result;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:ExportToolContentService.java


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