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:dhbw.clippinggorilla.external.solr.SOLR.java

/**
 * Creates search string for solr/*from  www  .j a  va  2 s  . c  o  m*/
 *
 * @param string
 * @param and
 * @return
 */
public static String replaceWhitespaces(String string, boolean and) {
    String word;
    String result = "";
    List<String> allMatches = new ArrayList<>();
    if (and) {
        word = " AND ";
    } else {
        word = " OR ";
    }

    if (StringUtils.countMatches(string, '"') > 0 && ((StringUtils.countMatches(string, '"') & 1) == 1)) {
        string = string.concat("\"");
    }

    Matcher m = Pattern.compile("[^,]+").matcher(string);
    while (m.find()) {
        allMatches.add(m.group());
    }

    for (String sub : allMatches) {
        sub = sub.trim();
        result = result.concat("\"" + sub + "\"" + word);
    }

    if (and) {
        result = result.substring(0, result.length() - 5);
    } else {
        result = result.substring(0, result.length() - 4);
    }

    return result;
}

From source file:net.bsrc.cbod.core.util.DBInitializeUtil.java

public static void saveImageModelstoDB() {

    String cbodDirPath = CBODUtil.getDefaultOutputDirectoryPath();
    ImageModelService service = ImageModelService.getInstance();

    List<ImageModel> saveImageModels = new ArrayList<ImageModel>();

    if (SAVE_WHEEL) {

        // Wheel paths
        String wheelTrainImagePath = cbodDirPath.concat("/image_db/wheel/train");
        String wheelTestImagePath = cbodDirPath.concat("/image_db/wheel/test");

        // Train//from www .jav  a2  s  .  co  m
        saveImageModels.addAll(createImageModels(wheelTrainImagePath, false, EObjectType.WHEEL));
        // Test
        saveImageModels.addAll(createImageModels(wheelTestImagePath, true, EObjectType.WHEEL));

    }

    if (SAVE_TAIL_LIGHT) {

        // Tail light paths
        String tailLightTrainImagePath = cbodDirPath.concat("/image_db/tail_light/train");
        String tailLightTestImagePath = cbodDirPath.concat("/image_db/tail_light/test");

        // Train
        saveImageModels.addAll(createImageModels(tailLightTrainImagePath, false, EObjectType.TAIL_LIGHT));
        // Test
        saveImageModels.addAll(createImageModels(tailLightTestImagePath, true, EObjectType.TAIL_LIGHT));

    }

    if (SAVE_HEAD_LIGHT) {
        // Head light paths
        String headLightTrainImagePath = cbodDirPath.concat("/image_db/head_light/train");
        String headLightTestImagePath = cbodDirPath.concat("/image_db/head_light/test");

        saveImageModels.addAll(createImageModels(headLightTrainImagePath, false, EObjectType.HEAD_LIGHT));

        saveImageModels.addAll(createImageModels(headLightTestImagePath, true, EObjectType.HEAD_LIGHT));
    }

    if (SAVE_LICENSE_PLATE) {
        // Head light paths
        String licensePlateTrainImagePath = cbodDirPath.concat("/image_db/license_plate/train");
        String headLightTestImagePath = cbodDirPath.concat("/image_db/license_plate/test");

        saveImageModels.addAll(createImageModels(licensePlateTrainImagePath, false, EObjectType.LICENSE_PLATE));

        saveImageModels.addAll(createImageModels(headLightTestImagePath, true, EObjectType.LICENSE_PLATE));

    }

    if (SAVE_NONE_CAR_PART) {

        String noneCarPartTrainImagePath = cbodDirPath.concat("/image_db/none_car_part/train");
        String noneCarPartTestImagePath = cbodDirPath.concat("/image_db/none_car_part/test");

        saveImageModels.addAll(createImageModels(noneCarPartTrainImagePath, false, EObjectType.NONE_CAR_PART));

        saveImageModels.addAll(createImageModels(noneCarPartTestImagePath, true, EObjectType.NONE_CAR_PART));
    }

    if (SAVE_CAR) {

        String carTrainImagePath = cbodDirPath.concat("/image_db/car/train");
        String carTestImagePath = cbodDirPath.concat("/image_db/car/test");

        saveImageModels.addAll(createImageModels(carTrainImagePath, false, EObjectType.CAR));

        saveImageModels.addAll(createImageModels(carTestImagePath, true, EObjectType.CAR));
    }

    if (SAVE_NONE_CAR) {

        String noneCarTrainImagePath = cbodDirPath.concat("/image_db/none_car/train");
        String noneCarTestImagePath = cbodDirPath.concat("/image_db/none_car/test");

        saveImageModels.addAll(createImageModels(noneCarTrainImagePath, false, EObjectType.NONE_CAR));

        saveImageModels.addAll(createImageModels(noneCarTestImagePath, true, EObjectType.NONE_CAR));

    }

    CvMat siftDictionary = null;

    if (EXTRACT_SIFT_DESCRIPTORS) {

        if (!CREATE_DICT_FOR_NONE_PARTS) {
            // Create sift dictionary
            siftDictionary = CBODSift.createDictionary(saveImageModels, 125);
            String tempDir = CBODUtil.getCbodTempDirectory() + "/";
            OpenCV.storeCvMatToFile(tempDir.concat("sift_dict.xml"), "sift_dict", siftDictionary);
        } else {

            siftDictionary = CBODSift.createDictionary(saveImageModels, 125);
            String tempDir = CBODUtil.getCbodTempDirectory() + "/";
            OpenCV.storeCvMatToFile(tempDir.concat("sift_dict_none_car_part.xml"), "sift_dict_none_car_part",
                    siftDictionary);
        }

    }

    extractFeatureVectors(saveImageModels, siftDictionary);
    service.saveImageModelList(saveImageModels);

}

