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:gov.va.isaac.gui.preferences.plugins.properties.PreferencesPluginTextFieldProperty.java

public PreferencesPluginTextFieldProperty(Label label, boolean emptyStringAllowed) {
    super(label, new TextField(), new SimpleStringProperty(), null, // validator handled below
            new StringConverter<String>() {
                @Override/*w ww .ja v a2 s  .c  o  m*/
                public String convertToString(String value) {
                    return value != null ? value.toString() : null;
                }
            }, new PropertyAction<String, TextField>() {
                @Override
                public void apply(PreferencesPluginProperty<String, TextField> property) {
                    property.getProperty().bind(property.getControl().textProperty());
                }
            }, new PropertyAction<String, TextField>() {
                @Override
                public void apply(PreferencesPluginProperty<String, TextField> property) {
                    property.getControl().textProperty().set(property.readFromPersistedPreferences());
                }
            }, new PropertyAction<String, TextField>() {
                @Override
                public void apply(PreferencesPluginProperty<String, TextField> property) {
                    GridPane.setHgrow(property.getLabel(), Priority.NEVER);
                    GridPane.setFillWidth(property.getControl(), true);
                    GridPane.setHgrow(property.getControl(), Priority.ALWAYS);
                }
            });
    validator = new ValidBooleanBinding() {
        {
            bind(getProperty());
            setComputeOnInvalidate(true);
        }

        @Override
        protected boolean computeValue() {
            if (!emptyStringAllowed && StringUtils.isBlank(getProperty().getValue())) {
                this.setInvalidReason("unspecified value for " + name);
                logger.debug(getReasonWhyInvalid().get());

                TextErrorColorHelper.setTextErrorColor(label);

                return false;
            } else {
                TextErrorColorHelper.clearTextErrorColor(label);
            }

            this.clearInvalidReason();

            return true;
        }
    };
}

From source file:gov.nih.nci.cabig.caaers.dao.report.ReportDao.java

@SuppressWarnings({ "unchecked" })
@Override//from ww  w. j a v a2s .c  o  m
public List<Report> search(final AbstractQuery query) {
    String queryString = query.getQueryString();
    log.debug("::: " + queryString.toString());
    return (List<Report>) getHibernateTemplate().execute(new HibernateCallback() {

        public Object doInHibernate(final Session session) throws HibernateException, SQLException {
            org.hibernate.Query hiberanteQuery = session.createQuery(query.getQueryString());
            Map<String, Object> queryParameterMap = query.getParameterMap();
            for (String key : queryParameterMap.keySet()) {
                Object value = queryParameterMap.get(key);
                hiberanteQuery.setParameter(key, value);

            }
            return hiberanteQuery.list();
        }

    });

}

From source file:org.o3project.ocnrm.model.bind.OduBindingData.java

@Override
public void bind(String name, String resource) throws JsonParseException, JsonMappingException, IOException {
    JsonFactory factory = new JsonFactory();
    JsonParser jp = factory.createParser(resource.toString());
    jp.nextToken();/*  w w w. j a va2  s  . com*/
    OduMapping terminationPoint = new OduMapping();
    terminationPoint.setName(name);
    while (jp.nextToken() != JsonToken.END_OBJECT) {
        String fieldname = jp.getCurrentName();
        jp.nextToken();
        if ("dpid".equals(fieldname)) {
            terminationPoint.setDpid(jp.getText());
        } else if ("port".equals(fieldname)) {
            terminationPoint.setPort(jp.getText());
        } else if ("odutype".equals(fieldname)) {
            terminationPoint.setOdutype(jp.getText());
        } else if ("ts".equals(fieldname)) {
            String ts = jp.getText();
            terminationPoint.setTs(ts);
        } else if ("tpn".equals(fieldname)) {
            terminationPoint.setTpn(jp.getText());
        } else {
            throw new IllegalStateException("Unrecognized field '" + fieldname + "'!");
        }
        bindMap.put(terminationPoint.getName(), terminationPoint);
    }
    jp.close();
}

From source file:com.blazemeter.bamboo.plugin.ServiceManager.java

