Example usage for java.lang String toString

List of usage examples for java.lang String toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

This object (which is already a string!) is itself returned.

Usage

From source file:ActualizadorLocal.Clientes.ClienteNodos.java

public void procesarDatosSplit(String datos) throws SQLException {
    String datosAInsertar = "";
    datos = "," + datos;
    String[] result = datos.toString().split("}");
    for (int x = 0; x < result.length - 1; x++) {
        String[] result2 = result[x].split(",");
        for (int y = 1; y < result2.length; y++) {
            String[] result3 = result2[y].split(":");
            //for (int w=1; w<result3.length; w++){
            if (y == 1) {
                nodos.add(result3[1]);//from w w w  .j  a v a 2s.com
            }
            datosAInsertar += result3[1] + ", ";

        }
        this.InsertarDatosSync(datosAInsertar.substring(0, datosAInsertar.lastIndexOf(",")));
        datosAInsertar = "";
    }

}

From source file:hu.bme.mit.trainbenchmark.generator.sql.SqlSerializer.java

@Override
public Object createVertex(final int id, final String type, final Map<String, ? extends Object> attributes,
        final Map<String, Object> outgoingEdges, final Map<String, Object> incomingEdges) throws IOException {
    final StringBuilder columns = new StringBuilder();
    final StringBuilder values = new StringBuilder();

    columns.append("\"" + ID + "\"");
    values.append(id);/*from  ww  w. j  ava  2s . co m*/

    structuralFeaturesToSQL(attributes, columns, values);
    structuralFeaturesToSQL(outgoingEdges, columns, values);
    structuralFeaturesToSQL(incomingEdges, columns, values);

    if (SUPERTYPES.containsKey(type)) {
        final String ancestorType = SUPERTYPES.get(type);
        write(String.format("INSERT INTO \"%s\" (\"%s\") VALUES (%s);", ancestorType, ID, id));
        write(String.format("INSERT INTO \"%s\" (%s) VALUES (%s);", type, columns.toString(),
                values.toString()));
    } else {
        final String insertQuery = String.format("INSERT INTO \"%s\" (%s) VALUES (%s);", type,
                columns.toString(), values.toString());
        write(insertQuery.toString());
    }

    return id;
}

From source file:com.kaltura.client.ClientBase.java

/** generate "ks" to be used fro requests - OVP */
public String generateSession(String adminSecretForSigning, String userId, SessionType type, int partnerId,
        int expiry, String privileges) throws Exception {
    try {//from w w w. j ava2 s.  c  om
        // initialize required values
        int rand = (int) (Math.random() * 32000);
        expiry += (int) (System.currentTimeMillis() / 1000);

        // build info string
        StringBuilder sbInfo = new StringBuilder();
        sbInfo.append(partnerId).append(";"); // index 0 - partner ID
        sbInfo.append(partnerId).append(";"); // index 1 - partner pattern - using partner ID
        sbInfo.append(expiry).append(";"); // index 2 - expiration timestamp
        sbInfo.append(type.getValue()).append(";"); // index 3 - session type
        sbInfo.append(rand).append(";"); // index 4 - random number
        sbInfo.append(userId).append(";"); // index 5 - user ID
        sbInfo.append(privileges); // index 6 - privileges

        byte[] infoSignature = EncryptionUtils.encryptSHA1(adminSecretForSigning + (sbInfo.toString()));

        // convert signature to hex:
        String signature = convertToHex(infoSignature);

        // build final string to base64 encode
        StringBuilder sbToEncode = new StringBuilder();
        sbToEncode.append(signature.toString()).append("|").append(sbInfo.toString());

        // encode the signature and info with base64
        String hashedString = new String(Base64.encodeBase64(sbToEncode.toString().getBytes()));

        // remove line breaks in the session string
        String ks = hashedString.replace("\n", "");
        ks = hashedString.replace("\r", "");

        // return the generated session key (KS)
        return ks;
    } catch (NoSuchAlgorithmException ex) {
        throw new Exception(ex);
    }
}

From source file:com.roncoo.pay.controller.login.LoginController.java

/**
 * ???????//from w w w .j  a v a 2  s  .  com
 * 
 * @param pId
 * @param treeBuf
 * @param menuList
 */
