Example usage for java.lang Boolean Boolean

List of usage examples for java.lang Boolean Boolean

Introduction

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

Prototype

@Deprecated(since = "9")
public Boolean(String s) 

Source Link

Document

Allocates a Boolean object representing the value true if the string argument is not null and is equal, ignoring case, to the string "true" .

Usage

From source file:com.icesoft.faces.component.datapaginator.DataPaginator.java

/**
 * <p>Set the value of the <code>disabled</code> property.</p>
 *///from   w w  w.  jav a2 s  . c om
public void setDisabled(boolean disabled) {
    this.disabled = new Boolean(disabled);
    ValueBinding vb = getValueBinding("disabled");
    if (vb != null) {
        vb.setValue(getFacesContext(), this.disabled);
        this.disabled = null;
    }
}

From source file:com.ibm.dbwkl.request.internal.LoggingHandler.java

@Override
public STAFResult execute() {
    StringBuilder resultString = new StringBuilder();

    // user for db logger
    String logdbuser = getRequestOption(Options.DB_USER);

    // password for db logger
    String logdbpassword = getRequestOption(Options.DB_PASSWORD);

    // URL for db logger
    String logdburl = getRequestOption(Options.DB_URL);

    if (hasRequestOption(Options.LOG_LOGTEST)) {
        for (int i = 0; i <= 25; i++) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                //ignore
            }/*  www .j  a  v  a2 s  .com*/
            Logger.log("LOGTEST:" + i, LogLevel.Debug);
        }
        return new STAFResult(STAFResult.Ok, "Logtest at Loglevel Debug executed!");
    }

    /*
     * everything went fine, thus do the changes and hope that all values are allowed
     */

    // level
    if (hasRequestOption(Options.LOG_LEVEL)) {
        String level = getRequestOption(Options.LOG_LEVEL);
        try {
            Logger.logLevel = LogLevel.getLevel(level);
            resultString.append("Log Level set to " + level + "\n");
        } catch (Exception e) {
            return new STAFResult(STAFResult.InvalidValue, "The value '" + level
                    + "' is not allowed as log level. Use one of the following instead: Debug Info Warning Error");
        }
    }

    // details
    if (hasRequestOption(Options.LOG_DETAILS)) {
        String details = getRequestOption(Options.LOG_DETAILS);
        try {
            Logger.details = new Boolean(details).booleanValue();
            resultString.append("Log Details now " + (Logger.details == true ? "ON" : "OFF") + "\n");
        } catch (Exception e) {
            return new STAFResult(STAFResult.InvalidValue, "The value '" + details
                    + "' is not allowed as detailed logging settings. Use either true or false as value.");
        }
    }

    // Cleaning the logger
    if (hasRequestOption(Options.LOG_CLEAN)) {
        String clean = getRequestOption(Options.LOG_CLEAN).trim();

        try {
            ILoggerService logger = getLoggerByName(clean);
            if (logger == null)
                return new STAFResult(STAFResult.DoesNotExist, "Logger could not be found!");

            logger.term();
            logger.clean();
            Logger.registeredLoggers.remove(logger);

            logger = logger.getClass().newInstance();
            Logger.addLogger(logger);

            resultString.append("Logger " + clean + " has been cleaned!");

        } catch (Exception e) {
            return new STAFResult(STAFResult.InvalidValue, "The logger '" + clean
                    + "' is unknown. Use one of the following: htmllogger filelogger dblogger sysout livelog livelogreceiver");
        }
    }

    // remove logger
    else if (hasRequestOption(Options.LOG_REMOVE)) {
        String remove = getRequestOption(Options.LOG_REMOVE).trim();

        try {
            if (remove.equalsIgnoreCase("LIVELOG")) {
                LiveLogger.getInstance().term();
                Logger.registeredLoggers.remove(LiveLogger.getInstance());
                resultString.append("Logger " + remove + " has been removed \n");
            } else {
                ILoggerService logger = getLoggerByName(remove);

                if (logger == null)
                    return new STAFResult(STAFResult.DoesNotExist, "Logger could not be found!");

                logger.term();
                Logger.registeredLoggers.remove(logger);

                resultString.append("Logger has been removed!");
            }

        } catch (Exception e) {
            return new STAFResult(STAFResult.InvalidValue,
                    "The logger '" + remove + "' to be removed is unknown.");
        }
    }

    // add logger
    else if (hasRequestOption(Options.LOG_ADD)) {
        String add = getRequestOption(Options.LOG_ADD);

        if (add.equalsIgnoreCase("FILELOGGER"))
            try {
                Logger.addLogger(new TextLogger());
            } catch (IOException e1) {
                return new STAFResult(STAFResult.JavaError, "Exception occurs while adding a FileLogger.");
            }
        else if (add.equalsIgnoreCase("DBLOGGER")) {
            try {
                Logger.addLogger(new DatabaseLogger(logdbuser, logdbpassword, logdburl));
            } catch (IOException e) {
                return new STAFResult(STAFResult.JavaError,
                        "Exception occurs while adding a DBLogger: " + e.getMessage());
            } catch (InterruptedException e) {
                //
            }
        }

        else if (add.equalsIgnoreCase("HTMLLOGGER"))
            try {
                Logger.addLogger(new HTMLLogger());
            } catch (IOException e) {
                return new STAFResult(STAFResult.JavaError, "Exception occurs while adding a HTMLLogger.");
            }
        else if (add.equalsIgnoreCase("LIVELOG")) {
            if (hasRequestOption(Options.SOCKET_HOST)) {
                if (getRequestOption(Options.SOCKET_HOST).length() != 0) {
                    LiveLogger liveLogger = LiveLogger.getInstance();
                    if (!Logger.getCopyOfLoggers().contains(liveLogger))
                        Logger.addLogger(liveLogger);
                    liveLogger.openServer(getRequestOption(Options.SOCKET_HOST).trim());
                    return new STAFResult(STAFResult.Ok,
                            "LiveLogger added, it will now accept a live logging connection!");
                }
            }
            Logger.log("Adding LiveLog not possible: Invalid Host", LogLevel.Error);
            return new STAFResult(STAFResult.JavaError, "Adding LiveLog not possible: Invalid Host");
        }

        else {
            Logger.log("Adding Logger failed: no such logger to add found: " + add, LogLevel.Error);
            return new STAFResult(STAFResult.JavaError,
                    "Adding Logger failed: no such logger to add found: " + add);
        }
        resultString.append("Logger " + add + " has been added \n");
    }

    else if (hasRequestOption(Options.LOG_SCHEMA)) {
        String xsd = null;
        try {
            xsd = XMLSerializer.createXMLSchema(LoggerEntry.class);
        } catch (IOException e) {
            Logger.log(e.getMessage(), LogLevel.Error);
            return new STAFResult(STAFResult.JavaError, e.getMessage());
        } catch (JAXBException e) {
            Logger.log(e.getMessage(), LogLevel.Error);
            return new STAFResult(STAFResult.JavaError, e.getMessage());
        }

        if (xsd != null)
            return new STAFResult(STAFResult.Ok, xsd);

        return new STAFResult(STAFResult.JavaError, "Error while creating the Schema");
    }

    // LIST shows logs on the console
    // schema:
    //      LIST <what> [FILTER <filter>] [COLUMNS <columns>]
    //          <what> = { , n} (empty=all, n=last n)
    //          <filter> = {LEVEL={DEBUG, INFO, WARNING, ERROR}*;REQID=<reqid>}
    //          <columns> = {REQUEST, THREAD, LOGLEVEL, MESSAGE}
    else if (hasRequestOption(Options.LOG_LIST)) {
        //read <what>
        String listValue = getRequestOption(Options.LOG_LIST);
        //the number of latest entries to retrieve
        int n = 0;
        if (listValue.equalsIgnoreCase("")) {
            //when n<=0, all entries are retrieved
            n = 0;
        } else {
            try {
                n = Integer.parseInt(listValue);
            } catch (NumberFormatException e) {
                return new STAFResult(STAFResult.InvalidValue,
                        "List option needs to be a positive number or empty");
            }
            if (n <= 0) {
                return new STAFResult(STAFResult.InvalidValue,
                        "List option needs to be a positive number or empty");
            }
        }

        //read <filter>
        String levels[] = null;
        int reqid = 0;
        if (hasRequestOption(Options.LOG_LIST_FILTER)) {
            String filter = getRequestOption(Options.LOG_LIST_FILTER).toLowerCase();
            StringTokenizer tokenizer = new StringTokenizer(filter, ";");
            while (tokenizer.hasMoreElements()) {
                String option = (String) tokenizer.nextElement();
                // an option is of the form key=value
                if (option.contains("=")) {
                    String key = option.substring(0, option.indexOf("="));
                    //read LEVEL={DEBUG,INFO,WARNING,ERROR}*
                    if (key.equalsIgnoreCase("level")) {
                        levels = option.substring(option.indexOf("=") + 1).split(",");
                        //Check if the given levels are supported.
                        if (!StringUtility.arrayContainsOnlyIgnoreCase(levels, LogLevel.Debug.toString().trim(),
                                LogLevel.Warning.toString().trim(), LogLevel.Error.toString().trim(),
                                LogLevel.Info.toString().trim())) {
                            return new STAFResult(STAFResult.InvalidValue,
                                    "Supporting only Log Levels: " + LogLevel.Debug.toString().trim() + ","
                                            + LogLevel.Warning.toString().trim() + ","
                                            + LogLevel.Error.toString().trim() + ","
                                            + LogLevel.Info.toString().trim());
                        }
                        //read REQID=<reqid>      
                    } else if (key.equals("reqid")) {
                        try {
                            reqid = Integer.parseInt(option.substring(option.indexOf("=") + 1));
                        } catch (NumberFormatException e) {
                            return new STAFResult(STAFResult.InvalidValue,
                                    "REQID needs to be a positive number.");
                        }
                        if (reqid <= 0) {
                            return new STAFResult(STAFResult.InvalidValue,
                                    "REQID needs to be a positive number.");
                        }
                    } else {
                        //option is not level= or reqid=
                        return new STAFResult(STAFResult.InvalidValue,
                                "Invalid option in the filter: " + option);
                    }
                } else {
                    //option doesn't have '='
                    return new STAFResult(STAFResult.InvalidValue,
                            "Invalid requestOptions in the filter: " + option);
                }
            }
        }

        //read <columns>
        String[] cols = null;
        if (hasRequestOption(Options.LOG_LIST_COL)) {
            cols = getRequestOption(Options.LOG_LIST_COL).toLowerCase().split(",");
            if (!StringUtility.arrayContainsOnlyIgnoreCase(cols, "request", "thread", "level", "message"))
                return new STAFResult(STAFResult.InvalidValue,
                        "Supporting only Columns: Request, Thread, Level, Message.");
        }

        // filter the entries accordingly
        List<LoggerEntry> logEntries = null;

        if (levels == null || levels.length == 0) {
            if (reqid == 0) {
                logEntries = Logger.getLogEntries(n);
            } else {
                logEntries = Logger.getLogEntries(n, reqid);
            }
        } else {
            if (reqid == 0) {
                logEntries = Logger.getLogEntries(n, levels);
            } else {
                logEntries = Logger.getLogEntries(n, levels, reqid);
            }
        }

        // print the lines, with selected columns.
        String ALLCOLUMNS[] = { "Request", "Thread", "Level", "Message" };
        String formats[] = { "%1$-8s", " %2$-12s", " %3$-7s", " %4$-100s" };

        //if no columns is set, display all columns
        if (cols == null || cols.length == 0) {
            cols = ALLCOLUMNS;
        }

        //check is one of the four columns exists, and construct the format string.
        boolean[] colExists = new boolean[ALLCOLUMNS.length];
        String format = "";

        for (int i = 0; i < ALLCOLUMNS.length; i++) {
            if (StringUtility.arrayContainsIgnoreCase(cols, ALLCOLUMNS[i])) {
                colExists[i] = true;
                format += formats[i];
            }
        }
        format += "\n";

        //print the table head
        resultString.append(String.format(format, colExists[0] ? "Request" : "", colExists[1] ? "Thread" : "",
                colExists[2] ? "Level" : "", colExists[3] ? "Message" : ""));

        resultString.append(String.format(format, colExists[0] ? "-------" : "", colExists[1] ? "------" : "",
                colExists[2] ? "-----" : "", colExists[3] ? "-------" : ""));

        //print the log entries
        for (LoggerEntry logEntry : logEntries) {

            if (colExists[3]) {
                //number of chars per row in the message column
                int charsPerRow = 100;
                //in case the message contains multiple lines.
                String msg = logEntry.getMessage();
                String[] lines = msg.split("\\n");
                for (int i = 0; i < lines.length; i++) {
                    //other columns should only appear once on the first row.
                    String formatedString = String.format(format,
                            (i == 0 && colExists[0]) ? logEntry.getRequestName() : "",
                            (i == 0 && colExists[1]) ? logEntry.getThread() : "",
                            (i == 0 && colExists[2]) ? logEntry.getLevel() : "",
                            StringUtils.left(lines[i], charsPerRow));
                    resultString.append(formatedString);

                    //if the line is longer than 'charsPerRow', split it into multiple rows
                    if (lines[i].length() > charsPerRow) {
                        //cut every 'charsPerRow' chars out, and put it in a new row.
                        String txt = "";
                        int j = 1;
                        while ((txt = StringUtils.mid(lines[i], charsPerRow * j, charsPerRow)).length() != 0) {
                            resultString.append(String.format(format, "", "", "", txt));
                            j++;
                        }
                    }
                }
            } else {
                String formatedString = String.format(format, colExists[0] ? logEntry.getRequestName() : "",
                        colExists[1] ? logEntry.getThread() : "", colExists[2] ? logEntry.getLevel() : "", "");
                resultString.append(formatedString);
            }
        }

    }

    return new STAFResult(STAFResult.Ok, resultString.toString());
}

