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:com.google.developers.gdgfirenze.mockep.AndroidSimulator.java

private static void postData(String url, JSONObject jsonSamplePacket)
        throws ClientProtocolException, IOException {

    HttpParams myParams = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(myParams, 10000);
    HttpConnectionParams.setSoTimeout(myParams, 10000);
    HttpClient httpclient = new DefaultHttpClient(myParams);

    HttpPost httppost = new HttpPost(url.toString());
    httppost.setHeader("Content-type", "application/json");

    StringEntity se = new StringEntity(jsonSamplePacket.toString());
    se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
    httppost.setEntity(se);//from   w  ww  . jav a 2 s .  c  om

    HttpResponse response = httpclient.execute(httppost);

    String temp = EntityUtils.toString(response.getEntity());
    System.out.println("JSON post response: " + temp);
}

From source file:net.oauth.signature.OAuthSignatureMethod.java

/** The factory for signature methods. */
public static OAuthSignatureMethod newMethod(String name, OAuthAccessor accessor) throws OAuthException {
    try {//from   w  w w.j  ava 2 s  .co  m
        Class methodClass = NAME_TO_CLASS.get(name);
        if (methodClass != null) {
            OAuthSignatureMethod method = (OAuthSignatureMethod) methodClass.newInstance();
            method.initialize(name, accessor);
            return method;
        }
        OAuthProblemException problem = new OAuthProblemException(OAuth.Problems.SIGNATURE_METHOD_REJECTED);
        String acceptable = OAuth.percentEncode(NAME_TO_CLASS.keySet());
        if (acceptable.length() > 0) {
            problem.setParameter("oauth_acceptable_signature_methods", acceptable.toString());
        }
        throw problem;
    } catch (InstantiationException e) {
        throw new OAuthException(e);
    } catch (IllegalAccessException e) {
        throw new OAuthException(e);
    }
}

From source file:net.bither.util.TransactionsUtil.java

public static BitherSetting.AddressType checkAddress(List<String> addressList) throws Exception {
    for (String address : addressList) {
        BitherMytransactionsApi bitherMytransactionsApi = new BitherMytransactionsApi(address.toString());
        bitherMytransactionsApi.handleHttpGet();
        String result = bitherMytransactionsApi.getResult();
        JSONObject json = new JSONObject(result);
        if (!json.isNull(HttpSetting.SPECIAL_TYPE)) {
            int specialType = json.getInt(HttpSetting.SPECIAL_TYPE);
            if (specialType == 0) {
                return BitherSetting.AddressType.SpecialAddress;
            } else {
                return BitherSetting.AddressType.TxTooMuch;
            }//from w  ww  .j  av a2 s  .c o  m
        }
    }
    return BitherSetting.AddressType.Normal;
}

From source file:com.redhat.lightblue.metadata.mongo.BSONParser.java

private static JsonNode toJson(String object) {
    try {/*from   www  .  j  a va 2  s  .c o  m*/
        return JsonUtils.json(object);
    } catch (Exception e) {
        throw Error.get(MetadataConstants.ERR_ILL_FORMED_METADATA, object.toString());
    }
}

From source file:com.noterik.bart.fs.fscommand.dynamic.presentation.playout.cache.java

public static void signalPost(String adr, String uri) {
    if (debuglevel.equals("high"))
        System.out.println("SIGNAL POST = " + adr.toString() + " U=" + uri);
    //System.out.println("SIGNAL POST = "+adr.toString()+" U="+uri);

    // do we have some of this in cache ?
    deleteCacheRecursive(uri, 0);//from w w  w .  j  a  va  2  s  .  com
}

From source file:org.opencastproject.remotetest.Main.java

/**
 * Runs the selenese test suite in src/main/resources/selenium/suite.html
 * /*  www .j  av  a 2  s  .  c  o m*/
 * @throws Exception
 *           if the selenese tests fail to run
 */
