Example usage for java.lang Boolean equals

List of usage examples for java.lang Boolean equals

Introduction

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

Prototype

public boolean equals(Object obj) 

Source Link

Document

Returns true if and only if the argument is not null and is a Boolean object that represents the same boolean value as this object.

Usage

From source file:Main.java

public static void main(String[] args) {
    Boolean b1 = new Boolean(true);
    Boolean b2 = new Boolean(false);

    boolean res = b1.equals(b2);

    System.out.println("b1:" + b1 + " and b2:" + b2 + " are equal is " + res);
}

From source file:Main.java

public static void main(String[] args) {
    boolean b = true;
    Boolean bool = Boolean.valueOf(b);
    System.out.println("bool = " + bool);

    if (bool.equals(Boolean.TRUE)) {
        System.out.println("bool = " + bool);
    }/*from ww w  .jav a2 s  . c  o  m*/

    String s = "false";

    Boolean bools = Boolean.valueOf(s);
    System.out.println("bools = " + bools);

    String f = "abc";
    Boolean abc = Boolean.valueOf(f);
    System.out.println("abc = " + abc);
}

From source file:org.openscience.jmol.app.Jmol.java

public static void main(String[] args) {

    Dialog.setupUIManager();// www.  jav  a2s  .  c o  m

    Jmol jmol = null;

    String modelFilename = null;
    String scriptFilename = null;

    Options options = new Options();
    options.addOption("b", "backgroundtransparent", false, GT._("transparent background"));
    options.addOption("h", "help", false, GT._("give this help page"));
    options.addOption("n", "nodisplay", false, GT._("no display (and also exit when done)"));
    options.addOption("c", "check", false, GT._("check script syntax only"));
    options.addOption("i", "silent", false, GT._("silent startup operation"));
    options.addOption("l", "list", false, GT._("list commands during script execution"));
    options.addOption("o", "noconsole", false, GT._("no console -- all output to sysout"));
    options.addOption("t", "threaded", false, GT._("independent commmand thread"));
    options.addOption("x", "exit", false, GT._("exit after script (implicit with -n)"));

    OptionBuilder.withLongOpt("script");
    OptionBuilder.withDescription("script file to execute");
    OptionBuilder.withValueSeparator('=');
    OptionBuilder.hasArg();
    options.addOption(OptionBuilder.create("s"));

    OptionBuilder.withLongOpt("menu");
    OptionBuilder.withDescription("menu file to use");
    OptionBuilder.withValueSeparator('=');
    OptionBuilder.hasArg();
    options.addOption(OptionBuilder.create("m"));

    OptionBuilder.withArgName(GT._("property=value"));
    OptionBuilder.hasArg();
    OptionBuilder.withValueSeparator();
    OptionBuilder.withDescription(GT._("supported options are given below"));
    options.addOption(OptionBuilder.create("D"));

    OptionBuilder.withLongOpt("geometry");
    // OptionBuilder.withDescription(GT._("overall window width x height, e.g. {0}", "-g512x616"));
    OptionBuilder.withDescription(GT._("window width x height, e.g. {0}", "-g500x500"));
    OptionBuilder.withValueSeparator();
    OptionBuilder.hasArg();
    options.addOption(OptionBuilder.create("g"));

    OptionBuilder.withLongOpt("quality");
    // OptionBuilder.withDescription(GT._("overall window width x height, e.g. {0}", "-g512x616"));
    OptionBuilder.withDescription(GT._(
            "JPG image quality (1-100; default 75) or PNG image compression (0-9; default 2, maximum compression 9)"));
    OptionBuilder.withValueSeparator();
    OptionBuilder.hasArg();
    options.addOption(OptionBuilder.create("q"));

    OptionBuilder.withLongOpt("write");
    OptionBuilder
            .withDescription(GT._("{0} or {1}:filename", new Object[] { "CLIP", "GIF|JPG|JPG64|PNG|PPM" }));
    OptionBuilder.withValueSeparator();
    OptionBuilder.hasArg();
    options.addOption(OptionBuilder.create("w"));

    int startupWidth = 0, startupHeight = 0;

    CommandLine line = null;
    try {
        CommandLineParser parser = new PosixParser();
        line = parser.parse(options, args);
    } catch (ParseException exception) {
        System.err.println("Unexpected exception: " + exception.toString());
    }

    if (line.hasOption("h")) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("Jmol", options);

        // now report on the -D options
        System.out.println();
        System.out.println(GT._("For example:"));
        System.out.println();
        System.out.println("Jmol -ions myscript.spt -w JPEG:myfile.jpg > output.txt");
        System.out.println();
        System.out.println(GT._("The -D options are as follows (defaults in parenthesis):"));
        System.out.println();
        System.out.println("  cdk.debugging=[true|false] (false)");
        System.out.println("  cdk.debug.stdout=[true|false] (false)");
        System.out.println("  display.speed=[fps|ms] (ms)");
        System.out.println("  JmolConsole=[true|false] (true)");
        System.out.println("  jmol.logger.debug=[true|false] (false)");
        System.out.println("  jmol.logger.error=[true|false] (true)");
        System.out.println("  jmol.logger.fatal=[true|false] (true)");
        System.out.println("  jmol.logger.info=[true|false] (true)");
        System.out.println("  jmol.logger.logLevel=[true|false] (false)");
        System.out.println("  jmol.logger.warn=[true|false] (true)");
        System.out.println("  plugin.dir (unset)");
        System.out.println("  user.language=[CA|CS|DE|EN|ES|FR|NL|PT|TR] (EN)");

        System.exit(0);
    }

    args = line.getArgs();
    if (args.length > 0) {
        modelFilename = args[0];
    }

    // Process more command line arguments
    // these are also passed to viewer

    String commandOptions = "";

    //silent startup
    if (line.hasOption("i")) {
        commandOptions += "-i";
        isSilent = Boolean.TRUE;
    }

    // transparent background
    if (line.hasOption("b")) {
        commandOptions += "-b";
    }

    // independent command thread
    if (line.hasOption("t")) {
        commandOptions += "-t";
    }

    //list commands during script operation
    if (line.hasOption("l")) {
        commandOptions += "-l";
    }

    //output to sysout
    if (line.hasOption("o")) {
        commandOptions += "-o";
        haveConsole = Boolean.FALSE;
    }

    //no display (and exit)
    if (line.hasOption("n")) {
        // this ensures that noDisplay also exits
        commandOptions += "-n-x";
        haveDisplay = Boolean.FALSE;
    }

    //check script only
    if (line.hasOption("c")) {
        commandOptions += "-c";
    }

    //run script
    if (line.hasOption("s")) {
        commandOptions += "-s";
        scriptFilename = line.getOptionValue("s");
    }

    //menu file
    if (line.hasOption("m")) {
        menuFile = line.getOptionValue("m");
    }

    //exit when script completes (or file is read)
    if (line.hasOption("x")) {
        commandOptions += "-x";
    }
    String imageType_name = null;
    //write image to clipboard or image file  
    if (line.hasOption("w")) {
        imageType_name = line.getOptionValue("w");
    }

    Dimension size;
    try {
        String vers = System.getProperty("java.version");
        if (vers.compareTo("1.1.2") < 0) {
            System.out.println("!!!WARNING: Swing components require a " + "1.1.2 or higher version VM!!!");
        }

        size = historyFile.getWindowSize(JMOL_WINDOW_NAME);
        if (size != null && haveDisplay.booleanValue()) {
            startupWidth = size.width;
            startupHeight = size.height;
        }

        //OUTER window dimensions
        /*
         if (line.hasOption("g") && haveDisplay.booleanValue()) {
         String geometry = line.getOptionValue("g");
         int indexX = geometry.indexOf('x');
         if (indexX > 0) {
         startupWidth = parseInt(geometry.substring(0, indexX));
         startupHeight = parseInt(geometry.substring(indexX + 1));
         }
         }
         */

        Point b = historyFile.getWindowBorder(JMOL_WINDOW_NAME);
        //first one is just approximate, but this is set in doClose()
        //so it will reset properly -- still, not perfect
        //since it is always one step behind.
        if (b == null)
            border = new Point(12, 116);
        else
            border = new Point(b.x, b.y);
        //note -- the first time this is run after changes it will not work
        //because there is a bootstrap problem.

        int width = -1;
        int height = -1;
        int quality = 75;
        //INNER frame dimensions
        if (line.hasOption("g")) {
            String geometry = line.getOptionValue("g");
            int indexX = geometry.indexOf('x');
            if (indexX > 0) {
                width = Parser.parseInt(geometry.substring(0, indexX));
                height = Parser.parseInt(geometry.substring(indexX + 1));
                //System.out.println("setting geometry to " + geometry + " " + border + " " + startupWidth + startupHeight);
            }
            if (haveDisplay.booleanValue()) {
                startupWidth = width + border.x;
                startupHeight = height + border.y;
            }
        }

        if (line.hasOption("q"))
            quality = Parser.parseInt(line.getOptionValue("q"));

        if (imageType_name != null)
            commandOptions += "-w\1" + imageType_name + "\t" + width + "\t" + height + "\t" + quality + "\1";

        if (startupWidth <= 0 || startupHeight <= 0) {
            startupWidth = 500 + border.x;
            startupHeight = 500 + border.y;
        }
        JFrame jmolFrame = new JFrame();
        Point jmolPosition = historyFile.getWindowPosition(JMOL_WINDOW_NAME);
        if (jmolPosition != null) {
            jmolFrame.setLocation(jmolPosition);
        }

        //now pass these to viewer
        jmol = getJmol(jmolFrame, startupWidth, startupHeight, commandOptions);

        // Open a file if one is given as an argument -- note, this CAN be a script file
        if (modelFilename != null) {
            jmol.viewer.openFile(modelFilename);
            jmol.viewer.getOpenFileError();
        }

        // OK, by now it is time to execute the script
        if (scriptFilename != null) {
            report("Executing script: " + scriptFilename);
            if (haveDisplay.booleanValue())
                jmol.splash.showStatus(GT._("Executing script..."));
            jmol.viewer.evalFile(scriptFilename);
        }
    } catch (Throwable t) {
        System.out.println("uncaught exception: " + t);
        t.printStackTrace();
    }

    if (haveConsole.booleanValue()) {
        Point location = jmol.frame.getLocation();
        size = jmol.frame.getSize();
        // Adding console frame to grab System.out & System.err
        consoleframe = new JFrame(GT._("Jmol Java Console"));
        consoleframe.setIconImage(jmol.frame.getIconImage());
        try {
            final ConsoleTextArea consoleTextArea = new ConsoleTextArea();
            consoleTextArea.setFont(java.awt.Font.decode("monospaced"));
            consoleframe.getContentPane().add(new JScrollPane(consoleTextArea), java.awt.BorderLayout.CENTER);
            if (Boolean.getBoolean("clearConsoleButton")) {
                JButton buttonClear = new JButton(GT._("Clear"));
                buttonClear.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        consoleTextArea.setText("");
                    }
                });
                consoleframe.getContentPane().add(buttonClear, java.awt.BorderLayout.SOUTH);
            }
        } catch (IOException e) {
            JTextArea errorTextArea = new JTextArea();
            errorTextArea.setFont(java.awt.Font.decode("monospaced"));
            consoleframe.getContentPane().add(new JScrollPane(errorTextArea), java.awt.BorderLayout.CENTER);
            errorTextArea.append(GT._("Could not create ConsoleTextArea: ") + e);
        }

        Dimension consoleSize = historyFile.getWindowSize(CONSOLE_WINDOW_NAME);
        Point consolePosition = historyFile.getWindowPosition(CONSOLE_WINDOW_NAME);
        if ((consoleSize != null) && (consolePosition != null)) {
            consoleframe.setBounds(consolePosition.x, consolePosition.y, consoleSize.width, consoleSize.height);
        } else {
            consoleframe.setBounds(location.x, location.y + size.height, size.width, 200);
        }

        Boolean consoleVisible = historyFile.getWindowVisibility(CONSOLE_WINDOW_NAME);
        if ((consoleVisible != null) && (consoleVisible.equals(Boolean.TRUE))) {
            consoleframe.show();
        }
    }
}

