List of usage examples for java.lang String toString
public String toString()
From source file:com.ChiriChat.DataAccessObject.DAOWebServer.ChiriChatMensajesDAO.java
@Override public Mensajes insert(Mensajes dto) throws Exception { //Enviamos una peticion post al insert del usuario. HttpPost httpPostNewMensaje = new HttpPost("http://chirichatserver.noip.me:85/ws/newMensaje"); //Creo el objeto Jason con los datos del contacto que se registra en la app. JSONObject newUsuario = new JSONObject(); try {//from w ww .ja v a 2s .co m newUsuario.put("idConver", dto.getIdConversacion()); newUsuario.put("idUsuario", dto.getIdUsuario()); newUsuario.put("texto", dto.getCadena()); } catch (JSONException e) { e.printStackTrace(); } List parametros = new ArrayList(); //Aade a la peticion post el parametro json, que contiene los datos a insertar.(json) parametros.add(new BasicNameValuePair("json", newUsuario.toString())); //Creamos la entidad con los datos que le hemos pasado httpPostNewMensaje.setEntity(new UrlEncodedFormEntity(parametros)); //Objeto para poder obtener respuesta del server HttpResponse response = httpClient.execute(httpPostNewMensaje); //Obtenemos el codigo de la respuesta int respuesta = response.getStatusLine().getStatusCode(); Log.w("Respueta", "" + respuesta); //Si respuesta 200 devuelvo mi usuario , si no devolvere null if (respuesta == 200) { //Nos conectamos para recibir los datos de respuesta HttpEntity entity = response.getEntity(); //Creamos el InputStream InputStream is = entity.getContent(); //Leemos el inputStream String temp = StreamToString(is); //Creamos el JSON con la cadena del inputStream Log.d("Cadena JSON", temp.toString()); JSONObject jsonRecibido = new JSONObject(temp); Log.d("InputStreamReader", temp.toString()); Log.d("JSON ==>", jsonRecibido.toString()); Mensajes mensaje = new Mensajes(jsonRecibido); return mensaje; } return null; }
From source file:com.thesmartweb.swebrank.TFIDF.java
/** * Method to calculate TF score/*from ww w .j a v a 2 s. c o m*/ * @param Doc the document to analyze * @param termToCheck the term to calculate tf for * @return th TF score */ public double tfCalculator(String Doc, String termToCheck) { double count = 0; //to count the overall occurrence of the term termToCheck String[] tokenizedTerms = Doc.toString().replaceAll("[\\W&&[^\\s]]", "").split("\\W+"); //to get individual terms for (String s : tokenizedTerms) { if (s.equalsIgnoreCase(termToCheck)) { count++; } } double tfvalue = Math.pow((count / tokenizedTerms.length), 0.5); return tfvalue; }
From source file:gov.nih.nci.cabig.caaers.dao.ResearchStaffDao.java
/** * Search for research staffs using query. * // www. ja v a2 s . co m * @param query * The query used to search for research staffs * @return The list of research staffs. */ @SuppressWarnings({ "unchecked" }) public List<ResearchStaff> searchResearchStaff(final ResearchStaffQuery query) { String queryString = query.getQueryString(); log.debug("::: " + queryString.toString()); List<ResearchStaff> researchStaffs = (List<ResearchStaff>) super.search(query); return researchStaffs; }
From source file:io.ucoin.ucoinj.core.client.model.bma.gson.IdentityTypeAdapter.java
@Override public JsonElement serialize(BlockchainBlock.Identity identity, Type type, JsonSerializationContext context) { String result = new StringBuilder().append(identity.getPubkey()).append(":").append(identity.getSignature()) .append(":").append(identity.getTimestamp()).append(":").append(identity.getUid()).toString(); return context.serialize(result.toString(), String.class); }
From source file:gov.nih.nci.cabig.caaers.dao.ResearchStaffDao.java
/** * This method queries the caAERS DB to get all the matching ResearchStaff for the given query. * @param query/*w w w.ja v a2s . co m*/ * @return */ @SuppressWarnings("unchecked") @Transactional(readOnly = false) public List<ResearchStaff> getLocalResearchStaff(final ResearchStaffQuery query) { String queryString = query.getQueryString(); log.debug("::: " + queryString.toString()); List<ResearchStaff> researchStaffs = (List<ResearchStaff>) super.search(query); return researchStaffs; }
From source file:gov.nih.nci.cabig.caaers.dao.ResearchStaffDao.java
/** * This method queries the caAERS DB to get all the matching SiteResearchStaff for the given query. * @param query// w w w . j a va 2s . co m * @return */ @SuppressWarnings("unchecked") @Transactional(readOnly = false) public List<SiteResearchStaff> getSiteResearchStaff(final SiteResearchStaffQuery query) { String queryString = query.getQueryString(); log.debug("::: " + queryString.toString()); List<SiteResearchStaff> siteResearchStaffs = (List<SiteResearchStaff>) super.search(query); return siteResearchStaffs; }
From source file:org.apache.storm.elasticsearch.trident.EsState.java
/** * Store current state to ElasticSearch. * * @param tuples list of tuples for storing to ES. * Each tuple should have relevant fields (source, index, type, id) for EsState's tupleMapper to extract ES document. * @throws IOException//from w ww .j a v a 2 s . c o m * @throws UnsupportedEncodingException */ public void updateState(List<TridentTuple> tuples) { try { String bulkRequest = buildRequest(tuples); Response response = client.performRequest("post", "_bulk", new HashMap<>(), new StringEntity(bulkRequest.toString())); BulkIndexResponse bulkResponse = objectMapper.readValue(response.getEntity().getContent(), BulkIndexResponse.class); if (bulkResponse.hasErrors()) { LOG.warn("failed processing bulk index requests: " + bulkResponse.getFirstError() + ": " + bulkResponse.getFirstResult()); throw new FailedException(); } } catch (IOException e) { LOG.warn("failed processing bulk index requests: " + e.toString()); throw new FailedException(e); } }
From source file:com.esofthead.mycollab.schedule.email.format.EmailLinkFieldFormat.java
private String formatEmail(String value) { if (value == null) { return new Span().write(); } else {//w w w . j a v a 2 s . c o m A link = new A(); link.setStyle("text-decoration: none; color: rgb(36, 127, 211);"); link.setHref("mailto:" + value.toString()); link.appendText(value.toString()); return new Span().appendChild(link).write(); } }
From source file:nz.net.orcon.kanban.controllers.TeamController.java
@RequestMapping(value = "", method = RequestMethod.POST) public @ResponseBody Team createTeam(@RequestBody Team team) throws Exception { if (team.getPath() != null) { logger.warn("Attempt to update team using POST"); throw new Exception("Attempt to Update team using POST. Use PUT instead"); }/*from ww w . j av a2s . c om*/ ObjectContentManager ocm = ocmFactory.getOcm(); try { String newId = IdentifierTools.getIdFromNamedModelClass(team); team.setPath(String.format(URI.TEAM_URI, newId.toString())); // Ensure that the current user is assigned as the owner of the new board. // By default also add the administrators group as a owner. team.setOwners(this.securityTool.initRole(team.getOwners())); ocm.insert(team); ocm.save(); this.cacheInvalidationManager.invalidate(TEAM, newId); } finally { ocm.logout(); } return team; }
From source file:fi.koku.services.utility.authorization.impl.GroupServiceLDAPImpl.java
@Override public GroupsType getGroups(GroupQueryCriteriaType gqc) { GroupsType g = new GroupsType(); String searchBase = groupTypeToDIT.get(gqc.getGroupClass()); if (searchBase == null) throw new KoKuFaultException(12345, "Invalid group query criteria: group class: " + gqc.getGroupClass()); searchBase += "," + groupSearchBase; List<LdapPerson> persons = getPersonDnsByPics(gqc.getMemberPics().getMemberPic()); if (persons.isEmpty()) return g; Map<String, String> dnToPic = new HashMap<String, String>(); for (LdapPerson p : persons) { dnToPic.put(p.getDn().toLowerCase(), p.getUid()); }/*from www . j a v a 2s. com*/ String q = getGroupsQuery(persons); logger.debug("getGroups: base: " + searchBase + ", query: " + q.toString()); List<GroupType> groups = ldapTemplate.search(searchBase, q, new GroupMapper(dnToPic)); logger.debug("groups: " + groups.size()); g.getGroup().addAll(groups); return g; }