From source file:fr.paris.lutece.plugins.directory.modules.pdfproducerarchive.utils.FilesUtils.java

/**
 * Thie method extracts the file to temp directory
 * @param strTempDirectoryExtract temp directory
 * @param plugin plugin/*from   ww  w  .  j  a  va2 s.co  m*/
 * @param nIdRecord id record
 * @param listEntry list of entry
 * @param entry entry
 */
private static void doExtractFiles(String strTempDirectoryExtract, Plugin plugin, int nIdRecord,
        List<IEntry> listEntry, IEntry entry) {
    for (RecordField recordField : DirectoryUtils.getMapIdEntryListRecordField(listEntry, nIdRecord, plugin)
            .get(String.valueOf(entry.getIdEntry()))) {
        String strTempPathExtract = strTempDirectoryExtract.concat(File.separator);
        if (StringUtils.isNotBlank(entry.getTitle())) {
            strTempPathExtract = strTempPathExtract
                    .concat(limitLengthName(PDFUtils.doPurgeNameFile(entry.getTitle())));
        }

        if (recordField.getFile() != null) {
            createTemporyZipDirectory(strTempPathExtract);
            doExtracFile(plugin, recordField, strTempPathExtract);
        }

        if (entry instanceof fr.paris.lutece.plugins.directory.business.EntryTypeDownloadUrl
                && StringUtils.isNotBlank(recordField.getValue())) {
            createTemporyZipDirectory(strTempPathExtract);
            doDownloadUrl(recordField.getValue(), strTempPathExtract);
        }
    }
}

From source file:org.fiware.apps.repository.it.queryService.QueryServiceITTest.java

@BeforeClass
public static void setUpClass() throws IOException {
    IntegrationTestHelper client = new IntegrationTestHelper();
    Resource resource = IntegrationTestHelper.generateResource(null, "fileName", null, "http://appTest", null,
            "Me", null, null, "queryResourceTest");

    List<Header> headers = new LinkedList<>();
    client.deleteCollection("queryCollection", headers);

    //Create a resource
    headers.add(new BasicHeader("Content-Type", "application/json"));
    HttpResponse response = client.postResourceMeta("queryCollection", client.resourceToJson(resource),
            headers);/*  w w  w .j a  v a2s . c  o m*/
    assertEquals(201, response.getStatusLine().getStatusCode());

    String auxString = "";
    FileReader file = new FileReader("src/test/resources/storeRDF.rdf");
    BufferedReader buffer = new BufferedReader(file);
    while (buffer.ready()) {
        auxString = auxString.concat(buffer.readLine() + "\n");
    }
    buffer.close();

    headers = new LinkedList<>();
    headers.add(new BasicHeader("Content-Type", "application/rdf+xml"));
    response = client.putResourceContent("queryCollection/queryResourceTest", auxString, headers);
    assertEquals(200, response.getStatusLine().getStatusCode());
}