From source file:org.sakaiproject.metaobj.shared.control.AbstractStructuredArtifactDefinitionController.java

protected Boolean isMaintainer() {
    return new Boolean(getAuthzManager().isAuthorized(WorksiteManager.WORKSITE_MAINTAIN,
            getIdManager().getId(ToolManager.getCurrentPlacement().getContext())));
}

From source file:com.espertech.esper.regression.expr.TestBitWiseOperators.java

private void runBitWiseOperators() {
    sendEvent(FIRST_EVENT, new Byte(FIRST_EVENT), SECOND_EVENT, new Short(SECOND_EVENT), FIRST_EVENT,
            new Integer(THIRD_EVENT), 3L, new Long(FOURTH_EVENT), FITH_EVENT, new Boolean(FITH_EVENT));

    EventBean received = listener.getAndResetLastNewData()[0];
    assertEquals((byte) 1, (received.get("myFirstProperty")));
    assertTrue(((Short) (received.get("mySecondProperty")) & SECOND_EVENT) == SECOND_EVENT);
    assertTrue(((Integer) (received.get("myThirdProperty")) & FIRST_EVENT) == FIRST_EVENT);
    assertEquals(7L, (received.get("myFourthProperty")));
    assertEquals(false, (received.get("myFifthProperty")));
}

