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:edu.unc.lib.dl.admin.controller.ExportController.java

private void printObject(CSVPrinter printer, BriefObjectMetadata object) throws IOException {

    // Vitals: object type, pid, title, path, label, depth

    printer.print(object.getResourceType());
    printer.print(object.getPid());/*from   www . j  ava  2s  . co m*/
    printer.print(object.getTitle());
    printer.print(object.getAncestorNames());

    String label = object.getLabel();

    if (label != null) {
        printer.print(label);
    } else {
        printer.print("");
    }

    printer.print(object.getAncestorPathFacet().getHighestTier());

    // Status: deleted

    printer.print(new Boolean(
            object.getStatus().contains("Deleted") || object.getStatus().contains("Parent Deleted")));

    // Dates: added, updated

    Date added = object.getDateAdded();

    if (added != null) {
        printer.print(dateFormat.format(added));
    } else {
        printer.print("");
    }

    Date updated = object.getDateUpdated();

    if (updated != null) {
        printer.print(dateFormat.format(updated));
    } else {
        printer.print("");
    }

    // DATA_FILE info: mime type, checksum, file size

    Datastream dataFileDatastream = null;

    if (ResourceType.File.equals(object.getResourceType())) {
        dataFileDatastream = object.getDatastreamObject(ContentModelHelper.Datastream.DATA_FILE.toString());
    }

    if (dataFileDatastream != null) {
        printer.print(dataFileDatastream.getMimetype());
        printer.print(dataFileDatastream.getChecksum());

        Long filesize = dataFileDatastream.getFilesize();

        // If we don't have a filesize for whatever reason, print a blank
        if (filesize != null && filesize >= 0) {
            printer.print(filesize);
        } else {
            printer.print("");
        }
    } else {
        printer.print("");
        printer.print("");
        printer.print("");
    }

    // Container info: child count

    if (object.getContentModel().contains(ContentModelHelper.Model.CONTAINER.toString())) {
        Long childCount = object.getCountMap().get("child");

        // If we don't have a childCount we will assume that the container contains zero
        // items, because the Solr query asked for facet.mincount=1
        if (childCount != null && childCount > 0) {
            printer.print(childCount);
        } else {
            printer.print(new Long(0));
        }
    } else {
        printer.print("");
    }

    printer.println();

}

From source file:com.icesoft.faces.util.CoreUtils.java

public static void recoverFacesMessages(FacesContext facesContext, UIComponent uiComponent) {
    if (!(uiComponent instanceof UIInput))
        return;/*from   ww  w .j a  v a2 s .c o  m*/
    UIInput input = (UIInput) uiComponent;
    String clientId = input.getClientId(facesContext);
    String localFacesMsgId = clientId + "$ice-msg$";
    String localRequired = clientId + "$ice-req$";
    //save the required attribute, specifically for UIData
    if (input.getAttributes().get(localRequired) == null) {
        // this property will be used by the UISeries.restoreRequiredAttribute()
        input.getAttributes().put(localRequired, new Boolean(input.isRequired()));
    }
    //component is invalid there should be a message in the default messages map
    if (!input.isValid()) {
        Iterator messages = facesContext.getMessages(clientId);
        FacesMessage message = null;
        //if no message found, then it might a page refresh call
        //or the request of dynamic rendering of the component. 
        //if so, get the message from the component's map and add
        //it to the default messages map
        if (messages == null || !messages.hasNext()) {
            if (input.getAttributes().get(localFacesMsgId) != null) {
                message = ((FacesMessageHolder) input.getAttributes().get(localFacesMsgId)).message;
                if (null != message) {
                    facesContext.addMessage(clientId, message);
                }
            }
        } else {//if found, then store it to the component's message map,
            //so can be served later.
            message = (FacesMessage) messages.next();
            input.getAttributes().put(localFacesMsgId, new FacesMessageHolder(message));
        }
    } else { //component is valid, so remove the old message.
        input.getAttributes().remove(localFacesMsgId);
    }
}

From source file:com.caucho.hessian.client.HessianProxy.java

