Example usage for java.lang String concat

List of usage examples for java.lang String concat

Introduction

In this page you can find the example usage for java.lang String concat.

Prototype

public String concat(String str) 

Source Link

Document

Concatenates the specified string to the end of this string.

Usage

From source file:net.sf.farrago.namespace.sfdc.SfdcUdx.java

private static String join(String delimiter, String[] array) {
    String ret = "";
    for (String s : array) {
        ret = ret.concat(s).concat(delimiter);
    }/*from   w  w w  . j a va2 s.  c  o  m*/
    return ret.trim();
}

From source file:com.theaigames.game.warlight2.MapCreator.java

/**
 * @param map/*from   ww  w  . j  ava 2 s  .co m*/
 * @return : the string representation of given map's regions
 */
private static String getRegionsString(Map map) {
    String regionsString = "setup_map regions";
    for (Region region : map.regions) {
        int id = region.getId();
        int superRegionId = region.getSuperRegion().getId();
        regionsString = regionsString.concat(" " + id + " " + superRegionId);
    }
    return regionsString;
}

From source file:com.theaigames.game.warlight2.MapCreator.java

/**
 * @param map// w  ww. j ava  2s .c o  m
 * @return : the string representation of given map's wastelands
 */
private static String getWastelandsString(Map map) {
    String wastelandsString = "setup_map wastelands";
    for (Region region : map.getRegions()) {
        if (region.getArmies() > 2) {
            int id = region.getId();
            wastelandsString = wastelandsString.concat(" " + id);
        }
    }
    return wastelandsString;
}

From source file:cc.gospy.core.util.StringHelper.java

public static String getNavigateTargetUrl(final String parentUrl, final String relativeUrl) {
    String prefix = parentUrl.replaceAll("://", "").contains("/")
            ? parentUrl.substring(0, parentUrl.lastIndexOf('/'))
            : parentUrl.concat("/");
    String suffix = relativeUrl.startsWith("./") ? relativeUrl.substring(2) : relativeUrl;
    while (suffix.startsWith("../")) {
        suffix = suffix.substring(3);/*from   w  w w  . j  a v a 2s. c  o  m*/
        prefix = prefix.replaceAll("://", "").contains("/") ? prefix.substring(0, prefix.lastIndexOf('/'))
                : prefix;
    }
    return prefix.concat(suffix.startsWith("/") ? suffix : "/" + suffix);
}

From source file:de.teamgrit.grit.preprocess.fetch.SvnFetcher.java

/**
 * Fetches from a remote svn repository. All login information and the
 * location of the svn repository are saved in the {@link Connection}. The
 * checkout will be placed in the targetDirectory.
 *
 * @param connection// w  w  w  .  jav  a 2 s  .com
 *            contains login information and address of remote svn
 * @param targetDirectory
 *            directory in which the checkout will be placed
 * @return the path to the root of the svn repository, null if checkout
 *         failed failed
 * @throws SubmissionFetchingException
 *             if the fetching fails
 */
public static Path fetchSubmissions(final Connection connection, final Path targetDirectory)
        throws SubmissionFetchingException {
    if (!checkConnectionToRemoteSVN(connection.getLocation())) {
        throw new SubmissionFetchingException("No connection to remote SVN.");
    }
    if (!isDataSourceInitialized(targetDirectory)) {
        initializeDataSource(connection, targetDirectory);
    }

    Path newTargetDirectory = updateDirectoryPath(connection.getLocation(), targetDirectory);

    LOGGER.info("Trying to update local svn repository.");

    SVNResultData svnResult = null;
    try {
        List<String> svnCommand = new LinkedList<>();
        svnCommand.add("svn");
        svnCommand.add("update");
        svnResult = runSVNCommand(connection, svnCommand, newTargetDirectory);
    } catch (IOException e) {
        throw new SubmissionFetchingException("SVN Update failed: Could not start SVN or could "
                + "not read from output stream." + e.getMessage());
    }

    if (svnResult != null) {
        // Any SVN return value != 0 implies an error and the fetch wasn't
        // clean. Hence we bundle the output into the exception and throw.
        if (svnResult.getReturnValue() != 0) {
            String svnOutForException = "";
            for (String message : svnResult.getSvnOutputLines()) {
                message = svnOutForException.concat(message + "\n");
            }
            throw new SubmissionFetchingException(svnOutForException);
        }

    } else {
        LOGGER.severe("BUG: Failed to acquire SVN result object.");
        throw new SubmissionFetchingException("Failed to acquire SVN result object, " + "should never happen.");
    }

    LOGGER.info("Done fetching from SVN Repository.");

    return newTargetDirectory;
}

From source file:com.klwork.common.utils.WebUtils.java

/**
 * ???//from w w  w  . j  av a2  s .  c o m
 * @param request
 * @param response
 */