From source file:org.fiware.apps.repository.it.collectionService.CollectionServicePutITTest.java

@BeforeClass
public static void setUpClass() throws IOException {
    IntegrationTestHelper client = new IntegrationTestHelper();

    String fileName = "fileNameExample";
    String contentUrl = "http://localhost:8080/contentUrl/resourceTestPut";
    String creator = "Me";
    String name = "resourceTestPut";
    Resource resource = IntegrationTestHelper.generateResource(null, fileName, null, contentUrl, null, creator,
            null, null, name);/* www.  j a  va 2 s  .c o m*/

    String auxString = "";
    FileReader file = new FileReader("src/test/resources/rdf+xml.rdf");
    BufferedReader buffer = new BufferedReader(file);
    while (buffer.ready()) {
        auxString = auxString.concat(buffer.readLine());
    }
    buffer.close();
    rdfXmlExample = auxString;

    auxString = "";
    file = new FileReader("src/test/resources/rdf+json.rdf");
    buffer = new BufferedReader(file);
    while (buffer.ready()) {
        auxString = auxString.concat(buffer.readLine());
    }
    buffer.close();
    rdfJsonExample = auxString;

    auxString = "";
    file = new FileReader("src/test/resources/N3.rdf");
    buffer = new BufferedReader(file);
    while (buffer.ready()) {
        auxString = auxString.concat(buffer.readLine());
    }
    buffer.close();
    rdfN3Example = auxString;

    auxString = "";
    file = new FileReader("src/test/resources/turttle.rdf");
    buffer = new BufferedReader(file);
    while (buffer.ready()) {
        auxString = auxString.concat(buffer.readLine());
    }
    buffer.close();
    rdfTurttleExample = auxString;

    dataExample = "Data example with nothing inside.";

    //Delete the collection
    List<Header> headers = new LinkedList<>();
    client.deleteCollection(collection, headers);

    //Create a resource in the repository
    headers.add(new BasicHeader("Content-Type", "application/json"));
    HttpResponse response = client.postResourceMeta(collection, IntegrationTestHelper.resourceToJson(resource),
            headers);
    assertEquals(201, response.getStatusLine().getStatusCode());

    resource.setName(name + "name");
    resource.setContentUrl(contentUrl + name);
    response = client.postResourceMeta(collection, IntegrationTestHelper.resourceToJson(resource), headers);
    assertEquals(201, response.getStatusLine().getStatusCode());
}

From source file:Main.java

private static String getXPath(Node node, String xpath) {
    String elementName = "";
    if (node instanceof Element) {
        elementName = node.getNodeName();
        int prev_siblings = 1;
        Node prev_sibling = node.getPreviousSibling();
        while (null != prev_sibling) {
            if (prev_sibling.getNodeType() == node.getNodeType()) {
                if (prev_sibling.getNodeName().equalsIgnoreCase(node.getNodeName())) {
                    prev_siblings++;/*w ww .ja va2 s.c  o m*/
                }
            }
            prev_sibling = prev_sibling.getPreviousSibling();
        }
        elementName = elementName.concat("[" + prev_siblings + "]");
    }
    Node parent = node.getParentNode();
    if (parent == null) {
        return xpath;
    }
    return getXPath(parent, "/" + elementName + xpath);
}

From source file:de.thischwa.pmcms.tool.file.FileTool.java

/**
 * Getter for an unique file in <code>directory</code>. If <code>fileName</code> exists, a number will be add on the base name. E.g.:<br>
 * <code>basename_1.ext</code>
 * //  w  w w.  ja v a2  s . com
 * @param directory
 * @param fileName
 * @return An unique {@link File} based on <code>fileName</code>.
 */
