Example usage for org.apache.commons.lang BooleanUtils toStringTrueFalse

List of usage examples for org.apache.commons.lang BooleanUtils toStringTrueFalse

Introduction

In this page you can find the example usage for org.apache.commons.lang BooleanUtils toStringTrueFalse.

Prototype

public static String toStringTrueFalse(boolean bool) 

Source Link

Document

Converts a boolean to a String returning 'true' or 'false'.

 BooleanUtils.toStringTrueFalse(true)   = "true" BooleanUtils.toStringTrueFalse(false)  = "false" 

Usage

From source file:info.magnolia.cms.gui.dialog.DialogControlImpl.java

public void setRequired(boolean required) {
    this.setConfig("required", BooleanUtils.toStringTrueFalse(required));
}

From source file:gr.abiss.calipso.domain.Metadata.java

public String getXmlString() {
    Document d = XmlUtils.getNewDocument(METADATA);
    Element root = d.getRootElement();
    Element dateFormats = root.addElement(DATEFORMATS);
    for (String dfKey : this.dateFormats.keySet()) {
        Element df = dateFormats.addElement(DATEFORMAT);
        df.addAttribute(NAME, dfKey);/*from ww  w .j a v a  2  s .  c om*/
        df.addAttribute(EXPRESSION, this.dateFormats.get(dfKey));
    }

    Element fs = root.addElement(FIELDS);
    for (FieldGroup fieldGroup : this.fieldGroups) {
        fieldGroup.addAsChildOf(fs);
    }
    for (Field field : fields.values()) {
        field.addAsChildOf(fs);
    }
    Element rs = root.addElement(ROLES);
    for (Role role : roles.values()) {
        role.addAsChildOf(rs);
    }
    Element ss = root.addElement(STATES);
    for (Map.Entry<Integer, String> entry : states.entrySet()) {
        Element e = ss.addElement(STATE);
        e.addAttribute(STATUS, entry.getKey() + "");
        e.addAttribute(LABEL, entry.getValue());
        e.addAttribute(PLUGIN, statesPlugins.get(entry.getKey()));
        Long lMaxDuration = maxDurations.get(entry.getKey());
        Long assetTypeId = assetTypeIdMap.get(entry.getKey());
        Long existingAssetTypeId = existingAssetTypeIdsMap.get(entry.getKey());
        Boolean existingAssetTypeMuliple = existingAssetTypeMultipleMap.get(entry.getKey());

        if (lMaxDuration != null) {
            e.addAttribute(MAX_DURATION, lMaxDuration.toString());
        }
        if (assetTypeId != null) {
            e.addAttribute(ASSET_TYPE_ID, assetTypeId.toString());
        }
        if (existingAssetTypeId != null) {
            e.addAttribute(EXISTING_ASSET_TYPE_ID, existingAssetTypeId.toString());
        }
        if (existingAssetTypeMuliple != null) {
            e.addAttribute(EXISTING_ASSET_TYPE_MULTIPLE,
                    BooleanUtils.toStringTrueFalse(existingAssetTypeMuliple));
        }
    }
    Element fo = fs.addElement(FIELD_ORDER);
    for (Field.Name f : fieldOrder) {
        Element e = fo.addElement(FIELD);
        e.addAttribute(NAME, f.toString());
    }
    String xml = XmlUtils.getAsPrettyXml(d.asXML());
    //logger.info("getXmlString: "+xml);
    return xml;
}

From source file:com.atlassian.jira.lookandfeel.EditLookAndFeel.java

@RequiresXsrfCheck
public String doResetLogo() {
    globalSettings.put(LookAndFeelConstants.USING_CUSTOM_LOGO, BooleanUtils.toStringTrueFalse(false));
    lookAndFeelProperties.resetDefaultLogo();
    autoLookAndFeelManager.backupColorScheme();
    autoLookAndFeelManager.generateFromLogo(getLoggedInUser());
    eventPublisher.publish(new LookAndFeelUpdatedEvent(getLoggedInUser(), Type.RESET_LOGO));
    return getRedirect("LookAndFeel!default.jspa");
}

From source file:com.atlassian.jira.lookandfeel.EditLookAndFeel.java