/**
 * Handles the object invocation./* www . ja  v  a2  s  . c o  m*/
 * 
 * @param proxy
 *            the proxy object to invoke
 * @param method
 *            the method to call
 * @param args
 *            the arguments to the proxy object
 */
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    String mangleName;

    synchronized (_mangleMap) {
        mangleName = _mangleMap.get(method);
    }

    if (mangleName == null) {
        String methodName = method.getName();
        Class<?>[] params = method.getParameterTypes();
        // equals and hashCode are special cased
        if (methodName.equals("equals") && params.length == 1 && params[0].equals(Object.class)) {
            Object value = args[0];
            if (value == null || !Proxy.isProxyClass(value.getClass()))
                return Boolean.FALSE;

            Object proxyHandler = Proxy.getInvocationHandler(value);

            if (!(proxyHandler instanceof HessianProxy))
                return Boolean.FALSE;

            HessianProxy handler = (HessianProxy) proxyHandler;

            return new Boolean(_url.equals(handler.getURL()));
        } else if (methodName.equals("hashCode") && params.length == 0)
            return new Integer(_url.hashCode());
        else if (methodName.equals("getHessianType"))
            return proxy.getClass().getInterfaces()[0].getName();
        else if (methodName.equals("getHessianURL"))
            return _url.toString();
        else if (methodName.equals("toString") && params.length == 0)
            return "HessianProxy[" + _url + "]";

        if (!_factory.isOverloadEnabled())
            mangleName = method.getName();
        else
            mangleName = mangleName(method);

        synchronized (_mangleMap) {
            _mangleMap.put(method, mangleName);
        }
    }
    InputStream is = null;
    HessianConnection conn = null;

    try {
        if (log.isLoggable(Level.FINER))
            log.finer("Hessian[" + _url + "] calling " + mangleName);
        conn = sendRequest(mangleName, args);

        if (conn.getStatusCode() != 200) {
            throw new HessianProtocolException("http code is " + conn.getStatusCode());
        }

        is = conn.getInputStream();

        if (log.isLoggable(Level.FINEST)) {
            PrintWriter dbg = new PrintWriter(new LogWriter(log));
            HessianDebugInputStream dIs = new HessianDebugInputStream(is, dbg);

            dIs.startTop2();

            is = dIs;
        }

        AbstractHessianInput in;

        int code = is.read();

        if (code == 'H') {
            int major = is.read();
            int minor = is.read();

            in = _factory.getHessian2Input(is);

            Object value = in.readReply(method.getReturnType());

            return value;
        } else if (code == 'r') {
            int major = is.read();
            int minor = is.read();

            in = _factory.getHessianInput(is);

            in.startReplyBody();

            Object value = in.readObject(method.getReturnType());

            if (value instanceof InputStream) {
                value = new ResultInputStream(conn, is, in, (InputStream) value);
                is = null;
                conn = null;
            } else
                in.completeReply();

            return value;
        } else
            throw new HessianProtocolException("'" + (char) code + "' is an unknown code");
    } catch (HessianProtocolException e) {
        throw new HessianRuntimeException(e);
    } finally {
        try {
            if (is != null)
                is.close();
        } catch (Exception e) {
            log.log(Level.FINE, e.toString(), e);
        }

        try {
            if (conn != null)
                conn.destroy();
        } catch (Exception e) {
            log.log(Level.FINE, e.toString(), e);
        }
    }
}

From source file:weavebytes.com.futureerp.activities.DashBoardActivity.java