private static File getUniqueFile(final File directory, final String fileName) {
    File tempFile = new File(directory, fileName);
    String name = FilenameUtils.getBaseName(tempFile.getAbsolutePath());
    String extension = FilenameUtils.getExtension(tempFile.getAbsolutePath());
    if (extension.length() > 1)
        extension = ".".concat(extension.toLowerCase());
    int i = 0;
    while (tempFile.exists()) {
        String newName = name.concat("_").concat(String.valueOf(i)).concat(extension);
        tempFile = new File(directory, newName);
        i++;
    }
    return tempFile;
}

From source file:li.l1t.common.util.CommandHelper.java

/**
 * Trims given input to sixteen characters of length and prepends it with given prefix if possible. The prefix is
 * not prepended if the combination of prefix and input exceeds sixteen characters. If the prefix is null, it is not
 * prepended./*  www  .j  a v a 2  s.c o m*/
 *
 * @param input  the input string to trim
 * @param prefix the prefix to append if possible, or null to just trim
 * @return a string with a length of sixteen characters or less
 * @throws NullPointerException if given input is null
 */
public static String sixteenCharColorize(String input, String prefix) {
    Preconditions.checkNotNull(input, "input");
    if (prefix == null) {
        return CommandHelper.sixteenCharLimit(input);
    }
    if ((input.length() + prefix.length()) > 16) {
        return CommandHelper.sixteenCharLimit(input);
    }
    return prefix.concat(input);
}

From source file:Main.java

public static boolean encodeLZW(String inText, int dictSize, int[] encodedData) {
    int[] returnData = { 0 };
    try {/*from   www .j a v  a  2 s.c  o m*/
        encodedData = new int[inText.length()];
        int outCount = 0;
        HashMap<Integer, String> dict = newDictLZW(inText);

        String teststring = "";
        for (int i = 0; i < inText.length() - 1; i++) {
            teststring = String.valueOf(inText.charAt(i));
            String prevstring = teststring;
            int j = 0;
            // System.out.println("teststring = " + teststring +
            // ";  prevstring= " + prevstring + ";  i= " + i);
            while (dict.containsValue(teststring) && i + j < inText.length() - 1) {
                prevstring = teststring;
                j++;
                teststring = teststring.concat(String.valueOf(inText.charAt(i + j)));
            }
            // get key value for the string that matched
            Integer mapIndex = (getKeyByValue(dict, prevstring));

            // add this key to the encoded outText as string (ASCII 8 bit) outText =
            // outText.concat(String.valueOf(((char)Integer.parseInt(mapIndex))));

            encodedData[outCount] = mapIndex;

            outCount++;
            // add to dictionary the string that matched plus the next char in
            // sequence in inText
            // test that the new dictionary entry is not in the dictionary and
            // does not contain the new-line character
            if (!dict.containsValue(teststring) && teststring.charAt(teststring.length() - 1) != '\n'
                    && dict.size() < dictSize)
                dict.put(dict.size(), teststring);

            // set index value i to point to that next char in sequence
            i = i + j - 1;
        }
        // TODO add switch to turn printing on and off
        System.out.println("\n-- Dictionary --");
        printDictionary(dict);

        returnData = new int[outCount]; // count entries and use here.
        for (int i = 0; i < outCount; i++) {
            returnData[i] = encodedData[i];
        }
        encodedData = returnData;
    } catch (Exception ex) {
        System.err.println(
                "---------------------------------------------\nencodeLZW() method failed\nprobably tried to encode an incompatable file\n---------------------------------------------");
        return false;
    }
    return true;
}

From source file:org.sakuli.services.forwarder.AbstractPerformanceDataBuilder.java

/**
 * Add to the assigned 'performanceData' a new data set in respect of the template {@link
 * #PERFORMANCE_DATA_TEMPLATE}./*from  w w w. j  av  a2  s .co m*/
 */
static String addPerformanceDataRow(String performanceData, String name, String value, String warning,
        String critical) {
    performanceData = (performanceData == null) ? "" : performanceData;
    name = (name == null) ? "" : StringUtils.replace(name.trim(), " ", "_");
    value = (value == null) ? "" : value.trim();
    warning = (warning == null) ? "" : warning.trim();
    critical = (critical == null) ? "" : critical.trim();

    //format string and remove not needed spaces at beginn and ending
    return performanceData.concat(" ")
            .concat(String.format(PERFORMANCE_DATA_TEMPLATE, name, value, warning, critical)).trim();
}