當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。