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.duroty.application.bookmark.actions.InsertBookmarkAction.java

protected ActionForward doExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    ActionMessages errors = new ActionMessages();

    try {/*w  w  w  .  j a va 2s  .  c o m*/
        DynaActionForm _form = (DynaActionForm) form;

        Bookmark bookmarkInstance = getBookmarkInstance(request);

        BookmarkObj bookmarkObj = new BookmarkObj();
        bookmarkObj.setUrl(_form.getString("url"));
        bookmarkObj.setTitle(_form.getString("title"));
        bookmarkObj.setComments(_form.getString("comments"));
        bookmarkObj.setKeywords(_form.getString("keywords"));

        Boolean flagged = (Boolean) _form.get("flagged");

        if (flagged == null) {
            flagged = new Boolean(false);
        }

        bookmarkObj.setFlagged(flagged.booleanValue());

        if (!StringUtils.isBlank(_form.getString("comments"))) {
            bookmarkObj.setNotebook(true);
        } else {
            bookmarkObj.setNotebook(false);
        }

        bookmarkInstance.addBookmark(bookmarkObj);
    } catch (Exception ex) {
        String errorMessage = ExceptionUtilities.parseMessage(ex);

        if (errorMessage == null) {
            errorMessage = "NullPointerException";
        }

        errors.add("general", new ActionMessage(ExceptionCode.ERROR_MESSAGES_PREFIX + "general", errorMessage));
        request.setAttribute("exception", errorMessage);
        doTrace(request, DLog.ERROR, getClass(), errorMessage);
    } finally {
    }

    if (errors.isEmpty()) {
        doTrace(request, DLog.INFO, getClass(), "OK");

        return mapping.findForward(Constants.ACTION_SUCCESS_FORWARD);
    } else {
        saveErrors(request, errors);

        return mapping.findForward(Constants.ACTION_FAIL_FORWARD);
    }
}

From source file:com.duroty.application.open.manager.OpenManager.java

/**
 * DOCUMENT ME!/* w ww  .j av a 2 s .  c  om*/
 *
 * @param hsession DOCUMENT ME!
 * @param msession DOCUMENT ME!
 * @param data DOCUMENT ME!
 *
 * @throws Exception DOCUMENT ME!
 */
public void forgotPassword(org.hibernate.Session hsession, Session msession, String data) throws Exception {
    try {
        int pos = data.indexOf('@');

        if (pos > -1) {
            data = data.substring(0, pos);
        }

        Criteria criteria = hsession.createCriteria(Users.class);
        criteria.add(Restrictions.eq("useUsername", data));

        Users user = (Users) criteria.uniqueResult();

        if (user != null) {
            InternetAddress _to = new InternetAddress(user.getUseEmail(), user.getUseName());

            Criteria crit = hsession.createCriteria(Identity.class);
            crit.add(Restrictions.eq("users", user));
            crit.add(Restrictions.eq("ideActive", new Boolean(true)));
            crit.add(Restrictions.eq("ideDefault", new Boolean(true)));

            Identity identity = (Identity) crit.uniqueResult();
            InternetAddress _from = new InternetAddress(identity.getIdeEmail(), identity.getIdeName());

            Iterator it = user.getMailPreferenceses().iterator();
            MailPreferences mailPreferences = (MailPreferences) it.next();

            sendData(msession, _from, _to, user.getUseUsername(), user.getUsePassword(),
                    mailPreferences.getMaprSignature());
        }
    } finally {
        GeneralOperations.closeHibernateSession(hsession);
    }
}

From source file:no.ntnu.mmfplanner.ui.graph.SaNpvChart.java

/**
 * Creates the chart//from  w w w . j  a  v  a  2  s  .c  o  m
 */
