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


Java NodeMap.put方法代码示例

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


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

示例1: writeReference

import org.simpleframework.xml.stream.NodeMap; //导入方法依赖的package包/类
/**
 * This is used to write the XML element attributes representing
 * the serialized object instance. If the object has already been
 * serialized to the XML document then a reference attribute is
 * inserted and this returns true, if not, then this will write
 * a unique identity marker attribute and return false.
 *
 * @param value this is the instance that is to be serialized    
 * @param node this is the node that contains the attributes
 * 
 * @return returns true if the element has been fully written
 */   
private boolean writeReference(Object value, NodeMap node) {
   String name = get(value);
   int size = size();
   
   if(name != null) {
      node.put(refer, name);
      return true;
   } 
   String unique = String.valueOf(size);
   
   node.put(mark, unique);
   put(value, unique);
   
   return false;   
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:28,代码来源:WriteGraph.java

示例2: write

import org.simpleframework.xml.stream.NodeMap; //导入方法依赖的package包/类
public boolean write(Type field, Object value, NodeMap<OutputNode> node, Map map) throws Exception {
    boolean done = strategy.write(field, value, node, map);
    Node entry = node.remove("class");
    
    if(entry != null) {
        String className = entry.getValue();
        Class type = Class.forName(className);
        String name = forward.get(type);

        if(name == null) {
            throw new PersistenceException("Could not find alias for class %s", className);
        }
        node.put("type", name);
    }
    return done;
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:17,代码来源:AliasTest.java

示例3: write

import org.simpleframework.xml.stream.NodeMap; //导入方法依赖的package包/类
/**
 * This is used to write the XML element attributes representing
 * the serialized object instance. If the object has already been
 * serialized to the XML document then a reference attribute is
 * inserted and this returns true, if not, then this will write
 * a unique identity marker attribute and return false.
 * 
 * @param type this is the type of the object to be serialized
 * @param value this is the instance that is to be serialized    
 * @param node this is the node that contains the attributes
 * 
 * @return returns true if the element has been fully written
 */
public boolean write(Type type, Object value, NodeMap node){
   Class actual = value.getClass();
   Class expect = type.getType();
   Class real = actual;
   
   if(actual.isArray()) {
      real = writeArray(actual, value, node);
   }
   if(actual != expect) {
      node.put(label, real.getName());
   }       
   return writeReference(value, node);
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:27,代码来源:WriteGraph.java

示例4: write

import org.simpleframework.xml.stream.NodeMap; //导入方法依赖的package包/类
public boolean write(Type type, Object value, NodeMap<OutputNode> node, Map map) throws Exception {
   Component component = type.getAnnotation(Component.class);
   
   if(component != null) {
      String name = component.name();
   
      if(name != null) {
         node.put(KEY, name);
      }
   }
   return strategy.write(type, value, node, map);
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:13,代码来源:AnnotationTypeTest.java

示例5: read

import org.simpleframework.xml.stream.NodeMap; //导入方法依赖的package包/类
public void read(Type field, NodeMap<InputNode> node) throws Exception {
   String namespace = node.getNode().getReference();
   if(namespace != null && namespace.length() > 0) {
      String type = new PackageParser().revert(namespace).getName();
      if(type == null) {
         throw new PersistenceException("Could not match name %s", namespace);
      }
      node.put("class", type);
   }
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:11,代码来源:ClassToNamespaceVisitor.java

示例6: read

import org.simpleframework.xml.stream.NodeMap; //导入方法依赖的package包/类
public Value read(Type field, NodeMap<InputNode> node, Map map) throws Exception {
    Node entry = node.remove("type");
    
    if(entry != null) {
        String value = entry.getValue();
        Class type = backward.get(value);
        
        if(type == null) {
            throw new PersistenceException("Could not find class for alias %s", value);
        }
        node.put("class", type.getName());
    }
    return strategy.read(field, node, map);
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:15,代码来源:AliasTest.java

示例7: read

import org.simpleframework.xml.stream.NodeMap; //导入方法依赖的package包/类
public void read(Class field, NodeMap<InputNode> node) throws Exception{
    InputNode value = node.remove(replace);
    if(value != null) {
        String name = value.getValue();
        String type = read.get(name);
        if(type == null) {
            throw new PersistenceException("Could not match name %s", name);
        }
        node.put(label, type);
    }
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:12,代码来源:DecoratorTest.java

示例8: write

import org.simpleframework.xml.stream.NodeMap; //导入方法依赖的package包/类
public void write(Class field, NodeMap<OutputNode> node) throws Exception {
    OutputNode value = node.remove(label);
    if(value != null) {
        String type = value.getValue();
        String name = write.get(type);
        if(name == null) {
            throw new PersistenceException("Could not match class %s", type);
        }
        node.put(replace, name);
    }
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:12,代码来源:DecoratorTest.java

示例9: write

import org.simpleframework.xml.stream.NodeMap; //导入方法依赖的package包/类
public void write(Type type, NodeMap<OutputNode> node) throws Exception {
   Class key = type.getType();
   String name = binding.get(key);
   if(name != null) {
      node.put("type", name);
   }
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:8,代码来源:ElementsStrategyCallbackTest.java

示例10: write

import org.simpleframework.xml.stream.NodeMap; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public boolean write(Type type, Object value, NodeMap node, Map map){
    Class actual = value.getClass();
    Class expect = type.getType();
    Class real = actual;
    
    if(actual != expect) {
       node.put("class", real.getName());
    }       
    return false;
 }
 
开发者ID:cternes,项目名称:openkeepass,代码行数:13,代码来源:TreeStrategyWithoutArrayLength.java

示例11: write

import org.simpleframework.xml.stream.NodeMap; //导入方法依赖的package包/类
public boolean write(Type field, Object value, NodeMap node, Map map) throws Exception {            
   if(field.getType() != value.getClass()) {                       
      node.put(ELEMENT_NAME, value.getClass().getName());
   }  
   return false;
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:7,代码来源:StrategyTest.java

示例12: write

import org.simpleframework.xml.stream.NodeMap; //导入方法依赖的package包/类
/**
 * This is used to attach a attribute to the provided element
 * that is used to identify the class. The attribute name is
 * "class" and has the value of the fully qualified class 
 * name for the object provided. This will only be invoked
 * if the object class is different from the field class.
 *
 * @param type this is the declared class for the field used
 * @param value this is the instance variable being serialized
 * @param node this is the element used to represent the value
 * @param map this is used to maintain contextual information
 * 
 * @return this returns true if serialization is complete
 */   
public boolean write(Type type, Object value, NodeMap node, Map map){
   Class actual = value.getClass();
   Class expect = type.getType();
   Class real = actual;
   
   if(actual.isArray()) {
      real = writeArray(expect, value, node);
   }
   if(actual != expect) {
      node.put(label, real.getName());
   }       
   return false;
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:28,代码来源:TreeStrategy.java

示例13: writeArray

import org.simpleframework.xml.stream.NodeMap; //导入方法依赖的package包/类
/**
 * This is used to add a length attribute to the element due to
 * the fact that the serialized value is an array. The length
 * of the array is acquired and inserted in to the attributes.
 * 
 * @param field this is the field type for the array to set
 * @param value this is the actual value for the array to set
 * @param node this is the map of attributes for the element
 * 
 * @return returns the array component type that is set
 */
private Class writeArray(Class field, Object value, NodeMap node){
   int size = Array.getLength(value);
   
   if(length != null) {       
      node.put(length, String.valueOf(size));
   }
   return field.getComponentType();
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:20,代码来源:TreeStrategy.java

示例14: writeArray

import org.simpleframework.xml.stream.NodeMap; //导入方法依赖的package包/类
/**
 * This is used to add a length attribute to the element due to
 * the fact that the serialized value is an array. The length
 * of the array is acquired and inserted in to the attributes.
 * 
 * @param field this is the field type for the array to set
 * @param value this is the actual value for the array to set
 * @param node this is the map of attributes for the element
 * 
 * @return returns the array component type that is set
 */
private Class writeArray(Class field, Object value, NodeMap node){
   int size = Array.getLength(value);
   
   if(!containsKey(value)) {       
      node.put(length, String.valueOf(size));
   }
   return field.getComponentType();
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:20,代码来源:WriteGraph.java


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