From source file:Main.java

public static Boolean isNotNull(Boolean bln) {
    if (bln == null || bln.equals("") || bln.equals(" ")) {
        return false;
    } else//from  w  w  w  .jav  a 2  s  . co  m
        return true;
}

From source file:org.saiku.adhoc.providers.impl.pentaho.PentahoMetadataUtil.java

public static boolean isVisible(Concept concept) {

    String context = null;/*from   w w w  .jav a 2 s  .  c om*/

    //check visible
    String vis = (String) concept.getProperty("visible");
    if (vis != null) {
        String[] visibleContexts = vis.split(",");
        for (String c : visibleContexts) {
            if (c.equals(context)) {
                return true;
            }
        }
        return false;
    }

    //also check hidden
    Boolean hidden = (Boolean) concept.getProperty("hidden");
    if (hidden != null && hidden.equals(Boolean.TRUE)) {
        return false;
    }

    return true;

}

From source file:me.doshou.admin.maintain.editor.web.controller.utils.OnlineEditorUtils.java

public static void sort(final List<Map<Object, Object>> files, final Sort sort) {

    Collections.sort(files, new Comparator<Map<Object, Object>>() {
        @Override//from w  ww. j  ava2s.co m
        public int compare(Map<Object, Object> o1, Map<Object, Object> o2) {
            if (sort == null) {
                return 0;
            }
            Sort.Order nameOrder = sort.getOrderFor("name");
            if (nameOrder != null) {
                String n1 = (String) o1.get("name");
                String n2 = (String) o2.get("name");
                Boolean n1IsDirecoty = (Boolean) o1.get("isDirectory");
                Boolean n2IsDirecoty = (Boolean) o2.get("isDirectory");

                if (n1IsDirecoty.equals(Boolean.TRUE) && n2IsDirecoty.equals(Boolean.FALSE)) {
                    return -1;
                } else if (n1IsDirecoty.equals(Boolean.FALSE) && n2IsDirecoty.equals(Boolean.TRUE)) {
                    return 1;
                }

                if (nameOrder.getDirection() == Sort.Direction.ASC) {
                    return n1.compareTo(n2);
                } else {
                    return -n1.compareTo(n2);
                }
            }

            Sort.Order lastModifiedOrder = sort.getOrderFor("lastModified");
            if (lastModifiedOrder != null) {
                Long l1 = (Long) o1.get("lastModifiedForLong");
                Long l2 = (Long) o2.get("lastModifiedForLong");
                if (lastModifiedOrder.getDirection() == Sort.Direction.ASC) {
                    return l1.compareTo(l2);
                } else {
                    return -l1.compareTo(l2);
                }
            }

            Sort.Order sizeOrder = sort.getOrderFor("size");
            if (sizeOrder != null) {
                Long s1 = (Long) o1.get("size");
                Long s2 = (Long) o2.get("size");
                if (sizeOrder.getDirection() == Sort.Direction.ASC) {
                    return s1.compareTo(s2);
                } else {
                    return -s1.compareTo(s2);
                }
            }

            return 0;
        }
    });

}