public boolean isOnline() {
    ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo netInfo = cm.getActiveNetworkInfo();
    if (netInfo != null && netInfo.isConnected()) {
        try {// ww w  .java 2s .c o m
            URL url = new URL("http://www.google.com");
            HttpURLConnection urlc = (HttpURLConnection) url.openConnection();
            urlc.setConnectTimeout(2000);
            urlc.connect();
            if (urlc.getResponseCode() == 200) {
                return new Boolean(true);
            }
        } catch (MalformedURLException e1) {
            e1.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return false;
}

From source file:de.ingrid.iplug.excel.service.SheetsService.java

/**
 * Create sheets.//w  w  w.  j  a v  a  2  s.  c  om
 * 
 * @param inputStream
 * @return Created sheets.
 * @throws IOException
 */
public static Sheets createSheets(final InputStream inputStream) throws IOException {
    // sheets
    final Sheets sheets = new Sheets();
    // create workbook
    final Workbook workbook = new HSSFWorkbook(inputStream);
    final FormulaEvaluator eval = new HSSFFormulaEvaluator((HSSFWorkbook) workbook);
    for (int sheetNum = 0; sheetNum < workbook.getNumberOfSheets(); sheetNum++) {
        final org.apache.poi.ss.usermodel.Sheet poiSheet = workbook.getSheetAt(sheetNum);
        // ingrid sheet
        final Sheet sheet = new Sheet();
        sheet.setSheetIndex(sheetNum);
        sheets.addSheet(sheet);
        final Values values = new Values();
        sheet.setValues(values);
        for (final org.apache.poi.ss.usermodel.Row poiRow : poiSheet) {
            boolean hasValues = false;
            final Map<Point, Comparable<? extends Object>> valuesInCell = new HashMap<Point, Comparable<? extends Object>>();
            for (final Cell poiCell : poiRow) {

                Comparable<? extends Object> value = null;
                switch (poiCell.getCellType()) {
                case Cell.CELL_TYPE_BOOLEAN:
                    value = new Boolean(poiCell.getBooleanCellValue());
                    break;
                case Cell.CELL_TYPE_NUMERIC:
                    if (DateUtil.isCellDateFormatted(poiCell)) {
                        value = getFormattedDateString(poiCell);
                    } else {
                        value = new Double(poiCell.getNumericCellValue());
                    }
                    break;
                case Cell.CELL_TYPE_STRING:
                    value = poiCell.getStringCellValue();
                    break;
                case Cell.CELL_TYPE_FORMULA:
                    value = calculateFormula(poiCell, eval);
                    break;
                default:
                    value = "";
                    break;
                }
                // trim strings
                if (value instanceof String) {
                    value = ((String) value).trim();
                }
                // only add if at least one value does exist in row
                if (!value.equals("")) {
                    hasValues = true;
                    // ingrid column
                    if (sheet.getColumn(poiCell.getColumnIndex()) == null) {
                        final Column column = new Column(poiCell.getColumnIndex());
                        sheet.addColumn(column);
                    }
                }

                // ingrid point and value
                final Point point = new Point(poiCell.getColumnIndex(), poiCell.getRowIndex());
                valuesInCell.put(point, value);
            }
            // ingrid row
            // ! only add if at least one value does exist
            if (hasValues) {
                final Row row = new Row(poiRow.getRowNum());
                sheet.addRow(row);
                for (final Point point : valuesInCell.keySet()) {
                    //
                    if (sheet.getColumn(point.getX()) != null) {
                        values.addValue(point, valuesInCell.get(point));
                    }
                }
            }
        }
    }

    return sheets;
}

From source file:de.helmholtz_muenchen.ibis.utils.threads.ExecuteThread.java

/**
 * Starts to run the command in a new thread and catches STDOUT and STDERR
 *//*from w  ww. j av  a  2  s .  c o m*/
@Override
public Boolean call() throws Exception {
    LOGGER.info("Running command: " + getCommandEscaped(this.command));
    HTEOutStr.append("Running command: " + getCommandEscaped(this.command) + "\n");

    //Start the process
    if (this.command.length == 1) {
        p = Runtime.getRuntime().exec(this.command[0], this.ENVIRONMENT);
    } else {
        try {
            p = Runtime.getRuntime().exec(this.command, this.ENVIRONMENT);
        } catch (Exception e) {
            System.err.println(e.getMessage());
            e.printStackTrace();
        }
    }

    stdErrStream = new StreamThread(p.getErrorStream(), stdErrFile, this.stdErrStr);
    stdErrStream.start();

    stdOutStream = new StreamThread(p.getInputStream(), stdOutFile, this.stdOutStr);
    stdOutStream.start();

    if (this.stdInFile != null) {
        stdInStream = new InputThread(p.getOutputStream(), stdInFile);
        stdInStream.start();
    }
    // WAIT FOR PROCESS TO BE FINISHED
    p.waitFor();

    // INTERRUPT STREAMS
    if (this.stdInFile != null) {
        stdInStream.interrupt();
    }

    stdErrStream.interrupt();
    stdOutStream.interrupt();

    LOGGER.info("finished command " + command[0]);
    HTEOutStr.append("finished command " + command[0] + "\n");

    return new Boolean(p.exitValue() == 0);
}

From source file:it.cnr.icar.eric.client.ui.thin.components.renderkit.SearchRegistryMenuTreeRenderer.java

public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
    try {//from   www .  ja  v a2s . c  o  m
        Graph graph = null;
        // Acquire the root node of the graph representing the menu
        graph = (Graph) ((GraphComponent) component).getValue();
        if (graph == null) {
            throw new FacesException(WebUIResourceBundle.getInstance().getString("excGraphNotLocated"));
        }
        Node root = graph.getRoot();
        if (root == null) {
            throw new FacesException(WebUIResourceBundle.getInstance().getString("excGraphNoRootNode"));
        }
        if (!root.hasChild()) {
            return; // Nothing to render
        }
        this.component = component;
        this.context = context;
        clientId = component.getClientId(context);
        imageLocation = getImagesLocation(context);

        treeClass = (String) component.getAttributes().get("graphClass");
        selectedClass = (String) component.getAttributes().get("selectedClass");
        unselectedClass = (String) component.getAttributes().get("unselectedClass");
        treeSelect = (String) component.getAttributes().get("treeSelect");

        showNoConcept = new Boolean(((String) component.getAttributes().get("showNoConcept"))).booleanValue();
        ResponseWriter writer = context.getResponseWriter();

        writer.write("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"");
        if (treeClass != null) {
            writer.write(" class=\"");
            writer.write(treeClass);
            writer.write("\"");
        }
        writer.write(">");
        writer.write("\n");

        int level = 0;
        encodeNode(writer, root, level, graph.getSelectedNodeDepth(), true);
        writer.write("<input type=\"hidden\" name=\"" + clientId + "\" />");
        writer.write("</table>");
        writer.write("\n");
    } catch (Throwable t) {
        String message = WebUIResourceBundle.getInstance().getString("searchPanelNotInitialized");
        log.error(message, t);
        message += " " + WebUIResourceBundle.getInstance().getString("registrySupport");
        FacesContext.getCurrentInstance().addMessage(null,
                new FacesMessage(FacesMessage.SEVERITY_ERROR, message, null));
    }
}

From source file:org.iwethey.forums.web.user.UserController.java

/**
 * Toggle binary settings. Requires a request parameter of "toggle" 
 * that contains the name of the property to toggle.
 *///from ww  w.  j  a v  a2  s.  c  o  m
public ModelAndView toggle(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    User user = (User) request.getAttribute(USER_ATTRIBUTE);

    String propName = RequestUtils.getStringParameter(request, "toggle", null);
    if (user != null && propName != null && !propName.equals("")) {
        BeanWrapper wrap = new BeanWrapperImpl(user);
        Boolean val = (Boolean) wrap.getPropertyValue(propName);

        wrap.setPropertyValue(propName, new Boolean(!val.booleanValue()));
        userManager.saveUserAttributes(user);
    }

    return new ModelAndView(new RedirectView(request.getHeader("referer")));
}

From source file:com.salesmanager.core.service.system.impl.dao.CentralMenuDao.java

public Collection<CentralGroup> loadAllCentralGroup() {

    try {/*from www .  ja va2 s  .c om*/
        List list = super.getSession().createCriteria(CentralGroup.class)
                .add(Restrictions.eq("centralGroupVisible", new Boolean(true)))
                .addOrder(org.hibernate.criterion.Order.asc("centralGroupPosition")).list();

        return list;
    } catch (RuntimeException re) {
        log.error("get failed", re);
        throw re;
    }
}