org.dataconservancy.model.dcs.support.Util类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(11.1k)|赞(0)|评价(0)|浏览(157)

本文整理了Java中org.dataconservancy.model.dcs.support.Util类的一些代码示例,展示了Util类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util类的具体详情如下:
包路径:org.dataconservancy.model.dcs.support.Util
类名称:Util

Util介绍

[英]Convenience methods to test for nullity or empty strings.
[中]测试空字符串或空字符串的简便方法。

代码示例

代码示例来源:origin: org.dataconservancy.model/dcs-model

/**
 * Throws {@link IllegalArgumentException} if <code>s</code> is <code>null</code> or the empty string.
 *
 * @param s a string
 * @return the string
 */
static public String notEmptyOrNull(String s) {
  final String msg = "String must not be empty or null.";
  if (Util.isEmptyOrNull(s)) {
    throw new IllegalArgumentException(msg);
  }
  return s;
}

代码示例来源:origin: org.dataconservancy.model/dcs-model

/**
 * Throws {@link IllegalArgumentException} if <code>o</code> is <code>null</code>.
 *
 * @param o an object
 * @return the object
 */
static public Object notNull(Object o) {
  final String msg = "Object must not be null";
  if (Util.isNull(o)) {
    throw new IllegalArgumentException(msg);
  }
  return o;
}

代码示例来源:origin: org.dataconservancy.model/dcs-model

/**
 * Returns true if <code>s</code> is empty or <code>null</code>.
 *
 * @param s a string
 * @return true if <code>s</code> is empty or <code>null</code>.
 */
public static boolean isEmptyOrNull(String s) {
  return isNull(s) || isEmpty(s);
}

代码示例来源:origin: org.dataconservancy.model/dcs-model-builder-xstream

