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.sun.faces.renderkit.ResponseStateManagerImpl.java

protected String replaceMarkers(String response, String marker, String hiddenField) {

    int markerIdx = response.indexOf(marker);
    while (markerIdx != -1) {
        String replacedContent = response.substring(0, markerIdx);
        int markerEnd = markerIdx + marker.length();
        String endPortion = response.substring(markerEnd, response.length());
        replacedContent = replacedContent.concat(hiddenField);
        replacedContent = replacedContent.concat(endPortion);
        response = replacedContent;/*from w w  w  .ja v  a  2  s. c o  m*/
        markerIdx = response.indexOf(marker);
    }
    return response;
}

From source file:fr.cnes.sitools.extensions.astro.application.OpenSearchDescription.java

/**
 * builds and returns the template URL.//from  w w w. ja  va2 s .c o  m
 *
 * @return the template
 * @throws JSONException Exception
 * @throws IOException Exception
 */
private String buildTemplateURL() throws JSONException, IOException {
    final String description = "%s/search?q={searchTerms}&startPage={startPage?}&startIndex={startIndex?}&count={count?}&%s&format=json%s";
    String fields = "";
    List<Index> indexedFields = getIndexedFields();
    for (Index indexedField : indexedFields) {
        if (!indexedField.getTopTerms().isEmpty()) {
            fields = fields.concat("&amp;");
            fields = fields.concat(indexedField.getName());
            fields = fields.concat("={sitools:");
            fields = fields.concat(indexedField.getName());
            fields = fields.concat("?}");
        }
    }
    String coordsystem = "ICRS".equals(getPluginParameters().get("referenceSystem").getValue()) ? "astro"
            : "geo";
    String queryShape = getPluginParameters().get("queryShape").getValue();
    OpenSearchApplicationPlugin.GeometryShape geometryShape = OpenSearchApplicationPlugin.GeometryShape
            .getGeometryShapeFrom(queryShape);
    return String.format(description,
            getSitoolsSetting("Starter.PUBLIC_HOST_DOMAIN") + getPluginModel().getUrlAttach(),
            geometryShape.getOpenSearchDescription(coordsystem), fields);
}

From source file:fr.cnes.sitools.extensions.astro.application.OpenSearchDescription.java

/**
 * builds and returns the cluster template URL.
 *
 * @return Return the template/*from w w w .  j av a  2s  .co m*/
 * @throws JSONException Exception
 * @throws IOException Exception
 */
private String buildClusterTemplateURL() throws JSONException, IOException {
    final String description = "%s/cluster/search?q={searchTerms}&amp;startPage={startPage?}&amp;startIndex={startIndex?}&amp;count={count?}&amp;%s&amp;format=json%s";
    String fields = "";
    List<Index> indexedFields = getIndexedFields();
    for (Index indexedField : indexedFields) {
        if (!indexedField.getTopTerms().isEmpty()) {
            fields = fields.concat("&amp;");
            fields = fields.concat(indexedField.getName());
            fields = fields.concat("={sitools:");
            fields = fields.concat(indexedField.getName());
            fields = fields.concat("?}");
        }
    }
    String coordsystem = "ICRS".equals(getPluginParameters().get("referenceSystem").getValue()) ? "astro"
            : "geo";
    String queryShape = getPluginParameters().get("queryShape").getValue();
    OpenSearchApplicationPlugin.GeometryShape geometryShape = OpenSearchApplicationPlugin.GeometryShape
            .getGeometryShapeFrom(queryShape);
    return String.format(description,
            getSitoolsSetting("Starter.PUBLIC_HOST_DOMAIN") + getPluginModel().getUrlAttach(),
            geometryShape.getOpenSearchDescription(coordsystem), fields);
}

From source file:fr.cnes.sitools.extensions.astro.application.OpenSearchDescription.java

/**
 * builds and returns template URL.//  w  w w.j  a  v  a  2 s  .c o  m
 *
 * @return the template
 * @throws JSONException Exception
 * @throws IOException Exception
 */
private String buildTemplateMOC() throws JSONException, IOException {
    final String description = "%s/moc?q={searchTerms}&amp;%s&amp;format=json%s";
    String fields = "";
    List<Index> indexedFields = getIndexedFields();
    for (Index indexedField : indexedFields) {
        if (!indexedField.getTopTerms().isEmpty()) {
            fields = fields.concat("&amp;");
            fields = fields.concat(indexedField.getName());
            fields = fields.concat("={sitools:");
            fields = fields.concat(indexedField.getName());
            fields = fields.concat("?}");
        }
    }
    String coordsystem = "ICRS".equals(getPluginParameters().get("referenceSystem").getValue()) ? "astro"
            : "geo";
    String queryShape = getPluginParameters().get("queryShape").getValue();
    OpenSearchApplicationPlugin.GeometryShape geometryShape = OpenSearchApplicationPlugin.GeometryShape
            .getGeometryShapeFrom(queryShape);
    return String.format(description,
            getSitoolsSetting("Starter.PUBLIC_HOST_DOMAIN") + getPluginModel().getUrlAttach(),
            geometryShape.getOpenSearchDescription(coordsystem), fields);
}

