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.pureinfo.srm.project.action.EmailRemindProjectAction.java

/**
 * @see com.pureinfo.ark.interaction.ActionBase#executeAction()
 *//* w ww.jav a2 s.  c  o  m*/
public ActionForward executeAction() throws PureException {
    IAuth2Mgr authMgr = Auth2Helper.getManager();
    Project project = new Project();
    boolean bHasRight = authMgr.hasRight(loginUser, project, ArkActionTypes.REMIND, false);
    if (!bHasRight) {
        throw new PureException(ArkExceptionTypes.AUTH_NO_RIGHT, "");
    }
    int nRemindType = request.getRequiredInt("type", "//");
    String[] sIds = request.getParameterValues("id");
    String sProjectIds = StringUtils.join(sIds, ',');
    IProjectMgr mgr = (IProjectMgr) ArkContentHelper.getContentMgrOf(Project.class);
    String[] msgs = mgr.sendEmailForHandRemind(sProjectIds, nRemindType);
    request.setAttribute("msg", msgs);
    request.setAttribute("forward", "projectToClose.do");
    return mapping.findForward("info");
}

From source file:com.redhat.rhn.common.security.SessionSwap.java

/** given an array of strings, compute the hex session swap, which
 * contains both the original data and the 'signature'.  so the
 * resulting string is encapsulated and can be passed around as
 * 'signed' data.//from w w  w.j av  a 2s  . c  o  m
 *
 * @param in an array of strings, all of which must be valud hex
 * @return String of the signature, in the form "D1:D2:D3xHEX"
 *         where D1... are the input data and HEX is the hex signature.
 */
public static String encodeData(String[] in) {
    for (int i = 0; i < in.length; i++) {
        if (!StringUtils.containsOnly(in[i], HEX_CHARS)) {
            throw new IllegalArgumentException(
                    "encodeData input must be " + "lowercase hex, but wasn't: " + in[i]);
        }
    }

    String joined = StringUtils.join(in, ':');

    String[] components = new String[] { joined, generateSwapKey(joined) };

    return StringUtils.join(components, "x");
}

From source file:net.nperkins.quizmaster3000.AskQuestionRunnable.java

@Override
public void run() {
    if (timer <= 0) {
        Bukkit.getScheduler().cancelTask(id);
        plugin.sendPlayers(plugin.getMessages().getString("quiz.question.timeup"));
        plugin.sendPlayers(MessageFormat.format(plugin.getMessages().getString("quiz.question.answer"),
                StringUtils.join(
                        Arrays.copyOfRange(plugin.getCurrentQuestion().getAnswer(), 0,
                                plugin.getCurrentQuestion().getAnswer().length),
                        plugin.getMessages().getString("quiz.answer.joiner"))));
        if (plugin.getScores().size() == 0) {
            plugin.sendPlayers(plugin.prefixMessage(plugin.getMessages().getString("error.allplayersleft")));
            plugin.setState(QuizState.FINISHED);
            plugin.setRunning(false);/*from   w w w.j ava2  s.  c o  m*/
        } else {
            plugin.setState(QuizState.WAITFORNEXT);
            plugin.sendPlayers(plugin.getMessages().getString("quiz.question.next"));
            plugin.getWaitForNextRunnable().start();
        }
    } else {
        plugin.sendPlayers(
                MessageFormat.format(plugin.getMessages().getString("quiz.question.timeleft"), timer));
        if (plugin.getConfig().getBoolean("quiz.hints"))
            plugin.sendPlayers(MessageFormat.format(plugin.getMessages().getString("quiz.question.hint"),
                    plugin.getHint(timer * 2)));
        timer -= 15;
    }
}

From source file:de.tudarmstadt.ukp.dkpro.core.io.brat.internal.model.BratAttributeDrawingDecl.java

@Override
public String getSpec() {
    StringBuilder sb = new StringBuilder();
    sb.append("glyph:");
    sb.append(StringUtils.join(attributeDecl.getValues(), "|"));
    return sb.toString();
}

From source file:com.tehbeard.beardstat.bukkit.commands.Commands.java

@Override
public List<String> onTabComplete(CommandSender cs, Command cmnd, String cmdlbl, String[] args) {
    CommandLocals locals = new CommandLocals();
    locals.put(CommandSender.class, cs);
    locals.put(EntityStatManager.class, playerStatManager);
    locals.put(BukkitPlugin.class, plugin);
    try {//from ww w .  j a v  a2 s. c om
        return dispatcher.getSuggestions(cmdlbl + " " + StringUtils.join(args, " "), locals);
    } catch (CommandException ex) {
        Logger.getLogger(Commands.class.getName()).log(Level.SEVERE, null, ex);
    }
    return new ArrayList<String>();
}

