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:com.gargoylesoftware.htmlunit.util.UrlUtils.java

/**
 * Resolves a given relative URL against a base URL using the algorithm
 * depicted in <a href="http://www.faqs.org/rfcs/rfc1808.html">RFC1808</a>:
 *
 * Section 4: Resolving Relative URLs/*from  w  w  w  .  ja  va 2s . co  m*/
 *
 *   This section describes an example algorithm for resolving URLs within
 *   a context in which the URLs may be relative, such that the result is
 *   always a URL in absolute form. Although this algorithm cannot
 *   guarantee that the resulting URL will equal that intended by the
 *   original author, it does guarantee that any valid URL (relative or
 *   absolute) can be consistently transformed to an absolute form given a
 *   valid base URL.
 *
 * @param baseUrl     The base URL in which to resolve the specification.
 * @param relativeUrl The relative URL to resolve against the base URL.
 * @return the resolved specification.
 */
private static Url resolveUrl(final Url baseUrl, final String relativeUrl) {
    final Url url = parseUrl(relativeUrl);
    // Step 1: The base URL is established according to the rules of
    //         Section 3.  If the base URL is the empty string (unknown),
    //         the embedded URL is interpreted as an absolute URL and
    //         we are done.
    if (baseUrl == null) {
        return url;
    }
    // Step 2: Both the base and embedded URLs are parsed into their
    //         component parts as described in Section 2.4.
    //      a) If the embedded URL is entirely empty, it inherits the
    //         entire base URL (i.e., is set equal to the base URL)
    //         and we are done.
    if (relativeUrl.isEmpty()) {
        return new Url(baseUrl);
    }
    //      b) If the embedded URL starts with a scheme name, it is
    //         interpreted as an absolute URL and we are done.
    if (url.scheme_ != null) {
        return url;
    }
    //      c) Otherwise, the embedded URL inherits the scheme of
    //         the base URL.
    url.scheme_ = baseUrl.scheme_;
    // Step 3: If the embedded URL's <net_loc> is non-empty, we skip to
    //         Step 7.  Otherwise, the embedded URL inherits the <net_loc>
    //         (if any) of the base URL.
    if (url.location_ != null) {
        return url;
    }
    url.location_ = baseUrl.location_;
    // Step 4: If the embedded URL path is preceded by a slash "/", the
    //         path is not relative and we skip to Step 7.
    if (url.path_ != null && !url.path_.isEmpty() && url.path_.charAt(0) == '/') {
        url.path_ = removeLeadingSlashPoints(url.path_);
        return url;
    }
    // Step 5: If the embedded URL path is empty (and not preceded by a
    //         slash), then the embedded URL inherits the base URL path,
    //         and
    if (url.path_ == null) {
        url.path_ = baseUrl.path_;
        //  a) if the embedded URL's <params> is non-empty, we skip to
        //     step 7; otherwise, it inherits the <params> of the base
        //     URL (if any) and
        if (url.parameters_ != null) {
            return url;
        }
        url.parameters_ = baseUrl.parameters_;
        //  b) if the embedded URL's <query> is non-empty, we skip to
        //     step 7; otherwise, it inherits the <query> of the base
        //     URL (if any) and we skip to step 7.
        if (url.query_ != null) {
            return url;
        }
        url.query_ = baseUrl.query_;
        return url;
    }
    // Step 6: The last segment of the base URL's path (anything
    //         following the rightmost slash "/", or the entire path if no
    //         slash is present) is removed and the embedded URL's path is
    //         appended in its place.  The following operations are
    //         then applied, in order, to the new path:
    final String basePath = baseUrl.path_;
    String path = "";

    if (basePath != null) {
        final int lastSlashIndex = basePath.lastIndexOf('/');

        if (lastSlashIndex >= 0) {
            path = basePath.substring(0, lastSlashIndex + 1);
        }
    } else {
        path = "/";
    }
    path = path.concat(url.path_);
    //      a) All occurrences of "./", where "." is a complete path
    //         segment, are removed.
    int pathSegmentIndex;

    while ((pathSegmentIndex = path.indexOf("/./")) >= 0) {
        path = path.substring(0, pathSegmentIndex + 1).concat(path.substring(pathSegmentIndex + 3));
    }
    //      b) If the path ends with "." as a complete path segment,
    //         that "." is removed.
    if (path.endsWith("/.")) {
        path = path.substring(0, path.length() - 1);
    }
    //      c) All occurrences of "<segment>/../", where <segment> is a
    //         complete path segment not equal to "..", are removed.
    //         Removal of these path segments is performed iteratively,
    //         removing the leftmost matching pattern on each iteration,
    //         until no matching pattern remains.
    while ((pathSegmentIndex = path.indexOf("/../")) > 0) {
        final String pathSegment = path.substring(0, pathSegmentIndex);
        final int slashIndex = pathSegment.lastIndexOf('/');

        if (slashIndex >= 0) {
            if (!"..".equals(pathSegment.substring(slashIndex))) {
                path = path.substring(0, slashIndex + 1).concat(path.substring(pathSegmentIndex + 4));
            }
        } else {
            path = path.substring(pathSegmentIndex + 4);
        }
    }
    //      d) If the path ends with "<segment>/..", where <segment> is a
    //         complete path segment not equal to "..", that
    //         "<segment>/.." is removed.
    if (path.endsWith("/..")) {
        final String pathSegment = path.substring(0, path.length() - 3);
        final int slashIndex = pathSegment.lastIndexOf('/');

        if (slashIndex >= 0) {
            path = path.substring(0, slashIndex + 1);
        }
    }

    path = removeLeadingSlashPoints(path);

    url.path_ = path;
    // Step 7: The resulting URL components, including any inherited from
    //         the base URL, are recombined to give the absolute form of
    //         the embedded URL.
    return url;
}