From source file:metadata.etl.dataset.hdfs.HdfsMetadataEtl.java

private void extractLocal() throws Exception {

    URL localJarUrl = classLoader.getResource("jar/schemaFetch.jar");
    String homeDir = System.getProperty("user.home");
    String remoteJarFile = homeDir + "/.wherehows/schemaFetch.jar";
    File dest = new File(remoteJarFile);
    try {/*from  w ww. j  a v  a 2  s . c  o  m*/
        FileUtils.copyURLToFile(localJarUrl, dest);
    } catch (Exception e) {
        logger.error(e.toString());
    }

    String outputSchemaFile = prop.getProperty(Constant.HDFS_SCHEMA_LOCAL_PATH_KEY);
    String outputSampleDataFile = prop.getProperty(Constant.HDFS_SAMPLE_LOCAL_PATH_KEY);
    String cluster = prop.getProperty(Constant.HDFS_CLUSTER_KEY);
    String whiteList = prop.getProperty(Constant.HDFS_WHITE_LIST_KEY);
    String numOfThread = prop.getProperty(Constant.HDFS_NUM_OF_THREAD_KEY, String.valueOf(1));
    String hdfsUser = prop.getProperty(Constant.HDFS_REMOTE_USER_KEY);
    // String hdfsKeyTab = prop.getProperty(Constant.HDFS_REMOTE_KEYTAB_LOCATION_KEY);
    String hdfsExtractLogFile = outputSchemaFile + ".log";

    String[] hadoopCmd = { "hadoop", "jar", remoteJarFile,
            "-D" + Constant.HDFS_SCHEMA_REMOTE_PATH_KEY + "=" + outputSchemaFile,
            "-D" + Constant.HDFS_SAMPLE_REMOTE_PATH_KEY + "=" + outputSampleDataFile,
            "-D" + Constant.HDFS_CLUSTER_KEY + "=" + cluster,
            "-D" + Constant.HDFS_WHITE_LIST_KEY + "=" + whiteList,
            "-D" + Constant.HDFS_NUM_OF_THREAD_KEY + "=" + numOfThread,
            "-D" + Constant.HDFS_REMOTE_USER_KEY + "=" + hdfsUser, "-Dlog.file.name=hdfs_schema_fetch" };
    // delete the line (no kerberos needed): "-D" + Constant.HDFS_REMOTE_KEYTAB_LOCATION_KEY + "=" + hdfsKeyTab,
    ProcessBuilder pb = new ProcessBuilder(hadoopCmd);
    File logFile = new File(hdfsExtractLogFile);
    pb.redirectErrorStream(true);
    pb.redirectOutput(ProcessBuilder.Redirect.appendTo(logFile));
    Process process = pb.start();
    int pid = -1;
    if (process.getClass().getName().equals("java.lang.UNIXProcess")) {
        /* get the PID on unix/linux systems */
        try {
            Field f = process.getClass().getDeclaredField("pid");
            f.setAccessible(true);
            pid = f.getInt(process);
        } catch (Throwable e) {
        }
    }
    logger.info("executue command [PID=" + pid + "]: " + hadoopCmd);

    // wait until this process finished.
    int execResult = process.waitFor();

    // if the process failed, log the error and throw exception
    if (execResult > 0) {
        BufferedReader br = new BufferedReader(new InputStreamReader(process.getErrorStream()));
        String errString = "HDFS Metadata Extract Error:\n";
        String line = "";
        while ((line = br.readLine()) != null)
            errString = errString.concat(line).concat("\n");
        logger.error("*** Process  failed, status: " + execResult);
        logger.error(errString);
        throw new Exception("Process + " + pid + " failed");
    }

}

From source file:ch.unil.genescore.vegas.GeneDataFakePhenotype.java

void writeSnpGenotypes(File file) {
    FileExport writerSnpGenotypes = new FileExport(Pascal.log, file);
    int nrOfSnps = snpList_.size();
    int nrOfGenotypes = Snp.getGenotypeLength();
    //for (int i=0;i < nrOfGenotypes ; i++){
    String myStr = null;
    for (int i = 0; i < nrOfSnps; i++) {
        Snp mySnps = snpList_.get(i);//from   ww w .j  a  v a 2  s. c o m
        byte[] genotypes = mySnps.getGenotypes();
        System.out.println(genotypes.length);
        myStr = "";
        myStr = myStr.concat(mySnps.id_);

        for (int j = 0; j < nrOfGenotypes; j++) {
            int currentGenotype = genotypes[j];
            myStr = myStr.concat("\t");
            myStr = myStr.concat(String.valueOf(currentGenotype));
        }
        writerSnpGenotypes.println(myStr);
    }

    writerSnpGenotypes.close();
}

