本文整理了Java中org.simpleframework.xml.Element
类的一些代码示例,展示了Element
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element
类的具体详情如下:
包路径:org.simpleframework.xml.Element
类名称:Element
暂无
代码示例来源:origin: Pay-Group/best-pay-sdk
/**
* Created by lly835@163.com
* 2018-05-17 11:32
*/
@Data
@Root(name = "xml", strict = false)
public class WxPaySandboxKeyResponse {
@Element(name = "return_code")
private String returnCode;
@Element(name = "return_msg", required = false)
private String returnMsg;
@Element(name = "mch_id", required = false)
private String mchId;
@Element(name = "sandbox_signkey", required = false)
private String sandboxSignkey;
}
代码示例来源: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: wmixvideo/nfe
@Root(name = "protMDFe")
public class MDFProtocolo extends DFBase {
private static final long serialVersionUID = 7056704602846442462L;
@Attribute(name = "versao", required = true)
private String versao;
@Element(name = "infProt", required = true)
private MDFProtocoloInfo protocoloInfo;
@Element(name = "Signature", required = false)
private NFSignature assinatura;
代码示例来源:origin: wmixvideo/nfe
public class CTeDetalhamentoEventoCancelamento extends DFBase {
private static final long serialVersionUID = 8502078404626629549L;
@Attribute(name = "versaoEvento", required = true)
private String versaoEvento;
@Element(name = "evCancCTe", required = true)
private CTeEnviaEventoCancelamento eventoCancelamento;
public void setVersaoEvento(final BigDecimal versaoEvento) {
this.versaoEvento = BigDecimalParser.tamanho5Com2CasasDecimais(versaoEvento, "Versao do Evento");
}
public String getVersaoEvento() {
return this.versaoEvento;
}
public CTeEnviaEventoCancelamento getEventoCancelamento() {
return this.eventoCancelamento;
}
public void setEventoCancelamento(final CTeEnviaEventoCancelamento eventoCancelamento) {
this.eventoCancelamento = eventoCancelamento;
}
}
代码示例来源:origin: syncany/syncany
public class LsFolderRequest extends FolderRequest {
@Element(required = false)
private LsOperationOptions options;
public LsOperationOptions getOptions() {
return options;
}
public void setOptions(OperationOptions options) {
this.options = (LsOperationOptions)options;
}
}
代码示例来源: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: 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: syncany/syncany
/**
* Validate if all required fields are present.
*
* @throws StorageException Thrown if the validation failed due to missing field values.
*/
@Validate
public final void validateRequiredFields() throws StorageException {
logger.log(Level.FINE, "Validating required fields");
try {
Field[] elementFields = ReflectionUtil.getAllFieldsWithAnnotation(this.getClass(), Element.class);
for (Field field : elementFields) {
field.setAccessible(true);
if (field.getAnnotation(Element.class).required() && field.get(this) == null) {
logger.log(Level.WARNING, "Missing mandatory field {0}#{1}", new Object[] { this.getClass().getSimpleName(), field.getName() });
throw new StorageException("Missing mandatory field " + this.getClass().getSimpleName() + "#" + field.getName());
}
}
}
catch (IllegalAccessException e) {
throw new RuntimeException("IllegalAccessException when validating required fields: ", e);
}
}
代码示例来源:origin: wmixvideo/nfe
@Root(name = "retCancCTe")
public class CTeRetornoCancelamento extends DFBase {
private static final long serialVersionUID = -578023299108955542L;
@Attribute(name = "versao", required = false)
private String versao;
@Element(name = "infEvento")
private CTeInfoEventoRetorno infoCancelamento;
public String getVersao() {
return this.versao;
}
public void setVersao(final String versao) {
this.versao = versao;
}
public CTeInfoEventoRetorno getInfoCancelamento() {
return this.infoCancelamento;
}
public void setInfoCancelamento(final CTeInfoEventoRetorno infoCancelamento) {
this.infoCancelamento = infoCancelamento;
}
}
代码示例来源:origin: wmixvideo/nfe
public class MDFeDetalhamentoEventoCancelamento extends DFBase {
private static final long serialVersionUID = 3638398807163771387L;
@Attribute(name = "versaoEvento", required = false)
private String versaoEvento;
@Element(name = "evCancMDFe")
private MDFeEnviaEventoCancelamento eventoCancelamento;
public void setVersaoEvento(final BigDecimal versaoEvento) {
this.versaoEvento = BigDecimalParser.tamanho5Com2CasasDecimais(versaoEvento, "Versao do Evento");
}
public String getVersaoEvento() {
return this.versaoEvento;
}
public MDFeEnviaEventoCancelamento getEventoCancelamento() {
return this.eventoCancelamento;
}
public void setEventoCancelamento(final MDFeEnviaEventoCancelamento eventoCancelamento) {
this.eventoCancelamento = eventoCancelamento;
}
}
代码示例来源:origin: syncany/syncany
public class RestoreFolderRequest extends FolderRequest {
@Element(required = true)
private RestoreOperationOptions options;
public RestoreOperationOptions getOptions() {
return options;
}
public void setOptions(OperationOptions options) {
this.options = (RestoreOperationOptions) options;
}
}
代码示例来源: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: wmixvideo/nfe
@Root(name = "protNFe")
public class NFProtocolo extends DFBase {
private static final long serialVersionUID = -784305871769382618L;
@Attribute(name = "versao", required = true)
private String versao;
@Element(name = "infProt", required = true)
private NFProtocoloInfo protocoloInfo;
public void setVersao(final String versao) {
this.versao = versao;
}
public void setProtocoloInfo(final NFProtocoloInfo protocoloInfo) {
this.protocoloInfo = protocoloInfo;
}
public NFProtocoloInfo getProtocoloInfo() {
return this.protocoloInfo;
}
public String getVersao() {
return this.versao;
}
}
代码示例来源:origin: syncany/syncany
@Root(strict = false)
public abstract class Request extends Message {
@Element(required = true)
private int id;
public Request() {
this.id = Math.abs(new Random().nextInt());
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
代码示例来源:origin: wmixvideo/nfe
public class MDFeRetorno extends DFBase {
private static final long serialVersionUID = -3320099037774115533L;
@Attribute(name = "versao", required = false)
private String versao;
@Element(name = "infEvento")
private MDFeInfoEventoRetorno eventoRetorno;
public String getVersao() {
return this.versao;
}
public void setVersao(final String versao) {
this.versao = versao;
}
public MDFeInfoEventoRetorno getEventoRetorno() {
return this.eventoRetorno;
}
public void setEventoRetorno(final MDFeInfoEventoRetorno eventoRetorno) {
this.eventoRetorno = eventoRetorno;
}
}
代码示例来源:origin: syncany/syncany
public class StatusFolderRequest extends FolderRequest {
@Element(required = false)
private StatusOperationOptions options;
public StatusOperationOptions getOptions() {
return options;
}
public void setOptions(OperationOptions options) {
this.options = (StatusOperationOptions)options;
}
}
代码示例来源: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;
}
代码示例来源: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: wmixvideo/nfe
@Root(name = "eventoCTe")
public class CTeEventoCancelamento extends DFBase {
private static final long serialVersionUID = -8363617761063438288L;
@Attribute(name = "versao", required = true)
private String versao;
@Element(name = "infEvento", required = true)
private CTeInfoEventoCancelamento infoEvento;
@Element(name = "Signature", required = false)
private NFSignature assinatura;
代码示例来源:origin: syncany/syncany
@Root(name="status")
public class StatusOperationOptions implements OperationOptions {
@Element(required = false)
private boolean forceChecksum = false;
@Element(required = false)
private boolean delete = true;
public boolean isForceChecksum() {
return forceChecksum;
}
public void setForceChecksum(boolean forceChecksum) {
this.forceChecksum = forceChecksum;
}
public boolean isDelete() {
return delete;
}
public void setDelete(boolean delete) {
this.delete = delete;
}
}
内容来源于网络,如有侵权,请联系作者删除!