private static void runSeleneseTests(String browser) throws Exception {
    if (!SELENESE_DATA_LOADED) {
        loadSeleneseData();
    }
    // Build the test suite and copy it, along with its associated files, to the temp directory
    String time = Long.toString(System.currentTimeMillis());
    File temp = new File(System.getProperty("java.io.tmpdir"), "selenium" + time);
    FileUtils.forceMkdir(temp);
    List<String> testNames = new ArrayList<String>();
    String[] relativePaths = getResourceListing("selenium");
    for (int i = 0; i < relativePaths.length; i++) {
        String relativePath = relativePaths[i];
        String filename = FilenameUtils.getName(relativePath.toString());
        File outFile = new File(temp, filename);
        // Copy the selenium test, prepending the login steps
        InputStream is = addLogin(Main.class.getResource("/" + relativePath).openStream());
        OutputStream os = new FileOutputStream(outFile);
        IOUtils.copy(is, os);
        IOUtils.closeQuietly(is);
        IOUtils.closeQuietly(os);
        testNames.add(filename);
    }

    // Construct the test suite from the files we've copied
    File testSuite = new File(temp, "suite.html");
    StringBuilder suiteHtml = new StringBuilder();
    suiteHtml.append("<html><head><title>Matterhorn Selenium Integration Test Suite</title>");
    suiteHtml.append("</head><body><table><tr><td><b>Suite Of Tests</b></td></tr>");
    for (String testName : testNames) {
        suiteHtml.append("<tr><td><a href=\"./");
        suiteHtml.append(testName);
        suiteHtml.append("\">");
        suiteHtml.append(testName);
        suiteHtml.append("</a></td></tr>");
    }
    suiteHtml.append("</table></body></html>");
    FileUtils.writeStringToFile(testSuite, suiteHtml.toString());

    File target = new File("target");
    if (!target.isDirectory()) {
        FileUtils.forceMkdir(target);
    }
    File report = new File(target, "selenium_results_" + browser.replaceAll("\\W", "") + "_" + time + ".html");

    // Run the selenese tests
    System.out.println("Beginning selenese tests for the '" + browser + "' browser on " + Main.BASE_URL);
    SeleniumServer seleniumServer = new NonExitingSeleniumServer(testSuite, report, browser);
    seleniumServer.boot();
    seleniumServer.stop();
    System.out.println("Finished selenese tests for '" + browser + "'.  Results are available at " + report);

    // Clean up
    // FileUtils.forceDelete(temp);
}

From source file:com.noterik.bart.fs.fscommand.dynamic.presentation.playout.cache.java

public static void signalDelete(String adr, String uri) {
    if (debuglevel.equals("high"))
        System.out.println("SIGNAL DELETE = " + adr.toString() + " U=" + uri);
    //System.out.println("SIGNAL DELETE = "+adr.toString()+" U="+uri);

    // do we have some of this in cache ?
    deleteCacheRecursive(uri, 0);/*  www.j  a  va  2s . co  m*/
}

From source file:edu.duke.cabig.c3pr.utils.StringUtils.java

public static String removeWildCard(String _name) {
    String trimmedName = _name;//from   w ww  .  j a  va  2 s.c o m

    if (trimmedName == null || trimmedName.equals("") || trimmedName.length() == 0) {
        return "";
    }
    trimmedName = _name.toString().trim();
    if (trimmedName.length() > 0 && trimmedName.endsWith("%")) {
        trimmedName = trimmedName.substring(0, (trimmedName.length() - 1));
    }
    if (trimmedName.length() > 0 && trimmedName.startsWith("%")) {
        trimmedName = trimmedName.substring(1, (trimmedName.length()));
    }

    return trimmedName;
}

From source file:com.noterik.bart.fs.fscommand.dynamic.presentation.playout.cache.java

public static void signalPut(String adr, String uri) {
    if (debuglevel.equals("high"))
        System.out.println("SIGNAL PUT = " + adr.toString() + " U=" + uri);
    //System.out.println("SIGNAL PUT = "+adr.toString()+" U="+uri);

    // do we have some of this in cache ?
    if (uri.indexOf("/domain/webtv/config/cache/presentationquickstart/1") != -1) {
        readCacheConfig();/* w ww.j a  va2 s .  c o m*/
        deleteCacheRecursive(uri, 0);
    } else if (uri.indexOf("/domain/webtv/service/smithers/nodes/192.168.1.107") != -1) {
        DiskExporter.exportSmithersNode(uri);
        deleteCacheRecursive(uri, 0);
    } else {
        deleteCacheRecursive(uri, 0);
    }
}

From source file:edu.duke.cabig.c3pr.utils.StringUtils.java

public static String preAndPostwildCard(String _name) {

    String trimmedName = _name;//from www.j  a  v a 2s .  c  o m

    if (trimmedName == null || trimmedName.equals("") || trimmedName.length() == 0) {
        return "";
    }
    trimmedName = _name.toString().trim();
    if (trimmedName.length() > 0 && !trimmedName.endsWith("%")) {
        trimmedName = trimmedName + "%";
    }
    if (trimmedName.length() > 0 && !trimmedName.startsWith("%")) {
        trimmedName = "%" + trimmedName;
    }

    return trimmedName;
}