From source file:org.gvnix.addon.datatables.addon.DatatablesOperationsImpl.java

/**
 * This method copy a new file in a directory if the file not exists in the
 * system/* w ww .  java  2 s  .  c o  m*/
 * 
 * @param fileManager
 * @param loadingClass
 * @param filePath
 * @param fileName
 * @param directory
 */
public static void createFilesInLocationIfNotExists(FileManager fileManager, Class loadingClass,
        String filePath, String fileName, String directory) {
    if (!fileManager.exists(filePath)) {
        InputStream inputStream = null;
        OutputStream outputStream = null;
        try {
            inputStream = FileUtils.getInputStream(loadingClass, directory.concat(fileName));
            outputStream = fileManager.createFile(filePath).getOutputStream();
            IOUtils.copy(inputStream, outputStream);
        } catch (final IOException ioe) {
            throw new IllegalStateException(ioe);
        } finally {
            IOUtils.closeQuietly(inputStream);
            IOUtils.closeQuietly(outputStream);
        }
    }

}

From source file:net.sf.jabref.importer.fetcher.GVKFetcher.java

private String processComplexQuery(String[] s) {
    String result = "";
    boolean lastWasKey = false;

    for (int x = 0; x < s.length; x++) {
        if (searchKeys.containsKey(s[x])) {
            if (x == 0) {
                result = searchKeys.get(s[x]);
            } else {
                result = result.concat("%20and%20" + searchKeys.get(s[x]));
            }/* w w w. j  a  va  2s  .c  o m*/
            lastWasKey = true;
        } else {
            if (!lastWasKey) {
                result = result.concat("%20");
            }
            String encoded = s[x];
            encoded = encoded.replace(",", "%2C").replace("?", "%3F");

            result = result.concat(encoded);
            lastWasKey = false;
        }
    }
    return result;
}

From source file:com.celements.web.plugin.cmd.SuggestListCommand.java

String getDBStringListXWQL(String query, String firstCol, String secCol) {
    String likeCol = firstCol;/*from w  w w  .j a  v  a 2  s . c  om*/
    if ((secCol != null) && !"".equals(secCol.trim()) && !"-".equals(secCol)) {
        likeCol = secCol;
    }
    String xwql;
    int idxWhere = query.toLowerCase().indexOf("where");
    if (idxWhere < 0) {
        xwql = query.concat(" where lower(" + likeCol.replaceAll("[^a-zA-Z0-9_.]", "") + ") like ? ");
    } else {
        idxWhere = idxWhere + 5;
        xwql = query.substring(0, idxWhere) + " lower(" + firstCol.replaceAll("[^a-zA-Z0-9_.]", "")
                + ") like ? and " + query.substring(idxWhere);
    }
    return xwql;
}

From source file:com.clevertrail.mobile.findtrail.Activity_FindTrail_ByName.java

private int submitSearch() {
    JSONArray jsonArray = null;//  w w w .j  a  v  a 2 s .  c o  m

    HttpURLConnection urlConnection = null;
    try {
        //api call to find trails by name
        String requestURL = "http://clevertrail.com/ajax/handleGetArticles.php";
        String sSearch = mActivity.sSearchText;
        sSearch = sSearch.replace(" ", "%20");
        sSearch = sSearch.replace("'", "\'");

        requestURL = requestURL.concat("?name=").concat(sSearch);

        URL url = new URL(requestURL);
        urlConnection = (HttpURLConnection) url.openConnection();

        InputStream in = new BufferedInputStream(urlConnection.getInputStream());

        BufferedReader r = new BufferedReader(new InputStreamReader(in));
        String line;
        //did we get a match from clevertrail.com?
        if ((line = r.readLine()) != null) {
            jsonArray = new JSONArray(line);
        }
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return R.string.error_contactingclevertrail;
    } catch (IOException e) {
        // TODO Auto-generated catch block
        // could not connect to clevertrail.com
        e.printStackTrace();
        return R.string.error_contactingclevertrail;
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return R.string.error_corrupttrailinfo;
    } finally {
        if (urlConnection != null)
            urlConnection.disconnect();
    }

    //clear the static object that holds the trails
    Object_TrailList.clearTrails();
    if (jsonArray != null && jsonArray.length() > 0) {
        int len = jsonArray.length();
        try {
            //add each trail to the array of trails
            for (int i = 0; i < len && i < 20; ++i) {
                JSONObject trail = jsonArray.getJSONObject(i);
                Object_TrailList.addTrailWithJSON(trail);
            }
        } catch (JSONException e) {
            return R.string.error_corrupttrailinfo;
        }
    }

    //prepare the extras before starting the trail list activity
    int icon = R.drawable.ic_viewtrailtab_details_unselected;
    Intent i = new Intent(mActivity, Activity_ListTrails.class);
    i.putExtra("icon", icon);
    i.putExtra("title", mActivity.getString(R.string.title_foundtrails));
    mActivity.startActivity(i);

    return 0;
}