private void createChart() {
    JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title
            "Period", // x axis label
            "Discounted Cash", // y axis label
            null, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.getDomainAxis().setLowerMargin(0.0);
    plot.getDomainAxis().setUpperMargin(0.0);
    plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT);

    // change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getDomainAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    setChart(chart);
    setMouseZoomable(false);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setLegendLine(new Rectangle2D.Double(0.0, 0.0, 6.0, 0.0));
    renderer.setUseFillPaint(true);

    // the x=0 line
    renderer.setSeriesPaint(0, Color.GRAY);
    renderer.setSeriesShapesVisible(0, false);
    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesVisibleInLegend(0, new Boolean(false));

    plot.setRenderer(renderer);
}

From source file:de.suse.swamp.modules.actions.LoginActions.java

/**
 * Checks the if the login data is correct, 
 * and provides Turbine with a Turbineuser afterwards.
 * //from   w  w w  .ja  va 2  s .c om
 * @author Thomas Schmidt
 * @param data - Turbine information.
 * @exception Exception, a generic exception.
 */
public void doLoginuser(RunData data, Context context) throws Exception {

    ParameterParser pp = data.getParameters();
    String username = pp.getString("username", "").toLowerCase();
    String password = pp.getString("password", "");
    // cause of login-error 
    String cause = null;

    if (StringUtils.isEmpty(username)) {
        return;
    }

    try {

        User user = TurbineSecurity.getAuthenticatedUser(username, password);
        // Store the user object.
        data.setUser(user);
        // Mark the user as being logged in.
        user.setHasLoggedIn(new Boolean(true));
        // Save the User object into the session.
        data.save();
        Logger.LOG(username + " has successfully logged in.");

        // if we have a "query", it's a redirect from the login page:
        // if we want restrict to do direct logins to special actions, we have to restrict it here
        if (pp.containsKey("query") && !pp.get("query").equals("")
                && !(pp.get("query").indexOf("doLogoutuser") > 0)) {
            Logger.DEBUG("Found a query, redirecting to " + pp.get("query"));
            data.declareDirectResponse();
            data.setRedirectURI(pp.get("query"));
        }
    } catch (Exception e) {
        Logger.ERROR("Login Error: " + e.getMessage());
        // Retrieve an anonymous user.
        data.setUser(TurbineSecurity.getAnonymousUser());
        data.setScreen(Turbine.getConfiguration().getString("screen.login"));
        data.setScreenTemplate(Turbine.getConfiguration().getString("template.login"));
        data.setLayoutTemplate("DefaultLayout.vm");

        // set the right error-message:
        if (e instanceof StorageException) {
            cause = "Error in communicating with authentication server: " + e.getMessage();
        } else if (e instanceof PasswordMismatchException) {
            cause = "Wrong password entered for username: " + username;
        } else if (e instanceof UnknownEntityException) {
            cause = "Unknown username: " + username;
        } else if (e instanceof NoSuchElementException) {
            cause = "Unknown username: " + username;
        } else if (e instanceof DataBackendException) {
            cause = "Could not connect to user database: " + e.getMessage();
        } else {
            cause = "Fatal Error : " + e.getMessage();
        }
        data.setMessage("Login failed. Cause: " + StringEscapeUtils.escapeHtml(cause));

    }

    // Check for XML-Output for external scripts
    if (data.getParameters().containsKey("xmlresponse")
            && data.getParameters().get("xmlresponse").equals("true")) {
        if (cause != null && !cause.equals("")) {
            // FIXME: Mapping ERROR to Errornumber must happen here
            ExternalActions.doSendXMLOutput(data, "1", StringEscapeUtils.escapeHtml(cause));
        } else {
            ExternalActions.doSendXMLOutput(data, "0", "Your are logged in");
        }
    }
}

From source file:com.hs.mail.security.login.JndiLoginModule.java

@Override
public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState,
        Map<String, ?> options) {
    super.initialize(subject, callbackHandler, sharedState, options);
    contextFactory = getOption("context.factory", "com.sun.jndi.ldap.LdapCtxFactory");
    url = getOption("url", null);
    if (url == null) {
        throw new Error("No JNDI URL specified");
    }//w  w w  .j  a v a  2s.com
    username = getOption("username", null);
    password = getOption("password", null);
    authentication = getOption("authentication", "simple");
    base = getOption("base", null);
    String filter = getOption("searchFilter", "(uid={0})");
    searchFilterFormat = new MessageFormat(filter);
    returnAttribute = getOption("returnAttribute", null);
    subtree = new Boolean(getOption("subtree", "true")).booleanValue();
}

