本文整理了Java中org.simpleframework.xml.Element.name()
方法的一些代码示例,展示了Element.name()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.name()
方法的具体详情如下:
包路径:org.simpleframework.xml.Element
类名称:Element
方法名:name
暂无
代码示例来源:origin: Pay-Group/best-pay-sdk
/**
* 对象转map
* @param obj
* @return
*/
public static Map<String, String> buildMap(Object obj) {
Map<String, String> map = new HashMap<>();
try {
Class<?> clazz = obj.getClass();
for (Field field : clazz.getDeclaredFields()) {
field.setAccessible(true);
String fieldName = field.getName();
//如果 element 注解 name 字段设置了内容, 使用其当成字段名
Element element = field.getAnnotation(Element.class);
if (element != null && StringUtils.isNotEmpty(element.name())) {
fieldName = element.name();
}
String value = field.get(obj) == null ? "" : String.valueOf(field.get(obj));
map.put(fieldName, value);
}
} catch (Exception e) {
e.printStackTrace();
}
return map;
}
代码示例来源:origin: syncany/syncany
private static TransferPluginOption getOptionFromField(Field field, Class<? extends TransferSettings> transferSettingsClass, int level) {
Element elementAnnotation = field.getAnnotation(Element.class);
Setup setupAnnotation = field.getAnnotation(Setup.class);
boolean hasName = !elementAnnotation.name().equalsIgnoreCase("");
boolean hasDescription = setupAnnotation != null && !setupAnnotation.description().equals("");
boolean hasCallback = setupAnnotation != null && !setupAnnotation.callback().isInterface();
boolean hasConverter = setupAnnotation != null && !setupAnnotation.converter().isInterface();
boolean hasFileType = setupAnnotation != null && setupAnnotation.fileType() != null;
String name = (hasName) ? elementAnnotation.name() : field.getName();
String description = (hasDescription) ? setupAnnotation.description() : field.getName();
FileType fileType = (hasFileType) ? setupAnnotation.fileType() : null;
boolean required = elementAnnotation.required();
boolean sensitive = setupAnnotation != null && setupAnnotation.sensitive();
boolean singular = setupAnnotation != null && setupAnnotation.singular();
boolean visible = setupAnnotation != null && setupAnnotation.visible();
boolean encrypted = field.getAnnotation(Encrypted.class) != null;
Class<? extends TransferPluginOptionCallback> callback = (hasCallback) ? setupAnnotation.callback() : null;
Class<? extends TransferPluginOptionConverter> converter = (hasConverter) ? setupAnnotation.converter() : null;
boolean isNestedOption = TransferSettings.class.isAssignableFrom(field.getType());
if (isNestedOption) {
return createNestedOption(field, level, name, description, fileType, encrypted, sensitive, singular, visible, required, callback, converter);
}
else {
return createNormalOption(field, transferSettingsClass, name, description, fileType, encrypted, sensitive, singular, visible, required, callback, converter);
}
}
代码示例来源:origin: ngallagher/simplexml
/**
* This returns the name of the parameter as taken from the XML
* annotation. The name provided here is taken by the label
* and used to compose a name consistent with how fields and
* methods are named by the system.
*
* @return this returns the name of the annotated parameter
*/
public String getName() {
return label.name();
}
}
代码示例来源:origin: org.simpleframework/simple-xml
/**
* This returns the name of the parameter as taken from the XML
* annotation. The name provided here is taken by the label
* and used to compose a name consistent with how fields and
* methods are named by the system.
*
* @return this returns the name of the annotated parameter
*/
public String getName() {
return label.name();
}
}
代码示例来源:origin: ngallagher/simplexml
/**
* This returns the name of the parameter as taken from the XML
* annotation. The name provided here is taken by the label
* and used to compose a name consistent with how fields and
* methods are named by the system.
*
* @return this returns the name of the annotated parameter
*/
public String getName() {
return label.name();
}
}
代码示例来源:origin: org.simpleframework/simple-xml
/**
* This returns the name of the parameter as taken from the XML
* annotation. The name provided here is taken by the label
* and used to compose a name consistent with how fields and
* methods are named by the system.
*
* @return this returns the name of the annotated parameter
*/
public String getName() {
return label.name();
}
}
代码示例来源:origin: org.restlet.lib/org.simpleframework.simple-xml
/**
* This returns the name of the parameter as taken from the XML
* annotation. The name provided here is taken by the label
* and used to compose a name consistent with how fields and
* methods are named by the system.
*
* @return this returns the name of the annotated parameter
*/
public String getName() {
return label.name();
}
}
代码示例来源:origin: org.restlet.lib/org.simpleframework.simple-xml
/**
* This returns the name of the parameter as taken from the XML
* annotation. The name provided here is taken by the label
* and used to compose a name consistent with how fields and
* methods are named by the system.
*
* @return this returns the name of the annotated parameter
*/
public String getName() {
return label.name();
}
}
代码示例来源:origin: thegrizzlylabs/sardine-android
private Map<String, Field> getEntityFields() {
Map<String, Field> elementsFields = new HashMap<>();
for (Field field : entityClass.getDeclaredFields()) {
Element fieldAnnotation = field.getAnnotation(Element.class);
if (fieldAnnotation != null) {
String name = fieldAnnotation.name().equals("") ? field.getName() : fieldAnnotation.name();
elementsFields.put(name, field);
}
}
return elementsFields;
}
代码示例来源:origin: org.simpleframework/simple-xml
/**
* Constructor for the <code>ElementLabel</code> object. This is
* used to create a label that can convert a XML node into a
* composite object or a primitive type from an XML element.
*
* @param contact this is the field that this label represents
* @param label this is the annotation for the contact
* @param format this is the format used to style this element
*/
public ElementLabel(Contact contact, Element label, Format format) {
this.detail = new Introspector(contact, this, format);
this.decorator = new Qualifier(contact);
this.required = label.required();
this.type = contact.getType();
this.override = label.name();
this.expect = label.type();
this.data = label.data();
this.format = format;
this.label = label;
}
代码示例来源:origin: org.restlet.lib/org.simpleframework.simple-xml
/**
* Constructor for the <code>ElementLabel</code> object. This is
* used to create a label that can convert a XML node into a
* composite object or a primitive type from an XML element.
*
* @param contact this is the field that this label represents
* @param label this is the annotation for the contact
* @param format this is the format used to style this element
*/
public ElementLabel(Contact contact, Element label, Format format) {
this.detail = new Introspector(contact, this, format);
this.decorator = new Qualifier(contact);
this.required = label.required();
this.type = contact.getType();
this.override = label.name();
this.expect = label.type();
this.data = label.data();
this.format = format;
this.label = label;
}
代码示例来源:origin: ngallagher/simplexml
/**
* Constructor for the <code>ElementLabel</code> object. This is
* used to create a label that can convert a XML node into a
* composite object or a primitive type from an XML element.
*
* @param contact this is the field that this label represents
* @param label this is the annotation for the contact
* @param format this is the format used to style this element
*/
public ElementLabel(Contact contact, Element label, Format format) {
this.detail = new Introspector(contact, this, format);
this.decorator = new Qualifier(contact);
this.required = label.required();
this.type = contact.getType();
this.override = label.name();
this.expect = label.type();
this.data = label.data();
this.format = format;
this.label = label;
}
内容来源于网络,如有侵权,请联系作者删除!