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:MBeanTyper.java

public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    if (MBeanTyper.DEBUG) {
        System.err.println("  ++ method=" + method.getName() + ",args=" + args);
    }//from   w w  w.j a  va 2s.c  o m
    try {
        if (method.getDeclaringClass() == Object.class) {
            String name = method.getName();
            if (name.equals("hashCode")) {
                return new Integer(this.hashCode());
            } else if (name.equals("toString")) {
                return this.toString();
            } else if (name.equals("equals")) {
                // FIXME: this needs to be reviewed - we should be
                // smarter about this ...
                return new Boolean(equals(args[0]));
            }
        } else if (isJMXAttribute(method) && (args == null || args.length <= 0)) {
            String name = method.getName().substring(3);
            return server.getAttribute(mbean, name);
        }

        String sig[] = (String[]) signatureCache.get(method);
        if (sig == null) {
            // get the method signature from the method argument directly
            // vs. the arguments passed, since there may be primitives that
            // are wrapped as objects in the arguments
            Class _args[] = method.getParameterTypes();
            if (_args != null && _args.length > 0) {
                sig = new String[_args.length];
                for (int c = 0; c < sig.length; c++) {
                    if (_args[c] != null) {
                        sig[c] = _args[c].getName();
                    }
                }
            } else {
                sig = new String[0];
            }
            signatureCache.put(method, sig);
        }
        return server.invoke(mbean, method.getName(), args, sig);
    } catch (Throwable t) {
        if (MBeanTyper.DEBUG) {
            t.printStackTrace();
        }
        if (t instanceof UndeclaredThrowableException) {
            UndeclaredThrowableException ut = (UndeclaredThrowableException) t;
            throw ut.getUndeclaredThrowable();
        } else if (t instanceof InvocationTargetException) {
            InvocationTargetException it = (InvocationTargetException) t;
            throw it.getTargetException();
        } else if (t instanceof MBeanException) {
            MBeanException me = (MBeanException) t;
            throw me.getTargetException();
        } else {
            throw t;
        }
    }
}

From source file:ch.entwine.weblounge.preview.imagemagick.ImageMagickPreviewGenerator.java

/**
 * {@inheritDoc}//from ww  w  .j  a va 2  s .  c o m
 * 
 * @see ch.entwine.weblounge.common.content.PreviewGenerator#supports(java.lang.String)
 */
public boolean supports(String format) {
    if (format == null)
        throw new IllegalArgumentException("Format cannot be null");

    if (!formatDecetionSupported)
        return true;

    // Check for verified support
    if (supportedFormats.containsKey(format))
        return supportedFormats.get(format);

    // Reach out to ImageMagick
    ConvertCmd imageMagick = new ConvertCmd();
    IMOperation op = new IMOperation();
    op.identify().list("format");
    try {
        final Pattern p = Pattern.compile("[\\s]+" + format.toUpperCase() + "[\\s]+rw");
        final Boolean[] supported = new Boolean[1];
        imageMagick.setOutputConsumer(new OutputConsumer() {
            public void consumeOutput(InputStream is) throws IOException {
                String output = IOUtils.toString(is);
                Matcher m = p.matcher(output);
                supported[0] = new Boolean(m.find());
            }
        });
        imageMagick.run(op);

        // Cache the result
        supportedFormats.put(format, supported[0]);

        return supported[0];
    } catch (Throwable t) {
        logger.warn("Error looking up formats supported by ImageMagick: {}", t.getMessage());
        formatDecetionSupported = false;
        logger.info("ImageMagick format lookup failed, assuming support for all formats");
        return true;
    }
}

From source file:io.nuun.plugin.configuration.common.ConfigurationMembersInjector.java

