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


Java HierarchicalStreamReader.moveUp方法代码示例

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


在下文中一共展示了HierarchicalStreamReader.moveUp方法的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包/类
@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

示例4: unmarshalIndividualByteElements

import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
private Object unmarshalIndividualByteElements(final HierarchicalStreamReader reader,
        final UnmarshallingContext context) {
    // have to create a temporary list because we don't know the size of the array
    final List<Byte> bytes = new ArrayList<Byte>();
    boolean firstIteration = true;
    while (firstIteration || reader.hasMoreChildren()) { // hangover from previous hasMoreChildren
        reader.moveDown();
        bytes.add((Byte)byteConverter.fromString(reader.getValue()));
        reader.moveUp();
        firstIteration = false;
    }
    // copy into real array
    final byte[] result = new byte[bytes.size()];
    for (int i = 0; i < result.length; ++i) {
        result[i] = bytes.get(i).byteValue();
    }
    return result;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:EncodedByteArrayConverter.java

示例5: 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

示例6: unmarshal

import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
@Override
public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
    final Map<String, Integer> elements = new HashMap<String, Integer>();
    while (reader.hasMoreChildren()) {
        reader.moveDown();
        elements.put(reader.getNodeName(), Integer.valueOf(reader.getValue()));
        reader.moveUp();
    }
    return new Color(elements.get("red").intValue(), elements.get("green").intValue(), elements
        .get("blue")
        .intValue(), elements.get("alpha").intValue());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:ColorConverter.java

示例7: unmarshal

import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
@Override
public Map<?, ?> unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
    reader.moveDown();
    reader.moveDown();
    final Object key = readItem(reader, context, null);
    reader.moveUp();

    reader.moveDown();
    final Object value = readItem(reader, context, null);
    reader.moveUp();
    reader.moveUp();

    return Collections.singletonMap(key, value);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:SingletonMapConverter.java

示例8: unmarshal

import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
/**
 * reads a <code>ConstantNode</code> from the XML file specified through
 * <code>reader</code>
 *
 * @pre     <code>reader</code> leads to a valid <code>ConstantNode</code>
 * @post the <code>ConstantNode</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>ConstantNode</code> - <code>ConstantNode</code> read from
 * file specified by <code>reader</code>
 */
@Override
public Object unmarshal(HierarchicalStreamReader reader,
        UnmarshallingContext context) {
    
    ExpressionTreeInterface constantNode = new ConstantNode();
    
    reader.moveDown();
    ((ConstantNode) constantNode).setName(reader.getValue());
    reader.moveUp();
    
    reader.moveDown();
    String constant = reader.getValue();
    if (constant.contains("e")) { // boolean
        ((ConstantNode) constantNode).setValue(Boolean.parseBoolean(reader.getValue()));
    } else if (constant.contains(".")) { // double
        ((ConstantNode) constantNode).setValue(Double.parseDouble(reader.getValue()));
    } else { // integer or string
        try {
            int myInt = Integer.parseInt(reader.getValue());
            ((ConstantNode) constantNode).setValue(myInt);
        } catch (NumberFormatException numberFormatException) {
            // String
            ((ConstantNode) constantNode).setValue(reader.getValue());
        }
    
    }
    
    reader.moveUp();
    
    return constantNode;
}
 
开发者ID:CIRDLES,项目名称:Squid,代码行数:45,代码来源:ConstantNodeXMLConverter.java

示例9: putCurrentEntryIntoMap

import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
protected void putCurrentEntryIntoMap(final HierarchicalStreamReader reader, final UnmarshallingContext context,
        final Map<?, ?> map, final Map<?, ?> target) {
    reader.moveDown();
    final Object key = readItem(reader, context, map);
    reader.moveUp();

    reader.moveDown();
    final Object value = readItem(reader, context, map);
    reader.moveUp();

    @SuppressWarnings("unchecked")
    final Map<Object, Object> targetMap = (Map<Object, Object>)target;
    targetMap.put(key, value);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:MapConverter.java

示例10: createObjectInputStream

import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
/**
 * Creates an ObjectInputStream that deserializes a stream of objects from a reader using XStream. <h3>Example</h3>
 * 
 * <pre>
 * ObjectInputStream in = xstream.createObjectOutputStream(aReader);
 * int a = out.readInt();
 * Object b = out.readObject();
 * Object c = out.readObject();
 * </pre>
 * 
 * @see #createObjectOutputStream(com.thoughtworks.xstream.io.HierarchicalStreamWriter, String)
 * @since 1.0.3
 */
public ObjectInputStream createObjectInputStream(final HierarchicalStreamReader reader) throws IOException {
    return new CustomObjectInputStream(new CustomObjectInputStream.StreamCallback() {
        @Override
        public Object readFromStream() throws EOFException {
            if (!reader.hasMoreChildren()) {
                throw new EOFException();
            }
            reader.moveDown();
            final Object result = unmarshal(reader);
            reader.moveUp();
            return result;
        }

        @Override
        public Map<String, Object> readFieldsFromStream() throws IOException {
            throw new NotActiveException("not in call to readObject");
        }

        @Override
        public void defaultReadObject() throws NotActiveException {
            throw new NotActiveException("not in call to readObject");
        }

        @Override
        public void registerValidation(final ObjectInputValidation validation, final int priority)
                throws NotActiveException {
            throw new NotActiveException("stream inactive");
        }

        @Override
        public void close() {
            reader.close();
        }
    }, classLoaderReference);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:49,代码来源:XStream.java

示例11: unmarshal

import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的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;
}
 
开发者ID:11590692,项目名称:Wechat-Group,代码行数:31,代码来源:WxPayOrderNotifyResultConverter.java

示例12: populateMap

import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
protected void populateMap(final HierarchicalStreamReader reader, final UnmarshallingContext context,
        final Map<?, ?> map, final Map<?, ?> target) {
    while (reader.hasMoreChildren()) {
        reader.moveDown();
        putCurrentEntryIntoMap(reader, context, map, target);
        reader.moveUp();
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:MapConverter.java

示例13: parseSubTree2

import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
private Element parseSubTree2(HierarchicalStreamReader reader, Document doc)
{
	String qname = reader.getNodeName();
	Element parent = doc.createElement(qname);

	Iterator i = reader.getAttributeNames();
	while( i.hasNext() )
	{
		String aname = i.next().toString();
		String value = reader.getAttribute(aname);
		parent.setAttribute(aname, value);
	}

	String text = reader.getValue();
	if( text.trim().length() != 0 )
	{
		Text textEl = doc.createTextNode(text);
		parent.appendChild(textEl);
	}

	for( ; reader.hasMoreChildren(); reader.moveUp() )
	{
		reader.moveDown();
		Element child = parseSubTree2(reader, doc);
		parent.appendChild(child);
	}

	return parent;
}
 
开发者ID:equella,项目名称:Equella,代码行数:30,代码来源:ElementMapping.java

示例14: populateTreeMap

import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
protected void populateTreeMap(final HierarchicalStreamReader reader, final UnmarshallingContext context,
        final TreeMap<?, ?> result, Comparator<?> comparator) {
    final boolean inFirstElement = comparator == NULL_MARKER;
    if (inFirstElement) {
        comparator = null;
    }
    @SuppressWarnings("unchecked")
    final SortedMap<Object, Object> sortedMap = new PresortedMap<Object, Object>(
        (Comparator<Object>)(comparator != null && JVM.hasOptimizedTreeMapPutAll() ? comparator : null));
    if (inFirstElement) {
        // we are already within the first entry
        putCurrentEntryIntoMap(reader, context, result, sortedMap);
        reader.moveUp();
    }
    populateMap(reader, context, result, sortedMap);
    @SuppressWarnings("unchecked")
    final TreeMap<Object, Object> typedResult = (TreeMap<Object, Object>)result;
    try {
        if (JVM.hasOptimizedTreeMapPutAll()) {
            if (comparator != null && comparatorField != null) {
                comparatorField.set(result, comparator);
            }
            typedResult.putAll(sortedMap); // internal optimization will not call comparator
        } else if (comparatorField != null) {
            comparatorField.set(result, sortedMap.comparator());
            typedResult.putAll(sortedMap); // "sort" by index
            comparatorField.set(result, comparator);
        } else {
            typedResult.putAll(sortedMap); // will use comparator for already sorted map
        }
    } catch (final IllegalAccessException e) {
        throw new ConversionException("Cannot set comparator of TreeMap", e);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:35,代码来源:TreeMapConverter.java

示例15: unmarshallElement

import com.thoughtworks.xstream.io.HierarchicalStreamReader; //导入方法依赖的package包/类
private void unmarshallElement(HierarchicalStreamReader reader, Branch branch) {
	Element element = branch.addElement(reader.getNodeName());
	for (int i=0; i<reader.getAttributeCount(); i++) {
		String attributeName = reader.getAttributeName(i);
		String attributeValue = reader.getAttribute(i);
		element.addAttribute(attributeName, attributeValue);
	}
	if (StringUtils.isNotBlank(reader.getValue()))
		element.setText(reader.getValue().trim());
	while (reader.hasMoreChildren()) {
		reader.moveDown();
		unmarshallElement(reader, element);
		reader.moveUp();
	}
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:16,代码来源:JpaConverter.java


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