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.uisteps.utils.api.zapi.Zapi.java

private void exportToPom(File file, String cycleId, String clonedCycleId, String projectKey, String metaFilter,
        Boolean createExecutions, RestApi api)
        throws RestApiException, IOException, ParserConfigurationException, SAXException,
        TransformerConfigurationException, TransformerException, JSONException {

    StringBuilder executionsExport = new StringBuilder();

    JSONArray executions = api.getRequest("/rest/zapi/latest/execution?cycleId=" + clonedCycleId).get()
            .toJSONObject().getJSONArray("executions");

    for (int i = 0; i < executions.length(); i++) {
        JSONObject execution = executions.getJSONObject(i);
        executionsExport.append("+").append(execution.getString("issueKey").replace("-", "")).append(" ");
    }//from www  .  j a  v a  2s .  c  o  m

    if (metaFilter != null && !metaFilter.isEmpty()) {
        executionsExport.append(" ").append(metaFilter);
    }

    Document doc = getXML(file);

    Element project = (Element) doc.getElementsByTagName("project").item(0);
    Element properties = (Element) project.getElementsByTagName("properties").item(0);

    Element metafilter = doc.createElement("metafilter");
    metafilter.setTextContent(executionsExport.toString());

    properties.appendChild(metafilter);

    Element cycleIdElement = doc.createElement("cycleId");
    cycleIdElement.setTextContent(cycleId);

    properties.appendChild(cycleIdElement);

    Element projectKeyElement = doc.createElement("projectKey");
    projectKeyElement.setTextContent(projectKey);

    properties.appendChild(projectKeyElement);

    Element createExecutionsElement = doc.createElement("createExecutions");
    createExecutionsElement.setTextContent(createExecutions.toString());

    properties.appendChild(createExecutionsElement);

    Transformer t = TransformerFactory.newInstance().newTransformer();
    t.transform(new DOMSource(doc), new StreamResult(file));

}

From source file:com.bibisco.servlet.BibiscoServlet.java

public void isDndTipEnabled(HttpServletRequest pRequest, HttpServletResponse pResponse) throws IOException {
    mLog.debug("Start isTipEnabled(HttpServletRequest, HttpServletResponse)");

    Boolean lBlnResult;
    String lStrTipCode = pRequest.getParameter("tipCode");
    mLog.debug("tipCode: " + lStrTipCode);

    // get tip settings
    TipSettings lTipSettings = (TipSettings) getServletContext().getAttribute("tipSettings");

    lBlnResult = lTipSettings.getDndTipMap().get(lStrTipCode);

    pResponse.setContentType("text/html; charset=UTF-8");
    Writer lWriter = pResponse.getWriter();
    lWriter.write(lBlnResult.toString());

    mLog.debug("End isTipEnabled(HttpServletRequest, HttpServletResponse)");
}

From source file:com.abiquo.abiserver.commands.stub.AbstractAPIStub.java

protected String createVirtualDatacenterDisksLink(final Integer vdcId, final Boolean forceSoftLimits) {
    Map<String, String> params = new HashMap<String, String>();
    params.put("vdcid", vdcId.toString());

    String uri = resolveURI(apiUri, "cloud/virtualdatacenters/{vdcid}/disks", params);
    Map<String, String[]> queryParams = new HashMap<String, String[]>();

    if (forceSoftLimits != null) {

        queryParams.put("force", new String[] { forceSoftLimits.toString() });
    }//from   w w w .  ja v a 2s .  co  m

    return UriHelper.appendQueryParamsToPath(uri, queryParams, false);
}

From source file:de.innovationgate.wgpublisher.webtml.Input.java