public static void VerificationCode(HttpServletRequest request, HttpServletResponse response) throws Exception {
    response.setHeader("Pragma", "No-cache");
    response.setHeader("Cache-Control", "no-cache");
    response.setDateHeader("Expires", 0);
    // 
    int width = 60, height = 20;
    BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

    // ?
    Graphics g = image.getGraphics();

    // ??
    Random random = new Random();

    // 
    g.setColor(getRandColor(200, 250));
    g.fillRect(0, 0, width, height);

    // 
    g.setFont(new Font("Times New Roman", Font.PLAIN, 18));

    // 
    // g.setColor(new Color());
    // g.drawRect(0,0,width-1,height-1);

    // ?155?????
    g.setColor(getRandColor(160, 200));
    for (int i = 0; i < 155; i++) {
        int x = random.nextInt(width);
        int y = random.nextInt(height);
        int xl = random.nextInt(12);
        int yl = random.nextInt(12);
        g.drawLine(x, y, x + xl, y + yl);
    }

    String base = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQUSTUVWXYZ0123456789";
    // ????(4?)
    String sRand = "";
    for (int i = 0; i < 4; i++) {
        int start = random.nextInt(base.length());
        String rand = base.substring(start, start + 1);
        sRand = sRand.concat(rand);
        // ??
        g.setColor(new Color(20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110)));
        g.drawString(rand, 13 * i + 6, 16);
    }

    // ??SESSION
    request.getSession().setAttribute("entrymrand", sRand);

    // 
    g.dispose();
    OutputStream out = response.getOutputStream();
    // ?
    ImageIO.write(image, "JPEG", out);

    out.flush();
    out.close();
}

From source file:com.stratelia.webactiv.util.FileRepositoryManager.java

/**
 * to create the array of the string this array represents the repertories where the files must be
 * stored./*from w w  w.j  a va  2s .  c o  m*/
 *
 * @param str : type String: the string of repertories
 * @return
 */
public static String[] getAttachmentContext(String str) {

    String strAt = "Attachment " + CONTEXT_TOKEN;

    if (str != null) {
        strAt = strAt.concat(str);
    }
    StringTokenizer strToken = new StringTokenizer(strAt, CONTEXT_TOKEN);
    // number of elements
    int nElt = strToken.countTokens();
    // to init array
    String[] context = new String[nElt];

    int k = 0;

    while (strToken.hasMoreElements()) {
        context[k] = ((String) strToken.nextElement()).trim();
        k++;
    }
    return context;
}

From source file:de.teamgrit.grit.preprocess.fetch.SvnFetcher.java

/**
 * Initializes the workspace by performing a checkout in a specified
 * directory.//from  ww  w. ja va2  s .c om
 *
 * @param connectionData
 *            holds login information an remote location of the svn
 *            repository
 * @param targetDirectory
 *            the local directory in which the checkout will be placed
 * @return true if checkout was successful, false otherwise
 * @throws SubmissionFetchingException
 *             if the fetching fails
 */
private static boolean initializeDataSource(Connection connectionData, Path targetDirectory)
        throws SubmissionFetchingException {
    // nuke previous contents, so we can be sure that we have a clean
    // state.
    try {
        FileUtils.deleteDirectory(targetDirectory.toFile());
        Files.createDirectories(targetDirectory);
    } catch (IOException e) {
        LOGGER.severe("Could not clean data source: " + targetDirectory.toAbsolutePath().toString() + " -> "
                + e.getMessage());
        return false;
    }

    if (!checkConnectionToRemoteSVN(connectionData.getLocation())) {
        return false;
    }

    // now tell svn to checkout.
    try {
        List<String> svnCommand = new LinkedList<>();
        svnCommand.add("svn");
        svnCommand.add("checkout");
        svnCommand.add(connectionData.getLocation());

        SVNResultData svnResult = runSVNCommand(connectionData, svnCommand, targetDirectory);

        if (svnResult != null) {
            LOGGER.info("Successful SVN pull from " + connectionData.getLocation());
        }

        // Any SVN return value != 0 implies an error and the fetch wasn't
        // clean. Hence we bundle the output into the exception and throw.
        if (svnResult.getReturnValue() != 0) {
            String svnOutForException = "";
            for (String message : svnResult.getSvnOutputLines()) {
                svnOutForException = svnOutForException.concat(message + "\n");
            }
            throw new SubmissionFetchingException(svnOutForException);
        }
    } catch (IOException e) {
        LOGGER.warning("unable to check out repository: " + connectionData.getLocation());
        return false;
    }

    LOGGER.config("Checked out, moving internal repository path to " + targetDirectory.toString());

    return true;
}

From source file:com.theaigames.game.warlight2.MapCreator.java

/**
 * @param map/*  w  w w . ja  v a 2s.  c om*/
 * @return : the string representation of given map's superRegions
 */
private static String getSuperRegionsString(Map map) {
    String superRegionsString = "setup_map super_regions";
    for (SuperRegion superRegion : map.superRegions) {
        int id = superRegion.getId();
        int reward = superRegion.getArmiesReward();
        superRegionsString = superRegionsString.concat(" " + id + " " + reward);
    }
    return superRegionsString;
}

From source file:eionet.util.SecurityUtil.java

/**
 * Returns the list of countries the logged in user represents detected from the roles assigned for the user in LDAP.
 * The country code is last 2 digits on role name. The country codes are detected only for the parent roles given as method
 * argument.//w  w  w  .ja  v a2 s .  c om
 *
 * @param dduser Logged in user object.
 * @param parentRoles List of parent roles, where country code will be detected as last 2 digits.
 * @return List of ISO2 country codes in upper codes. Null if user object or parentRoles are null.
 */
public static List<String> getUserCountriesFromRoles(DDUser dduser, String[] parentRoles) {

    if (dduser == null || dduser.getUserRoles() == null || parentRoles == null) {
        return null;
    }

    List<String> countries = new ArrayList<String>();

    for (String role : dduser.getUserRoles()) {
        for (String parentRole : parentRoles) {
            if (!parentRole.endsWith("-")) {
                parentRole = parentRole.concat("-");
            }
            if (role.startsWith(parentRole)) {
                String roleSuffix = StringUtils.substringAfter(role, parentRole).toUpperCase();
                if (roleSuffix.length() == 2 && !countries.contains(roleSuffix)) {
                    countries.add(roleSuffix);
                }
            }
        }
    }
    return countries;
}