本文整理了Java中com.thoughtworks.xstream.mapper.Mapper.shouldSerializeMember()
方法的一些代码示例,展示了Mapper.shouldSerializeMember()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mapper.shouldSerializeMember()
方法的具体详情如下:
包路径:com.thoughtworks.xstream.mapper.Mapper
类名称:Mapper
方法名:shouldSerializeMember
[英]Determine whether a specific member should be serialized.
[中]确定是否应序列化特定成员。
代码示例来源:origin: jenkinsci/jenkins
public boolean shouldSerializeMember(Class definedIn, String fieldName) {
return delegate.shouldSerializeMember(definedIn, fieldName);
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
public boolean shouldVisit(String name, Class definedIn) {
return mapper.shouldSerializeMember(definedIn, name);
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
public boolean shouldSerializeMember(Class definedIn, String fieldName) {
return shouldSerializeMemberMapper.shouldSerializeMember(definedIn, fieldName);
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
private void handleUnknownField(Class classDefiningField, String fieldName,
Class resultType, String originalNodeName) {
if (classDefiningField == null) {
for (Class cls = resultType; cls != null; cls = cls.getSuperclass()) {
if (!mapper.shouldSerializeMember(cls, originalNodeName)) {
return;
}
}
}
throw new UnknownFieldException(resultType.getName(), fieldName);
}
代码示例来源: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 visit(String fieldName, Class type, Class definedIn, Object value) {
if (!mapper.shouldSerializeMember(definedIn, fieldName)) {
return;
&& !mapper.shouldSerializeMember(lookupType, fieldName)) {
lookupType = definedIn;
代码示例来源:origin: com.thoughtworks.xstream/xstream
public void writeFieldsToStream(Map fields) {
ObjectStreamClass objectStreamClass = ObjectStreamClass.lookup(currentType[0]);
writer.startNode(ELEMENT_DEFAULT);
for (Iterator iterator = fields.keySet().iterator(); iterator.hasNext();) {
String name = (String) iterator.next();
if (!mapper.shouldSerializeMember(currentType[0], name)) {
continue;
}
ObjectStreamField field = objectStreamClass.getField(name);
Object value = fields.get(name);
if (field == null) {
throw new MissingFieldException(value.getClass().getName(), name);
}
if (value != null) {
ExtendedHierarchicalStreamWriterHelper.startNode(
writer, mapper.serializedMember(source.getClass(), name),
value.getClass());
if (field.getType() != value.getClass() && !field.getType().isPrimitive()) {
String attributeName = mapper.aliasForSystemAttribute(ATTRIBUTE_CLASS);
if (attributeName != null) {
writer.addAttribute(attributeName, mapper.serializedClass(value.getClass()));
}
}
context.convertAnother(value);
writer.endNode();
}
}
writer.endNode();
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
final Object result = instantiateNewInstance(context);
final Set seenProperties = new HashSet() {
public boolean add(Object e) {
if (!super.add(e)) {
throw new DuplicatePropertyException(((FastField)e).getName());
}
return true;
}
};
Class resultType = result.getClass();
while (reader.hasMoreChildren()) {
reader.moveDown();
String propertyName = mapper.realMember(resultType, reader.getNodeName());
if (mapper.shouldSerializeMember(resultType, propertyName)) {
boolean propertyExistsInClass = beanProvider.propertyDefinedInClass(propertyName, resultType);
if (propertyExistsInClass) {
Class type = determineType(reader, result, propertyName);
Object value = context.convertAnother(result, type);
beanProvider.writeProperty(result, propertyName, value);
seenProperties.add(new FastField(resultType, propertyName));
} else if (!mapper.isIgnoredElement(propertyName)) {
throw new MissingFieldException(resultType.getName(), propertyName);
}
}
reader.moveUp();
}
return result;
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
if (field != null && shouldUnmarshalField(field)) {
Class classDefiningField = field.getDeclaringClass();
if (!mapper.shouldSerializeMember(classDefiningField, attrName)) {
continue;
while (field != null
&& !(fieldAlreadyChecked = shouldUnmarshalField(field)
&& mapper.shouldSerializeMember(
field.getDeclaringClass(), fieldName))) {
field = reflectionProvider.getFieldOrNull(field
.shouldSerializeMember(field.getDeclaringClass(), fieldName)))) {
String classAttribute = HierarchicalStreams.readClassAttribute(
reader, mapper);
代码示例来源:origin: com.thoughtworks.xstream/xstream
public void visit(final String fieldName, final Class type, final Class definedIn,
final Object value) {
if (!mapper.shouldSerializeMember(definedIn, fieldName)) {
return;
代码示例来源:origin: com.thoughtworks.xstream/xstream
reader.moveDown();
String name = mapper.realMember(currentType[0], reader.getNodeName());
if (mapper.shouldSerializeMember(currentType[0], name)) {
String classAttribute = HierarchicalStreams.readClassAttribute(reader, mapper);
Class type;
代码示例来源:origin: com.thoughtworks.xstream/xstream
writtenDefaultFields = true;
if (!mapper.shouldSerializeMember(currentType[0], field.getName())) {
continue;
代码示例来源:origin: com.thoughtworks.xstream/xstream
public void defaultReadObject() {
if (serializationMembers.getSerializablePersistentFields(currentType[0]) != null) {
readFieldsFromStream();
return;
}
if (!reader.hasMoreChildren()) {
return;
}
reader.moveDown();
if (!reader.getNodeName().equals(ELEMENT_DEFAULT)) {
throw new ConversionException("Expected <" + ELEMENT_DEFAULT + "/> element in readObject() stream");
}
while (reader.hasMoreChildren()) {
reader.moveDown();
String fieldName = mapper.realMember(currentType[0], reader.getNodeName());
if (mapper.shouldSerializeMember(currentType[0], fieldName)) {
String classAttribute = HierarchicalStreams.readClassAttribute(reader, mapper);
final Class type;
if (classAttribute != null) {
type = mapper.realClass(classAttribute);
} else {
type = mapper.defaultImplementationOf(reflectionProvider.getFieldType(result, fieldName, currentType[0]));
}
Object value = context.convertAnother(result, type);
reflectionProvider.writeField(result, fieldName, value, currentType[0]);
}
reader.moveUp();
}
reader.moveUp();
}
代码示例来源:origin: x-stream/xstream
@Override
public boolean shouldVisit(final String name, final Class<?> definedIn) {
return mapper.shouldSerializeMember(definedIn, name);
}
代码示例来源:origin: x-stream/xstream
@Override
public boolean shouldSerializeMember(final Class<?> definedIn, final String fieldName) {
return shouldSerializeMemberMapper.shouldSerializeMember(definedIn, fieldName);
}
代码示例来源:origin: x-stream/xstream
private void handleUnknownField(final Class<?> classDefiningField, final String fieldName,
final Class<?> resultType, final String originalNodeName) {
if (classDefiningField == null) {
for (Class<?> cls = resultType; cls != null; cls = cls.getSuperclass()) {
if (!mapper.shouldSerializeMember(cls, originalNodeName)) {
return;
}
}
}
throw new UnknownFieldException(resultType.getName(), fieldName);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.xstream
private void handleUnknownField(Class classDefiningField, String fieldName,
Class resultType, String originalNodeName) {
if (classDefiningField == null) {
for (Class cls = resultType; cls != null; cls = cls.getSuperclass()) {
if (!mapper.shouldSerializeMember(cls, originalNodeName)) {
return;
}
}
}
throw new UnknownFieldException(resultType.getName(), fieldName);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.xstream-java8
private void handleUnknownField(Class classDefiningField, String fieldName,
Class resultType, String originalNodeName) {
if (classDefiningField == null) {
for (Class cls = resultType; cls != null; cls = cls.getSuperclass()) {
if (!mapper.shouldSerializeMember(cls, originalNodeName)) {
return;
}
}
}
throw new UnknownFieldException(resultType.getName(), fieldName);
}
代码示例来源:origin: org.sonatype.nexus.xstream/xstream
private void handleUnknownField(Class classDefiningField, String fieldName,
Class resultType, String originalNodeName) {
if (classDefiningField == null) {
for (Class cls = resultType; cls != null; cls = cls.getSuperclass()) {
if (!mapper.shouldSerializeMember(cls, originalNodeName)) {
return;
}
}
}
throw new UnknownFieldException(resultType.getName(), fieldName);
}
代码示例来源:origin: apache/servicemix-bundles
private void handleUnknownField(Class classDefiningField, String fieldName,
Class resultType, String originalNodeName) {
if (classDefiningField == null) {
for (Class cls = resultType; cls != null; cls = cls.getSuperclass()) {
if (!mapper.shouldSerializeMember(cls, originalNodeName)) {
return;
}
}
}
throw new UnknownFieldException(resultType.getName(), fieldName);
}
内容来源于网络,如有侵权,请联系作者删除!