@RequiresXsrfCheck
public String doResetFavicon() {

    globalSettings.put(LookAndFeelConstants.USING_CUSTOM_FAVICON, BooleanUtils.toStringTrueFalse(false));
    lookAndFeelProperties.resetDefaultFavicon();
    lookAndFeelProperties.setFaviconChoice(LogoChoice.JIRA);
    eventPublisher.publish(new LookAndFeelUpdatedEvent(getLoggedInUser(), Type.RESET_FAVICON));
    return getRedirect("LookAndFeel!default.jspa");
}

From source file:org.apache.cocoon.generation.HSSFGenerator.java

/**
 * Returns the cell value.//from w  w w  .j  av a 2s  . co  m
 * @param cell   POI cell
 * @return the cell value
 */
private String getValue(HSSFCell cell) {
    switch (cell.getCellType()) {
    case HSSFCell.CELL_TYPE_BLANK:
        return "";
    case HSSFCell.CELL_TYPE_BOOLEAN:
        return BooleanUtils.toStringTrueFalse(cell.getBooleanCellValue());
    case HSSFCell.CELL_TYPE_NUMERIC:
        return Double.toString(cell.getNumericCellValue());
    case HSSFCell.CELL_TYPE_ERROR:
        return "#ERR" + cell.getErrorCellValue();
    case HSSFCell.CELL_TYPE_FORMULA:
    case HSSFCell.CELL_TYPE_STRING:
    default:
        return cell.getStringCellValue();
    }
}

From source file:org.apache.cocoon.portal.pluto.om.common.PreferenceImpl.java

public String getReadOnly() {
    return BooleanUtils.toStringTrueFalse(BooleanUtils.toBoolean(readOnly));
}

From source file:org.apache.cocoon.transformation.TraxTransformer.java

/**
 * Get the parameters for the logicsheet
 *///from w  w  w  . ja  va 2 s.co  m
protected Map getLogicSheetParameters() {
    if (this.logicSheetParameters != null) {
        return this.logicSheetParameters;
    }
    HashMap map = null;
    if (par != null) {
        String[] params = par.getNames();
        if (params != null) {
            for (int i = 0; i < params.length; i++) {
                String name = params[i];
                if (isValidXSLTParameterName(name)) {
                    String value = par.getParameter(name, null);
                    if (value != null) {
                        if (map == null) {
                            map = new HashMap(params.length);
                        }
                        map.put(name, value);
                    }
                }
            }
        }
    }

    if (this._useParameters) {
        Request request = ObjectModelHelper.getRequest(objectModel);

        Enumeration parameters = request.getParameterNames();
        if (parameters != null) {
            while (parameters.hasMoreElements()) {
                String name = (String) parameters.nextElement();
                if (isValidXSLTParameterName(name)) {
                    String value = request.getParameter(name);
                    if (map == null) {
                        map = new HashMap();
                    }
                    map.put(name, value);
                }
            }
        }
    }

    if (this._useSessionInfo) {
        final Request request = ObjectModelHelper.getRequest(objectModel);
        if (map == null) {
            map = new HashMap(6);
        }

        final Session session = request.getSession(false);
        if (session != null) {
            map.put("session-available", "true");
            map.put("session-is-new", BooleanUtils.toStringTrueFalse(session.isNew()));
            map.put("session-id-from-cookie",
                    BooleanUtils.toStringTrueFalse(request.isRequestedSessionIdFromCookie()));
            map.put("session-id-from-url",
                    BooleanUtils.toStringTrueFalse(request.isRequestedSessionIdFromURL()));
            map.put("session-valid", BooleanUtils.toStringTrueFalse(request.isRequestedSessionIdValid()));
            map.put("session-id", session.getId());
        } else {
            map.put("session-available", "false");
        }
    }

    if (this._useCookies) {
        Request request = ObjectModelHelper.getRequest(objectModel);
        Cookie cookies[] = request.getCookies();
        if (cookies != null) {
            for (int i = 0; i < cookies.length; i++) {
                String name = cookies[i].getName();
                if (isValidXSLTParameterName(name)) {
                    String value = cookies[i].getValue();
                    if (map == null) {
                        map = new HashMap(cookies.length);
                    }
                    map.put(name, value);
                }
            }
        }
    }
    this.logicSheetParameters = map;
    return this.logicSheetParameters;
}

