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.example.klaudia.myapplication.Searcher.java

public boolean checkTypeCorrectness(String key, String value) {
    boolean correct = true;
    char type = key.toString().charAt(0);
    switch (type) {
    case 'b':
        correct = isBoolean(value);/* ww  w.  jav a 2  s  .c o  m*/
        break;

    case 'i':
        correct = isInteger(value);
        break;

    case 'd':
        correct = isDouble(value);
        break;

    case 's':
        correct = !(isBoolean(value) || isInteger(value) || isDouble(value));
        break;

    default:
        break;
    }
    return correct;
}

From source file:com.esoft.yeepay.user.service.impl.YeePayCorpAccountOperation.java

@Override
@Transactional(rollbackFor = Exception.class, noRollbackFor = TrusteeshipReturnException.class)
public void receiveOperationPostCallback(ServletRequest request) throws TrusteeshipReturnException {
    try {//from   ww w. j a  v  a  2  s  .  c o  m
        request.setCharacterEncoding("UTF-8");
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
    }
    // ?? xml?
    String respXML = request.getParameter("resp");
    log.debug(respXML.toString());
    // ??
    String sign = request.getParameter("sign");
    boolean flag = CFCASignUtil.isVerifySign(respXML, sign);
    if (flag) {
        // ??
        @SuppressWarnings("unchecked")
        Map<String, String> resultMap = Dom4jUtil.xmltoMap(respXML);
        // ?? userId
        String requestNo = resultMap.get("requestNo").substring(resultMap.get("requestNo").indexOf("a") + 1);
        // ?
        String code = resultMap.get("code");
        String description = resultMap.get("description");
        TrusteeshipOperation to = trusteeshipOperationBO.get(YeePayConstants.OperationType.ENTERPRISE_REGISTER,
                requestNo, requestNo, "yeepay");
        ht.evict(to);
        to = ht.get(TrusteeshipOperation.class, to.getId(), LockMode.UPGRADE);

        to.setResponseTime(new Date());
        to.setResponseData(respXML);
        // ? ????
        User user = ht.get(User.class, requestNo);
        if ("1".equals(code)) {
            if (user != null) {
                TrusteeshipAccount ta = ht.get(TrusteeshipAccount.class, user.getId());
                if (ta == null) {
                    ta = new TrusteeshipAccount();
                    ta.setId(user.getId());
                    ta.setUser(user);
                }
                ta.setAccountId(user.getId());
                ta.setCreateTime(new Date());
                ta.setStatus(TrusteeshipConstants.Status.PASSED);
                ta.setTrusteeship("yeepay");
                ht.saveOrUpdate(ta);
                userBO.removeRole(user, new Role("WAIT_CONFIRM"));
                userBO.addRole(user, new Role("LOANER"));
                // ??
                springSecurityService.refreshLoginUserAuthorities(user.getId());
                to.setStatus(TrusteeshipConstants.Status.PASSED);
                ht.merge(to);
            }
        } else {
            to.setStatus(TrusteeshipConstants.Status.REFUSED);
            ht.merge(to);
            userBO.removeRole(user, new Role("WAIT_CONFIRM"));
            // ??
            springSecurityService.refreshLoginUserAuthorities(user.getId());
            if ("0".equals(code)) {
                throw new TrusteeshipReturnException(description);
            }
            // 
            throw new TrusteeshipReturnException(code + ":" + description);
        }
    }

}

From source file:cc.kave.episodes.mining.reader.ReposParser.java

public List<Event> validationStream(int numbRepos) throws IOException {
    List<String> learningRepos = reader.readFile(new File(getReposPath(numbRepos)));
    EventStreamGenerator generator = new EventStreamGenerator();

    for (String zip : findZips(contextsDir)) {
        String repoName = getRepoName(zip);
        if (learningRepos.contains(repoName)) {
            continue;
        }/* w  w  w .j  a  va  2  s.  c  om*/
        Logger.log("Reading zip file %s", zip.toString());
        ReadingArchive ra = contextsDir.getReadingArchive(zip);

        while (ra.hasNext()) {
            Context ctx = ra.getNext(Context.class);
            if (ctx == null) {
                continue;
            }
            generator.add(ctx);
        }
        ra.close();
    }
    List<Event> allEvents = generator.getEventStream();
    return allEvents;
}