@Override
public void injectMembers(T instance) {
    NuunProperty injectConfigAnnotation = null;
    // The annotation is actual NuunProperty.class
    if (clonedAnno.annotationType() == NuunProperty.class) {
        injectConfigAnnotation = field.getAnnotation(NuunProperty.class);
    } else { // The annotation has the NuunProperty annotation on it we proxy it
        injectConfigAnnotation = AssertUtils.annotationProxyOf(NuunProperty.class, clonedAnno);
    }//from  w  ww. j  a  va2  s.c  o  m

    String configurationParameterName = injectConfigAnnotation.value();

    // Pre verification //
    if (StringUtils.isEmpty(configurationParameterName)) {
        log.error("Value for annotation {} on field {} can not be null or empty.", clonedAnno.annotationType(),
                field.toGenericString());
        throw new PluginException("Value for annotation %s on field %s can not be null or empty.",
                clonedAnno.annotationType(), field.toGenericString());
    }

    if (!configuration.containsKey(configurationParameterName) && injectConfigAnnotation.mandatory()) {
        throw new PluginException("\"%s\" must be in one properties file for field %s.",
                configurationParameterName, field.toGenericString());
    }

    try {
        this.field.setAccessible(true);
        Class<?> type = field.getType();
        if (type == Integer.TYPE) {
            if (configuration.containsKey(configurationParameterName)) {
                field.setInt(instance, configuration.getInt(configurationParameterName));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.setInt(instance, injectConfigAnnotation.defaultIntValue());
            }
        } else if (type == Integer.class) {
            if (configuration.containsKey(configurationParameterName)) {
                field.set(instance, new Integer(configuration.getInt(configurationParameterName)));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.set(instance, new Integer(injectConfigAnnotation.defaultIntValue()));
            }
        } else if (type == Boolean.TYPE) {
            if (configuration.containsKey(configurationParameterName)) {
                field.setBoolean(instance, configuration.getBoolean(configurationParameterName));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.setBoolean(instance, injectConfigAnnotation.defaultBooleanValue());
            }

        } else if (type == Boolean.class) {
            if (configuration.containsKey(configurationParameterName)) {
                field.set(instance, new Boolean(configuration.getBoolean(configurationParameterName)));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.set(instance, new Boolean(injectConfigAnnotation.defaultBooleanValue()));
            }

        } else if (type == Short.TYPE) {
            if (configuration.containsKey(configurationParameterName)) {
                field.setShort(instance, configuration.getShort(configurationParameterName));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.setShort(instance, injectConfigAnnotation.defaultShortValue());
            }
        } else if (type == Short.class) {
            if (configuration.containsKey(configurationParameterName)) {
                field.set(instance, new Short(configuration.getShort(configurationParameterName)));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.set(instance, new Short(injectConfigAnnotation.defaultShortValue()));
            }
        } else if (type == Byte.TYPE) {
            if (configuration.containsKey(configurationParameterName)) {
                field.setByte(instance, configuration.getByte(configurationParameterName));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.setByte(instance, injectConfigAnnotation.defaultByteValue());
            }
        } else if (type == Byte.class) {
            if (configuration.containsKey(configurationParameterName)) {
                field.set(instance, new Byte(configuration.getByte(configurationParameterName)));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.set(instance, new Byte(injectConfigAnnotation.defaultByteValue()));
            }
        } else if (type == Long.TYPE) {
            if (configuration.containsKey(configurationParameterName)) {
                field.setLong(instance, configuration.getLong(configurationParameterName));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.setLong(instance, injectConfigAnnotation.defaultLongValue());
            }
        } else if (type == Long.class) {
            if (configuration.containsKey(configurationParameterName)) {
                field.set(instance, new Long(configuration.getLong(configurationParameterName)));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.set(instance, new Long(injectConfigAnnotation.defaultLongValue()));
            }
        } else if (type == Float.TYPE) {
            if (configuration.containsKey(configurationParameterName)) {
                field.setFloat(instance, configuration.getFloat(configurationParameterName));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.setFloat(instance, injectConfigAnnotation.defaultFloatValue());
            }
        } else if (type == Float.class) {
            if (configuration.containsKey(configurationParameterName)) {
                field.set(instance, new Float(configuration.getFloat(configurationParameterName)));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.set(instance, new Float(injectConfigAnnotation.defaultFloatValue()));
            }
        } else if (type == Double.TYPE) {
            if (configuration.containsKey(configurationParameterName)) {
                field.setDouble(instance, configuration.getDouble(configurationParameterName));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.setDouble(instance, injectConfigAnnotation.defaultDoubleValue());
            }
        } else if (type == Double.class) {
            if (configuration.containsKey(configurationParameterName)) {
                field.set(instance, new Double(configuration.getDouble(configurationParameterName)));
            } else {
                log.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName);
                field.set(instance, new Double(injectConfigAnnotation.defaultDoubleValue()));
            }
        } else if (type == Character.TYPE) {
            if (configuration.containsKey(configurationParameterName)) {
                field.setChar(instance, configuration.getString(configurationParameterName).charAt(0));
            }
        } else if (type == Character.class) {
            if (configuration.containsKey(configurationParameterName)) {
                field.set(instance,
                        new Character(configuration.getString(configurationParameterName).charAt(0)));
            }
        } else {
            Object property = getProperty(configurationParameterName, injectConfigAnnotation);
            field.set(instance, property);
        }
    } catch (IllegalArgumentException ex) {
        log.error("Wrong argument or argument type during configuration injection", ex);
    } catch (IllegalAccessException ex) {
        log.error("Illegal access during configuration injection", ex);
    } catch (InstantiationException ex) {
        log.error("Impossible to instantiate value converter", ex);
    } finally {
        this.field.setAccessible(false);
    }
}