From source file:org.gvnix.service.roo.addon.addon.util.WsdlParserUtils.java

/**
 * Get the path to the generated service class.
 * /*from w  w  w.j a v  a 2 s  . co  m*/
 * @param root Wsdl root element
 * @param sense Communication sense type
 * @return Path to the class
 */
public static String getServiceClassPath(Element root, WsType sense) {

    Validate.notNull(root, ROOT_ELEMENT_REQUIRED);

    // Build the classpath related to the namespace
    String path = getTargetNamespaceRelatedPackage(root);

    // Find a compatible service name
    String name = findFirstCompatibleServiceClassName(root, sense);

    if (sense.equals(WsType.IMPORT_RPC_ENCODED)) {

        // Rpc generated service source ends with this string
        name = name.concat("Locator");
    }

    // Class path is the concat of path and name
    return path + capitalizeFirstChar(name);
}

From source file:io.bitsquare.gui.components.paymentmethods.CryptoCurrencyForm.java

@Override
protected void autoFillNameTextField() {
    if (useCustomAccountNameCheckBox != null && !useCustomAccountNameCheckBox.isSelected()) {
        String method = BSResources.get(paymentAccount.getPaymentMethod().getId());
        String address = addressInputTextField.getText();
        address = StringUtils.abbreviate(address, 9);
        String currency = paymentAccount.getSingleTradeCurrency() != null
                ? paymentAccount.getSingleTradeCurrency().getCode()
                : "?";
        accountNameTextField.setText(currency.concat(": ").concat(address));
    }/*w  w  w  . j ava2  s  .  c  o  m*/
}

From source file:org.gvnix.support.MessageBundleUtilsImpl.java

/**
 * Creates if it doesn't exist the messages_xx.properties file for the given
 * I18n locale./*from  w ww.j av  a  2  s. c om*/
 * <p>
 * Note that English locale is an especial case where the file is
 * messages.properties
 * 
 * @param i18n
 */
@Override
public void installI18nMessages(I18n i18n, ProjectOperations projectOperations, FileManager fileManager) {
    Validate.notNull(i18n, "Language choice required");

    if (i18n.getLocale() == null) {
        LOGGER.warning("could not parse language choice");
        return;
    }
    LogicalPath webappPath = getWebProjectUtils().getWebappPath(projectOperations);
    String targetDirectory = projectOperations.getPathResolver().getIdentifier(webappPath, "");

    // Install message bundle
    String messageBundle = targetDirectory.concat("WEB-INF/i18n/messages_")
            .concat(i18n.getLocale().getLanguage()).concat(".properties");

    // Special case for English locale (default)
    if (i18n.getLocale().equals(Locale.ENGLISH)) {
        messageBundle = targetDirectory.concat("WEB-INF/i18n/messages.properties");
    }
    if (!fileManager.exists(messageBundle)) {
        OutputStream outputStream = null;
        try {

            outputStream = fileManager.createFile(messageBundle).getOutputStream();
            IOUtils.copy(i18n.getMessageBundle(), outputStream);

        } catch (IOException e) {

            throw new IllegalStateException("Error during copying of message bundle MVC JSP addon", e);
        } finally {

            IOUtils.closeQuietly(outputStream);
        }
    }
    return;
}

From source file:ricecompression.RiceCompression.java