From source file:com.sun.socialsite.web.ui.core.struts2.CustomizedActionSupport.java

public boolean getBooleanProp(String key) {
    // first try static config
    String value = Config.getProperty(key);
    if (value == null) {
        value = RuntimeConfig.getProperty(key);
    }//w w  w . j  a v  a2  s  .  co m
    return (value == null) ? false : (new Boolean(value)).booleanValue();
}

From source file:org.hdiv.web.servlet.tags.form.CheckboxTagTests.java

public void testWithSingleValueBooleanObjectUnchecked() throws Exception {

    this.bean.setSomeBoolean(new Boolean(false));
    this.tag.setPath("someBoolean");
    int result = this.tag.doStartTag();
    assertEquals(Tag.SKIP_BODY, result);

    String output = getWriter().toString();

    // wrap the output so it is valid XML
    output = "<doc>" + output + "</doc>";

    SAXReader reader = new SAXReader();
    Document document = reader.read(new StringReader(output));
    Element checkboxElement = (Element) document.getRootElement().elements().get(0);
    assertEquals("input", checkboxElement.getName());
    assertEquals("checkbox", checkboxElement.attribute("type").getValue());
    assertEquals("someBoolean", checkboxElement.attribute("name").getValue());
    assertNull(checkboxElement.attribute("checked"));
    assertEquals("true", checkboxElement.attribute("value").getValue());
}

