Example usage for java.lang Boolean toString

List of usage examples for java.lang Boolean toString

Introduction

In this page you can find the example usage for java.lang Boolean toString.

Prototype

public String toString() 

Source Link

Document

Returns a String object representing this Boolean's value.

Usage

From source file:com.haulmont.cuba.desktop.gui.components.SwingXTableSettings.java

@Override
public boolean saveSettings(Element element) {
    element.addAttribute("horizontalScroll", String.valueOf(table.isHorizontalScrollEnabled()));

    saveFontPreferences(element);/*from ww w.  ja  v  a2  s. c om*/

    Element columnsElem = element.element("columns");
    if (columnsElem != null) {
        element.remove(columnsElem);
    }
    columnsElem = element.addElement("columns");

    final List<TableColumn> visibleTableColumns = table.getColumns();
    final List<Table.Column> visibleColumns = new ArrayList<>();
    for (TableColumn tableColumn : visibleTableColumns) {
        visibleColumns.add((Table.Column) tableColumn.getIdentifier());
    }

    List<TableColumn> columns = table.getColumns(true);
    Collections.sort(columns, new Comparator<TableColumn>() {
        @SuppressWarnings("SuspiciousMethodCalls")
        @Override
        public int compare(TableColumn col1, TableColumn col2) {
            if (col1 instanceof TableColumnExt && !((TableColumnExt) col1).isVisible()) {
                return 1;
            }
            if (col2 instanceof TableColumnExt && !((TableColumnExt) col2).isVisible()) {
                return -1;
            }
            int i1 = visibleColumns.indexOf(col1.getIdentifier());
            int i2 = visibleColumns.indexOf(col2.getIdentifier());
            return Integer.compare(i1, i2);
        }
    });

    for (TableColumn column : columns) {
        Element colElem = columnsElem.addElement("column");
        colElem.addAttribute("id", column.getIdentifier().toString());

        int width = column.getWidth();
        colElem.addAttribute("width", String.valueOf(width));

        if (column instanceof TableColumnExt) {
            Boolean visible = ((TableColumnExt) column).isVisible();
            colElem.addAttribute("visible", visible.toString());
        }
    }

    if (table.getRowSorter() != null) {
        TableColumn sortedColumn = table.getSortedColumn();
        List<? extends RowSorter.SortKey> sortKeys = table.getRowSorter().getSortKeys();
        if (sortedColumn != null && !sortKeys.isEmpty()) {
            columnsElem.addAttribute("sortColumn", String.valueOf(sortedColumn.getIdentifier()));
            columnsElem.addAttribute("sortOrder", sortKeys.get(0).getSortOrder().toString());
        }
    }

    return true;
}

From source file:com.thoughtworks.go.server.database.H2Database.java

private String dburl(Boolean mvccEnabled) {
    return "jdbc:h2:" + systemEnvironment.getDbPath() + "/" + configuration.getName() + ";DB_CLOSE_DELAY=-1"
            + ";DB_CLOSE_ON_EXIT=FALSE" + ";MVCC=" + mvccEnabled.toString().toUpperCase() + ";CACHE_SIZE="
            + systemEnvironment.getCruiseDbCacheSize() + ";TRACE_LEVEL_FILE="
            + systemEnvironment.getCruiseDbTraceLevel() + ";TRACE_MAX_FILE_SIZE="
            + systemEnvironment.getCruiseDbTraceFileSize()
            //                Commented out until H2 fix their bug
            //                + ";CACHE_TYPE=SOFT_LRU" //See http://www.h2database.com/html/changelog.html
            + ";DATABASE_EVENT_LISTENER='" + H2EventListener.class.getName() + "'";
}

From source file:com.ibm.streamsx.topology.internal.context.AnalyticsServiceStreamsContext.java

