Example usage for java.lang Boolean getBoolean

List of usage examples for java.lang Boolean getBoolean

Introduction

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

Prototype

public static boolean getBoolean(String name) 

Source Link

Document

Returns true if and only if the system property named by the argument exists and is equal to, ignoring case, the string "true" .

Usage

From source file:gov.va.isaac.mojos.profileSync.ProfilesMojoBase.java

protected String getUsername() throws MojoExecutionException {
    if (username == null) {
        username = System.getProperty(PROFILE_SYNC_USERNAME_PROPERTY);

        //still blank, try property
        if (StringUtils.isBlank(username)) {
            username = profileSyncUsername;
        }/* ww  w . j  a  v a  2  s  . c  om*/

        //still no username, prompt if allowed
        if (StringUtils.isBlank(username) && !Boolean.getBoolean(PROFILE_SYNC_NO_PROMPTS)) {
            Callable<Void> callable = new Callable<Void>() {
                @Override
                public Void call() throws Exception {
                    if (!disableHintGiven) {
                        System.out.println("To disable remote sync during build, add '-D" + PROFILE_SYNC_DISABLE
                                + "=true' to your maven command");
                        disableHintGiven = true;
                    }

                    try {
                        System.out.println("Enter the " + config_.getChangeSetUrlType().name()
                                + " username for the Profiles/Changset remote store ("
                                + config_.getChangeSetUrl() + "):");
                        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                        username = br.readLine();
                    } catch (IOException e) {
                        throw new MojoExecutionException("Error reading username from console");
                    }
                    return null;
                }
            };

            try {
                Executors.newSingleThreadExecutor(new ThreadFactory() {
                    @Override
                    public Thread newThread(Runnable r) {
                        Thread t = new Thread(r, "User Prompt Thread");
                        t.setDaemon(true);
                        return t;
                    }
                }).submit(callable).get(2, TimeUnit.MINUTES);
            } catch (TimeoutException | InterruptedException e) {
                throw new MojoExecutionException("Username not provided within timeout");
            } catch (ExecutionException ee) {
                throw (ee.getCause() instanceof MojoExecutionException ? (MojoExecutionException) ee.getCause()
                        : new MojoExecutionException("Unexpected", ee.getCause()));
            }
        }
    }
    return username;
}

From source file:org.ejbca.config.ScepConfiguration.java

/**
 * Client Certificate Renewal is defined in the SCEP draft as the capability of a certificate enrollment request to be interpreted as a 
 * certificate renewal request if the previous certificate has passed half its validity. 
 * /*  www. ja va2  s.  com*/
 * @param alias A SCEP configuration alias
 * @return true of SCEP Client Certificate Renewal is enabled
 */
public boolean getClientCertificateRenewal(final String alias) {
    String key = alias + "." + SCEP_CLIENT_CERTIFICATE_RENEWAL;
    String value = getValue(key, alias);
    //Lazy initialization for SCEP configurations older than 6.3.1
    if (value == null) {
        data.put(alias + "." + SCEP_CLIENT_CERTIFICATE_RENEWAL, DEFAULT_CLIENT_CERTIFICATE_RENEWAL);
        return Boolean.getBoolean(DEFAULT_CLIENT_CERTIFICATE_RENEWAL);
    }
    return Boolean.valueOf(value);
}

From source file:cern.c2mon.shared.common.datatag.address.impl.HardwareAddressImpl.java

/**
 * Create a HardwareAddress object from its XML representation.
 *
 * @param pElement DOM element containing the XML representation of a HardwareAddress object, as created by the
 *                 toConfigXML() method.
 * @throws RuntimeException if unable to instantiate the Hardware address
 * @see cern.c2mon.shared.common.datatag.address.HardwareAddress#toConfigXML()
 *///from   w ww .j a v a2s. c  o  m
