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:lti.oauth.OAuthMessageSigner.java

/**
 * This method double encodes the parameter keys and values.
 * Thus, it expects the keys and values contained in the 'parameters' SortedMap
 * NOT to be encoded.//from   w  ww. j a  va 2 s  . c  om
 * 
 * @param secret
 * @param algorithm
 * @param method
 * @param url
 * @param parameters
 * @return oauth signature
 * @throws Exception
 */
public String sign(String secret, String algorithm, String method, String url,
        SortedMap<String, String> parameters) throws Exception {
    SecretKeySpec secretKeySpec = new SecretKeySpec((secret.concat(OAuthUtil.AMPERSAND)).getBytes(), algorithm);
    Mac mac = Mac.getInstance(secretKeySpec.getAlgorithm());
    mac.init(secretKeySpec);

    StringBuilder signatureBase = new StringBuilder(OAuthUtil.percentEncode(method));
    signatureBase.append(OAuthUtil.AMPERSAND);

    signatureBase.append(OAuthUtil.percentEncode(url));
    signatureBase.append(OAuthUtil.AMPERSAND);

    int count = 0;
    for (String key : parameters.keySet()) {
        count++;
        signatureBase.append(OAuthUtil.percentEncode(OAuthUtil.percentEncode(key)));
        signatureBase.append(URLEncoder.encode(OAuthUtil.EQUAL, OAuthUtil.ENCODING));
        signatureBase.append(OAuthUtil.percentEncode(OAuthUtil.percentEncode(parameters.get(key))));

        if (count < parameters.size()) {
            signatureBase.append(URLEncoder.encode(OAuthUtil.AMPERSAND, OAuthUtil.ENCODING));
        }
    }

    if (log.isDebugEnabled()) {
        log.debug(signatureBase.toString());
    }

    byte[] bytes = mac.doFinal(signatureBase.toString().getBytes());
    byte[] encodedMacBytes = Base64.encodeBase64(bytes);

    return new String(encodedMacBytes);
}

From source file:com.addthis.hydra.task.output.DefaultOutputWrapperFactory.java

private File getTempFileName(String fileName) {
    return new File(dir, fileName.concat(".tmp"));
}

From source file:com.adobe.acs.commons.util.InfoWriterTest.java

@Test
public void testPrint_ArrayVars() throws Exception {
    String expected = "String Array [foo, bar], Integer Array [1, 2, 3]";

    iw.message("String Array {}, Integer Array {}", new String[] { "foo", "bar" }, new int[] { 1, 2, 3 });

    assertEquals(expected.concat(LS), iw.toString());
}

From source file:com.cloudera.sqoop.util.AppendUtils.java

/**
 * Move files from source to target using a specified starting partition.
 *//*ww  w .j  a v  a  2  s  .co m*/
private void moveFiles(FileSystem fs, Path sourceDir, Path targetDir, int partitionStart) throws IOException {

    NumberFormat numpart = NumberFormat.getInstance();
    numpart.setMinimumIntegerDigits(PARTITION_DIGITS);
    numpart.setGroupingUsed(false);
    Pattern patt = Pattern.compile("part.*-([0-9][0-9][0-9][0-9][0-9]).*");
    FileStatus[] tempFiles = fs.listStatus(sourceDir);

    if (null == tempFiles) {
        // If we've already checked that the dir exists, and now it can't be
        // listed, this is a genuine error (permissions, fs integrity, or other).
        throw new IOException("Could not list files from " + sourceDir);
    }

    // Move and rename files & directories from temporary to target-dir thus
    // appending file's next partition
    for (FileStatus fileStat : tempFiles) {
        if (!fileStat.isDir()) {
            // Move imported data files
            String filename = fileStat.getPath().getName();
            Matcher mat = patt.matcher(filename);
            if (mat.matches()) {
                String name = getFilename(filename);
                String fileToMove = name.concat(numpart.format(partitionStart++));
                String extension = getFileExtension(filename);
                if (extension != null) {
                    fileToMove = fileToMove.concat(extension);
                }
                LOG.debug("Filename: " + filename + " repartitioned to: " + fileToMove);
                fs.rename(fileStat.getPath(), new Path(targetDir, fileToMove));
            }
        } else {
            // Move directories (_logs & any other)
            String dirName = fileStat.getPath().getName();
            Path path = new Path(targetDir, dirName);
            int dirNumber = 0;
            while (fs.exists(path)) {
                path = new Path(targetDir, dirName.concat("-").concat(numpart.format(dirNumber++)));
            }
            LOG.debug("Directory: " + dirName + " renamed to: " + path.getName());
            fs.rename(fileStat.getPath(), path);
        }
    }
}

From source file:com.pentaho.oem.datasource.TenantedDatasourceService.java

private String modifyDsNameForTenancy(String dsName) {

    logger.debug("Original DSName is " + dsName);
    IPentahoSession session = PentahoSessionHolder.getSession();
    if (session == null) {
        logger.warn("Session is null; no modifications made to the JNDI dsName.");
        return dsName;
    }//from  w  ww .jav  a  2  s  .  c om

    String tenantId = (String) session.getAttribute("tenantId");

    if (StringUtils.isEmpty(tenantId)) {
        logger.warn("ID not found in session; no modifications made to the JNDI dsName.");
        return dsName;
    }
    String dsname = tenantId.concat("_").concat(dsName);
    logger.debug("New DSName is " + dsname);
    return dsname;
}