From source file:com.cyberway.issue.crawler.writer.WARCWriterProcessor.java

/**
 * @param name Name of this writer.//from   w w w  .  j av a  2s . c  o  m
 */
public WARCWriterProcessor(final String name) {
    super(name, "Experimental WARCWriter processor (Version 0.17)");
    Type e = addElementToDefinition(new SimpleType(ATTR_WRITE_REQUESTS,
            "Whether to write 'request' type records. " + "Default is true.", new Boolean(true)));
    e.setOverrideable(true);
    e.setExpertSetting(true);
    e = addElementToDefinition(new SimpleType(ATTR_WRITE_METADATA,
            "Whether to write 'metadata' type records. " + "Default is true.", new Boolean(true)));
    e.setOverrideable(true);
    e.setExpertSetting(true);
    e = addElementToDefinition(new SimpleType(ATTR_WRITE_REVISIT_FOR_IDENTICAL_DIGESTS,
            "Whether to write 'revisit' type records when a URI's "
                    + "history indicates the previous fetch had an identical " + "content digest. "
                    + "Default is true.",
            new Boolean(true)));
    e.setOverrideable(true);
    e.setExpertSetting(true);
    e = addElementToDefinition(
            new SimpleType(ATTR_WRITE_REVISIT_FOR_NOT_MODIFIED,
                    "Whether to write 'revisit' type records when a "
                            + "304-Not Modified response is received. " + "Default is true.",
                    new Boolean(true)));
    e.setOverrideable(true);
    e.setExpertSetting(true);
}

From source file:gov.nih.nci.cabig.caaers.web.ae.CaptureAdverseEventAjaxFacade.java

/**
 * Create AdverseEvent objects corresponding to the terms(listOfTermIDs).
 *  Add the following parameters to request :- 
 *     1. "index" - corresponds to begin (of AE).
 *     2. "ajaxView" - 'observedAdverseEventSection'
 *  //  w  w  w . j  a v a2 s.co  m
 * @param listOfTermIDs
 * @return
 */
public AjaxOutput addObservedAE(int[] listOfTermIDs) {

    AjaxOutput ajaxOutput = new AjaxOutput();

    CaptureAdverseEventInputCommand command = (CaptureAdverseEventInputCommand) extractCommand();

    int index = command.getAdverseEvents().size();

    List<Integer> filteredTermIDs = new ArrayList<Integer>();
    //filter off the terms that are already present
    for (int id : listOfTermIDs) {
        filteredTermIDs.add(id);
    }

    //
    if (filteredTermIDs.isEmpty())
        return ajaxOutput;

    boolean isMeddra = command.getAdverseEventReportingPeriod().getStudy().getAeTerminology()
            .getTerm() == Term.MEDDRA;
    Study study = studyDao.getById(command.getAdverseEventReportingPeriod().getStudy().getId());
    for (int id : filteredTermIDs) {
        AdverseEvent ae = new AdverseEvent();
        ae.setSolicited(false);
        ae.setRequiresReporting(false);
        ae.setGradedDate(new Date());

        if (isMeddra) {
            //populate MedDRA term
            LowLevelTerm llt = lowLevelTermDao.getById(id);
            AdverseEventMeddraLowLevelTerm aellt = new AdverseEventMeddraLowLevelTerm();
            aellt.setLowLevelTerm(llt);
            ae.setAdverseEventMeddraLowLevelTerm(aellt);
            aellt.setAdverseEvent(ae);
        } else {
            //properly set CTCterm
            CtcTerm ctc = ctcTermDao.getById(id);
            AdverseEventCtcTerm aeCtc = new AdverseEventCtcTerm();
            aeCtc.setCtcTerm(ctc);
            ae.setAdverseEventCtcTerm(aeCtc);
            aeCtc.setAdverseEvent(ae);
            if (study.isExpectedAdverseEventTerm(ctc)) {
                if (!ctc.isOtherRequired())
                    ae.setExpected(new Boolean(Boolean.TRUE));
            }
        }

        ae.setReportingPeriod(command.getAdverseEventReportingPeriod());
        command.getAdverseEvents().add(ae);
    }

    Map<String, String> params = new LinkedHashMap<String, String>(); // preserve order for testing
    //params.put("adverseEventReportingPeriod", "" + command.getAdverseEventReportingPeriod());
    params.put("index", Integer.toString(index));

    ajaxOutput.setHtmlContent(renderAjaxView("observedAdverseEventSection", 0, params));
    reportingPeriodDao.save(command.getAdverseEventReportingPeriod());
    return ajaxOutput;
}