From source file:org.nextreamlabs.simplex.model.component.SmartVariable.java

/**
 * Create a new variable/*  w  w  w  .ja  v a 2s. c  o m*/
 * @param id The id for the new variable
 * @param coefficient The coefficient for the new variable
 * @param augmented The new variable is augmented or not
 * @return The created variable
 */
public static Variable create(Integer id, BigDecimal coefficient, Boolean augmented) {
    for (MutableInt usedId : idsRegister.keySet()) {
        if (usedId.intValue() == id) {
            assert augmented.equals(idsRegister.get(usedId));
            return createFromExistingId(id, coefficient);
        }
    }
    return new SmartVariable(assignId(id, augmented), coefficient, augmented);
}

From source file:com.p5solutions.core.utils.Comparison.java

/**
 * Checks if is true or null./*from  w w  w  .  ja v  a 2s.c  o  m*/
 * 
 * @param val
 *          the val
 * 
 * @return true, if is true or null
 */
public static boolean isTrueOrNull(Boolean val) {
    return val == null || val.equals(true);
}

From source file:com.p5solutions.core.utils.Comparison.java

/**
 * Checks if is false or null.// w w w.j ava2  s  .  com
 * 
 * @param val
 *          the val
 * @return true, if is false or null
 */
public static boolean isFalseOrNull(Boolean val) {
    return val == null || val.equals(false);
}