private JSONObject getBluemixSubmitConfig(Map<String, Object> config) throws IOException {
    JSONObject submitConfig = new JSONObject();

    JobConfig jc = JobConfig.fromProperties(config);
    addSubmitValue(submitConfig, jc.getJobName(), "jobName");
    addSubmitValue(submitConfig, jc.getJobGroup(), "jobGroup");
    addSubmitValue(submitConfig, jc.getDataDirectory(), "data-directory");
    if (jc.hasSubmissionParameters()) {
        JSONObject joParams = new JSONObject();
        for (SubmissionParameter param : jc.getSubmissionParameters()) {
            joParams.put(param.getName(), param.getValue());
        }/* w w w .  j  a v a 2 s  .c  om*/
        addSubmitValue(submitConfig, joParams, "submissionParameters");
    }

    addSubmitValue(submitConfig, jc.getOverrideResourceLoadProtection(), "overrideResourceLoadProtection");

    JSONObject submitConfigConfig = new JSONObject();
    Boolean preLoad = jc.getPreloadApplicationBundles();
    if (preLoad != null && preLoad)
        addSubmitValue(submitConfigConfig, preLoad.toString(), "preloadApplicationBundles");
    if (jc.getTracing() != null) {
        submitConfigConfig.put("tracing", jc.getStreamsTracing());
    }
    if (!submitConfigConfig.isEmpty())
        submitConfig.put("configurationSettings", submitConfigConfig);

    Topology.STREAMS_LOGGER.info("Streaming Analytics Service submit job request:" + submitConfig.serialize());

    return submitConfig;
}

From source file:fr.itldev.koya.services.impl.DossierServiceImpl.java

/**
 * change dossier confidentiality status
 * //from  w ww.  j  av a  2 s  . c om
 * @param user
 * @param dossier
 * @return
 * @throws AlfrescoServiceException
 */
@Override
public Boolean setConfidentiality(User user, Dossier dossier, Boolean confidential)
        throws AlfrescoServiceException {
    Map<String, String> params = new HashMap<>();
    params.put("confidential", confidential.toString());
    return Boolean.valueOf(user.getRestTemplate().postForObject(getAlfrescoServerUrl() + REST_CONFIDENTIAL,
            params, String.class, dossier.getNodeRef()));
}

From source file:infosistema.openbaas.dataaccess.models.UserModel.java

/**
 * Checks if user is present in the app:{appId}:all:users and if it is returns
 * its fields// w  w  w .ja  v a  2s.  c  om
 * 
 * @param appId
 * @param userId
 * @return
 */
public JSONObject getUser(String appId, String userId, boolean getMetadata) {
    SessionModel sessionModel = SessionModel.getInstance();
    Jedis jedis = pool.getResource();
    jedis.auth(Const.getRedisGeneralPass());
    Map<String, String> userFields = null;
    try {
        String userKey = getUserKey(appId, userId);
        userFields = jedis.hgetAll(userKey);
        Boolean online = sessionModel.isUserOnline(userId);
        userFields.put("online", online.toString());
        if (!getMetadata)
            userFields.remove(_METADATA);
        if (userFields == null || userFields.size() <= 0)
            return null;
        return getJSonObject(userFields);
    } catch (Exception e) {
        Log.error("", this, "getUser", "Error getting user", e);
        return null;
    } finally {
        pool.returnResource(jedis);
    }
}

From source file:edu.kit.dama.mdm.admin.UserPropertyCollection.java

/**
 * Set the value of property with key pKey to pValue. If there is no property
 * with the provided key, a new property is added. If the provided value is
 * null, the property with the provided key will be removed.
 *
 * @param pKey The property key. This value must not be null.
 * @param pValue The property value. If pValue is null, the property will be
 * removed.//from w  w w .  j  a  va 2  s  . c o m
 *
 * @return TRUE if a property has been modified/added/removed, FALSE if the
 * removal failed.
 */
public boolean setBooleanProperty(final String pKey, Boolean pValue) {
    if (pValue == null) {
        return setStringProperty(pKey, null);
    }
    return setStringProperty(pKey, pValue.toString());
}

From source file:com.twosigma.beaker.NamespaceClient.java

public Object set4(String name, Object value, Boolean unset, Boolean sync)
        throws ClientProtocolException, IOException {
    Form form = Form.form().add("name", name).add("sync", sync.toString()).add("session", this.session);
    if (!unset) {
        StringWriter sw = new StringWriter();
        JsonGenerator jgen = objectMapper.get().getJsonFactory().createJsonGenerator(sw);
        if (!objectSerializerProvider.get().writeObject(value, jgen, true))
            form.add("value", value.toString());
        else {/*from   ww  w.ja  va2s .c  o m*/
            jgen.flush();
            form.add("value", sw.toString());
        }
    }
    String reply = Request.Post(urlBase + "/set").addHeader("Authorization", auth).bodyForm(form.build())
            .execute().returnContent().asString();
    if (!reply.equals("ok")) {
        throw new RuntimeException(reply);
    }
    return value;
}