public static String startTest(Api api, String testId, BuildLogger logger) {
    int countStartRequests = 0;
    String masterId = null;
    try {//  w ww  .  jav  a  2 s  . c o m
        logger.addBuildLogEntry(
                "Trying to start test with testId=" + testId + " for userKey=" + api.getUserKey());
        TestType testType = getTestType(api, testId, logger);
        do {
            masterId = api.startTest(testId, testType);
            countStartRequests++;
            if (countStartRequests > 5) {
                logger.addErrorLogEntry("Could not start BlazeMeter Test with userKey=" + api.getUserKey()
                        + " testId=" + testId);
                return masterId;
            }
        } while (masterId.length() == 0);
        logger.addBuildLogEntry(
                "Test with testId=" + testId + " was started with masterId=" + masterId.toString());
    } catch (Exception e) {
        logger.addErrorLogEntry("Error: Exception while starting BlazeMeter Test [" + e.getMessage() + "]");
        logger.addErrorLogEntry("Check server & proxy settings");
    }
    return masterId;
}

From source file:org.duracloud.snapshot.service.impl.SnapshotJobExecutionListener.java

private void sendEmail(String subject, String msg, String... destinations) {
    notificationManager.sendNotification(NotificationType.EMAIL, subject, msg.toString(), destinations);
    log.info("sent email with subject=\"" + subject + "\" to " + StringUtils.join(destinations, ","));

}

From source file:com.taobao.tddl.common.sync.RowBasedReplicationExecutor.java

/**
 * jdbcupdate//from   w w w  . j a  v  a 2s  .  c  o m
 */
public static void batchUpdateSyncLog(Collection<RowBasedReplicationContext> contexts,
        final long extraPlusTime) {
    long timeused, time0 = System.currentTimeMillis();
    String sqlpattern = "update sync_log_{0} set next_sync_time=? where id = ?";

    /**
     * RowBasedReplicationContextupdateSql
     */
    Map<JdbcTemplate, Map<String/*logSQL*/, List<RowBasedReplicationContext>>> sortedContexts = buildSortedContexts(
            contexts, sqlpattern.toString());

    for (Map.Entry<JdbcTemplate, Map<String, List<RowBasedReplicationContext>>> e0 : sortedContexts
            .entrySet()) {
        JdbcTemplate jt = e0.getKey();
        for (Map.Entry<String, List<RowBasedReplicationContext>> e : e0.getValue().entrySet()) {
            final List<RowBasedReplicationContext> endContexts = e.getValue();
            BatchPreparedStatementSetter setter = new BatchPreparedStatementSetter() {
                public int getBatchSize() {
                    return endContexts.size();
                }

                public void setValues(PreparedStatement ps, int i) throws SQLException {
                    RowBasedReplicationContext context = endContexts.get(i);
                    ps.setTimestamp(1, getNextSyncTime(context, extraPlusTime));
                    ps.setString(2, context.getSyncLogId());
                }
            };
            jt.batchUpdate(e.getKey(), setter);
            if (log.isDebugEnabled()) {
                log.debug("[batchUpdateSyncLog], sql = [" + e.getKey() + "], batch size=" + endContexts.size());
            }
        }
    }

    timeused = System.currentTimeMillis() - time0;
    log.warn(contexts.size() + " replication logs updated, time used:" + timeused);
    Monitor.add(Monitor.KEY1, Monitor.KEY2_SYNC, Monitor.KEY3_BatchUpdateSyncLog, contexts.size(), timeused);
}

From source file:org.owasp.webgoat.plugin.BypassRestrictionsFieldRestrictions.java

@RequestMapping(method = RequestMethod.POST)
public @ResponseBody AttackResult completed(@RequestParam String select, @RequestParam String radio,
        @RequestParam String checkbox, @RequestParam String shortInput) throws IOException {
    if (select.toString().equals("option1") || select.toString().equals("option2")) {
        return trackProgress(failed().build());
    }//from w w w.  ja  v a  2  s  .  c om
    if (radio.toString().equals("option1") || radio.toString().equals("option2")) {
        return trackProgress(failed().build());
    }
    if (checkbox.toString().equals("on") || checkbox.toString().equals("off")) {
        return trackProgress(failed().build());
    }
    if (shortInput.toString().length() <= 5) {
        return trackProgress(failed().build());
    }
    /*if (disabled == null) {
      return trackProgress(failed().build());
    }
    if (submit.toString().equals("submit")) {
      return trackProgress(failed().build());
    }*/
    return trackProgress(success().build());
}

