List of usage examples for java.lang String concat
public String concat(String str)
From source file:com.oneandone.sdk.VPNApi.java
/** * Returns a list of your VPNs./*from ww w . ja v a2 s. c om*/ * * @param page Allows to use pagination. Sets the number of servers that * will be shown in each page. * @param perPage Current page to show. * @param sort Allows to sort the result by priority:sort=name retrieves a * list of elements ordered by their names.sort=-creation_date retrieves a * list of elements ordered according to their creation date in descending * order of priority. * @param query Allows to search one string in the response and return the * elements that contain it. In order to specify the string use parameter q: * q=My server * @param fields Returns only the parameters requested: * fields=id,name,description,hardware.ram * @return VPNResponse[] * @throws RestClientException * @throws IOException */ public List<VPNResponse> getVPNs(int page, int perPage, String sort, String query, String fields) throws RestClientException, IOException { String queryUrl = getUrlBase().concat(resource).concat("?"); boolean firstParameter = true; if (page != 0) { if (!firstParameter) { queryUrl = queryUrl.concat("&"); } queryUrl = queryUrl.concat("page=").concat(Integer.toString(page)); firstParameter = false; } if (perPage != 0) { if (!firstParameter) { queryUrl = queryUrl.concat("&"); } queryUrl = queryUrl.concat("per_page=").concat(Integer.toString(perPage)); firstParameter = false; } if (sort != null && !sort.isEmpty()) { if (!firstParameter) { queryUrl = queryUrl.concat("&"); } queryUrl = queryUrl.concat("sort=").concat(sort); firstParameter = false; } if (query != null && !query.isEmpty()) { if (!firstParameter) { queryUrl = queryUrl.concat("&"); } queryUrl = queryUrl.concat("q=").concat(query); firstParameter = false; } if (fields != null && !fields.isEmpty()) { if (!firstParameter) { queryUrl = queryUrl.concat("&"); } queryUrl = queryUrl.concat("fields=").concat(fields); } VPNResponse[] result = client.get(queryUrl, null, VPNResponse[].class); return Arrays.asList(result); }
From source file:com.github.alexfalappa.nbspringboot.projects.initializr.InitializrService.java
public JsonNode getDependencies(String bootVersion) throws Exception { if (!dependencyMetaMap.containsKey(bootVersion)) { // set connection timeouts timeoutFromPrefs();/*from w w w . ja va2 s. com*/ // prepare request final String serviceUrl = NbPreferences.forModule(PrefConstants.class).get(PREF_INITIALIZR_URL, "http://start.spring.io"); UriTemplate template = new UriTemplate(serviceUrl.concat("/dependencies?{bootVersion}")); RequestEntity<Void> req = RequestEntity.get(template.expand(bootVersion)) .accept(MediaType.valueOf("application/vnd.initializr.v2.1+json")) .header("User-Agent", REST_USER_AGENT).build(); // connect logger.log(INFO, "Getting Spring Initializr dependencies metadata from: {0}", template); logger.log(INFO, "Asking metadata as: {0}", REST_USER_AGENT); long start = System.currentTimeMillis(); ResponseEntity<String> respEntity = rt.exchange(req, String.class); // analyze response final HttpStatus statusCode = respEntity.getStatusCode(); if (statusCode == OK) { ObjectMapper mapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT); final JsonNode depMeta = mapper.readTree(respEntity.getBody()); logger.log(INFO, "Retrieved Spring Initializr dependencies metadata for boot version {0}. Took {1} msec", new Object[] { bootVersion, System.currentTimeMillis() - start }); if (logger.isLoggable(FINE)) { logger.fine(mapper.writeValueAsString(depMeta)); } dependencyMetaMap.put(bootVersion, depMeta); } else { // log status code final String errMessage = String.format( "Spring initializr service connection problem. HTTP status code: %s", statusCode.toString()); logger.severe(errMessage); // throw exception in order to set error message throw new RuntimeException(errMessage); } } return dependencyMetaMap.get(bootVersion); }
From source file:nl.surfnet.mujina.spring.SAMLAuthenticationEntryPoint.java
private String transparentProxying(HttpServletRequest request, String singleSignOnServiceURL) { String entityID = request.getParameter("entityID"); String virtualOrganization = request.getParameter("vo"); if (StringUtils.hasText(virtualOrganization)) { try {/*from w w w . j av a 2s.c o m*/ singleSignOnServiceURL = singleSignOnServiceURL.concat("/vo:") .concat(URLEncoder.encode(virtualOrganization, "UTF-8")); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } if (StringUtils.hasText(entityID)) { String encodeEntityID = new MessageDigestPasswordEncoder("MD5").encodePassword(entityID, null); singleSignOnServiceURL = singleSignOnServiceURL.concat("/").concat(encodeEntityID); } return singleSignOnServiceURL; }
From source file:fr.natoine.model_annotation.Annotation.java
public String toSeeAlso(String _url_rdf_resources) { String rdf = ""; if (status != null) rdf = rdf.concat("<jeu2debat:").concat(status.getRDFLabel()).concat(" rdf:about=\"") .concat(_url_rdf_resources).concat("?id=").concat(getId().toString()).concat("\" >"); else/* ww w .j av a 2 s .c o m*/ rdf = rdf.concat("<annotea:Annotation rdf:about=\"").concat(_url_rdf_resources).concat("?id=") .concat(getId().toString()).concat("\" >"); rdf = rdf.concat("<rdfs:seeAlso rdf:resource=\"").concat(_url_rdf_resources).concat("?id=") .concat(getId().toString()).concat("\"/>"); if (status != null) rdf = rdf.concat("</jeu2debat:").concat(status.getRDFLabel()).concat(">"); else rdf = rdf.concat("</annotea:Annotation>"); return rdf; }
From source file:fr.eurecom.nerd.core.proxy.TextRazorClient.java
private List<TEntity> parse(String json, String text, OntologyType otype) { List<TEntity> result = new LinkedList<TEntity>(); Gson gson = new Gson(); try {/*from w ww. j a v a 2s . co m*/ JSONObject o = new JSONObject(json); JSONObject response = o.getJSONObject("response"); String entityjson = response.getJSONArray("entities").toString(); //System.out.println(entityjson); Type listType = new TypeToken<LinkedList<TextRazorEntity>>() { }.getType(); List<TextRazorEntity> entities = gson.fromJson(entityjson, listType); for (TextRazorEntity e : entities) { Integer startChar = e.getStartingPos(); Integer endChar = e.getEndingPos(); String label = text.substring(startChar, endChar); // we relax a bit this constraint //if( ! label.equalsIgnoreCase(e.getMatchedText()) ) // continue; String uri = e.getWikiLink(); String extractorType = ""; Boolean found = false; if (e.getType() != null) { extractorType = "DBpedia:"; for (String t : e.getType()) extractorType += t.concat(","); extractorType = extractorType.substring(0, extractorType.length() - 1); found = true; } if (e.getFreebaseTypes() != null) { if (found) extractorType += ";"; extractorType += "Freebase:"; for (String t : e.getFreebaseTypes()) extractorType += t.concat(","); extractorType = extractorType.substring(0, extractorType.length() - 1); found = true; } if (!found) extractorType = "null"; //FIXME //String nerdType = OntoFactory.mapper.getNerdType(otype, label, SOURCE, extractorType).toString(); //patch for classifying entities according to the main 3 types String nerdType = "http://nerd.eurecom.fr/ontology#Thing"; if (extractorType != null) { if (extractorType.indexOf("/organization/organization_") != -1) { nerdType = "http://nerd.eurecom.fr/ontology#Thing"; } else if (extractorType.indexOf("Person") != -1 || extractorType.indexOf("/people/person") != -1) nerdType = "http://nerd.eurecom.fr/ontology#Person"; else if (extractorType.indexOf("Organization") != -1 || extractorType.indexOf("Organisation") != -1 || extractorType.indexOf("/organization/organization") != -1) nerdType = "http://nerd.eurecom.fr/ontology#Organization"; else if (extractorType.indexOf("Place") != -1 || extractorType.indexOf("AdministrativeRegion") != -1 || extractorType.indexOf("AdministrativeArea") != -1 || extractorType.indexOf("Settlement") != -1 || extractorType.indexOf("/location/statistical_region") != -1 || extractorType.indexOf("/location/citytown") != -1 || extractorType.indexOf("/location/location") != -1) nerdType = "http://nerd.eurecom.fr/ontology#Location"; } //FIXME Double confidence = e.getConfidenceScore() / 4; Double relevance = e.getRelevanceScore(); TEntity entity = new TEntity(label, extractorType, uri, nerdType, startChar, endChar, confidence, relevance, SOURCE); //System.out.println(entity.toString()); result.add(entity); } } catch (JSONException e) { e.printStackTrace(); } return result; }
From source file:org.n52.sos.soe.GetObservationTest.java
@Test public void validateGetObservation() throws ClientProtocolException, IllegalStateException, IOException, XmlException { Configuration config = Configuration.instance(); String url = HttpUtil.resolveServiceURL().concat(String.format( "GetObservation?service=SOS&version=2.0.0&request=GetObservation&observedProperty=%s&procedure=%s&f=xml", config.getObservedProperty(), config.getProcedure())); if (config.getTemporalFilter() != null) { url = url.concat("&temporalFilter=").concat(config.getTemporalFilter()); }//from ww w . ja v a 2s . com XmlObject xo = HttpUtil.executeGetAndParseAsXml(url); Assert.assertTrue("Not a GetObservationResponse: " + xo.getClass(), xo instanceof GetObservationResponseDocument); validateXml(xo); GetObservationResponseDocument obs = (GetObservationResponseDocument) xo; Assert.assertTrue("Got no ObservationData!", obs.getGetObservationResponse().getObservationDataArray().length > 0); Assert.assertNotNull("Got no Result!", obs.getGetObservationResponse().getObservationDataArray(0).getOMObservation().getResult()); for (ObservationData od : obs.getGetObservationResponse().getObservationDataArray()) { validateContentsAndReturnValueCount(od.getOMObservation()); } }
From source file:ar.com.zauber.commons.gis.street.impl.SQLStreetsDAO.java
/** * Escapes a character from a string intended to be used in a like clause. * /* w w w.j av a 2s . com*/ * @param text string to escape * @param escapeChar escape character * @return the escaped string */ private String escapeForLike(final String text, final Character escapeChar) { String escape = escapeChar.toString(); return text.replace("%", escape.concat("%")).replace("_", escape.concat("_")); }
From source file:egovframework.rte.bat.core.launch.support.EgovBatchRunner.java
/** * ? ?? JobParamters String? JobParameter . * @param jobParameters/*www. j a v a 2 s .com*/ * @param parameterName : JobParamter ? * @param parameterValue : JobParamter * @return String ? JobParamters */ public String addJobParameter(String jobParameters, String parameterName, String parameterValue) { String delim = ""; if (!"".equals(jobParameters)) { delim = ","; } return jobParameters.concat(delim).concat(parameterName).concat("=").concat(parameterValue); }
From source file:org.jasig.portlets.FeedbackPortlet.dao.hibernate.HibernateFeedbackStore.java
@Override public long getFeedbackTotal(FeedbackQueryParameters params) { String role = params.getString(params.USER_ROLE); String feedbacktype = params.getString(params.FEEDBACK_TYPE); boolean comments = params.getBoolean(params.COMMENTS_ONLY_DISPLAYED); Date startDate = params.getDate(params.START_DISPLAY_DATE); Date endDate = params.getEndDate(params.END_DISPLAY_DATE); try {/*from w ww.j ava 2 s . c o m*/ final Session session = this.getSession(false); String sql = "select count(item.id) from FeedbackItem item"; if (role != null && !role.isEmpty()) { sql = sql.concat(!sql.contains(" where ") ? " where " : " and "); sql = sql.concat("userrole = :userrole"); } if (feedbacktype != null && !feedbacktype.isEmpty()) { sql = sql.concat(!sql.contains(" where ") ? " where " : " and "); sql = sql.concat("feedbacktype = :feedbacktype"); } if (comments != false) { sql = sql.concat(!sql.contains(" where ") ? " where " : " and "); sql = sql.concat("LENGTH(feedback) > 0"); } if (startDate != null && endDate != null) { sql = sql.concat(!sql.contains(" where ") ? " where " : " and "); sql = sql.concat("submissiontime BETWEEN :startDate AND :endDate"); } Query query = session.createQuery(sql); if (role != null && !role.isEmpty()) { query.setString("userrole", role); } if (feedbacktype != null && !feedbacktype.isEmpty()) { query.setString("feedbacktype", feedbacktype); } if (startDate != null && endDate != null) { query.setDate("startDate", startDate); query.setDate("endDate", endDate); } return (Long) query.uniqueResult(); } catch (HibernateException ex) { throw convertHibernateAccessException(ex); } }
From source file:ua.pp.msk.maven.MavenHttpClient.java
public void setUrl(String url) { if (url.contains("/nexus/service/local/artifact/maven/content")) { this.url = url; } else {// ww w .j av a2 s . c om this.url = url.concat("/nexus/service/local/artifact/maven/content"); } }