From source file:org.apache.cocoon.transformation.XSLTTransformer.java

/**
 * Get the parameters for the logicsheet
 *//*ww  w .j  a v a 2 s.  co  m*/
protected Map getLogicSheetParameters() {
    if (this.logicSheetParameters != null) {
        return this.logicSheetParameters;
    }
    HashMap map = null;
    if (par != null) {
        String[] params = par.getNames();
        if (params != null) {
            for (int i = 0; i < params.length; i++) {
                String name = params[i];
                if (isValidXSLTParameterName(name)) {
                    String value = par.getParameter(name, null);
                    if (value != null) {
                        if (map == null) {
                            map = new HashMap(params.length);
                        }
                        map.put(name, value);
                    }
                }
            }
        }
    }

    if (this._useParameters) {
        Request request = ObjectModelHelper.getRequest(objectModel);

        Enumeration parameters = request.getParameterNames();
        if (parameters != null) {
            while (parameters.hasMoreElements()) {
                String name = (String) parameters.nextElement();
                if (isValidXSLTParameterName(name)) {
                    String value = request.getParameter(name);
                    if (map == null) {
                        map = new HashMap();
                    }
                    map.put(name, value);
                }
            }
        }
    }

    if (this._useSessionInfo) {
        final Request request = ObjectModelHelper.getRequest(objectModel);
        if (map == null) {
            map = new HashMap(6);
        }

        final HttpSession session = request.getSession(false);
        if (session != null) {
            map.put("session-available", "true");
            map.put("session-is-new", BooleanUtils.toStringTrueFalse(session.isNew()));
            map.put("session-id-from-cookie",
                    BooleanUtils.toStringTrueFalse(request.isRequestedSessionIdFromCookie()));
            map.put("session-id-from-url",
                    BooleanUtils.toStringTrueFalse(request.isRequestedSessionIdFromURL()));
            map.put("session-valid", BooleanUtils.toStringTrueFalse(request.isRequestedSessionIdValid()));
            map.put("session-id", session.getId());
        } else {
            map.put("session-available", "false");
        }
    }

    if (this._useCookies) {
        Request request = ObjectModelHelper.getRequest(objectModel);
        Cookie cookies[] = request.getCookies();
        if (cookies != null) {
            for (int i = 0; i < cookies.length; i++) {
                String name = cookies[i].getName();
                if (isValidXSLTParameterName(name)) {
                    String value = cookies[i].getValue();
                    if (map == null) {
                        map = new HashMap(cookies.length);
                    }
                    map.put(name, value);
                }
            }
        }
    }
    this.logicSheetParameters = map;
    return this.logicSheetParameters;
}

From source file:org.apache.cocoon.webapps.session.context.RequestSessionContext.java

/**
 * Build attributes XML//from  w w w.  j  a va  2s  . co  m
 */
