List of usage examples for org.apache.commons.lang ObjectUtils toString
public static String toString(Object obj)
Gets the toString
of an Object
returning an empty string ("") if null
input.
ObjectUtils.toString(null) = "" ObjectUtils.toString("") = "" ObjectUtils.toString("bat") = "bat" ObjectUtils.toString(Boolean.TRUE) = "true"
From source file:org.pentaho.platform.scheduler2.email.Emailer.java
public void setUseAuthentication(boolean useAuthentication) { props.put("mail.smtp.auth", ObjectUtils.toString(useAuthentication)); }
From source file:org.pentaho.platform.scheduler2.email.Emailer.java
public void setSmtpPort(int port) { props.put("mail.smtp.port", ObjectUtils.toString(port)); }
From source file:org.pentaho.platform.scheduler2.email.Emailer.java
public void setUseSSL(boolean useSSL) { props.put("mail.smtp.ssl", ObjectUtils.toString(useSSL)); }
From source file:org.pentaho.platform.scheduler2.email.Emailer.java
public void setStartTLS(boolean startTLS) { props.put("mail.smtp.starttls.enable", ObjectUtils.toString(startTLS)); }
From source file:org.pentaho.platform.scheduler2.email.Emailer.java
public void setQuitWait(boolean quitWait) { props.put("mail.smtp.quitwait", ObjectUtils.toString(quitWait)); }
From source file:org.pentaho.platform.scheduler2.email.Emailer.java
public boolean setup() { try {//w ww . j av a 2 s. c om final IEmailService service = PentahoSystem.get(IEmailService.class, "IEmailService", PentahoSessionHolder.getSession()); props.put("mail.smtp.host", service.getEmailConfig().getSmtpHost()); props.put("mail.smtp.port", ObjectUtils.toString(service.getEmailConfig().getSmtpPort())); props.put("mail.transport.protocol", service.getEmailConfig().getSmtpProtocol()); props.put("mail.smtp.starttls.enable", ObjectUtils.toString(service.getEmailConfig().isUseStartTls())); props.put("mail.smtp.auth", ObjectUtils.toString(service.getEmailConfig().isAuthenticate())); props.put("mail.smtp.ssl", ObjectUtils.toString(service.getEmailConfig().isUseSsl())); props.put("mail.smtp.quitwait", ObjectUtils.toString(service.getEmailConfig().isSmtpQuitWait())); props.put("mail.from.default", service.getEmailConfig().getDefaultFrom()); String fromName = service.getEmailConfig().getFromName(); if (StringUtils.isEmpty(fromName)) { fromName = Messages.getInstance().getString("schedulerEmailFromName"); } props.put("mail.from.name", fromName); props.put("mail.debug", ObjectUtils.toString(service.getEmailConfig().isDebug())); if (service.getEmailConfig().isAuthenticate()) { props.put("mail.userid", service.getEmailConfig().getUserId()); props.put("mail.password", service.getEmailConfig().getPassword()); setAuthenticator(new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(service.getEmailConfig().getUserId(), service.getEmailConfig().getPassword()); } }); } return true; } catch (Exception e) { logger.error("Email.ERROR_0013_CONFIG_FILE_INVALID", e); //$NON-NLS-1$ } return false; }
From source file:org.pentaho.platform.util.Emailer.java
public boolean setup() { try {//w w w. j a v a 2 s. co m final IEmailService service = PentahoSystem.get(IEmailService.class, "IEmailService", PentahoSessionHolder.getSession()); props.put("mail.smtp.host", service.getEmailConfig().getSmtpHost()); props.put("mail.smtp.port", ObjectUtils.toString(service.getEmailConfig().getSmtpPort())); props.put("mail.transport.protocol", service.getEmailConfig().getSmtpProtocol()); props.put("mail.smtp.starttls.enable", ObjectUtils.toString(service.getEmailConfig().isUseStartTls())); props.put("mail.smtp.auth", ObjectUtils.toString(service.getEmailConfig().isAuthenticate())); props.put("mail.smtp.ssl", ObjectUtils.toString(service.getEmailConfig().isUseSsl())); props.put("mail.smtp.quitwait", ObjectUtils.toString(service.getEmailConfig().isSmtpQuitWait())); props.put("mail.from.default", service.getEmailConfig().getDefaultFrom()); String fromName = service.getEmailConfig().getFromName(); if (StringUtils.isEmpty(fromName)) { fromName = getEmailFromName(); } props.put("mail.from.name", fromName); props.put("mail.debug", ObjectUtils.toString(service.getEmailConfig().isDebug())); if (service.getEmailConfig().isAuthenticate()) { props.put("mail.userid", service.getEmailConfig().getUserId()); props.put("mail.password", service.getEmailConfig().getPassword()); setAuthenticator(new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { String decrypted; try { Base64PasswordService ps = new Base64PasswordService(); String pass = service.getEmailConfig().getPassword(); if (pass.startsWith("ENC:")) { decrypted = ps.decrypt( service.getEmailConfig().getPassword().substring(4, pass.length())); } else { decrypted = ps.decrypt(service.getEmailConfig().getPassword()); } } catch (Exception e) { decrypted = service.getEmailConfig().getPassword(); } return new PasswordAuthentication(service.getEmailConfig().getUserId(), decrypted); } }); } return true; } catch (Exception e) { logger.error("Email.ERROR_0013_CONFIG_FILE_INVALID", e); //$NON-NLS-1$ } return false; }
From source file:org.pivot4j.ui.aggregator.AbstractAggregator.java
/** * @param cell/*from w w w . j ava 2 s . c o m*/ * @return */ protected NumberFormat getNumberFormat(Cell cell) { NumberFormat format = null; String pattern = ObjectUtils.toString(cell.getPropertyValue(StandardCellProperty.FORMAT_STRING)); if (pattern != null && !"Standard".equals(pattern)) { try { format = new DecimalFormat(pattern); } catch (IllegalArgumentException e) { if (logger.isWarnEnabled()) { logger.warn("Illegal number format : {}", pattern); } } } if (format == null) { format = DecimalFormat.getNumberInstance(); } return format; }
From source file:org.pivot4j.ui.property.ConditionalRenderProperty.java
/** * @see org.pivot4j.ui.property.RenderProperty#getValue(org.pivot4j.ui.RenderContext) *//*ww w. j a v a2 s .com*/ @Override public String getValue(RenderContext context) { if (values == null) { return null; } String value = null; for (ConditionalValue conditionValue : values) { if (conditionValue.getCondition().matches(context)) { value = conditionValue.getValue(); } } if (value == null) { value = defaultValue; } if (value != null) { ExpressionEvaluator evaluator = context.getExpressionEvaluator(); value = ObjectUtils.toString(evaluator.evaluate(value, context.getExpressionContext())); } return value; }
From source file:org.pivot4j.ui.property.SimplePropertyTest.java
@Test public void testSimpleExpression() { TableRenderContext context = createDummyRenderContext(); context.setColIndex(2);//from w w w . j av a2s . co m context.setRowIndex(1); RenderProperty property = new SimpleRenderProperty("label", "(${rowIndex}, ${columnIndex})"); String result = ObjectUtils.toString(property.getValue(context)); assertThat("Wrong property value.", result, is(equalTo("(1, 2)"))); }