From source file:com.zht.common.codegen.util.HiberStrUtil.java

public static void handlerProperty_Date(GenEntityProperty prop) {
    StringBuffer hibModelStr = new StringBuffer("");
    String editType = prop.getEditType();
    String sft = "";
    String timeType = "";
    String timeScope = "";
    Boolean isFrutrue = prop.getIsDateFutrue();
    Boolean isPost = prop.getIsDatePost();
    if (isFrutrue != null && !(isFrutrue.equals(isPost))) {
        if (isFrutrue) {
            timeScope += "@javax.validation.constraints.Future\r\t";
        }//from  www.  j  a va  2  s.  c  o m
    }
    if (isPost != null && !(isPost.equals(isFrutrue))) {
        if (isPost) {
            timeScope += "@javax.validation.constraints.Past\r\t";
        }
    }

    if ("date".equals(editType)) {
        sft = "@org.springframework.format.annotation.DateTimeFormat(pattern = \"yyyy-MM-dd\")";
        timeType = "@javax.persistence.Temporal(javax.persistence.TemporalType.DATE)";
    } else if ("time".equals(editType)) {
        sft = "@org.springframework.format.annotation.DateTimeFormat(pattern = \"HH:mm:ss\")";
        timeType = "@javax.persistence.Temporal(javax.persistence.TemporalType.TIME)";
    } else if ("datetime".equals(editType)) {
        sft = "@org.springframework.format.annotation.DateTimeFormat(pattern = \"yyyy-MM-dd HH:mm:ss\")";
        timeType = "@javax.persistence.Temporal(javax.persistence.TemporalType.TIMESTAMP)";
    } else if ("autoCurrentTime".equals(editType)) {
        //sft="@org.springframework.format.annotation.DateTimeFormat(pattern = \"yyyy-MM-dd HH:mm:ss\")";
        timeType = "@javax.persistence.Temporal(javax.persistence.TemporalType.TIMESTAMP)";
        hibModelStr.append("@org.zht.framework.annos.CurrentTimeStamp");
    }
    String clumnname = prop.getColumnName();
    hibModelStr.append(timeScope).append(sft).append("\r\t").append(timeType).append("\r\t");
    hibModelStr.append("@javax.persistence.Column(name = \"" + clumnname + "\")");
    prop.setGeneratedHibernateModelOfPropertyStr(hibModelStr.toString());

}