From source file:com.anite.zebra.hivemind.impl.ZebraStateFactoryImpl.java

public void deleteObject(IStateObject stateObject) throws StateFailureException {

    try {//w  w  w  .  j  a v a  2s .  c om
        if (stateObject instanceof ZebraTaskInstance) {

            ZebraTaskInstance antelopeTaskInstance = (ZebraTaskInstance) stateObject;

            if (this.log.isInfoEnabled()) {
                produceDetailedDeleteLog(antelopeTaskInstance);
            }
            // Copy to history
            ZebraTaskInstanceHistory antelopeTaskInstanceHistory = new ZebraTaskInstanceHistory(
                    antelopeTaskInstance);
            ZebraTaskDefinition taskDefinition = (ZebraTaskDefinition) antelopeTaskInstance.getTaskDefinition();
            antelopeTaskInstanceHistory.setShowInHistory(new Boolean(taskDefinition.getShowInHistory()));
            getSession().save(antelopeTaskInstanceHistory);

            // Tidy up process reference
            ZebraProcessInstance processInstance = (ZebraProcessInstance) antelopeTaskInstance
                    .getProcessInstance();
            processInstance.getTaskInstances().remove(antelopeTaskInstance);
            antelopeTaskInstance.setProcessInstance(null);

            // Add history to processInstance
            processInstance.getHistoryInstances().add(antelopeTaskInstanceHistory);
            antelopeTaskInstanceHistory.setProcessInstance(processInstance);

            getSession().save(processInstance);

        }
        getSession().delete(stateObject);
    } catch (Exception e) {
        this.log.error("Failed to delete:" + stateObject.toString(), e);
        throw new StateFailureException("Failed to delete State Object", e);
    }

}