From source file:org.kie.smoke.wb.util.RestUtil.java

public static <T> T postEntity(URL deploymentUrl, String relativeUrl, String mediaType, int status, String user,
        String password, Object entity, Class<T>... responseTypes) {
    String uriStr = createBaseUriString(deploymentUrl, relativeUrl);

    ResponseHandler<T> rh = createResponseHandler(mediaType, status, responseTypes);

    String entityStr = ((AbstractResponseHandler) rh).serialize(entity);
    HttpEntity bodyEntity = null;/*from w  ww . ja  v a 2s . co  m*/
    try {
        bodyEntity = new StringEntity(entityStr);
    } catch (UnsupportedEncodingException uee) {
        logAndFail("Unable to encode serialized " + entity.getClass().getSimpleName() + " entity", uee);
    }

    // @formatter:off
    Request request = Request.Post(uriStr).body(bodyEntity)
            .addHeader(HttpHeaders.CONTENT_TYPE, mediaType.toString())
            .addHeader(HttpHeaders.ACCEPT, mediaType.toString())
            .addHeader(HttpHeaders.AUTHORIZATION, basicAuthenticationHeader(user, password));
    // @formatter:on

    Response resp = null;
    try {
        logOp("POST", entity, uriStr);
        resp = request.execute();
    } catch (Exception e) {
        logAndFail("[GET] " + uriStr, e);
    }

    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 postEntity(URL deploymentUrl, String relativeUrl, String mediaType, int status, String user,
        String password, Object entity, Class<T>... responseTypes) {
    String uriStr = createBaseUriString(deploymentUrl, relativeUrl);

    ResponseHandler<T> rh = createResponseHandler(mediaType, status, responseTypes);

    String entityStr = ((AbstractResponseHandler) rh).serialize(entity);
    HttpEntity bodyEntity = null;//from w w w  . ja va  2s. com
    try {
        bodyEntity = new StringEntity(entityStr);
    } catch (UnsupportedEncodingException uee) {
        failAndLog("Unable to encode serialized " + entity.getClass().getSimpleName() + " entity", uee);
    }

    // @formatter:off
    Request request = Request.Post(uriStr).body(bodyEntity)
            .addHeader(HttpHeaders.CONTENT_TYPE, mediaType.toString())
            .addHeader(HttpHeaders.ACCEPT, mediaType.toString())
            .addHeader(HttpHeaders.AUTHORIZATION, basicAuthenticationHeader(user, password));
    // @formatter:on

    Response resp = null;
    try {
        logOp("POST", entity, uriStr);
        resp = request.execute();
    } catch (Exception e) {
        failAndLog("[GET] " + uriStr, e);
    }

    try {
        return resp.handleResponse(rh);
    } catch (Exception e) {
        failAndLog("Failed retrieving response from [GET] " + uriStr, e);
    }

    // never happens
    return null;
}

From source file:com.andrewkroh.cisco.xmlservices.HttpTestServerHandler.java

public void setResponse(Object ciscoJaxbObject) {
    // Marshal object to XML:
    String objectAsXml = XmlMarshaller.marshalToXml(ciscoJaxbObject);

    // Build the content of the response body:
    byte[] bodyContent = objectAsXml.toString().getBytes(Charsets.ISO_8859_1);
    ByteBuf bodyContentByteBuf = Unpooled.wrappedBuffer(bodyContent);

    // Build the HTTP response:
    FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, OK, bodyContentByteBuf);
    response.headers().set(HttpHeaders.Names.CACHE_CONTROL,
            Arrays.asList(HttpHeaders.Values.MUST_REVALIDATE, HttpHeaders.Values.NO_STORE));
    response.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE);
    response.headers().set(HttpHeaders.Names.CONTENT_TYPE, "text/html");
    response.headers().set(HttpHeaders.Names.CONTENT_LENGTH, bodyContent.length);

    httpResponseRef.set(response);/* w  ww . ja va2s .  c om*/
}