From source file:FileTable2.java

public void setFileStats(File dir) {
    String files[] = dir.list();//  w  w w.  j  a  va 2 s.  c  o m
    data = new Object[files.length][titles.length];

    for (int i = 0; i < files.length; i++) {
        File tmp = new File(files[i]);
        data[i][0] = new Boolean(tmp.isDirectory());
        data[i][1] = tmp.getName();
        data[i][2] = new Boolean(tmp.canRead());
        data[i][3] = new Boolean(tmp.canWrite());
        data[i][4] = new Long(tmp.length());
        data[i][5] = new Date(tmp.lastModified());
    }

    // Just in case anyone's listening...
    fireTableDataChanged();
}

From source file:com.aurel.track.screen.dashboard.action.DashboardParamsConfigAction.java

@Override
public void prepare() {
    locale = (Locale) session.get(Constants.LOCALE_KEY);
    Boolean fromAdmin = (Boolean) session.get(DashboardScreenEditAction.DASHBOARD_EDIT_FROM);
    if (fromAdmin == null) {
        fromAdmin = new Boolean(false);
    }//from ww  w  .  j  av a2  s .c  o m
    if (fromAdmin.booleanValue()) {
        //set in dashboardAssign
        personBean = DashboardAssignBL
                .loadPersonByKey((Integer) session.get(DashboardScreenEditAction.DASHBOARD_EDIT_PERSON));
        backAction = "dashboardAssign.action";
    } else {
        personBean = (TPersonBean) session.get(Constants.USER_KEY);
        backAction = "cockpit.action";
    }
}

From source file:com.duroty.application.bookmark.actions.UpdateBookmarkAction.java

protected ActionForward doExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    ActionMessages errors = new ActionMessages();

    try {/*from  w  w  w.j  ava  2 s .  c o m*/
        DynaActionForm _form = (DynaActionForm) form;

        Bookmark bookmarkInstance = getBookmarkInstance(request);

        BookmarkObj bookmarkObj = new BookmarkObj();
        bookmarkObj.setIdint(_form.getString("idint"));
        bookmarkObj.setUrl(_form.getString("url"));
        bookmarkObj.setTitle(_form.getString("title"));
        bookmarkObj.setComments(_form.getString("comments"));
        bookmarkObj.setKeywords(_form.getString("keywords"));

        Boolean flagged = (Boolean) _form.get("flagged");

        if (flagged == null) {
            flagged = new Boolean(false);
        }

        bookmarkObj.setFlagged(flagged.booleanValue());

        if (!StringUtils.isBlank(_form.getString("comments"))) {
            bookmarkObj.setNotebook(true);
        } else {
            bookmarkObj.setNotebook(false);
        }

        bookmarkInstance.updateBookmark(bookmarkObj);
    } catch (Exception ex) {
        String errorMessage = ExceptionUtilities.parseMessage(ex);

        if (errorMessage == null) {
            errorMessage = "NullPointerException";
        }

        errors.add("general", new ActionMessage(ExceptionCode.ERROR_MESSAGES_PREFIX + "general", errorMessage));
        request.setAttribute("exception", errorMessage);
        doTrace(request, DLog.ERROR, getClass(), errorMessage);
    } finally {
    }

    if (errors.isEmpty()) {
        doTrace(request, DLog.INFO, getClass(), "OK");

        return mapping.findForward(Constants.ACTION_SUCCESS_FORWARD);
    } else {
        saveErrors(request, errors);

        return mapping.findForward(Constants.ACTION_FAIL_FORWARD);
    }
}

From source file:net.decix.jatlasx.test.HandlerTest.java