public void tmlEndTag() throws WGException {
    // Retrieve basic parameters
    String type = this.getType();
    String name = this.getName();
    String format = getStatus().format;
    if (format != null && WGUtils.isEmpty(format)) {
        format = null;//from ww  w  .j ava  2s  . com
    }

    Object defaultvalue = this.getDefault();
    if (defaultvalue == null) {
        String expression = getDefaultexpression();
        if (expression != null) {
            ExpressionEngine engine = ExpressionEngineFactory.getEngine(getDefaultExpressionLanguage());
            if (engine == null) {
                this.addWarning("Unknown expression language: " + getDefaultExpressionLanguage(), true);
            }

            Map<String, Object> objects = new HashMap<String, Object>();
            objects.put(RhinoExpressionEngine.PARAM_SCRIPTNAME, "DefaultExpression on " + getTagDescription());
            ExpressionResult result = engine.evaluateExpression(expression, this.getTMLContext(),
                    ExpressionEngine.TYPE_EXPRESSION, objects);
            if (result.isError()) {
                addExpressionWarning(expression, result);
            } else {
                defaultvalue = result.getResult();
            }
        }

        // If no default value determined we must see if we have an input type with "implicit" default value (#00000263)
        else {
            /* Deactivated as of #00000366 because it broke more than it saved
            if (type.equals("select")) {
                List<InputOption> options = retrieveInputOptions();
                if (options.size() > 0) {
             defaultvalue = options.get(0).getValue();
                }
            }
            else */
            if (type.equals("boolean")) {
                defaultvalue = Boolean.FALSE;
            }
        }
    }

    boolean readonlyMode = false;
    String computedMode = getMode();

    String cssClass = this.getCssclass();
    if (cssClass != null) {
        cssClass = "class=\"" + cssClass + "\" ";
    }

    String cssStyle = this.getCssstyle();
    if (cssStyle != null) {
        cssStyle = "style=\"" + cssStyle + "\" ";
    }

    // Register with form (or item for BI-CustomEditor) parent (if present) and retrieve item values from it;
    FormInputRegistrator formBase = (FormInputRegistrator) getStatus().getAncestorTag(FormBase.class);

    if (formBase == null && isAjaxRequest()) {
        // try to retrieve form from ajax call
        final TMLForm form = getTMLContext().gettmlform();
        if (form != null) {
            formBase = new AjaxFormInputRegistrator(form);
        }
    }

    List<Object> values;
    if (formBase != null) {
        // retrieve values from inputRegistrator
        boolean useRelation = false;
        if (getRelationtype() != null) {
            useRelation = true;
        }

        values = formBase.getFieldValue(name, stringToBoolean(getMeta()), defaultvalue, useRelation);

        // compute mode
        if (formBase.getFormMode().equals(TMLFormInfo.VIEW_MODE)) {
            if (this.getMode().equals(FieldReg.EDIT_MODE)) {
                computedMode = FieldReg.VIEW_MODE;
            } else {
                computedMode = getMode();
            }
        } else if (formBase.getFormMode().equals(TMLFormInfo.READONLY_MODE)) {
            if (this.getMode().equals(FieldReg.EDIT_MODE)) {
                computedMode = FieldReg.READONLY_MODE;
            } else {
                computedMode = getMode();
            }
        } else {
            computedMode = getMode();
        }

        //build clear if errorlist
        List<String> cleariferrorList = new ArrayList<String>();
        String cleariferror = getCleariferror();
        if (cleariferror != null) {
            cleariferrorList = WGUtils.deserializeCollection(cleariferror, ",");
        }

        formBase.addField(new FieldReg(name, type, format, stringToBoolean(getMeta()), isMultipleInput(),
                getValidation(), getMessage(), getValidationdivider(), stringToBoolean(getTrim()), computedMode,
                cleariferrorList, stringToBoolean(getStore()), getRelationtype()), values);

        if (computedMode.equals(TMLFormInfo.EDIT_MODE)) {
            // nothing to do
        } else if (computedMode.equals(TMLFormInfo.VIEW_MODE)) {
            // clear results
            this.clearResult();
            // display optionText not optionValues

            if (type.equals("boolean")) {
                String ret = "";
                List<InputOption> opts = this.retrieveInputOptions();

                Boolean boolValue = Boolean.FALSE;
                if (values.size() >= 1) {
                    Object theValue = values.get(0);
                    if (theValue instanceof String) {
                        boolValue = Boolean.valueOf((String) theValue);
                    } else if (theValue instanceof Boolean) {
                        boolValue = (Boolean) theValue;
                    }
                }

                if (opts.size() == 0) {
                    getStatus().encode = "none";
                    ret = "<img align=\"bottom\" src=\"" + getWGPPath() + "/static/images/"
                            + boolValue.toString() + ".png\"> ";
                } else if (opts.size() == 1) {
                    getStatus().encode = "none";
                    ret = "<span";
                    if (!boolValue)
                        ret += " style=\"text-decoration:line-through\"";
                    ret += ">";
                    InputOption opt = opts.get(0);
                    ret += opt.getText();
                    ret += "</span>";
                } else {
                    Iterator<InputOption> options = opts.iterator();
                    while (options.hasNext()) {
                        InputOption option = (InputOption) options.next();
                        List<String> stringValues = WGUtils.toString(values);
                        if (stringValues.contains(option.getValue())) {
                            ret = option.getText();
                            break;
                        }
                    }
                }

                this.setResult(ret);
            }

            else if (type.equals("select") || type.equals("checkbox") || type.equals("radio")) {
                List<String> textValues = new ArrayList<String>();

                List<InputOption> options = this.retrieveInputOptions();
                if (options.size() > 0) {
                    // prepare regular list so we can use WGA.alias()
                    ArrayList<String> optionsValues = new ArrayList<String>();
                    String relationNullPlaceholderOptionValue = null;
                    for (InputOption o : options) {
                        optionsValues.add(o.getText() + "|" + o.getValue());
                        if (TMLForm.RELATION_NULLPLACE_HOLDER.equals(o.getValue())) {
                            relationNullPlaceholderOptionValue = o.getText();
                        }
                    }
                    if (values.size() == 0 && relationNullPlaceholderOptionValue != null) {
                        textValues.add(relationNullPlaceholderOptionValue);
                    } else {
                        WGA wga = WGA.get();
                        List<String> stringValues = WGUtils.toString(values);
                        textValues.addAll(wga.aliases(stringValues, optionsValues));
                    }
                    this.setResult(textValues);
                    getStatus().divider = getMultiValueDivider();
                } else {
                    this.setResult(values);
                }

            } else {
                // do not render original value if type is password
                if (this.getType().equals("password")) {
                    values = Collections.<Object>singletonList("********");
                }
                // if type is hashedpassword show "*" instead of hashed
                // value in viewmode
                if (this.getType().equals("hashedpassword")) {
                    values = Collections.<Object>singletonList("********");
                }

                // Set default divider for multivalue textarea fields
                if (type.equals("textarea") && isMultipleInput()) {
                    getStatus().divider = getMultiValueDivider();
                }
                // do not display hidden values in VIEW_MODE
                if (!this.getType().equals("hidden")) {
                    this.setResult(values);
                }
            }
            return;
        } else if (computedMode.equals(TMLFormInfo.READONLY_MODE)) {
            readonlyMode = true;
        } else {
            this.addWarning("Unsupported mode: " + this.getMode(), true);
        }
    } else {
        values = new ArrayList<Object>();
        String[] params = this.getTMLContext().getrequest().getParameterValues(name);
        if (params != null) {
            for (String param : params)
                values.add(param);
        } else
            values.add(defaultvalue);
    }

    // Disable encoding, since this tag is in edit or readonly mode
    getStatus().encode = "none";

    String disabledString = "";
    if (!computedMode.equals(FieldReg.EDIT_MODE)) {
        disabledString = "disabled ";
    }

    //this.setBlockDivider(true);

    if (values == null) {
        values = new ArrayList<Object>();
    }

    Object singleValue = (values.size() == 0 ? "" : values.get(0));

    String tagContent = this.getResultString(false);
    this.clearResult();

    // Render
    try {
        if (type.equals("text") || type.equals("password")) {
            renderSimpleInput(type, name, format, cssClass, cssStyle, singleValue, tagContent, disabledString);
        } else if (type.equals("hidden")) {
            if (isMultipleInput()) {
                String renderedValue = WGUtils.serializeCollection(values, "~~~");
                renderSimpleInput(type, name, format, cssClass, cssStyle, renderedValue, tagContent,
                        disabledString);
            } else
                renderSimpleInput(type, name, format, cssClass, cssStyle, singleValue, tagContent,
                        disabledString);
        } else if (type.equals("boolean")) {
            renderBoolean(name, cssClass, cssStyle, formBase, singleValue, tagContent, disabledString);
        } else if (type.equals("date")) {
            if (!hasInputOptions()) {
                renderDateInput(name, format, cssClass, cssStyle, singleValue, tagContent, disabledString);
            } else {
                renderSelectInput(name, cssClass, cssStyle, formBase, values, tagContent, disabledString,
                        readonlyMode, format);
            }
        } else if (type.equals("number")) {
            if (!hasInputOptions()) {
                renderSimpleInput("text", name, format, cssClass, cssStyle, singleValue, tagContent,
                        disabledString);
            } else {
                renderSelectInput(name, cssClass, cssStyle, formBase, values, tagContent, disabledString,
                        readonlyMode, format);
            }
        } else if (type.equals("textarea")) {
            boolean multipleInput = isMultipleInput();
            Object renderValue = (multipleInput ? values : singleValue);
            renderTextArea(name, format, cssClass, cssStyle, renderValue, tagContent, isMultipleInput(),
                    disabledString);

        } else if (type.equals("checkbox") || type.equals("radio")) {
            renderOptionInput(type, name, cssClass, cssStyle, formBase, values, tagContent, disabledString);
        } else if (type.equals("select")) {
            renderSelectInput(name, cssClass, cssStyle, formBase, values, tagContent, disabledString,
                    readonlyMode, null);
        } else if (type.equals("file")) {
            renderFileInput(type, name, cssClass, cssStyle, values, tagContent, disabledString);
        } else if (type.equals("hashedpassword")) {
            renderHashedPassword(name, cssClass, cssStyle, singleValue, tagContent, disabledString);
        } else {
            this.addWarning("Unknown input type:" + type, true);
            return;
        }
    } catch (FormattingException e) {
        throw new TMLException("Exception formatting input field", e, true);
    }

    if (formBase != null && this.getFocus().equals("true")) {
        this.appendResult("<script>try{document.forms['" + formBase.getId() + "'].elements['" + this.getName()
                + "'].focus()}catch(e){}</script>");
    }

    getStatus().divider = "";

}