From source file:com.sm.transport.grizzly.EchoFilter.java

/**
 * Handle just read operation, when some message has come and ready to be
 * processed.// w w  w.  jav  a 2  s. c o  m
 *
 * @param ctx Context of {@link org.glassfish.grizzly.filterchain.FilterChainContext} processing
 * @return the next action
 * @throws java.io.IOException
 */
@Override
public NextAction handleRead(FilterChainContext ctx) throws IOException {
    // Peer address is used for non-connected UDP Connection :)
    final Object peerAddress = ctx.getAddress();

    final String message = ctx.getMessage();
    logger.info(
            "reeving from " + ctx.getConnection().getPeerAddress().toString() + " length " + message.length());
    if (server)
        ctx.write(peerAddress, "message length " + message.length(), null);
    else
        logger.info("msg " + message.toString());
    return ctx.getStopAction();
}

From source file:com.feedhenry.sdk.tests.api.FHSDKTest.java

private void verifyCloudRequest(String path, String method, Header[] headers, JSONObject params)
        throws Exception {
    RecordedRequest request = mockWebServer.takeRequest();
    assertEquals(method.toLowerCase(), request.getMethod().toLowerCase());

    String cuidHeader = request.getHeader("x-fh-cuid");
    assertEquals(getDeviceId(), cuidHeader);

    if (null != headers) {
        for (int i = 0; i < headers.length; i++) {
            String requestHeaderValue = request.getHeader(headers[i].getName());
            assertEquals(requestHeaderValue, headers[i].getValue());
        }//from  ww  w.java2 s .c o  m
    }

    if (null != params) {
        String requestBody = new String(request.getBody().readUtf8());
        assertEquals(requestBody.toString(), params.toString());
    }

}

From source file:com.ChiriChat.DataAccessObject.DAOWebServer.ChiriChatContactosDAO.java

@Override
public Contactos insert(Contactos dto) throws Exception {

    Contactos c = null;/*from www .  j  a  va 2s  .  c  o  m*/

    //Enviamos una peticion post al insert del usuario.
    HttpPost httpPostNuevoUsuario = new HttpPost("http://chirichatserver.noip.me:85/ws/insertUsuario");

    //Creo el objeto Jason con los datos del contacto que se registra en la app.
    JSONObject newUsuario = new JSONObject();
    try {
        newUsuario.put("nombre", dto.getNombre());
        newUsuario.put("telefono", dto.getTelefono());
        newUsuario.put("estado", dto.getEstado());
        newUsuario.put("id_gcm", dto.getIdgcm());
    } 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()));

    Log.d("JSON de insert usaurio DAO", newUsuario.toString());
    try {
        //Creamos la entidad con los datos que le hemos pasado
        httpPostNuevoUsuario.setEntity(new UrlEncodedFormEntity(parametros));
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    //Objeto para poder obtener respuesta del server
    HttpResponse response = httpClient.execute(httpPostNuevoUsuario);
    //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());

        c = new Contactos(jsonRecibido);

    }

    return c;

}

From source file:com.openshift.internal.restclient.ResourceFactory.java