@SuppressWarnings("rawtypes")
private void buildAdminPermissionTree(String pId, StringBuffer treeBuf, List menuList) {

    List<Map> listMap = getSonMenuListByPid(pId.toString(), menuList);
    for (Map map : listMap) {
        String id = map.get("id").toString();// id
        String name = map.get("name").toString();// ??
        String isLeaf = map.get("isLeaf").toString();// ???
        String level = map.get("level").toString();// ??1?2?3?4
        String url = map.get("url").toString(); // ACTION?
        String navTabId = "";
        if (!StringUtil.isEmpty(map.get("targetName"))) {
            navTabId = map.get("targetName").toString(); // ?
        }

        if ("1".equals(level)) {
            treeBuf.append("<div class='accordionHeader'>");
            treeBuf.append("<h2> <span>Folder</span> " + name + "</h2>");
            treeBuf.append("</div>");
            treeBuf.append("<div class='accordionContent'>");
        }

        if ("YES".equals(isLeaf)) {
            treeBuf.append(
                    "<li><a href='" + url + "' target='navTab' rel='" + navTabId + "'>" + name + "</a></li>");
        } else {

            if ("1".equals(level)) {
                treeBuf.append("<ul class='tree treeFolder'>");
            } else {
                treeBuf.append("<li><a>" + name + "</a>");
                treeBuf.append("<ul>");
            }

            buildAdminPermissionTree(id, treeBuf, menuList);

            if ("1".equals(level)) {
                treeBuf.append("</ul>");
            } else {
                treeBuf.append("</ul></li>");
            }

        }

        if ("1".equals(level)) {
            treeBuf.append("</div>");
        }
    }

}

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

@Override
public String encode(String str) throws EncoderException {
    if (str == null)
        return null;
    String[] s = code(str.toString());
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < s.length; i++) {
        sb.append(s[i]);//from   www.java  2 s .co  m
        if (i < s.length - 1) {
            sb.append('_');
        }
    }
    return sb.toString();
}

From source file:com.mnxfst.stream.pipeline.element.script.ScriptEvaluatorPipelineElement.java

/**
 * @see akka.actor.UntypedActor#preStart()
 */// w ww .  j a v  a  2  s.c o m
public void preStart() throws Exception {

    // initialize the script engine 
    ScriptEngineManager factory = new ScriptEngineManager();
    try {
        this.scriptEngine = factory.getEngineByName(getStringProperty(CONFIG_SCRIPT_ENGINE_NAME));
    } catch (Exception e) {
        context().parent()
                .tell(new PipelineElementSetupFailedMessage(getPipelineElementConfiguration().getPipelineId(),
                        getPipelineElementConfiguration().getElementId(),
                        PipelineElementSetupFailedMessage.GENERAL, e.getMessage()), getSelf());
        return;
    }

    // iterate from zero to max, read out init code snippets and interrupt if an empty one occurs
    for (int i = 0; i < Integer.MAX_VALUE; i++) {
        String initScript = getStringProperty(CONFIG_SCRIPT_INIT_CODE_PREFIX + i);
        if (StringUtils.isNotBlank(initScript)) {
            this.initScripts.add(loadScript(initScript.toString()));
        } else {
            break;
        }
    }

    // fetch the script to be applied for each message
    String scriptUrl = getStringProperty(CONFIG_SCRIPT_EVAL_CODE);
    //      this.evalScript = getStringProperty(CONFIG_SCRIPT_EVAL_CODE);
    if (StringUtils.isBlank(scriptUrl)) {
        context().parent()
                .tell(new PipelineElementSetupFailedMessage(getPipelineElementConfiguration().getPipelineId(),
                        getPipelineElementConfiguration().getElementId(),
                        PipelineElementSetupFailedMessage.GENERAL, "Required script code missing"), getSelf());
        return;
    }
    this.evalScript = loadScript(scriptUrl);

    // retrieve the name of the variable where the script expects the input 
    this.scriptInputVariable = getStringProperty(CONFIG_SCRIPT_INPUT_VARIABLE);
    if (StringUtils.isBlank(this.scriptInputVariable)) {
        context().parent()
                .tell(new PipelineElementSetupFailedMessage(getPipelineElementConfiguration().getPipelineId(),
                        getPipelineElementConfiguration().getElementId(),
                        PipelineElementSetupFailedMessage.GENERAL, "Required input variable missing"),
                        getSelf());
        return;
    }

    // retrieve the name of the variable where the script writes the identifier of the next pipeline element to
    this.scriptOutputNextElementVariable = getStringProperty(CONFIG_SCRIPT_OUTPUT_NEXT_ELEMENT_VARIABLE);
    if (StringUtils.isBlank(this.scriptOutputNextElementVariable)) {
        context().parent()
                .tell(new PipelineElementSetupFailedMessage(getPipelineElementConfiguration().getPipelineId(),
                        getPipelineElementConfiguration().getElementId(),
                        PipelineElementSetupFailedMessage.GENERAL,
                        "Required output (next element) variable missing"), getSelf());
        return;
    }

    // if the set of init scripts is not empty, provide them to the script engine 
    if (!initScripts.isEmpty()) {
        for (String script : initScripts) {
            this.scriptEngine.eval(script);
        }
    }
}

