本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}