public List<IResource> createList(String json, String kind) {
    ModelNode data = ModelNode.fromJSONString(json);
    final String dataKind = data.get(KIND).asString();
    if (!(kind.toString() + "List").equals(dataKind)) {
        throw new RuntimeException(
                String.format("Unexpected container type '%s' for desired kind: %s", dataKind, kind));
    }//from w  w  w . ja v a  2  s .co  m

    try {
        final String version = data.get(APIVERSION).asString();
        return buildList(version, data.get("items").asList(), kind);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:com.ChiriChat.DataAccessObject.DAOWebServer.ChiriChatContactosDAO.java

@Override
public List<Contactos> getAll() throws Exception {

    List<Contactos> allContacts = new ArrayList<Contactos>();

    //Enviamos una peticion post al insert del usuario.
    HttpPost httpPostNuevoUsuario = new HttpPost("http://chirichatserver.noip.me:85/ws/usuarios");

    try {/*  w  ww  .  j  ava  2 s.  c  o m*/
        HttpResponse response = httpClient.execute(httpPostNuevoUsuario);

        int respuesta = response.getStatusLine().getStatusCode();

        Log.d("=>>>>reponse", String.valueOf(respuesta));

        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());
            JSONArray jsonRecibido = new JSONArray(temp);

            Log.d("InputStreamReader", temp.toString());
            Log.d("JSON ==>", jsonRecibido.toString());

            for (int i = 0; i < jsonRecibido.length(); i++) {
                Log.d("Item de la array", jsonRecibido.get(i).toString());

                JSONObject jo = (JSONObject) jsonRecibido.get(i);

                Contactos us = new Contactos(jo);

                Log.d("Datos del usuario", us.toString());

                allContacts.add(us);
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    } catch (JSONException e) {
        e.printStackTrace();

    }

    return allContacts;
}

From source file:fi.helsinki.cs.iot.hub.api.handlers.feeds.FeedGetRequestHandler.java

private Response handleExecutableFeed(Feed feed) {
    ExecutableFeed executableFeed = (ExecutableFeed) feed;
    if (!executableFeed.isReadable()) {
        Log.e(TAG, "The feed " + feed.getName() + " is not readable");
        return getResponseKo(ERROR, "The feed " + feed.getName() + " is not readable");
    } else {/*from w w  w.ja va2 s.  co m*/
        String jValue = executableFeed.getValue(libdir);
        if (jValue != null) {
            Log.d(TAG, "Returns the feed's value");
            return getResponseOk(jValue.toString());
        } else {
            Log.e(TAG, "The feed " + feed.getName() + " has no value");
            return getResponseKo(ERROR, "The feed " + feed.getName() + " has no value");
        }
    }
}

From source file:gov.nih.nci.caadapter.ui.mapping.sdtm.SDTMMapFileTransformer.java

public void startTransform() {
    // _mappedData _csvDataFromFile Iterate over the keys in the map
    Iterator it = _mappedData.keySet().iterator();
    while (it.hasNext()) {
        // Get key
        Object key = it.next();//  w  w w  .  j  a v a 2 s. co  m
        if (_csvDataFromFile.containsKey(key)) {
            String _tmp = (String) _csvDataFromFile.get(key);
            StringTokenizer _str = new StringTokenizer(_tmp.toString(), "&");
            while (_str.hasMoreTokens()) {
                LinkedList<String> _new = new LinkedList<String>();
                // dummy list initialized
                for (int j = 0; j < defineXMLList.size(); j++) {
                    _new.add("");
                }
                // to retrieve the data from the csv file
                EmptyStringTokenizer _emp = new EmptyStringTokenizer(_str.nextToken(), ",");
                // to get all the fields for the segment
                // StringBuffer _md = (StringBuffer) _mappedData.get(key);
                // for (int j=0; j<_mappedData.size(); j++){
                Iterator it1 = _mappedData.keySet().iterator();
                while (it1.hasNext()) {
                    // Get key
                    Object key1 = it1.next();
                    StringBuffer _md = (StringBuffer) _mappedData.get(key1);
                    StringTokenizer _strT = new StringTokenizer(_md.toString(), ",");
                    while (_strT.hasMoreTokens()) {
                        StringTokenizer s = new StringTokenizer(_strT.nextToken(), "?");
                        int pos_ = new Integer(s.nextToken().substring(0, 1)).intValue();
                        String _sRef = s.nextToken();
                        // System.out.println(pos_+" for is "+_sRef);
                        _new.set(defineXMLList.indexOf(_sRef), _emp.getTokenAt(pos_ - 1));
                    }
                }
                System.out.println(_new);
            }
        }
    }
}