From source file:com.aurel.track.admin.customize.scripting.GroovyScriptExecuter.java

/**
 *
 * @param eventNo//from   ww  w.  j  ava  2s.  co  m
 * @param inputBinding
 * @return
 */
public Map handleEvent(int eventNo, Map<String, Object> inputBinding) {
    Map returnBinding = null;// = new HashMap();
    inputBinding.put(BINDING_PARAMS.CONTINUE, new Boolean(true));
    inputBinding.put(BINDING_PARAMS.EVENT, new Integer(eventNo));
    if (eventNo >= IEventSubscriber.EVENT_ISSUE_BASE && eventNo < IEventSubscriber.EVENT_ISSUE_BASE + 1000) {
        if (GroovyScriptLoader.getInstance().doesGroovyClassExist(ITEM_SAVE_HANDLER)) {
            returnBinding = executeGroovyHandler(ITEM_SAVE_HANDLER, inputBinding);
        }
    } else if (eventNo >= IEventSubscriber.EVENT_USER_BASE
            && eventNo < IEventSubscriber.EVENT_USER_BASE + 1000) {
        if (GroovyScriptLoader.getInstance().doesGroovyClassExist(EVENT_HANDLER_USER_CLASS)) {
            returnBinding = executeGroovyHandler(EVENT_HANDLER_USER_CLASS, inputBinding);
        }
    } else if (eventNo >= IEventSubscriber.EVENT_PROJECT_BASE
            && eventNo < IEventSubscriber.EVENT_PROJECT_BASE + 1000) {
        if (GroovyScriptLoader.getInstance().doesGroovyClassExist(EVENT_HANDLER_PROJECT_CLASS)) {
            returnBinding = executeGroovyHandler(EVENT_HANDLER_PROJECT_CLASS, inputBinding);
        }
    } else if (eventNo >= IEventSubscriber.EVENT_SYSTEM_BASE
            && eventNo < IEventSubscriber.EVENT_SYSTEM_BASE + 1000) {
        if (GroovyScriptLoader.getInstance().doesGroovyClassExist(EVENT_HANDLER_SYSTEM_CLASS)) {
            returnBinding = executeGroovyHandler(EVENT_HANDLER_SYSTEM_CLASS, inputBinding);
        }
    }
    if (returnBinding == null || returnBinding.get(BINDING_PARAMS.CONTINUE) == null
            || !returnBinding.get(BINDING_PARAMS.CONTINUE).getClass().equals(Boolean.class)) {
        if (returnBinding != null) {
            LOGGER.warn("Problem with Groovy EventHandler returnBinding type: is not Boolean");
        }
        returnBinding = new HashMap();
        returnBinding.put(BINDING_PARAMS.CONTINUE, new Boolean(true)); // default
        // is
        // to
        // proceed
        // with
        // operation
    }
    return returnBinding;
}

From source file:es.caib.seycon.ng.servei.XarxaServiceImpl.java

protected Boolean handleTeXarxaAdministrada() throws Exception {
    Usuari usuari = getUsuariService().getCurrentUsuari();
    Collection codisXarxa = getCodiXarxesAmbAccesAdministracio(usuari.getCodi());
    return new Boolean(codisXarxa.size() > 0);
}

From source file:net.jradius.server.TCPListener.java

