本文整理了Java中com.thoughtworks.xstream.mapper.Mapper.aliasForSystemAttribute()
方法的一些代码示例,展示了Mapper.aliasForSystemAttribute()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mapper.aliasForSystemAttribute()
方法的具体详情如下:
包路径:com.thoughtworks.xstream.mapper.Mapper
类名称:Mapper
方法名:aliasForSystemAttribute
[英]Get the alias for a system attribute's name.
[中]获取系统属性名称的别名。
代码示例来源:origin: jenkinsci/jenkins
public String aliasForSystemAttribute(String attribute) {
return delegate.aliasForSystemAttribute(attribute);
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
public String aliasForSystemAttribute(String attribute) {
return aliasForSystemAttributeMapper.aliasForSystemAttribute(attribute);
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
public static String readClassAttribute(HierarchicalStreamReader reader, Mapper mapper) {
String attributeName = mapper.aliasForSystemAttribute("resolves-to");
String classAttribute = attributeName == null ? null : reader.getAttribute(attributeName);
if (classAttribute == null) {
attributeName = mapper.aliasForSystemAttribute("class");
if (attributeName != null) {
classAttribute = reader.getAttribute(attributeName);
}
}
return classAttribute;
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
protected void fireValidReference(Object referenceKey) {
String attributeName = getMapper().aliasForSystemAttribute("id");
if (attributeName != null) {
writer.addAttribute(attributeName, referenceKey.toString());
}
}
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
private Class readDeclaringClass(HierarchicalStreamReader reader) {
String attributeName = mapper.aliasForSystemAttribute("defined-in");
String definedIn = attributeName == null ? null : reader.getAttribute(attributeName);
return definedIn == null ? null : mapper.realClass(definedIn);
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
protected Object getCurrentReferenceKey() {
String attributeName = getMapper().aliasForSystemAttribute("id");
return attributeName == null ? null : reader.getAttribute(attributeName);
}
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
@SuppressWarnings("unchecked")
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
String attributeName = mapper.aliasForSystemAttribute("enum-type");
if (attributeName == null) {
throw new ConversionException("No EnumType specified for EnumSet");
}
Class enumTypeForSet = mapper.realClass(reader.getAttribute(attributeName));
EnumSet set = EnumSet.noneOf(enumTypeForSet);
String[] enumValues = reader.getValue().split(",");
for (int i = 0; i < enumValues.length; i++) {
String enumValue = enumValues[i];
if(enumValue.length() > 0) {
set.add(Enum.valueOf(enumTypeForSet, enumValue));
}
}
return set;
}
代码示例来源:origin: jenkinsci/jenkins
private void writeField(String fieldName, String aliasName, Class fieldType, Class definedIn, Object newObj) {
try {
if (!mapper.shouldSerializeMember(definedIn, aliasName)) {
return;
}
ExtendedHierarchicalStreamWriterHelper.startNode(writer, mapper.serializedMember(definedIn, aliasName), fieldType);
Class actualType = newObj.getClass();
Class defaultType = mapper.defaultImplementationOf(fieldType);
if (!actualType.equals(defaultType)) {
String serializedClassName = mapper.serializedClass(actualType);
if (!serializedClassName.equals(mapper.serializedClass(defaultType))) {
writer.addAttribute(mapper.aliasForSystemAttribute("class"), serializedClassName);
}
}
if (seenFields.contains(aliasName)) {
writer.addAttribute(mapper.aliasForAttribute("defined-in"), mapper.serializedClass(definedIn));
}
Field field = reflectionProvider.getField(definedIn,fieldName);
marshallField(context, newObj, field);
writer.endNode();
} catch (RuntimeException e) {
// intercept an exception so that the stack trace shows how we end up marshalling the object in question
throw new RuntimeException("Failed to serialize "+definedIn.getName()+"#"+fieldName+" for "+source.getClass(),e);
}
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
public void marshal(Object original, final HierarchicalStreamWriter writer,
final MarshallingContext context) {
final Object source = serializationMembers.callWriteReplace(original);
if (source != original && context instanceof ReferencingMarshallingContext) {
((ReferencingMarshallingContext)context).replace(original, source);
}
if (source.getClass() != original.getClass()) {
String attributeName = mapper.aliasForSystemAttribute("resolves-to");
if (attributeName != null) {
writer.addAttribute(attributeName, mapper.serializedClass(source.getClass()));
}
context.convertAnother(source);
} else {
doMarshal(source, writer, context);
}
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
@Override
public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
final boolean oldFormat = "custom".equals(reader.getAttribute(mapper.aliasForSystemAttribute("serialization")));
if (oldFormat) {
reader.moveDown();
reader.moveDown();
}
final Map<String, Long> elements = new HashMap<>();
while (reader.hasMoreChildren()) {
reader.moveDown();
final String name = reader.getNodeName();
elements.put(oldFormat ? name : mapper.realMember(ValueRange.class, name), Long.valueOf(reader.getValue()));
reader.moveUp();
}
if (oldFormat) {
reader.moveUp();
reader.moveUp();
}
return ValueRange.of(elements.get("minSmallest").longValue(), elements.get("minLargest").longValue(), elements
.get("maxSmallest")
.longValue(), elements.get("maxLargest").longValue());
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
InvocationHandler invocationHandler = Proxy.getInvocationHandler(source);
addInterfacesToXml(source, writer);
writer.startNode("handler");
String attributeName = mapper.aliasForSystemAttribute("class");
if (attributeName != null) {
writer.addAttribute(attributeName, mapper.serializedClass(invocationHandler.getClass()));
}
context.convertAnother(invocationHandler);
writer.endNode();
}
代码示例来源:origin: geoserver/geoserver
protected static void marshalComparator(
Mapper mapper,
Comparator comparator,
HierarchicalStreamWriter writer,
MarshallingContext context) {
if (comparator != null) {
writer.startNode("comparator");
writer.addAttribute(
mapper.aliasForSystemAttribute("class"),
mapper.serializedClass(comparator.getClass()));
context.convertAnother(comparator);
writer.endNode();
}
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
private Class determineType(HierarchicalStreamReader reader, Object result, String fieldName) {
final String classAttributeName = classAttributeIdentifier != null ? classAttributeIdentifier : mapper.aliasForSystemAttribute("class");
String classAttribute = classAttributeName == null ? null : reader.getAttribute(classAttributeName);
if (classAttribute != null) {
return mapper.realClass(classAttribute);
} else {
return mapper.defaultImplementationOf(beanProvider.getPropertyType(result, fieldName));
}
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
@SuppressWarnings("unchecked")
public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
String attributeName = mapper().aliasForSystemAttribute("enum-type");
if (attributeName == null) {
throw new ConversionException("No EnumType specified for EnumMap");
}
Class type = mapper().realClass(reader.getAttribute(attributeName));
EnumMap map = new EnumMap(type);
populateMap(reader, context, map);
return map;
}
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
protected void writeItem(String name, Class type, Object item, MarshallingContext context,
HierarchicalStreamWriter writer) {
Class itemType = item == null ? Mapper.Null.class : item.getClass();
ExtendedHierarchicalStreamWriterHelper.startNode(writer, name, itemType);
if (!itemType.equals(type)) {
String attributeName = mapper().aliasForSystemAttribute("class");
if (attributeName != null) {
writer.addAttribute(attributeName, mapper().serializedClass(itemType));
}
}
if (item != null) {
context.convertAnother(item);
}
writer.endNode();
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
/**
* @deprecated As of 1.4.11 use {@link #writeCompleteItem(Object, MarshallingContext, HierarchicalStreamWriter)}
* instead.
*/
protected void writeItem(Object item, MarshallingContext context, HierarchicalStreamWriter writer) {
final Class itemType = item == null ? Mapper.Null.class : item.getClass();
ExtendedHierarchicalStreamWriterHelper.startNode(writer, name, itemType);
if (!itemType.equals(type)) {
String attributeName = mapper().aliasForSystemAttribute("class");
if (attributeName != null) {
writer.addAttribute(attributeName, mapper().serializedClass(itemType));
}
}
if (item != null) {
context.convertAnother(item);
}
writer.endNode();
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
EnumSet set = (EnumSet) source;
Class enumTypeForSet = (Class) Fields.read(typeField, set);
String attributeName = mapper.aliasForSystemAttribute("enum-type");
if (attributeName != null) {
writer.addAttribute(attributeName, mapper.serializedClass(enumTypeForSet));
}
writer.setValue(joinEnumValues(set));
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
protected void marshalComparator(Comparator comparator, HierarchicalStreamWriter writer,
MarshallingContext context) {
if (comparator != null) {
writer.startNode("comparator");
writer.addAttribute(mapper().aliasForSystemAttribute("class"),
mapper().serializedClass(comparator.getClass()));
context.convertAnother(comparator);
writer.endNode();
}
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
Class type = (Class) Fields.read(typeField, source);
String attributeName = mapper().aliasForSystemAttribute("enum-type");
if (attributeName != null) {
writer.addAttribute(attributeName, mapper().serializedClass(type));
}
super.marshal(source, writer, context);
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
protected Object instantiateNewInstance(HierarchicalStreamReader reader,
UnmarshallingContext context) {
String attributeName = mapper.aliasForSystemAttribute("resolves-to");
String readResolveValue = attributeName == null ? null : reader
.getAttribute(attributeName);
Object currentObject = context.currentObject();
if (currentObject != null) {
return currentObject;
} else if (readResolveValue != null) {
return reflectionProvider.newInstance(mapper.realClass(readResolveValue));
} else {
return reflectionProvider.newInstance(context.getRequiredType());
}
}
内容来源于网络,如有侵权,请联系作者删除!