private void buildMiscXML(Element root) {
    Document doc = root.getOwnerDocument();

    Element node;

    node = doc.createElementNS(null, "characterEncoding");
    node.appendChild(this.createTextNode(doc, this.request.getCharacterEncoding()));
    root.appendChild(node);
    node = doc.createElementNS(null, "contentLength");
    node.appendChild(this.createTextNode(doc, "" + this.request.getContentLength()));
    root.appendChild(node);
    node = doc.createElementNS(null, "contentType");
    node.appendChild(this.createTextNode(doc, this.request.getContentType()));
    root.appendChild(node);
    node = doc.createElementNS(null, "protocol");
    node.appendChild(this.createTextNode(doc, this.request.getProtocol()));
    root.appendChild(node);
    node = doc.createElementNS(null, "remoteAddress");
    node.appendChild(this.createTextNode(doc, this.request.getRemoteAddr()));
    root.appendChild(node);
    node = doc.createElementNS(null, "remoteHost");
    node.appendChild(this.createTextNode(doc, this.request.getRemoteHost()));
    root.appendChild(node);
    node = doc.createElementNS(null, "scheme");
    node.appendChild(this.createTextNode(doc, this.request.getScheme()));
    root.appendChild(node);
    node = doc.createElementNS(null, "serverName");
    node.appendChild(this.createTextNode(doc, this.request.getServerName()));
    root.appendChild(node);
    node = doc.createElementNS(null, "serverPort");
    node.appendChild(this.createTextNode(doc, "" + this.request.getServerPort()));
    root.appendChild(node);
    node = doc.createElementNS(null, "method");
    node.appendChild(this.createTextNode(doc, this.request.getMethod()));
    root.appendChild(node);
    node = doc.createElementNS(null, "contextPath");
    node.appendChild(this.createTextNode(doc, this.request.getContextPath()));
    root.appendChild(node);
    node = doc.createElementNS(null, "pathInfo");
    node.appendChild(this.createTextNode(doc, this.request.getPathInfo()));
    root.appendChild(node);
    node = doc.createElementNS(null, "pathTranslated");
    node.appendChild(this.createTextNode(doc, this.request.getPathTranslated()));
    root.appendChild(node);
    node = doc.createElementNS(null, "remoteUser");
    node.appendChild(this.createTextNode(doc, this.request.getRemoteUser()));
    root.appendChild(node);
    node = doc.createElementNS(null, "requestedSessionId");
    node.appendChild(this.createTextNode(doc, this.request.getRequestedSessionId()));
    root.appendChild(node);
    node = doc.createElementNS(null, "requestURI");
    node.appendChild(this.createTextNode(doc, this.request.getRequestURI()));
    root.appendChild(node);
    node = doc.createElementNS(null, "servletPath");
    node.appendChild(this.createTextNode(doc, this.request.getServletPath()));
    root.appendChild(node);
    node = doc.createElementNS(null, "isRequestedSessionIdFromCookie");
    node.appendChild(
            doc.createTextNode(BooleanUtils.toStringTrueFalse(this.request.isRequestedSessionIdFromCookie())));
    root.appendChild(node);
    node = doc.createElementNS(null, "isRequestedSessionIdFromURL");
    node.appendChild(
            doc.createTextNode(BooleanUtils.toStringTrueFalse(this.request.isRequestedSessionIdFromURL())));
    root.appendChild(node);
    node = doc.createElementNS(null, "isRequestedSessionIdValid");
    node.appendChild(
            doc.createTextNode(BooleanUtils.toStringTrueFalse(this.request.isRequestedSessionIdValid())));
    root.appendChild(node);
}

From source file:org.apache.cocoon.webapps.session.context.RequestSessionContext.java

/**
 * Build cookies XML/*from w ww .  j  ava 2s  .  co m*/
 */
private void buildCookiesXML(Element root) {
    Document doc = root.getOwnerDocument();

    Element cookiesElement = doc.createElementNS(null, "cookies");
    root.appendChild(cookiesElement);

    Cookie[] cookies = this.request.getCookies();
    if (cookies != null) {
        Cookie current;
        Element node;
        Element parent;
        for (int i = 0; i < cookies.length; i++) {
            current = cookies[i];
            parent = doc.createElementNS(null, "cookie");
            parent.setAttributeNS(null, "name", current.getName());
            cookiesElement.appendChild(parent);
            node = doc.createElementNS(null, "comment");
            node.appendChild(this.createTextNode(doc, current.getComment()));
            parent.appendChild(node);
            node = doc.createElementNS(null, "domain");
            node.appendChild(this.createTextNode(doc, current.getDomain()));
            parent.appendChild(node);
            node = doc.createElementNS(null, "maxAge");
            node.appendChild(this.createTextNode(doc, "" + current.getMaxAge()));
            parent.appendChild(node);
            node = doc.createElementNS(null, "name");
            node.appendChild(this.createTextNode(doc, current.getName()));
            parent.appendChild(node);
            node = doc.createElementNS(null, "path");
            node.appendChild(this.createTextNode(doc, current.getPath()));
            parent.appendChild(node);
            node = doc.createElementNS(null, "secure");
            node.appendChild(doc.createTextNode(BooleanUtils.toStringTrueFalse(current.getSecure())));
            parent.appendChild(node);
            node = doc.createElementNS(null, "value");
            node.appendChild(this.createTextNode(doc, current.getValue()));
            parent.appendChild(node);
            node = doc.createElementNS(null, "version");
            node.appendChild(this.createTextNode(doc, "" + current.getVersion()));
            parent.appendChild(node);
        }
    }
}