From source file:com.nominanuda.hyperapi.PayloadCodecTest.java

@Test
public void testAnyJsonApi() {
    HyperApiWsSkelton skelton = makeSkelton(Api3.class, new Api3() {
        public String x(String x) {
            return x;
        }//  w  ww.j  a  v a2 s.co  m

        public Boolean y(Boolean y) {
            return y;
        }

        public Double w(Double w) {
            return w;
        }

        public Long k(Long k) {
            return k;
        }
    });
    Api3 api = makeStub(skelton, Api3.class);
    assertEquals("B", api.x("B"));
    assertEquals("", api.x(""));
    assertEquals(null, api.x(null));
    assertEquals(null, api.y(null));
    assertEquals(null, api.w(null));
    assertEquals(null, api.k(null));
    assertEquals(new Long(1), api.k(1l));
    assertEquals(new Boolean(false), api.y(false));
    assertEquals(new Double(1.1), api.w(1.1));
}

From source file:com.adito.tunnels.wizards.forms.TunnelDetailsForm.java

public void apply(AbstractWizardSequence sequence) throws Exception {
    super.apply(sequence);
    sequence.putAttribute(ATTR_SOURCE_PORT, new Integer(sourcePort));
    sequence.putAttribute(ATTR_DESTINATION_HOST, destinationHost);
    sequence.putAttribute(ATTR_DESTINATION_PORT, new Integer(destinationPort));
    sequence.putAttribute(ATTR_TYPE, new Integer(tunnelType));
    sequence.putAttribute(ATTR_TRANSPORT, transport);
    sequence.putAttribute(ATTR_AUTO_START, new Boolean(autoStart));
    sequence.putAttribute(ATTR_SOURCE_INTERFACE, sourceInterface);
}

From source file:bboss.org.artofsolving.jodconverter.OfficeDocumentConverter.java

public File getRealWordFromWordTemplateWithMapdatas(String wordtemplate, String wordfile,
        Map<String, Object> bookdatas) throws Exception {
    String outputExtension = FilenameUtils.getExtension(wordfile);
    DocumentFormat outputFormat = formatRegistry.getFormatByExtension(outputExtension);
    String inputExtension = FilenameUtils.getExtension(outputExtension);
    DocumentFormat inputFormat = formatRegistry.getFormatByExtension(inputExtension);
    WorkBookmarkConvertorTask conversionTask = new WorkBookmarkConvertorTask(wordtemplate, wordfile, bookdatas,
            outputFormat);/*from   w w  w . j a v  a2s. c om*/
    Map<String, Object> defaultLoadProperties = new HashMap<String, Object>();
    defaultLoadProperties.put("AsTemplate", new Boolean(true));
    defaultLoadProperties.put("Hidden", new Boolean(true));
    conversionTask.setDefaultLoadProperties(defaultLoadProperties);
    //         conversionTask.setDefaultStroreProperties(defaultLoadProperties);
    conversionTask.setInputFormat(inputFormat);
    officeManager.execute(conversionTask);
    return conversionTask.getOutputFile();
}