From source file:edu.ku.brc.specify.extras.ViewToSchemaReview.java

/**
 * //w  ww . jav a2s . c o m
 */
protected void updateSchema() {
    Connection conn = DBConnection.getInstance().getConnection();
    Statement stmt = null;

    try {
        stmt = conn.createStatement();

        for (Object[] row : modelList) {
            Boolean isChanged = !row[4].equals(row[5]);
            if (isChanged) {
                String fieldName = row[1].toString();
                Boolean isHidden = (Boolean) row[4];

                String title = row[0].toString();
                DBTableInfo ti = DBTableIdMgr.getInstance().getInfoByTableName(tblTitle2Name.get(title));
                DBFieldInfo fi = ti.getFieldByName(fieldName);
                if (fi != null) {
                    fi.setHidden(isHidden);
                } else {
                    DBRelationshipInfo ri = ti.getRelationshipByName(fieldName);
                    if (ri != null) {
                        ri.setHidden(isHidden);
                    } else {
                        continue;
                    }
                }

                //System.out.println(row[0]+"  "+fieldName);

                Discipline discipline = AppContextMgr.getInstance().getClassObject(Discipline.class);
                String srchSQL = String.format(
                        "SELECT SpLocaleContainerID FROM splocalecontainer WHERE Name = '%s' AND DisciplineID = %d AND SchemaType = %d",
                        ti.getName(), discipline.getId(), SpLocaleContainer.CORE_SCHEMA);
                Integer id = BasicSQLUtils.getCount(conn, srchSQL);
                if (id != null) {
                    String sql = "UPDATE splocalecontaineritem SET IsHidden="
                            + isHidden.toString().toUpperCase() + " WHERE Name = '" + fieldName
                            + "' AND SpLocaleContainerID = " + id;
                    if (stmt.executeUpdate(sql) == 1) {
                        //System.out.println("Saved.");
                    }
                }
            }
        }

        stmt.close();

    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:com.vmware.photon.controller.deployer.xenon.task.ProvisionHostTaskService.java

private void processInstallVibsSubStage(VibService.State vibState, DeploymentService.State deploymentState,
        HostService.State hostState, Boolean createCert) {

    String oAuthDomain = "";
    String oAuthAddress = "";
    String oAuthPassword = "";
    if (deploymentState.oAuthTenantName != null) {
        oAuthDomain = deploymentState.oAuthTenantName;
    }//from  w w  w .  j  a v a  2s.c  o  m
    if (deploymentState.oAuthServerAddress != null) {
        oAuthAddress = deploymentState.oAuthServerAddress;
    }
    if (deploymentState.oAuthPassword != null) {
        oAuthPassword = deploymentState.oAuthPassword;
    }
    List<String> command = Arrays.asList("./" + INSTALL_VIB_SCRIPT_NAME, hostState.hostAddress,
            hostState.userName, hostState.password, vibState.uploadPath, createCert.toString(), oAuthDomain,
            oAuthAddress, oAuthPassword);

    DeployerContext deployerContext = HostUtils.getDeployerContext(this);

    File scriptLogFile = new File(deployerContext.getScriptLogDirectory(),
            INSTALL_VIB_SCRIPT_NAME + "-" + hostState.hostAddress + "-"
                    + ServiceUtils.getIDFromDocumentSelfLink(vibState.documentSelfLink) + ".log");

    ScriptRunner scriptRunner = new ScriptRunner.Builder(command, deployerContext.getScriptTimeoutSec())
            .directory(deployerContext.getScriptDirectory())
            .redirectOutput(ProcessBuilder.Redirect.to(scriptLogFile)).redirectErrorStream(true).build();

    ListenableFutureTask<Integer> futureTask = ListenableFutureTask.create(scriptRunner);
    HostUtils.getListeningExecutorService(this).submit(futureTask);

    Futures.addCallback(futureTask, new FutureCallback<Integer>() {
        @Override
        public void onSuccess(@javax.validation.constraints.NotNull Integer result) {
            try {
                if (result != 0) {
                    logVibInstallationFailureAndFail(vibState, hostState, result, scriptLogFile);
                } else {
                    deleteVibService(vibState);
                }
            } catch (Throwable t) {
                failTask(t);
            }
        }

        @Override
        public void onFailure(Throwable throwable) {
            failTask(throwable);
        }
    });
}

From source file:com.abiquo.abiserver.commands.stub.AbstractAPIStub.java

protected String createVirtualMachineDisksLink(final Integer vdcId, final Integer vappId, final Integer vmId,
        final Boolean forceSoftLimits) {
    Map<String, String> params = new HashMap<String, String>();
    params.put("vdcid", vdcId.toString());
    params.put("vappid", vappId.toString());
    params.put("vmid", vmId.toString());

    String uri = resolveURI(apiUri,
            "cloud/virtualdatacenters/{vdcid}/virtualappliances/{vappid}/virtualmachines/{vmid}/storage/disks/",
            params);/*from   w w w  .  ja va  2  s .c  om*/
    Map<String, String[]> queryParams = new HashMap<String, String[]>();

    if (forceSoftLimits != null) {

        queryParams.put("force", new String[] { forceSoftLimits.toString() });
    }

    return UriHelper.appendQueryParamsToPath(uri, queryParams, false);
}

From source file:edu.harvard.hms.dbmi.scidb.SciDB.java

/**
 * Creates a list operation on an element with a version
 * //from   w  ww. jav a2  s .c  om
 * @param element
 *            Element
 * @param version
 *            Version
 * @return SciDB Operation
 */
public SciDBOperation list(SciDBListElement element, Boolean version) {

    SciDBOperation listOperation = new SciDBOperation("list");
    listOperation.setCommandString("'" + element.name().toLowerCase() + "'");
    if (version != null) {
        listOperation.setPostFix(version.toString());
    }

    return listOperation;
}

From source file:com.cloud.hypervisor.xenserver.resource.XenServerStorageProcessor.java

protected String backupSnapshotToS3(final Connection connection, final S3TO s3, final String srUuid,
        final String folder, final String snapshotUuid, final Boolean iSCSIFlag, final int wait) {

    final String filename = iSCSIFlag ? "VHD-" + snapshotUuid : snapshotUuid + ".vhd";
    final String dir = (iSCSIFlag ? "/dev/VG_XenStorage-" : "/var/run/sr-mount/") + srUuid;
    final String key = folder + "/" + filename; // String.format("/snapshots/%1$s", snapshotUuid);

    try {/*  w  w w .  j  a va  2 s .co m*/

        final List<String> parameters = newArrayList(flattenProperties(s3, ClientOptions.class));
        // https workaround for Introspector bug that does not
        // recognize Boolean accessor methods ...

        parameters.addAll(Arrays.asList("operation", "put", "filename", dir + "/" + filename, "iSCSIFlag",
                iSCSIFlag.toString(), "bucket", s3.getBucketName(), "key", key, "https",
                s3.isHttps() != null ? s3.isHttps().toString() : "null", "maxSingleUploadSizeInBytes",
                String.valueOf(s3.getMaxSingleUploadSizeInBytes())));
        final String result = hypervisorResource.callHostPluginAsync(connection, "s3xenserver", "s3", wait,
                parameters.toArray(new String[parameters.size()]));

        if (result != null && result.equals("true")) {
            return key;
        }
        return null;

    } catch (final Exception e) {
        s_logger.error(
                String.format("S3 upload failed of snapshot %1$s due to %2$s.", snapshotUuid, e.toString()), e);
    }

    return null;

}

From source file:com.cloud.hypervisor.xenserver.resource.XenServerStorageProcessor.java

@VisibleForTesting
List<String> getSwiftParams(SwiftTO swift, String container, String ldir, String lfilename, Boolean isISCSI) {
    // ORDER IS IMPORTANT
    List<String> params = new ArrayList<>();

    //operation/* w  ww.  j av  a  2 s . c om*/
    params.add("op");
    params.add("upload");

    //auth
    params.add("url");
    params.add(swift.getUrl());
    params.add("account");
    params.add(swift.getAccount());
    params.add("username");
    params.add(swift.getUserName());
    params.add("key");
    params.add(swift.getKey());

    // object info
    params.add("container");
    params.add(container);
    params.add("ldir");
    params.add(ldir);
    params.add("lfilename");
    params.add(lfilename);
    params.add("isISCSI");
    params.add(isISCSI.toString());

    if (swift.getStoragePolicy() != null) {
        params.add("storagepolicy");
        params.add(swift.getStoragePolicy());
    }

    return params;
}