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