@Test
public void testMeasurementIDHandler() {

    boolean receivedData = false;
    ResponseHandler<Long> handler = new MeasurementIDHandler();

    JSONArray jsonTestArrayLong = new JSONArray();
    jsonTestArrayLong.put(new Long(10));
    jsonTestArrayLong.put(new Long(100));
    jsonTestArrayLong.put(new Long(1000));
    jsonTestArrayLong.put(new Long(10000));
    jsonTestArrayLong.put(new Long(0));

    JSONObject obj = new JSONObject();
    obj.put("measurements", jsonTestArrayLong);
    obj.put("num", new Integer(100));
    obj.put("balance", new Double(1000.21));
    obj.put("is_vip", new Boolean(true));
    obj.put("nickname", new Object());

    String definitions = new JSONStringer().array().object().key("target").value("192.168.178.1").key("af")
            .value("4").endObject().object().key("newline").value("123").key("newline2").value("456")
            .endObject().endArray().toString();

    String probes = new JSONStringer().array().object().key("value").value("21931").key("type").value("probes")
            .key("requested").value("1").endObject().endArray().toString();

    String myString = new JSONStringer().object().key("definitions").value(definitions).key("probes")
            .value(probes).key("measurements").value(jsonTestArrayLong).key("is_oneoff").value(false)
            .endObject().toString();/*from  ww  w  . ja  va2 s.c o  m*/

    List<Long> list = handler.handleResponse(myString);
    if (!list.isEmpty()) {
        if (PRINT_RESULTS) {
            System.out.println("TEST (HandlerTest) - MeasurementIDHandler " + list);
        }
        receivedData = true;
    }
    assertTrue(receivedData);
}

From source file:SimpleTableSelectionDemo.java

public SimpleTableSelectionDemo() {
    super(new GridLayout(1, 0));

    final String[] columnNames = { "First Name", "Last Name", "Sport", "# of Years", "Vegetarian" };

    final Object[][] data = { { "Mary", "Campione", "Snowboarding", new Integer(5), new Boolean(false) },
            { "Alison", "Huml", "Rowing", new Integer(3), new Boolean(true) },
            { "Kathy", "Walrath", "Knitting", new Integer(2), new Boolean(false) },
            { "Sharon", "Zakhour", "Speed reading", new Integer(20), new Boolean(true) },
            { "Philip", "Milne", "Pool", new Integer(10), new Boolean(false) } };

    final JTable table = new JTable(data, columnNames);
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));

    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    if (ALLOW_ROW_SELECTION) { // true by default
        ListSelectionModel rowSM = table.getSelectionModel();
        rowSM.addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                //Ignore extra messages.
                if (e.getValueIsAdjusting())
                    return;

                ListSelectionModel lsm = (ListSelectionModel) e.getSource();
                if (lsm.isSelectionEmpty()) {
                    System.out.println("No rows are selected.");
                } else {
                    int selectedRow = lsm.getMinSelectionIndex();
                    System.out.println("Row " + selectedRow + " is now selected.");
                }//from   w ww .  j  a v  a2s.c  o  m
            }
        });
    } else {
        table.setRowSelectionAllowed(false);
    }

    if (ALLOW_COLUMN_SELECTION) { // false by default
        if (ALLOW_ROW_SELECTION) {
            //We allow both row and column selection, which
            //implies that we *really* want to allow individual
            //cell selection.
            table.setCellSelectionEnabled(true);
        }
        table.setColumnSelectionAllowed(true);
        ListSelectionModel colSM = table.getColumnModel().getSelectionModel();
        colSM.addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                //Ignore extra messages.
                if (e.getValueIsAdjusting())
                    return;

                ListSelectionModel lsm = (ListSelectionModel) e.getSource();
                if (lsm.isSelectionEmpty()) {
                    System.out.println("No columns are selected.");
                } else {
                    int selectedCol = lsm.getMinSelectionIndex();
                    System.out.println("Column " + selectedCol + " is now selected.");
                }
            }
        });
    }

    if (DEBUG) {
        table.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                printDebugData(table);
            }
        });
    }

    //Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);

    //Add the scroll pane to this panel.
    add(scrollPane);
}