Example usage for org.apache.commons.lang3 ArrayUtils toString

List of usage examples for org.apache.commons.lang3 ArrayUtils toString

Introduction

In this page you can find the example usage for org.apache.commons.lang3 ArrayUtils toString.

Prototype

public static String toString(final Object array, final String stringIfNull) 

Source Link

Document

Outputs an array as a String handling null s.

Multi-dimensional arrays are handled correctly, including multi-dimensional primitive arrays.

The format is that of Java source code, for example {a,b}.

Usage

From source file:be.error.rpi.heating.jobs.HeatingInfoPollerJob.java

@Override
public void execute(final JobExecutionContext context) throws JobExecutionException {
    try {/*from w  ww  .j  ava2  s.  c o m*/
        logger.debug("Status poller job starting...");
        JobConfig jobConfig = (JobConfig) context.getJobDetail().getJobDataMap().get(JOB_CONFIG_KEY);

        for (Entry<EbusCommand<?>, GroupAddress> entry : jobConfig.getEbusCommands().entrySet()) {
            logger.debug("Requesting status with command " + entry.getKey().getEbusCommands());
            List<String> result = new EbusdTcpCommunicatorImpl(jobConfig.getEbusDeviceAddress())
                    .send(entry.getKey());
            logger.debug("Result for command " + entry.getKey().getEbusCommands() + " -> "
                    + ArrayUtils.toString(result, ""));
            Object converted = entry.getKey().convertResult(result);
            logger.debug("Sending result " + converted + " to GA: " + entry.getValue());

            if (converted instanceof Float) {
                getInstance().getKnxConnectionFactory()
                        .runWithProcessCommunicator(pc -> pc.write(entry.getValue(), (Float) converted, false));
            } else if (converted instanceof BigDecimal) {
                getInstance().getKnxConnectionFactory().runWithProcessCommunicator(
                        pc -> pc.write(entry.getValue(), ((BigDecimal) converted).floatValue(), false));
            } else if (converted instanceof Boolean) {
                getInstance().getKnxConnectionFactory()
                        .runWithProcessCommunicator(pc -> pc.write(entry.getValue(), (Boolean) converted));
            } else if (converted instanceof String) {
                getInstance().getKnxConnectionFactory()
                        .runWithProcessCommunicator(pc -> pc.write(entry.getValue(), (String) converted));
            } else {
                throw new IllegalStateException("Could not send type " + converted.getClass());
            }
        }
    } catch (Exception e) {
        logger.error(HeatingInfoPollerJob.class.getSimpleName() + " exception", e);
        throw new JobExecutionException(e);
    }
}

From source file:com.jaeksoft.searchlib.web.AutoCompletionServlet.java

private void set(ServletTransaction transaction, Client client, User user, String name)
        throws SearchLibException {
    if (user != null && !user.hasRole(transaction.getIndexName(), Role.INDEX_SCHEMA))
        throw new SearchLibException("Not permitted");
    String[] fields = transaction.getParameterValues("field");
    AutoCompletionItem autoComp = client.getAutoCompletionManager().getItem(name);
    if (autoComp == null)
        throw new SearchLibException("Autocompletion item not found " + name);
    autoComp.setField(fields);/*from  w  ww.j a v a 2  s.c om*/
    autoComp.save();
    transaction.addXmlResponse("Status", "OK");
    transaction.addXmlResponse("Field", ArrayUtils.toString(fields, ""));
}

From source file:edu.umich.flowfence.common.QMDescriptor.java

public String printCall(Object[] args) {
    String format = getNameFormat();
    String argString = ArrayUtils.toString(args, "{}");
    return String.format(format, ClassUtils.getShortClassName(definingClass.getClassName()), methodName,
            // strip off {}
            argString.substring(1, argString.length() - 1));
}

From source file:jp.terasoluna.fw.util.StringUtil.java

/**
 * ???????/*from   w  w w . j  a  va  2 s. c o m*/
 * ????????????
 *
 * @param arrayObj ?
 * @return ?
 */
public static String getArraysStr(Object[] arrayObj) {
    return ArrayUtils.toString(arrayObj, null);
}

From source file:org.efaps.util.EFapsException.java

/**
 * @param _className  name of class in which the exception is thrown
 * @param _id         id of the exception which is thrown
 * @param _args       argument arrays/*from ww w. j  a  va 2s. c  o  m*/
 */
public EFapsException(final Class<?> _className, final String _id, final Object... _args) {
    super("error in " + _className.getName() + "(" + _id + "," + ArrayUtils.toString(_args, "Null ARRAY ")
            + ")");
    this.id = _id;
    this.className = _className;
    if (_args != null && _args.length > 0 && _args[0] instanceof Throwable) {
        initCause((Throwable) _args[0]);
    }
    this.args = _args;
}

From source file:org.kalypso.ui.editor.abstractobseditor.actions.RemoveThemeAction.java

/**
 * @see org.eclipse.jface.action.Action#run()
 *//*w w w.java  2  s  .  com*/
@Override
public void run() {
    final ObsViewItem[] items = m_page.getSelectedItems();

    if (items.length > 0) {
        final String str = ArrayUtils.toString(items, ", "); //$NON-NLS-1$
        final String msg = Messages
                .getString("org.kalypso.ui.editor.abstractobseditor.actions.RemoveThemeAction.3") //$NON-NLS-1$
                + (items.length > 1 ? "n " : " ") + str //$NON-NLS-1$//$NON-NLS-2$
                + Messages.getString("org.kalypso.ui.editor.abstractobseditor.actions.RemoveThemeAction.6"); //$NON-NLS-1$
        if (MessageDialog.openConfirm(m_page.getSite().getShell(),
                Messages.getString("org.kalypso.ui.editor.abstractobseditor.actions.RemoveThemeAction.7"), msg)) //$NON-NLS-1$
        {
            for (final ObsViewItem item : items) {
                m_page.getEditor().postCommand(new RemoveThemeCommand(m_page.getView(), item), null);
            }
        }
    }
}

From source file:uk.org.funcube.fcdw.server.email.VelocityTemplateEmailSender.java

@Override
public void sendEmailUsingTemplate(final String fromAddress, final String toAddress,
        final String[] bccAddresses, final String subject, final String templateLocation,
        final Map<String, Object> model) {

    final Map<String, Object> augmentedModel = new HashMap<String, Object>(model);
    augmentedModel.put("dateTool", new DateTool());
    augmentedModel.put("numberTool", new NumberTool());
    augmentedModel.put("mathTool", new MathTool());

    final Writer writer = new StringWriter();
    VelocityEngineUtils.mergeTemplate(velocityEngine, templateLocation, augmentedModel, writer);
    final String emailBody = writer.toString();

    final MimeMessagePreparator prep = new MimeMessagePreparator() {
        @Override/*from w ww  .  java2  s  .  c  om*/
        public void prepare(final MimeMessage mimeMessage) throws Exception {
            final MimeMessageHelper message = new MimeMessageHelper(mimeMessage, EMAIL_CONTENT_ENCODING);
            message.setTo(toAddress);
            message.setFrom(fromAddress);
            message.setSubject(subject);
            message.setText(emailBody);

            if (!ArrayUtils.isEmpty(bccAddresses)) {
                message.setBcc(bccAddresses);
            }
        }
    };

    try {
        mailSender.send(prep);
        LOGGER.debug(String.format("Sent %3$s email To: %1$s, Bcc: %2$s", toAddress,
                ArrayUtils.toString(bccAddresses, "None"), templateLocation));
    } catch (final MailException e) {
        LOGGER.error("Could not send email " + subject, e);
        throw e;
    }
}