public String compress(int m, int n) {
    String riceCode;
    int nBitsM = (int) (Math.log10(m) / Math.log10(2));
    if (n < 0)
        riceCode = "0"; //Valor negatiu
    else/*ww  w  .j a  v a  2 s .  c o m*/
        riceCode = "1"; //Valor negatiu
    int q = Math.abs(n) / m;
    char[] array = new char[q];
    Arrays.fill(array, '1');
    if (array.length > 0)
        riceCode = riceCode.concat(String.valueOf(array)); //Si el quocient es major a 0
    riceCode = riceCode.concat("0");
    int r = Math.abs(n) % m;
    String rBinary = String.format("%" + nBitsM + "s", Integer.toBinaryString(r)).replace(' ', '0');
    riceCode = riceCode.concat(rBinary);
    return riceCode;
}

From source file:org.nuxeo.box.api.service.BoxServiceImpl.java

public String computeCollaborationId(String folderId, String collaborationId) {
    return folderId.concat(BoxConstants.BOX_COLLAB_DELIM).concat(collaborationId);
}

From source file:com.clevertrail.mobile.Database_SavedTrails.java

public String getJSONString() {
    String[] columns = new String[] { "json" };
    Cursor cursor = sqLiteDatabase.query(MYDATABASE_TABLE, columns, null, null, null, null, null);

    cursor.moveToFirst();//from   www  . j  a  v  a  2s .  com
    int index_JSON = cursor.getColumnIndex("json");

    //we will create a simple return value of the format:
    //"[trail1JSON, trail2JSON, ...]"
    String sReturn = "[";
    while (!cursor.isAfterLast()) {
        String sTrailJSON = cursor.getString(index_JSON);
        sReturn = sReturn.concat(sTrailJSON);
        cursor.moveToNext();
        if (!cursor.isAfterLast()) {
            if (sTrailJSON.compareTo("") != 0)
                sReturn = sReturn.concat(",");
        } else {
            break;
        }
    }
    sReturn = sReturn.concat("]");

    return sReturn;
}

From source file:edu.wisc.hr.demo.InMemoryBusinessEmailUpdateDao.java

@Override
public PreferredEmail getPreferedEmail(String emplId) {

    if (emplId == null) {
        throw new IllegalArgumentException(
                "Cannot get the preferred email of a user identified by a null emplId");
    }/*w  ww.j a  v  a 2 s . c  om*/

    String preferredEmailAddress = emplId.concat("@").concat(DEMO_DOMAIN);

    if (idToEmail.containsKey(emplId)) {
        preferredEmailAddress = (String) idToEmail.get(emplId);
    }

    PreferredEmail preferredEmail = new PreferredEmail();
    preferredEmail.setEmail(preferredEmailAddress);
    preferredEmail.setEmplid(emplId);

    PersonInformation personalData = contactInfoDao.getPersonalData(emplId);

    preferredEmail.setName(personalData.getName());
    preferredEmail.setMessage("Rain in Spain falls mainly on the plain.");

    return preferredEmail;
}

From source file:com.o19s.solr.swan.LuceneSwanSearcher.java

@Override
public SwanNode fieldedExpression(String field, SwanNode expression) {
    field = field.toLowerCase();/*from w ww. ja v a2s  .  co m*/
    if (SwanNode.isFieldStemming()) {
        field = field.concat(stemSuffix);
    }

    if (_fieldAliases.containsKey(field)) {
        try {
            return getFieldAliasExpression(_fieldAliases.get(field), expression);
        } catch (Exception ex) {
            //need to do something here.  Log? pass the exception on?
        }
    }
    expression.setField(field);
    return expression;
}

From source file:com.example.phonetic.KoelnerPhonetik.java

private List<String> getVariations(String str) {
    int position = 0;
    List<String> variations = new ArrayList<>();
    variations.add("");
    while (position < str.length()) {
        int i = 0;
        int substPos = -1;
        while (substPos < position && i < getPatterns().length) {
            Matcher m = variationsPatterns[i].matcher(str);
            while (substPos < position && m.find()) {
                substPos = m.start();/* ww  w . j  av a2  s . c o  m*/
            }
            i++;
        }
        if (substPos >= position) {
            i--;
            List<String> varNew = new ArrayList<>();
            String prevPart = str.substring(position, substPos);
            for (int ii = 0; ii < variations.size(); ii++) {
                String tmp = variations.get(ii);
                varNew.add(tmp.concat(prevPart + getReplacements()[i]));
                variations.set(ii, variations.get(ii) + prevPart + getPatterns()[i]);
            }
            variations.addAll(varNew);
            position = substPos + getPatterns()[i].length();
        } else {
            for (int ii = 0; ii < variations.size(); ii++) {
                variations.set(ii, variations.get(ii) + str.substring(position, str.length()));
            }
            position = str.length();
        }
    }
    return variations;
}