Example usage for org.apache.commons.lang StringUtils join

List of usage examples for org.apache.commons.lang StringUtils join

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils join.

Prototype

public static String join(Collection<?> collection, String separator) 

Source Link

Document

Joins the elements of the provided Collection into a single String containing the provided elements.

Usage

From source file:com.hihsoft.sso.sysmonitor.syslogs.aop.LogServiceCallAdvice.java

@Override
public Object invoke(final MethodInvocation invocation) throws Throwable {
    final String clazzString = invocation.getThis().getClass().getName();// ??
    final String methodName = invocation.getMethod().getName();// ??
    final String fullPath = clazzString + "." + methodName;
    final StopWatch clock = new StopWatch();
    clock.start(); // 
    final Object result = invocation.proceed();
    clock.stop(); // ? //????

    final Class<?>[] params = invocation.getMethod().getParameterTypes();
    final String[] simpleParams = new String[params.length];
    for (int i = 0; i < params.length; i++) {
        simpleParams[i] = params[i].getSimpleName();
    }/*from  w w  w  .  j  a v a  2 s.co  m*/
    //log4j.xml???
    log.info(
            "-----------------------------------------------------------------------------");
    log.info("[" + methodName + "(" + StringUtils.join(simpleParams, ",") + ")];:"
            + clock.getTime() + ";[" + fullPath + "]");
    return result;
}

From source file:com.aliyun.openservices.odps.console.commands.logview.LogViewBaseAction.java

protected static String deduceTaskName(Instance inst) throws ODPSConsoleException, OdpsException {
    Map<String, TaskStatus> ss = inst.getTaskStatus();
    if (ss.size() == 1) {
        for (String key : ss.keySet()) {
            return key;
        }/*from   w ww .  ja  v a2  s  .c o  m*/
    } else {
        throw new ODPSConsoleException(
                "Please specify one of these tasks with option '-t': " + StringUtils.join(ss.keySet(), ','));
    }
    return null;
}

From source file:adalid.core.ViewSelect.java

private String columns(List<String> list) {
    return list == null || list.isEmpty() ? "*" : StringUtils.join(list, ", ");
}

From source file:com.linkedin.pinot.tools.segment.converter.PinotSegmentToCsvConverter.java

@Override
public void convert() throws Exception {
    PinotSegmentRecordReader recordReader = new PinotSegmentRecordReader(new File(_segmentDir));
    try {/*from   w w  w  . ja  v  a2s  . co  m*/
        recordReader.init();

        try (BufferedWriter recordWriter = new BufferedWriter(new FileWriter(_outputFile))) {
            if (_withHeader) {
                GenericRow row = recordReader.next();
                recordWriter.write(StringUtils.join(row.getFieldNames(), _delimiter));
                recordWriter.newLine();
                recordReader.rewind();
            }

            while (recordReader.hasNext()) {
                GenericRow row = recordReader.next();
                String[] fields = row.getFieldNames();
                List<String> record = new ArrayList<>(fields.length);

                for (String field : fields) {
                    Object value = row.getValue(field);
                    if (value instanceof Object[]) {
                        record.add(StringUtils.join((Object[]) value, _listDelimiter));
                    } else {
                        record.add(value.toString());
                    }
                }

                recordWriter.write(StringUtils.join(record, _delimiter));
                recordWriter.newLine();
            }
        }
    } finally {
        recordReader.close();
    }
}

From source file:io.pelle.mango.db.util.MergingPersistenceUnitPostProcessor.java

/** {@inheritDoc} */
@Override//from  w  w  w.j  a v a  2s  .  com
public void postProcessPersistenceUnitInfo(MutablePersistenceUnitInfo pui) {
    if (pui.getPersistenceUnitName().endsWith(targetPersistenceUnitName)) {
        LOG.info(String.format("target persistence unit '%s' (%s)", pui.getPersistenceUnitName(),
                StringUtils.join(pui.getManagedClassNames().listIterator(), ",")));
        targetPui = pui;

        for (MutablePersistenceUnitInfo puiToMerge : puisToMerge) {
            mergeManagedClasses(puiToMerge);
        }
    } else {
        if (targetPui == null) {
            LOG.info(String.format("persistence unit '%s' marked for later merging (%s)",
                    pui.getPersistenceUnitName(),
                    StringUtils.join(pui.getManagedClassNames().listIterator(), ",")));
            puisToMerge.add(pui);
        } else {
            mergeManagedClasses(pui);
        }
    }
}

From source file:edu.northwestern.bioinformatics.studycalendar.web.subject.ScheduleDay.java