public final synchronized HardwareAddress fromConfigXML(Element pElement) {
    Class hwAddressClass = null;
    HardwareAddressImpl hwAddress = null;

    try {
        hwAddressClass = Class.forName(pElement.getAttribute("class"));
        hwAddress = (HardwareAddressImpl) hwAddressClass.newInstance();
    } catch (ClassNotFoundException cnfe) {
        cnfe.printStackTrace();
        throw new RuntimeException("Exception caught when instantiating a hardware address from XML", cnfe);
    } catch (IllegalAccessException iae) {
        iae.printStackTrace();
        throw new RuntimeException("Exception caught when instantiating a hardware address from XML", iae);
    } catch (InstantiationException ie) {
        ie.printStackTrace();
        throw new RuntimeException("Exception caught when instantiating a hardware address from XML", ie);
    }

    NodeList fields = pElement.getChildNodes();
    Node fieldNode = null;
    int fieldsCount = fields.getLength();
    String fieldName;
    String fieldValueString;
    String fieldTypeName = "";

    for (int i = 0; i < fieldsCount; i++) {
        fieldNode = fields.item(i);
        if (fieldNode.getNodeType() == Node.ELEMENT_NODE) {
            fieldName = fieldNode.getNodeName();

            if (fieldNode.getFirstChild() != null) {
                fieldValueString = fieldNode.getFirstChild().getNodeValue();
            } else {
                fieldValueString = "";
            }
            try {
                Field field = hwAddressClass.getDeclaredField(decodeFieldName(fieldName));
                fieldTypeName = field.getType().getName();

                if (fieldTypeName.equals("short")) {
                    field.setShort(hwAddress, Short.parseShort(fieldValueString));
                } else if (fieldTypeName.equals("java.lang.Short")) {
                    field.set(hwAddress, new Integer(Integer.parseInt(fieldValueString)));
                } else if (fieldTypeName.equals("int")) {
                    field.setInt(hwAddress, Integer.parseInt(fieldValueString));
                } else if (fieldTypeName.equals("java.lang.Integer")) {
                    field.set(hwAddress, new Integer(Integer.parseInt(fieldValueString)));
                } else if (fieldTypeName.equals("float")) {
                    field.setFloat(hwAddress, Float.parseFloat(fieldValueString));
                } else if (fieldTypeName.equals("java.lang.Float")) {
                    field.set(hwAddress, new Float(Float.parseFloat(fieldValueString)));
                } else if (fieldTypeName.equals("double")) {
                    field.setDouble(hwAddress, Double.parseDouble(fieldValueString));
                } else if (fieldTypeName.equals("java.lang.Double")) {
                    field.set(hwAddress, new Double(Double.parseDouble(fieldValueString)));
                } else if (fieldTypeName.equals("long")) {
                    field.setLong(hwAddress, Long.parseLong(fieldValueString));
                } else if (fieldTypeName.equals("java.lang.Long")) {
                    field.set(hwAddress, new Long(Long.parseLong(fieldValueString)));
                } else if (fieldTypeName.equals("byte")) {
                    field.setByte(hwAddress, Byte.parseByte(fieldValueString));
                } else if (fieldTypeName.equals("java.lang.Byte")) {
                    field.set(hwAddress, new Byte(Byte.parseByte(fieldValueString)));
                } else if (fieldTypeName.equals("char")) {
                    field.setChar(hwAddress, fieldValueString.charAt(0));
                } else if (fieldTypeName.equals("java.lang.Character")) {
                    field.set(hwAddress, new Character(fieldValueString.charAt(0)));
                } else if (fieldTypeName.equals("boolean")) {
                    field.setBoolean(hwAddress, Boolean.getBoolean(fieldValueString));
                } else if (fieldTypeName.equals("java.lang.Boolean")) {
                    field.set(hwAddress, new Boolean(Boolean.getBoolean(fieldValueString)));
                } else if (fieldTypeName.equals("java.util.HashMap")) {
                    field.set(hwAddress, SimpleXMLParser.domNodeToMap(fieldNode));
                } else if (field.getType().isEnum()) {
                    Object[] enumConstants = field.getType().getEnumConstants();
                    for (Object enumConstant : enumConstants) {
                        if (enumConstant.toString().equals(fieldValueString)) {
                            field.set(hwAddress, enumConstant);
                        }
                    }
                } else {
                    field.set(hwAddress, fieldValueString);
                }
            } catch (NoSuchFieldException nsfe) {
                String errorMsg = "fromConfigXML(...) - Error occured while parsing XML <HardwareAddress> tag. "
                        + "The following variable does not exist in " + hwAddressClass.toString() + ": \""
                        + decodeFieldName(fieldName) + "\"";
                log.error(errorMsg);
                throw new IllegalArgumentException(errorMsg);
            } catch (IllegalAccessException iae) {
                iae.printStackTrace();
                throw new RuntimeException(iae);
            } catch (NumberFormatException npe) {
                String errorMsg = "fromConfigXML(...) - Error occured while parsing XML <HardwareAddress> tag. Field \""
                        + fieldName + "\" shall not be empty since we expect a \"" + fieldTypeName
                        + "\" value. Please correct the XML configuration for " + hwAddressClass.toString();
                log.error(errorMsg);
                throw new IllegalArgumentException(errorMsg);
            }
        }
    }
    return hwAddress;
}

From source file:org.apache.maven.surefire.its.fixture.SurefireLauncher.java

