Пример #1
0
  @Override
  public Properties getProperties() {
    Properties properties = new Properties();

    if (getClearGlobalMap() != null) {
      properties.put(
          CLEAR_GLOBAL_MAP, BooleanUtils.toIntegerObject(getClearGlobalMap()).toString());
    }
    if (getQueueBufferSize() != null) {
      properties.put(QUEUE_BUFFER_SIZE, getQueueBufferSize().toString());
    }
    if (getDefaultMetaDataColumns() != null) {
      properties.put(
          DEFAULT_METADATA_COLUMNS,
          ObjectXMLSerializer.getInstance().serialize(getDefaultMetaDataColumns()));
    }
    if (getSmtpHost() != null) {
      properties.put(SMTP_HOST, getSmtpHost());
    }
    if (getSmtpPort() != null) {
      properties.put(SMTP_PORT, getSmtpPort());
    }
    if (getSmtpTimeout() != null) {
      properties.put(SMTP_TIMEOUT, getSmtpTimeout().toString());
    }
    if (getSmtpFrom() != null) {
      properties.put(SMTP_FROM, getSmtpFrom());
    }
    if (getSmtpSecure() != null) {
      properties.put(SMTP_SECURE, getSmtpSecure());
    }
    if (getSmtpAuth() != null) {
      properties.put(SMTP_AUTH, BooleanUtils.toIntegerObject(getSmtpAuth()).toString());
    }
    if (getSmtpUsername() != null) {
      properties.put(SMTP_USERNAME, getSmtpUsername());
    }
    if (getSmtpPassword() != null) {
      properties.put(SMTP_PASSWORD, getSmtpPassword());
    }

    return properties;
  }
Пример #2
0
 public static Integer toInt(Object obj, Integer defaultVal) {
   if (obj == null) {
     return defaultVal;
   } else if (obj instanceof Integer) {
     return (Integer) obj;
   } else if (obj instanceof Boolean) {
     return BooleanUtils.toIntegerObject((Boolean) obj);
   } else {
     String value = toString(obj);
     return isInt(value)
         ? Integer.valueOf((int) NumberUtils.toDouble(value))
         : (value.equals("true")
             ? Integer.valueOf(1)
             : (value.equals("false") ? Integer.valueOf(0) : defaultVal));
   }
 }
Пример #3
0
 public static Long toLong(Object obj, Long defaultVal) {
   if (obj == null) {
     return defaultVal;
   } else if (obj instanceof Long) {
     return (Long) obj;
   } else if (obj instanceof Integer) {
     return Long.valueOf((long) ((Integer) obj).intValue() * 1L);
   } else if (obj instanceof Boolean) {
     return Long.valueOf((long) BooleanUtils.toIntegerObject((Boolean) obj).intValue() * 1L);
   } else {
     String value = toString(obj);
     return isLong(value)
         ? Long.valueOf((long) NumberUtils.toDouble(value))
         : (value.equals("true")
             ? Long.valueOf(1L)
             : (value.equals("false") ? Long.valueOf(0L) : defaultVal));
   }
 }