From source file:com.idega.bedework.presentation.BedeworkPersonalCalendarView.java

private void addFormItem(Layer container, String label, InterfaceObject ui) {
    Label labelUI = new Label(label.concat(CoreConstants.COLON), ui);
    Layer itemContainer = new Layer();
    itemContainer.setStyleClass("formItem");
    itemContainer.add(labelUI);/*  w  w w . j  a va  2 s .  co m*/

    itemContainer.add(ui);
    container.add(itemContainer);
}

From source file:tarefas.controller.DAOController.java

public String getFastestWay() throws ClassNotFoundException, SQLException {
    String way = "";
    Class.forName("org.postgresql.Driver");
    Connection connection = null;
    connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/GasoAbast", "postgres",
            "caoc10");
    Statement statement = connection.createStatement();
    ResultSet rs = statement.executeQuery("select * from all_fillposts_way('central_trofa')");
    while (rs.next()) {
        String aux = rs.getString("txt");
        aux = aux.replace("LINESTRING(", "");
        aux = aux.replace(")", "");
        aux = aux.concat(", ");
        way = way.concat(aux);//from   ww w .j a v a 2  s.com
    }
    way = way.substring(0, way.length() - 2);
    System.out.println(way);
    return way;
}

From source file:com.autentia.wuija.util.web.jsf.NumberAsBigDecimalConverter.java

@Override
public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String value)
        throws ConverterException {
    super.setPattern(getPattern(uiComponent));

    Object object = super.getAsObject(facesContext, uiComponent, value);
    if (object == null) {
        return object;
    }//from  ww w  .  j a  va  2 s  .  c o  m

    if (value == null) {
        return null;
    }

    if (!StringUtils.containsOnly(value, "0123456789.,-+")) {
        throw new ConverterException(value);
    }

    if (!checkIfIsCorrectDecimal(value)) {
        JsfUtils.addMessage(uiComponent.getClientId(facesContext), FacesMessage.SEVERITY_ERROR,
                "javax.faces.converter.BigDecimalConverter.DECIMAL", value);
        throw new ConverterException(value);
    }

    if (value.contains(",")) {
        final String decimalValue = value.substring(value.indexOf(',') + 1);
        String integerValue;
        try {
            integerValue = value.substring(0, value.indexOf(','));
            integerValue = integerValue.replace(".", "");
            return new BigDecimal(integerValue.concat(".").concat(decimalValue));
        } catch (NumberFormatException e) {
            throw new ConverterException(value);
        }
    }
    return new BigDecimal(value.replace(".", ""));
}

From source file:edu.northwestern.bioinformatics.studycalendar.web.activity.AdvancedEditActivityCommand.java

public void saveNewUri() {
    Map<String, UriPropertyList> addedUri = getNewUri();
    Set entries = addedUri.entrySet();
    Iterator iterator = entries.iterator();
    while (iterator.hasNext()) {
        Map.Entry entry = (Map.Entry) iterator.next();
        List<ActivityProperty> activityProperties;
        String templateName = "0".concat(".").concat("template");
        String textName = "0".concat(".").concat("text");
        activityProperties = activityPropertyDao.getByActivityId(activity.getId());
        if (activityProperties != null) {
            for (int k = activityProperties.size(); k > 0; k--) {
                ActivityProperty property = activityProperties.get(k - 1);
                String[] indexValue = property.getName().split("\\.");
                if (indexValue != null && indexValue[0].matches("\\d+")) {
                    int value = Integer.parseInt(indexValue[0]);
                    String index = String.valueOf(value + 1);
                    templateName = index.concat(".").concat("template");
                    textName = index.concat(".").concat("text");
                    break;
                }//w  w  w  .  j  a  va 2  s . c o  m
            }
        }
        if (getNewUri().get(entry.getKey()).getTemplateValue() != null) {
            ActivityProperty activityProperty1 = new ActivityProperty();
            activityProperty1.setActivity(activity);
            activityProperty1.setNamespace(namespace);
            activityProperty1.setName(templateName);
            activityProperty1.setValue(getNewUri().get(entry.getKey()).getTemplateValue());
            activityPropertyDao.save(activityProperty1);
        }
        if (getNewUri().get(entry.getKey()).getTextValue() != null) {
            ActivityProperty activityProperty2 = new ActivityProperty();
            activityProperty2.setActivity(activity);
            activityProperty2.setNamespace(namespace);
            activityProperty2.setName(textName);
            activityProperty2.setValue(getNewUri().get(entry.getKey()).getTextValue());
            activityPropertyDao.save(activityProperty2);
        }
    }
}

From source file:com.pawandubey.griffin.model.Page.java

@Override
public String getKeyword() {
    String result = "";
    if (tags != null) {
        result = StringUtils.join(tags, ",");
    }/*w  w  w  . j a  v  a2 s . c o m*/
    return result.concat("|").concat(this.category);
}