List of usage examples for java.lang String toString
public String toString()
From source file:edu.ku.brc.specify.dbsupport.cleanuptools.LocalityCleanupIndexer.java
/** * @param localityStr/*from w ww . j av a2 s . c o m*/ * @return */ protected static String getMiles(final String localityStr) { String locStr = localityStr.toString(); if (StringUtils.contains(locStr, " mi") || StringUtils.contains(locStr, " km")) { String[] tokens = StringUtils.split(locStr, ' '); for (int i = 0; i < tokens.length; i++) { if (tokens[i].equals("mi") || tokens[i].equals("km")) { if (i > 0 && StringUtils.isNumeric(tokens[i - 1])) { return tokens[i - 1]; } } } } return null; }
From source file:eu.learnpad.simulator.mon.manager.ResponseDispatcher.java
public static void NotifyMeValue(String ruleMatched, String enablerName, String key, String value) { ConsumerProfile enablerMatched = (ConsumerProfile) requestMap.get(ruleMatched); ComplexEventResponseListDocument rsp; rsp = ComplexEventResponseListDocument.Factory.newInstance(); ComplexEventResponse response = rsp.addNewComplexEventResponseList(); response.setRuleName(ruleMatched);// w w w .jav a 2 s . co m response.setResponseKey(key); response.setResponseValue(value); ResponseDispatcher.sendResponse(response, enablerName, enablerMatched.getAnswerTopic()); DebugMessages.print(TimeStamp.getCurrentTime(), ResponseDispatcher.class.getSimpleName(), "ruleMatched: " + ruleMatched + " - enablerName: " + enablerName + " - evaluationResult: " + value.toString()); }
From source file:com.example.heya.couchdb.ConnectionHandler.java
/** * Http GET//from ww w .j a va 2s . c o m * * @param url * @return * @throws JSONException * @throws SpikaException * @throws IOException * @throws IllegalStateException * @throws ClientProtocolException * @throws SpikaForbiddenException */ public static String getString(String url, String userId) throws ClientProtocolException, IllegalStateException, IOException, SpikaException, JSONException, SpikaForbiddenException { String result = null; InputStream is = httpGetRequest(url, userId); result = getString(is); is.close(); Logger.debug("Response: ", result.toString()); return result; }
From source file:edu.wright.daselab.linkgen.ConfigurationParams.java
public final static boolean checkStatusOnLoad() throws Exception { // using reflection to check all properties/params fields. // you can use annotation for better retrieval // http://stackoverflow.com/questions/2020202/pitfalls-in-getting-member-variable-values-in-java-with-reflection // by this time, none of the values are empty. String name = ""; String value = ""; logger.info("Displaying all param values:"); boolean isFine = true; Field[] fields = ConfigurationParams.class.getDeclaredFields(); for (Field field : fields) { // check only final static fields if (!Modifier.isFinal((field.getModifiers())) || (!Modifier.isStatic(field.getModifiers()))) { continue; }//from w w w .j a v a 2 s . c o m name = field.getName(); try { value = (String) field.get(null).toString(); } catch (Exception e) { Monitor.error(Error.INVALID_CONFIG_PARAMS.toString()); throw new IllegalArgumentException(Error.INVALID_CONFIG_PARAMS.toString()); } if ((value == null) || value.toString().trim().equals("")) { isFine = false; } String status = isFine ? "OK" : "Failed"; logger.info(status + " \t" + name + "=" + value); if (!isFine) throw new IllegalArgumentException(Error.INVALID_CONFIG_PARAMS.toString()); } return isFine; }
From source file:org.ofbiz.party.tool.SmsSimpleClient.java
/** * ??http POSThttp?//from ww w. java 2 s . c o m * * @param urlstr url * @return */ public static String doPostRequest(String urlstr, HashMap<String, String> content) { HttpClient client = new DefaultHttpClient(); client.getParams().setIntParameter("http.socket.timeout", 10000); client.getParams().setIntParameter("http.connection.timeout", 5000); List<NameValuePair> ls = new ArrayList<NameValuePair>(); for (String key : content.keySet()) { NameValuePair param = new BasicNameValuePair(key, content.get(key)); ls.add(param); } HttpEntity entity = null; String entityContent = null; try { HttpPost httpPost = new HttpPost(urlstr.toString()); UrlEncodedFormEntity uefe = new UrlEncodedFormEntity(ls, "UTF-8"); httpPost.setEntity(uefe); HttpResponse httpResponse = client.execute(httpPost); entityContent = EntityUtils.toString(httpResponse.getEntity()); } catch (Exception e) { Debug.logError(e, module); } finally { if (entity != null) { try { entity.consumeContent(); } catch (Exception e) { Debug.logError(e, module); } } } return entityContent; }
From source file:org.kie.smoke.wb.util.RestUtil.java
public static <T> T postForm(URL deploymentUrl, String relativeUrl, String mediaType, int status, String user, String password, Map<String, String> formParams, Class<T>... responseTypes) { String uriStr = createBaseUriString(deploymentUrl, relativeUrl); // form content Form formContent = Form.form();// w ww . java 2 s .c o m for (Entry<String, String> entry : formParams.entrySet()) { formContent.add(entry.getKey(), entry.getValue()); } // @formatter:off Request request = Request.Post(uriStr).addHeader(HttpHeaders.CONTENT_TYPE, mediaType.toString()) .addHeader(HttpHeaders.ACCEPT, mediaType.toString()) .addHeader(HttpHeaders.AUTHORIZATION, basicAuthenticationHeader(user, password)) .bodyForm(formContent.build()); // @formatter:on Response resp = null; try { logOp("POST", uriStr); resp = request.execute(); } catch (Exception e) { logAndFail("[GET] " + uriStr, e); } ResponseHandler<T> rh = createResponseHandler(mediaType, status, responseTypes); try { return resp.handleResponse(rh); } catch (Exception e) { logAndFail("Failed retrieving response from [GET] " + uriStr, e); } // never happens return null; }
From source file:org.kie.remote.tests.base.RestUtil.java
public static <T> T postForm(URL deploymentUrl, String relativeUrl, String mediaType, int status, String user, String password, Map<String, String> formParams, Class<T>... responseTypes) { String uriStr = createBaseUriString(deploymentUrl, relativeUrl); // form content Form formContent = Form.form();/*from w w w . ja v a2s. c o m*/ for (Entry<String, String> entry : formParams.entrySet()) { formContent.add(entry.getKey(), entry.getValue()); } // @formatter:off Request request = Request.Post(uriStr).addHeader(HttpHeaders.CONTENT_TYPE, mediaType.toString()) .addHeader(HttpHeaders.ACCEPT, mediaType.toString()) .addHeader(HttpHeaders.AUTHORIZATION, basicAuthenticationHeader(user, password)) .bodyForm(formContent.build()); // @formatter:on Response resp = null; long before = 0, after = 0; try { logOp("POST", uriStr); resp = request.execute(); } catch (Exception e) { failAndLog("[GET] " + uriStr, e); } ResponseHandler<T> rh = createResponseHandler(mediaType, status, responseTypes); try { return resp.handleResponse(rh); } catch (Exception e) { failAndLog("Failed retrieving response from [GET] " + uriStr, e); } // never happens return null; }
From source file:com.bonsai.wallet32.SweepKeyActivity.java
private static double parseNumberWorkaround(String numstr) throws NumberFormatException { // Some countries use comma as the decimal separator. // Android's numberDecimal EditText fields don't handle this // correctly (https://code.google.com/p/android/issues/detail?id=2626). // As a workaround we substitute ',' -> '.' manually ... return Double.parseDouble(numstr.toString().replace(',', '.')); }
From source file:com.google.gwt.dev.shell.jetty.JettyLauncher.java
/** * Setup a connector for the bind address/port. * * @param connector/*from w w w . j a va2 s . c om*/ * @param bindAddress * @param port */ private static void setupConnector(AbstractConnector connector, String bindAddress, int port) { if (bindAddress != null) { connector.setHost(bindAddress.toString()); } connector.setPort(port); // Allow binding to a port even if it's still in state TIME_WAIT. connector.setReuseAddress(true); // Linux keeps the port blocked after shutdown if we don't disable this. connector.setSoLingerTime(0); }
From source file:cd.what.DutchBot.AccessList.java
/** * Load the configuration// w w w .j a v a 2s . com * * @param configfile * @throws ConfigurationException * @throws FileNotFoundException */ public static void loadFromConfig(String configfile) throws ConfigurationException, FileNotFoundException { config.setAutoSave(true); config.setThrowExceptionOnMissing(true); config.setFileName(configfile); config.load(); @SuppressWarnings("rawtypes") Iterator keys = config.getKeys("acl.user"); while (keys.hasNext()) { String key = keys.next().toString(); String host = key.substring("acl.user.".length()).toLowerCase(); Privileges axx = Privileges.lookup((config.getInt(key))); accessList.put(host, axx); } keys = config.getKeys("acl.channel"); while (keys.hasNext()) { String key = keys.next().toString(); String channel = "#" + key.substring("acl.channel.".length()).toLowerCase(); Privileges axx = Privileges.lookup(config.getInt(key)); channelAccessList.put(channel, axx); } keys = config.getKeys("alias"); while (keys.hasNext()) { String key = keys.next().toString(); String host = String.copyValueOf(key.toCharArray(), 6, key.toString().length() - 6).toLowerCase(); aliasList.put(host, config.getString(key)); } }