public void setConfiguration(ListenerConfigurationItem cfg, boolean noKeepAlive)
        throws KeyStoreException, NoSuchAlgorithmException, CertificateException, UnrecoverableKeyException,
        KeyManagementException, IOException {
    keepAlive = !noKeepAlive;/*from w w w .  j  a  v  a 2 s  .  c  om*/
    config = cfg;

    Map props = config.getProperties();

    String s = (String) props.get("port");
    if (s != null)
        port = new Integer(s).intValue();

    s = (String) props.get("backlog");
    if (s != null)
        backlog = new Integer(s).intValue();

    if (keepAlive) {
        s = (String) props.get("keepAlive");
        if (s != null)
            keepAlive = new Boolean(s).booleanValue();
    }

    String useSSL = (String) props.get("useSSL");
    String trustAll = (String) props.get("trustAll");

    if (requiresSSL || "true".equalsIgnoreCase(useSSL)) {
        KeyManager[] keyManagers = null;
        TrustManager[] trustManagers = null;

        String keyManager = (String) props.get("keyManager");

        if (keyManager != null && keyManager.length() > 0) {
            try {
                KeyManager manager = (KeyManager) Configuration.getBean(keyManager);
                keyManagers = new KeyManager[] { manager };
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else {
            String keystore = (String) props.get("keyStore");
            String keystoreType = (String) props.get("keyStoreType");
            String keystorePassword = (String) props.get("keyStorePassword");
            String keyPassword = (String) props.get("keyPassword");

            if (keystore != null) {
                if (keystoreType == null)
                    keystoreType = "pkcs12";

                KeyStore ks = KeyStore.getInstance(keystoreType);
                ks.load(new FileInputStream(keystore),
                        keystorePassword == null ? null : keystorePassword.toCharArray());

                KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
                kmf.init(ks, keyPassword == null ? null : keyPassword.toCharArray());
                keyManagers = kmf.getKeyManagers();
            }
        }

        String trustManager = (String) props.get("trustManager");

        if (trustManager != null && trustManager.length() > 0) {
            try {
                TrustManager manager = (TrustManager) Configuration.getBean(trustManager);
                trustManagers = new TrustManager[] { manager };
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if ("true".equalsIgnoreCase(trustAll)) {
            trustManagers = new TrustManager[] { new X509TrustManager() {
                public void checkClientTrusted(X509Certificate[] chain, String authType) {

                }

                public void checkServerTrusted(X509Certificate[] chain, String authType) {

                }

                public X509Certificate[] getAcceptedIssuers() {
                    return new X509Certificate[0];
                }
            } };
        } else {
            String keystore = (String) props.get("caStore");
            String keystoreType = (String) props.get("caStoreType");
            String keystorePassword = (String) props.get("caStorePassword");

            if (keystore != null) {
                if (keystoreType == null)
                    keystoreType = "pkcs12";

                KeyStore caKeys = KeyStore.getInstance(keystoreType);
                caKeys.load(new FileInputStream(keystore),
                        keystorePassword == null ? null : keystorePassword.toCharArray());
                TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
                tmf.init(caKeys);
                trustManagers = tmf.getTrustManagers();
            }
        }

        SSLContext sslContext = SSLContext.getInstance("SSLv3");
        sslContext.init(keyManagers, trustManagers, null);

        ServerSocketFactory socketFactory = sslContext.getServerSocketFactory();
        SSLServerSocket sslServerSocket = (SSLServerSocket) socketFactory.createServerSocket(port, backlog);
        serverSocket = sslServerSocket;

        if (sslWantClientAuth)
            sslServerSocket.setWantClientAuth(true);

        if (sslNeedClientAuth)
            sslServerSocket.setNeedClientAuth(true);

        if (sslEnabledProtocols != null)
            sslServerSocket.setEnabledProtocols(sslEnabledProtocols);

        if (sslEnabledCiphers != null)
            sslServerSocket.setEnabledCipherSuites(sslEnabledCiphers);

        usingSSL = true;
    } else {
        serverSocket = new ServerSocket(port, backlog);
    }

    serverSocket.setReuseAddress(true);
    setActive(true);
}

From source file:com.adito.webforwards.webforwardwizard.forms.WebForwardSpecificDetailsForm.java

public void apply(AbstractWizardSequence sequence) throws Exception {
    super.apply(sequence);
    sequence.putAttribute(ATTR_DESTINATION_URL, this.destinationURL);
    sequence.putAttribute(ATTR_CATEGORY, this.category);
    sequence.putAttribute(ATTR_ENCODEING, this.encoding);
    sequence.putAttribute(ATTR_PATHS, this.paths);
    sequence.putAttribute(ATTR_ACTIVE_DNS, new Boolean(this.activeDNS));
    sequence.putAttribute(ATTR_HOST_HEADER, activeDNS ? "" : this.hostHeader);
    sequence.putAttribute(ATTR_CUSTOM_HEADERS, this.customHeaders);
    sequence.putAttribute(ATTR_RESTRICT_TO_HOSTS, restrictToHosts);
}

From source file:gate.DocumentFormat.java

public void setShouldCollectRepositioning(Boolean b) {
    if (supportsRepositioning().booleanValue() && b.booleanValue()) {
        shouldCollectRepositioning = b;/*from   w w  w .  j a  v  a2 s  .c o m*/
    } else {
        shouldCollectRepositioning = new Boolean(false);
    } // if
}