if (!isEmptyOrNull(man.getId())) {
  writer.addAttribute(A_ID, man.getId());
if (!isEmptyOrNull(man.getDateCreated())) {
  writer.addAttribute(A_DATE_CREATED, man.getDateCreated());
if (!isNull(man.getDeliverableUnit())) {
  writer.startNode(E_DUNIT);
  writer.addAttribute(A_REF, man.getDeliverableUnit());
if (!isNull(techenv)) {
  for (String e : techenv) {
    if (!isEmptyOrNull(e)) {
      writer.startNode(E_TECHENV);
      writer.setValue(e);
if (!isEmptyOrNull(type)) {
  writer.startNode(E_TYPE);
  writer.setValue(type);
if (!isNull(files)) {
  for (DcsManifestationFile mf : files) {
    writer.startNode(ManifestationFileConverter.E_MANFILE);
if (!isNull(metadataRef)) {
  for (DcsMetadataRef md : metadataRef) {
    writer.startNode(MetadataConverter.E_METADATA);
if (!isNull(metadata)) {

代码示例来源:origin: org.dataconservancy.dcs/dcs-model-builder-xstream

if (!isEmptyOrNull(man.getId())) {
  writer.addAttribute(A_ID, man.getId());
if (!isEmptyOrNull(man.getDateCreated())) {
  writer.addAttribute(A_DATE_CREATED, man.getDateCreated());
if (!isNull(man.getDeliverableUnit())) {
  writer.startNode(E_DUNIT);
  writer.addAttribute(A_REF, man.getDeliverableUnit());
if (!isNull(techenv)) {
  for (String e : techenv) {
    if (!isEmptyOrNull(e)) {
      writer.startNode(E_TECHENV);
      writer.setValue(e);
if (!isEmptyOrNull(type)) {
  writer.startNode(E_TYPE);
  writer.setValue(type);
if (!isNull(files)) {
  for (DcsManifestationFile mf : files) {
    writer.startNode(ManifestationFileConverter.E_MANFILE);
if (!isNull(metadataRef)) {
  for (DcsMetadataRef md : metadataRef) {
    writer.startNode(MetadataConverter.E_METADATA);
if (!isNull(metadata)) {

代码示例来源:origin: org.dataconservancy.dcs/dcs-ui-model-builder-xstream

@Override
public Object unmarshal(HierarchicalStreamReader reader,
            UnmarshallingContext context) {
  DateTime date = null;
  String value = reader.getValue();
  if (!isEmptyOrNull(value)) {
    date = fmt.parseDateTime(value);
  }
  return date;
}

代码示例来源:origin: org.dataconservancy.model/dcs-model-builder-xstream

@Override
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
  super.marshal(source, writer, context);
  final DcsManifestationFile mf = (DcsManifestationFile) source;
  if (mf.getRef() != null) {
    writer.addAttribute(A_REF, mf.getRef().getRef());
  }
  if (!isEmptyOrNull(mf.getPath())) {
    writer.startNode(E_PATH);
    writer.setValue(mf.getPath());
    writer.endNode();
  }
  if (!isNull(mf.getRelSet()) && !mf.getRelSet().isEmpty()) {
    for (DcsRelation rel : mf.getRelSet()) {
      writer.startNode(E_REL);
      context.convertAnother(rel);
      writer.endNode();
    }
  }
}

代码示例来源:origin: org.dataconservancy.model/dcs-ui-model-builder-xstream

@Override
public void marshal(Object source,
          HierarchicalStreamWriter writer,
          MarshallingContext context) {
  super.marshal(source, writer, context);
  final AdiAjaxTransport adiAjaxTransportSource = (AdiAjaxTransport) source;
  if (adiAjaxTransportSource != null) {
    writer.startNode("");
    if (!isNull(adiAjaxTransportSource.getMessage())) {
      writer.startNode("message");
      writer.setValue(adiAjaxTransportSource.getMessage());
      writer.endNode();
    }
    List<DataItemTransport> dataItemTransportList = adiAjaxTransportSource.getDataItemTransportList();
    if (!isNull(dataItemTransportList) && !dataItemTransportList.isEmpty()) {
      ((JsonWriter) writer).startNode("dataItemTransportList", dataItemTransportList.getClass());
      for (DataItemTransport dataItemTransport: dataItemTransportList) {
        context.convertAnother(dataItemTransport);
      }
      writer.endNode();
    }
    writer.endNode();
  }
}

代码示例来源:origin: org.dataconservancy.model/dcs-ui-model-builder-xstream

@Override
public Object unmarshal(HierarchicalStreamReader reader,
            UnmarshallingContext context) {
  DateTime date = null;
  String value = reader.getValue();
  if (!isEmptyOrNull(value)) {
    date = fmt.parseDateTime(value);
  }
  return date;
}

代码示例来源:origin: org.dataconservancy.dcs/dcs-model-builder-xstream

@Override
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
  super.marshal(source, writer, context);
  final DcsManifestationFile mf = (DcsManifestationFile) source;
  if (mf.getRef() != null) {
    writer.addAttribute(A_REF, mf.getRef().getRef());
  }
  if (!isEmptyOrNull(mf.getPath())) {
    writer.startNode(E_PATH);
    writer.setValue(mf.getPath());
    writer.endNode();
  }
  if (!isNull(mf.getRelSet()) && !mf.getRelSet().isEmpty()) {
    for (DcsRelation rel : mf.getRelSet()) {
      writer.startNode(E_REL);
      context.convertAnother(rel);
      writer.endNode();
    }
  }
}

代码示例来源:origin: org.dataconservancy.dcs/dcs-ui-model-builder-xstream

@Override
public void marshal(Object source,
          HierarchicalStreamWriter writer,
          MarshallingContext context) {
  super.marshal(source, writer, context);
  final AdiAjaxTransport adiAjaxTransportSource = (AdiAjaxTransport) source;
  if (adiAjaxTransportSource != null) {
    writer.startNode("");
    if (!isNull(adiAjaxTransportSource.getMessage())) {
      writer.startNode("message");
      writer.setValue(adiAjaxTransportSource.getMessage());
      writer.endNode();
    }
    List<DataItemTransport> dataItemTransportList = adiAjaxTransportSource.getDataItemTransportList();
    if (!isNull(dataItemTransportList) && !dataItemTransportList.isEmpty()) {
      ((JsonWriter) writer).startNode("dataItemTransportList", dataItemTransportList.getClass());
      for (DataItemTransport dataItemTransport: dataItemTransportList) {
        context.convertAnother(dataItemTransport);
      }
      writer.endNode();
    }
    writer.endNode();
  }
}

代码示例来源:origin: org.dataconservancy.model/dcs-ui-model-builder-xstream

@Override
public Object unmarshal(HierarchicalStreamReader reader,
            UnmarshallingContext context) {
  DateTime date = null;
  String value = reader.getValue();
  if (!isEmptyOrNull(value)) {
    date = fmt.parseDateTime(value);
  }
  return date;
}

代码示例来源:origin: org.dataconservancy.model/dcs-ui-model-builder-xstream

if (dataItemSource != null) {
  if (!isEmptyOrNull(dataItemSource.getId())) {
    writer.addAttribute(E_ID, dataItemSource.getId());
  if (!isEmptyOrNull(dataItemSource.getName())) {
    writer.startNode(E_NAME);
    writer.setValue(dataItemSource.getName());
  if (!isEmptyOrNull(dataItemSource.getDescription())) {
    writer.startNode(E_DESCRIPTION);
    writer.setValue(dataItemSource.getDescription());
  if (!isNull(dataItemSource.getDepositorId())) {
    writer.startNode(E_DEPOSITOR);
    writer.addAttribute(ATTR_REF, dataItemSource.getDepositorId());
  if (!isNull(dataItemSource.getDepositDate())) {
    writer.startNode(E_DEPOSIT_DATE);
    context.convertAnother(dataItemSource.getDepositDate());

代码示例来源:origin: org.dataconservancy.dcs/dcs-ui-model-builder-xstream

reader.moveDown();
String value = reader.getValue();
if (!isNull(value) && !value.isEmpty()) {
  adiAjaxTransportObject.setMessage(value);

代码示例来源:origin: org.dataconservancy.dcs/dcs-ui-model-builder-xstream

@Override
public Object unmarshal(HierarchicalStreamReader reader,
            UnmarshallingContext context) {
  DateTime date = null;
  String value = reader.getValue();
  if (!isEmptyOrNull(value)) {
    date = fmt.parseDateTime(value);
  }
  return date;
}

代码示例来源:origin: org.dataconservancy.dcs/dcs-ui-model-builder-xstream

if (!isEmptyOrNull(dataItemSource.getId())) {
  writer.addAttribute(E_ID, dataItemSource.getId());
if (!isEmptyOrNull(dataItemSource.getName())) {
  writer.startNode(E_NAME);
  writer.setValue(dataItemSource.getName());
if (!isEmptyOrNull(dataItemSource.getDescription())) {
  writer.startNode(E_DESCRIPTION);
  writer.setValue(dataItemSource.getDescription());
if (!isNull(dataItemSource.getDepositorId())) {
  writer.startNode(E_DEPOSITOR);
  writer.addAttribute(ATTR_REF, dataItemSource.getDepositorId());
if (!isNull(dataItemSource.getDepositDate())) {
  writer.startNode(E_DEPOSIT_DATE);
  context.convertAnother(dataItemSource.getDepositDate());

代码示例来源:origin: org.dataconservancy.model/dcs-ui-model-builder-xstream

reader.moveDown();
String value = reader.getValue();
if (!isNull(value) && !value.isEmpty()) {
  adiAjaxTransportObject.setMessage(value);

代码示例来源:origin: org.dataconservancy.dcs/dcs-gqm-builder-xstream

@Override
public Object unmarshal(HierarchicalStreamReader reader,
            UnmarshallingContext context) {
  String start = reader.getAttribute(A_START);
  String end = reader.getAttribute(A_END);
  
  long startVal = -1;
  if( !isEmptyOrNull(start)){
    startVal = Long.parseLong(start);
  }
  
  long endVal = -1;
  if( !isEmptyOrNull(end)){
    endVal = Long.parseLong(end);
  }
  DateTimeInterval interval = new DateTimeInterval(startVal, endVal);
  
  return interval;
}

代码示例来源:origin: org.dataconservancy.model/dcs-ui-model-builder-xstream

if (!isEmptyOrNull(dataItemSource.getId())) {
  writer.addAttribute(E_ID, dataItemSource.getId());
if (!isEmptyOrNull(dataItemSource.getName())) {
  writer.startNode(E_NAME);
  writer.setValue(dataItemSource.getName());
if (!isEmptyOrNull(dataItemSource.getDescription())) {
  writer.startNode(E_DESCRIPTION);
  writer.setValue(dataItemSource.getDescription());
if (!isNull(dataItemSource.getDepositorId())) {
  writer.startNode(E_DEPOSITOR);
  writer.addAttribute(ATTR_REF, dataItemSource.getDepositorId());
if (!isNull(dataItemSource.getDepositDate())) {
  writer.startNode(E_DEPOSIT_DATE);
  context.convertAnother(dataItemSource.getDepositDate());
if (!isNull(dataItemSource.getCreatedDate())) {
  writer.startNode(E_CREATE_DATE);
  context.convertAnother(dataItemSource.getCreatedDate());
if (!isNull(dataItemSource.getModifiedDate())) {
  writer.startNode(E_MODIFIED_DATE);
  context.convertAnother(dataItemSource.getModifiedDate());
if (!isEmptyOrNull(dataItemSource.getParentId())) {
  writer.startNode(E_PARENT_ID);

代码示例来源:origin: org.dataconservancy.model/dcs-ui-model-builder-xstream

@Override
public void marshal(Object source,
          HierarchicalStreamWriter writer,
          MarshallingContext context) {
  super.marshal(source, writer, context);
  final DataItemTransport dataItemTransportSource = (DataItemTransport) source;
  if (dataItemTransportSource != null) {
    writer.startNode(E_DATA_ITEM_TRANSPORT);
    if (!isNull(dataItemTransportSource.getDataItem())) {
      writer.startNode(E_DATA_ITEM);
      context.convertAnother(dataItemTransportSource.getDataItem());
      writer.endNode();
    }
    if (!isNull(dataItemTransportSource.getInitialDepositDate())) {
      writer.startNode(E_INITIAL_DEPOSIT_DATE);
      context.convertAnother(dataItemTransportSource.getInitialDepositDate());
      writer.endNode();
    }
    if (!isNull(dataItemTransportSource.getDepositStatus())) {
      writer.startNode(E_DEPOSIT_STATUS);
      writer.setValue(dataItemTransportSource.getDepositStatus().toString());
      writer.endNode();
    }
    writer.endNode();
  }
}

相关文章