public OutputValidator executeCurrentGoals() {

    String userLocalRepo = System.getProperty("user.localRepository");
    String testBuildDirectory = System.getProperty("testBuildDirectory");
    boolean useInterpolatedSettings = Boolean.getBoolean("useInterpolatedSettings");

    try {//from   w w w .j  av a 2  s  .c  o m
        if (useInterpolatedSettings) {
            File interpolatedSettings = new File(testBuildDirectory, "interpolated-settings");

            if (!interpolatedSettings.exists()) {
                // hack "a la" invoker plugin to download dependencies from local repo
                // and not download from central

                Map<String, String> values = new HashMap<String, String>(1);
                values.put("localRepositoryUrl", toUrl(userLocalRepo));
                StrSubstitutor strSubstitutor = new StrSubstitutor(values);

                String fileContent = FileUtils.fileRead(new File(testBuildDirectory, "settings.xml"));

                String filtered = strSubstitutor.replace(fileContent);

                FileUtils.fileWrite(interpolatedSettings.getAbsolutePath(), filtered);

            }

            cliOptions.add("-s " + interpolatedSettings.getCanonicalPath());
        }
        verifier.setCliOptions(cliOptions);

        verifier.executeGoals(goals, envvars);
        return surefireVerifier;
    } catch (IOException e) {
        throw new SurefireVerifierException(e.getMessage(), e);
    } catch (VerificationException e) {
        throw new SurefireVerifierException(e.getMessage(), e);
    } finally {
        verifier.resetStreams();
    }
}

From source file:com.github.mrstampy.esp.neurosky.MultiConnectionThinkGearSocket.java

/**
 * Connects to the ThinkGear socket on the local host. The system property
 * 'broadcast.messages' is used to enable/disable broadcasting for
 * {@link ThinkGearSocketConnector}s, and the system property
 * 'send.neurosky.messages' is used to enable/disable remote
 * {@link ThinkGearSocketConnector}s sending messages to the Neurosky device.
 * //w  ww. ja  v a  2  s  .  c  om
 * @throws IOException
 */
public MultiConnectionThinkGearSocket() throws IOException {
    this(LOCAL_HOST, Boolean.getBoolean(BROADCAST_MESSAGES), Boolean.getBoolean(SEND_NEUROSKY_MESSAGES));
}

From source file:org.geotools.data.wms.test.LocalGeoServerOnlineTest.java

public void testImgSample130() throws Exception {
    Layer water_bodies = find("topp:tasmania_water_bodies");
    assertNotNull("Img_Sample layer found", water_bodies);
    CRSEnvelope latLon = water_bodies.getLatLonBoundingBox();
    assertEquals("LatLonBoundingBox axis 0 name", "Geodetic longitude",
            axisName(latLon.getCoordinateReferenceSystem(), 0));
    assertEquals("LatLonBoundingBox axis 0 name", "Geodetic latitude",
            axisName(latLon.getCoordinateReferenceSystem(), 1));

    boolean globalXY = Boolean.getBoolean("org.geotools.referencing.forceXY");

    CRSEnvelope bounds = water_bodies.getBoundingBoxes().get("EPSG:4326");
    CoordinateReferenceSystem boundsCRS = bounds.getCoordinateReferenceSystem();
    if (globalXY) {
        // ensure WMS CRSEnvelope returned according to application globalXY setting
        assertEquals("EPSG:4326", AxisOrder.EAST_NORTH, CRS.getAxisOrder(boundsCRS));
    } else {//from   ww  w. j a  va 2 s .  c  om
        assertEquals("EPSG:4326", AxisOrder.NORTH_EAST, CRS.getAxisOrder(boundsCRS));
    }
    if (CRS.getAxisOrder(boundsCRS) == AxisOrder.EAST_NORTH) {
        assertEquals("axis order 0 min", latLon.getMinimum(1), bounds.getMinimum(1));
        assertEquals("axis order 1 min", latLon.getMinimum(0), bounds.getMinimum(0));
        assertEquals("axis order 1 max", latLon.getMaximum(0), bounds.getMaximum(0));
        assertEquals("axis order 1 min", latLon.getMaximum(1), bounds.getMaximum(1));
    }

    if (CRS.getAxisOrder(boundsCRS) == AxisOrder.NORTH_EAST) {
        assertEquals("axis order 0 min", latLon.getMinimum(1), bounds.getMinimum(0));
        assertEquals("axis order 1 min", latLon.getMinimum(0), bounds.getMinimum(1));
        assertEquals("axis order 1 max", latLon.getMaximum(0), bounds.getMaximum(1));
        assertEquals("axis order 1 min", latLon.getMaximum(1), bounds.getMaximum(0));
    }

    // GETMAP
    checkGetMap(wms, water_bodies, DefaultGeographicCRS.WGS84);
    checkGetMap(wms, water_bodies, CRS.decode("CRS:84"));
    checkGetMap(wms, water_bodies, CRS.decode("EPSG:4326"));
    checkGetMap(wms, water_bodies, CRS.decode("urn:x-ogc:def:crs:EPSG::4326"));

    // GETFEATURE INFO
    checkGetFeatureInfo(wms, water_bodies, DefaultGeographicCRS.WGS84);
    checkGetFeatureInfo(wms, water_bodies, CRS.decode("CRS:84"));
    checkGetFeatureInfo(wms, water_bodies, CRS.decode("EPSG:4326"));
    checkGetFeatureInfo(wms, water_bodies, CRS.decode("urn:x-ogc:def:crs:EPSG::4326"));
}