From source file:fr.itldev.koya.webscript.dossier.IsConfidential.java

@Override
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException {
    Map<String, String> urlParams = KoyaWebscript.getUrlParamsMap(req);

    Boolean isConfidential = false;
    try {/*from w  w  w  . j av  a  2 s. co  m*/
        SecuredItem item = koyaNodeService.getSecuredItem(
                koyaNodeService.getNodeRef((String) urlParams.get(KoyaWebscript.WSCONST_NODEREF)));

        isConfidential = SubSpaceAclService.isConfidential(item);

    } catch (KoyaServiceException ex) {
        //silently ignore exception 
    }
    res.setContentType("application/json");
    res.getWriter().write(isConfidential.toString());
}

From source file:com.comcast.cns.test.unit.CNSRawMessageDeliveryTest.java

@Test
public void testRawMessageDelivery() throws Exception {

    // create topic
    String topicArn = getTopic(1, USR.USER1);

    // subscribe and confirm http endpoint to receive raw message
    String id = rand.nextLong() + "";

    String rawEndPointUrl = CMBTestingConstants.HTTP_ENDPOINT_BASE_URL + "recv/" + id;
    String rawEndPointLastMessageUrl = CMBTestingConstants.HTTP_ENDPOINT_BASE_URL + "info/" + id
            + "?showLast=true";

    SubscribeRequest rawEndPointSubscribeRequest = new SubscribeRequest();
    rawEndPointSubscribeRequest.setEndpoint(rawEndPointUrl);
    rawEndPointSubscribeRequest.setProtocol("http");
    rawEndPointSubscribeRequest.setTopicArn(topicArn);
    SubscribeResult subscribeResult = cns1.subscribe(rawEndPointSubscribeRequest);
    String rawEndPointsubscriptionArn = subscribeResult.getSubscriptionArn();

    if (rawEndPointsubscriptionArn.equals("pending confirmation")) {

        Thread.sleep(500);//from   w w  w . j  ava  2 s . c om
        String response = CNSTestingUtils.sendHttpMessage(rawEndPointLastMessageUrl, "");
        logger.info(response);
        JSONObject o = new JSONObject(response);
        if (!o.has("SubscribeURL")) {
            throw new Exception("message is not a confirmation messsage");
        }
        String subscriptionUrl = o.getString("SubscribeURL");
        response = CNSTestingUtils.sendHttpMessage(subscriptionUrl, "");

        String startTag = "<SubscriptionArn>";
        String endTag = "</SubscriptionArn>";
        int startIndex = response.indexOf(startTag);
        int endIndex = response.indexOf(endTag);
        String subArn = response.substring(startIndex + startTag.length(), endIndex);
        if (subArn != null && !subArn.isEmpty()) {
            rawEndPointsubscriptionArn = subArn;
        }
        logger.info("Raw-message EndPoint subscription Arn after confirmation: " + rawEndPointsubscriptionArn);
    }

    // set subscription attribute for raw message delivery

    Boolean rawMessageDelivery = true;
    try {
        SetSubscriptionAttributesRequest setSubscriptionAttributesRequest = new SetSubscriptionAttributesRequest(
                rawEndPointsubscriptionArn, "RawMessageDelivery", rawMessageDelivery.toString());
        cns1.setSubscriptionAttributes(setSubscriptionAttributesRequest);

        Map<String, String> attributes = null;
        GetSubscriptionAttributesRequest getSubscriptionAttributesRequest = new GetSubscriptionAttributesRequest(
                rawEndPointsubscriptionArn);
        GetSubscriptionAttributesResult getSubscriptionAttributesResult = cns1
                .getSubscriptionAttributes(getSubscriptionAttributesRequest);
        attributes = getSubscriptionAttributesResult.getAttributes();
        String rawMessageDeliveryStr = attributes.get("RawMessageDelivery");
        if (rawMessageDeliveryStr != null && !rawMessageDeliveryStr.isEmpty()) {
            rawMessageDelivery = Boolean.parseBoolean(rawMessageDeliveryStr);
            assertTrue("Set raw message delivery successful", rawMessageDelivery);
        } else {
            fail("no raw message delivery flag found");
        }
        logger.info("Raw Message Delivery attribute:" + rawMessageDeliveryStr);
    } catch (Exception ex) {
        throw new Exception(
                "Can't set raw message delivery attribute to subscription arn " + rawEndPointsubscriptionArn);
    }

    // subscribe and confirm http endpoint to receive JSON message
    id = rand.nextLong() + "";
    String jsonEndPointUrl = CMBTestingConstants.HTTP_ENDPOINT_BASE_URL + "recv/" + id;
    String jsonEndPointLastMessageUrl = CMBTestingConstants.HTTP_ENDPOINT_BASE_URL + "info/" + id
            + "?showLast=true";

    SubscribeRequest jsonEndPointSubscribeRequest = new SubscribeRequest();
    jsonEndPointSubscribeRequest.setEndpoint(jsonEndPointUrl);
    jsonEndPointSubscribeRequest.setProtocol("http");
    jsonEndPointSubscribeRequest.setTopicArn(topicArn);
    SubscribeResult jsonSubscribeResult = cns1.subscribe(jsonEndPointSubscribeRequest);
    String jsonEndPointsubscriptionArn = jsonSubscribeResult.getSubscriptionArn();
    logger.info("JSON EndPoint subscription arn:" + jsonEndPointsubscriptionArn);

    if (jsonEndPointsubscriptionArn.equals("pending confirmation")) {

        Thread.sleep(500);
        String response = CNSTestingUtils.sendHttpMessage(jsonEndPointLastMessageUrl, "");
        JSONObject o = new JSONObject(response);
        if (!o.has("SubscribeURL")) {
            throw new Exception("message is not a confirmation messsage");
        }
        String subscriptionUrl = o.getString("SubscribeURL");
        response = CNSTestingUtils.sendHttpMessage(subscriptionUrl, "");

        String startTag = "<SubscriptionArn>";
        String endTag = "</SubscriptionArn>";
        int startIndex = response.indexOf(startTag);
        int endIndex = response.indexOf(endTag);
        String subArn = response.substring(startIndex + startTag.length(), endIndex);
        if (subArn != null && !subArn.isEmpty()) {
            jsonEndPointsubscriptionArn = subArn;
        }
        logger.info("JSON EndPoint subscription arn after confirmation:" + jsonEndPointsubscriptionArn);
    }

    // publish and receive message

    String messageText = "Pulish a raw message";
    PublishRequest publishRequest = new PublishRequest();
    publishRequest.setMessage(messageText);
    publishRequest.setSubject("unit test raw message");
    publishRequest.setTopicArn(topicArn);
    cns1.publish(publishRequest);

    Thread.sleep(500);

    // check raw message is received         
    String response = CNSTestingUtils.sendHttpMessage(rawEndPointLastMessageUrl, "");
    logger.info("Reponse of raw-message endpoint:" + response);
    if (response != null && response.length() > 0) {
        assertEquals("Receive raw message", response, messageText);
    } else {
        fail("no messages found");
    }

    // check json message is received
    response = CNSTestingUtils.sendHttpMessage(jsonEndPointLastMessageUrl, "");
    logger.info("Reponse of JSON-message endpoint: " + response);
    if (response != null && response.length() > 0) {
        try {
            JSONObject obj = new JSONObject(response);
        } catch (Exception ex) {
            fail("message not surrounded by json envelope");
        }
    } else {
        fail("no messages found");
    }
}

From source file:net.sf.clickclick.control.BooleanSelect.java

/**
 * Set the value of the field to the given Boolean value. The Boolean can
 * be null, meaning the value is not set.
 *
 * @param value the field's value, can be <tt>null</tt>, meaning the value
 * is not set/* w w  w  .  ja  va  2 s . co m*/
 */
public void setBoolean(Boolean value) {
    this.value = ((value == null) ? "" : value.toString());
}