From source file:it.av.youeat.web.security.OpenIDAttributes2UserDetailsImpl.java

/**
 * {@inheritDoc}//ww w .j  av a  2 s.  c o  m
 */
@Override
public Eater extract(OpenIDAuthenticationToken token) {
    Eater user = new Eater();
    List<OpenIDAttribute> attributes = token.getAttributes();
    for (OpenIDAttribute openIDAttribute : attributes) {
        if (openIDAttribute.getName().equals("firstName")) {
            user.setFirstname(StringUtils.join(openIDAttribute.getValues(), ""));
        }

        if (openIDAttribute.getName().equals("email")) {
            user.setEmail(StringUtils.join(openIDAttribute.getValues(), ""));
        }

        if (openIDAttribute.getName().equals("lastName")) {
            user.setLastname(StringUtils.join(openIDAttribute.getValues(), ""));
        }

        if (openIDAttribute.getName().equals("language")) {
            String langage = StringUtils.join(openIDAttribute.getValues(), "");
            user.setLanguage(languageService.getSupportedLanguage(new Locale(langage)));
        }
        if (openIDAttribute.getName().equals("country")) {
            String country = StringUtils.join(openIDAttribute.getValues(), "");
            user.setCountry(countryService.getByIso2(country));
        }
    }
    if (user.getCountry() == null) {
        user.setCountry(countryService.getByIso2(user.getLanguage().getCountry()));
        //user.setLanguage(languageService.getSupportedLanguage(new Locale(user.getLocale())));
    }
    user.setEmail(user.getEmail());
    user.setSocialType(SocialType.GOOGLE);
    user.setSocialUID(token.getIdentityUrl());
    return user;
}

From source file:info.magnolia.cms.gui.controlx.search.SelectSearchControlDefinition.java

public String getJsField() {

    List pairs = new ArrayList();
    for (MapIterator iter = this.getOptions().orderedMapIterator(); iter.hasNext();) {
        iter.next();//from w  ww  .j  a  v a 2  s.co  m
        String key = (String) iter.getKey();
        String value = (String) iter.getValue();
        pairs.add("'" + key + "': '" + value + "'");
    }

    String str = super.getJsField();
    str = StringUtils.removeEnd(str, "}");
    str += ",options: {";
    str += StringUtils.join(pairs.iterator(), ",");
    str += "}}";
    return str;
}

From source file:com.pureinfo.srm.view.function.ShowOtherPartnersFunctionHandler.java

/**
 * @see com.pureinfo.dolphinview.parser.function.FunctionHandlerDVImplBase#perform(java.lang.Object[], com.pureinfo.dolphinview.context.model.IDVContext)
 *//*w  w  w. j a va  2s  .  co  m*/
public Object perform(Object[] _args, IDVContext _context) throws PureException {
    DolphinObject obj = _context.getObject();
    String sSeperator = " ";
    if (_args.length > 0) {
        sSeperator = (String) _args[0];
    }
    String[] sNames = new String[0];
    if (obj instanceof Project) {
        sNames = ((Project) obj).getOtherAuthors();
    } else if (obj instanceof Product) {
        sNames = ((Product) obj).getOtherAuthors();
    } else if (obj instanceof Honor) {
        sNames = ((Honor) obj).getOtherAuthors();
    }
    return StringUtils.join(sNames, sSeperator);
}

From source file:com.bigdatafly.flume.zookeeper.Zookeeper.java

public static CuratorFramework newCurator(Map conf, List<String> servers, Object port, String root) {
    List<String> serverPorts = new ArrayList<String>();
    for (String zkServer : (List<String>) servers) {
        serverPorts.add(zkServer + ":" + "");
    }/*from   w  ww. j  a  v  a  2s  . c o m*/
    String zkStr = StringUtils.join(serverPorts, ",") + root;
    CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder();
    setupBuilder(builder, zkStr, conf);
    return builder.build();
}

From source file:com.moz.fiji.schema.tools.synth.NGramSynthesizer.java

@Override
public String synthesize() {
    // Pick n words from the dictionary.
    List<String> grams = new ArrayList<String>(mN);
    for (int i = 0; i < mN; i++) {
        grams.add(mWordSynthesizer.synthesize());
    }//from   ww w . j  av  a  2 s .co m
    return StringUtils.join(grams, " ");
}