From source file:com.hypersocket.client.hosts.HostsFileManager.java

private synchronized void flushFile(boolean outputAliases) throws IOException {

    if (!outputAliases) {
        for (String alias : hostsToLoopbackAlias.values()) {
            aliasPool.addLast(alias);/*from w  ww  .  j  a  va 2s . c o  m*/
        }
        hostsToLoopbackAlias.clear();
    }

    if (Boolean.getBoolean("hypersocket.development")) {
        File tmp = File.createTempFile("hypersocket", ".tmp");
        writeFile(tmp, outputAliases);

        CommandExecutor cmd = new BashSilentSudoCommand(System.getProperty("sudo.password").toCharArray(), "mv",
                "-f", tmp.getAbsolutePath(), hostsFile.getAbsolutePath());

        if (cmd.execute() != 0) {
            throw new IOException("Could not flush localhost alias to " + hostsFile.getAbsolutePath());
        }
    } else {
        writeFile(hostsFile, outputAliases);
    }
}

From source file:org.commonreality.mina.service.ClientService.java

/**
 * @see org.commonreality.net.service.IClientService#stop(SocketAddress)
 *//*from w  ww.jav  a 2 s .com*/
public void stop(SocketAddress address) throws Exception {
    if (_connector == null) {
        if (LOGGER.isWarnEnabled())
            LOGGER.warn("Already stopped");
        return;
    }

    for (IoSession session : _connector.getManagedSessions().values())
        if (session.getRemoteAddress().equals(address))
            try {
                session.close(true).awaitUninterruptibly();
            } catch (Exception e) {
                if (LOGGER.isDebugEnabled())
                    LOGGER.debug("Exception while closing connection", e);
            }

    if (_connector != null)
        _connector.dispose();

    if (_actualExecutor != null && !Boolean.getBoolean("participant.useSharedThreads")) {
        _actualExecutor.shutdown();
        _actualExecutor = null;
    }

    _connector = null;
    _handler = null;
    _provider = null;
}

From source file:com.jkoolcloud.tnt4j.streams.configure.StreamsConfigLoader.java

/**
 * Loads the configuration XML using SAX parser.
 * <p>/*from   ww  w  . j a  v a2s.c om*/
 * Configuration XML validation against XSD schema is performed if system property
 * {@code com.jkoolcloud.tnt4j.streams.validate.config} is set to {@code true}.
 *
 * @param config
 *            input stream to get configuration data from
 * @throws SAXException
 *             if there was an error parsing the configuration
 * @throws ParserConfigurationException
 *             if there is an inconsistency in the configuration
 * @throws IOException
 *             if there is an error reading the configuration data
 * @see StreamsConfigSAXParser#parse(InputStream, boolean)
 */
protected void load(InputStream config) throws SAXException, ParserConfigurationException, IOException {
    boolean validate = Boolean.getBoolean("com.jkoolcloud.tnt4j.streams.validate.config");
    try {
        streamsCfgData = StreamsConfigSAXParser.parse(config, validate);
    } finally {
        Utils.close(config);
    }
}

From source file:org.jboss.errai.marshalling.rebind.util.MarshallingGenUtil.java

public static boolean isUseStaticMarshallers() {
    if (isForceStaticMarshallers())
        return true;

    if (EnvUtil.isDevMode() && !EnvUtil.isJUnitTest())
        return false;

    if (System.getProperty(USE_STATIC_MARSHALLERS) != null) {
        return Boolean.getBoolean(USE_STATIC_MARSHALLERS);
    }/*from w w  w  . java  2  s. c o m*/

    final Map<String, String> frameworkProperties = EnvUtil.getEnvironmentConfig().getFrameworkProperties();
    if (frameworkProperties.containsKey(USE_STATIC_MARSHALLERS)) {
        return "true".equals(frameworkProperties.get(USE_STATIC_MARSHALLERS));
    } else {
        return !EnvUtil.isDevMode();
    }
}