public String getDetailTimelineClasses() {
    Calendar queriableDate = Calendar.getInstance();
    queriableDate.setTime(getDate());//from   ww w . j av a  2 s. c om

    List<String> classes = new ArrayList<String>(6);
    classes.add("day");
    classes.add(dateClass(getDate()));
    if (queriableDate.get(Calendar.DAY_OF_MONTH) == 1)
        classes.add("month-start");
    if (queriableDate.get(Calendar.DAY_OF_YEAR) == 1)
        classes.add("year-start");
    if (isToday())
        classes.add("today");
    if (!isEmpty())
        classes.add("has-activities");

    return StringUtils.join(classes.iterator(), ' ');
}

From source file:gov.nih.nci.cabig.caaers.rules.common.CaaersRuleUtil.java

public static Map<String, Object> multiplexAndEvaluate(Object src, String path) {
    Map<String, Object> map = new HashMap<String, Object>();
    String[] pathParts = path.split("\\[\\]\\.");
    if (pathParts.length < 2)
        return map;

    BeanWrapper bw = new BeanWrapperImpl(src);
    Object coll = bw.getPropertyValue(pathParts[0]);
    if (coll instanceof Collection) {
        int i = 0;
        for (Object o : (Collection) coll) {
            if (pathParts.length == 2) {
                String s = pathParts[0] + "[" + i + "]." + pathParts[1];
                map.put(s, o);//from   w  w w  .  j ava2 s .  com

            } else {
                String s = pathParts[0] + "[" + i + "]";
                String[] _newPathParts = new String[pathParts.length - 1];
                System.arraycopy(pathParts, 1, _newPathParts, 0, _newPathParts.length);
                String _p = StringUtils.join(_newPathParts, "[].");
                Map<String, Object> m = multiplexAndEvaluate(o, _p);
                //map.put(s, o);
                for (String k : m.keySet()) {
                    map.put(s + "." + k, m.get(k));
                }
            }
            i++;
        }
    }

    return map;
}

From source file:com.titankingdoms.dev.titanchat.command.defaults.PrivMsgCommand.java

@Override
public void execute(CommandSender sender, String[] args) {
    Participant target = plugin.getParticipantManager().getParticipant(args[0]);

    if (!target.isOnline()) {
        sendMessage(sender, target.getDisplayName() + " &4is currently offline");
        return;//from w  w w . j  av  a 2s  .  c o m
    }

    Participant participant = plugin.getParticipantManager().getParticipant(sender);
    participant.link(target);
    sendMessage(sender, "&6You have started a private conversation with " + target.getDisplayName());
    target.notice(participant.getDisplayName() + " &6has started a private conversation with you");

    String message = StringUtils.join(Arrays.copyOfRange(args, 1, args.length), " ");

    if (args.length > 1)
        target.processConversation(participant, target.getConversationFormat(), message);
}

From source file:com.ms.commons.test.math.expression.util.MathExpressionParseUtil.java

private static Stack<String> adjustExpressionStack(Stack<String> expressionStack) {
    if (expressionStack.size() <= 2) {
        return expressionStack;
    }// www.ja v  a  2  s. com
    int lastOpPr = Integer.MAX_VALUE;
    int lowerPrOp = -1;
    for (int i = (expressionStack.size() - 1); i >= 0; i--) {
        String expr = expressionStack.get(i);
        if ((expr.length() == 1) && hasSeparators(expr)) {
            int opPr = ("*".equals(expr) || "/".equals(expr)) ? 2 : 1;
            if (opPr < lastOpPr) {
                lastOpPr = opPr;
                lowerPrOp = i;
            }
        }
    }
    if (lowerPrOp != -1) {
        Stack<String> tempStack = new Stack<String>();
        int popCount = expressionStack.size() - lowerPrOp - 1;
        for (int i = 0; i < popCount; i++) {
            tempStack.push(expressionStack.pop());
        }
        Collections.reverse(tempStack);
        expressionStack.push(StringUtils.join(tempStack, ""));
    }

    return expressionStack;
}

From source file:mitm.djigzo.web.bindings.JoinBinding.java

@Override
public Object get() {
    Object value = delegate.get();

    if (value instanceof String) {
        return (String) value;
    } else if (value instanceof Collection) {
        return StringUtils.join((Collection<?>) value, SEPARATOR);
    } else if (value instanceof Object[]) {
        return StringUtils.join((Object[]) value, SEPARATOR);
    } else if (value instanceof Iterator<?>) {
        return StringUtils.join((Iterator<?>) value, SEPARATOR);
    }//from   www . j a  va  2s .  c o m

    return value;
}