From source file:ddf.catalog.transformer.input.pdf.GeoPdfParser.java

/**
 * Parses a given NeatLine and Transformation matrix into a WKT String
 *
 * @param lgidict         - The PDF's LGIDict object
 * @param neatLineArray   - The NeatLine array of points for the PDF
 * @param toDoubleVisitor - A visitor that converts PDF Strings / Ints / Longs into doubles.
 * @return the generated WKT Lat/Lon set
 * @throws IOException/*from   w  w  w.ja  va2  s  .c  om*/
 */
private String getWktFromNeatLine(COSDictionary lgidict, COSArray neatLineArray, ICOSVisitor toDoubleVisitor)
        throws IOException {
    List<Double> neatline = new LinkedList<>();
    List<String> coordinateList = new LinkedList<>();
    String firstCoordinate = null;

    double[] points = new double[CTM_SIZE];
    for (int i = 0; i < CTM_SIZE; i++) {
        points[i] = (Double) lgidict.getObjectFromPath(CTM + "/[" + i + "]").accept(toDoubleVisitor);
    }
    AffineTransform affineTransform = new AffineTransform(points);

    for (int i = 0; i < neatLineArray.size(); i++) {
        neatline.add((Double) neatLineArray.get(i).accept(toDoubleVisitor));
    }

    for (int i = 0; i < neatline.size(); i += 2) {
        double x = neatline.get(i);
        double y = neatline.get(i + 1);

        Point2D p = new Point2D.Double(x, y);

        Point2D pprime = affineTransform.transform(p, null);

        String xySet = point2dToWkt(pprime);

        if (firstCoordinate == null) {
            firstCoordinate = xySet;
        }
        coordinateList.add(xySet);
    }
    coordinateList.add(firstCoordinate);
    String wktString = StringUtils.join(coordinateList, ", ");
    LOGGER.debug("{}", wktString);
    return wktString.toString();
}

From source file:in.gov.uidai.core.aua.client.KYCClient.java

private String generateSignedKycXML(String kycXML) throws JAXBException, Exception {
    boolean includeKeyInfo = true;
    return this.digitalSignator.signXML(kycXML.toString(), includeKeyInfo);

}

From source file:io.stallion.dataAccess.file.FilePersisterBase.java

public boolean reloadIfNewer(T obj) {
    String path = fullFilePathForObj(obj);
    File file = new File(path.toString());
    Long currentTs = file.lastModified();
    Long fileLastModified = or(obj.getLastModifiedMillis(), 0L);
    if (currentTs >= fileLastModified) {
        getStash().loadForId(obj.getId());
        fileToTimestampMap.put(path.toString(), currentTs);
        return true;
    }/*  w w  w  . ja v  a 2 s  .co  m*/
    return false;
}

From source file:org.osiam.client.OsiamGroupServiceTest.java

private void thenReturnedGroupHasID(String id) {
    Group result = service.getGroup(id, accessToken);
    assertEquals(id.toString(), result.getId());
}