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:net.kamhon.ieagle.function.user.vo.UserMenu.java

@Transient
public String getAcrud() {
    if (StringUtils.isBlank(accessCode)) {
        return "";
    }/*w  w w.  ja  v  a 2  s  .  co  m*/

    Boolean t = new Boolean(true);

    String s = "";
    s += t.equals(adminMode) ? "Y" : "N";
    s += t.equals(createMode) ? "Y" : "N";
    s += t.equals(readMode) ? "Y" : "N";
    s += t.equals(updateMode) ? "Y" : "N";
    s += t.equals(deleteMode) ? "Y" : "N";

    return s;
}

From source file:com.redhat.lightblue.metadata.mongo.BSONParser.java

private static Object convertValue(JsonNode node) {
    if (node instanceof BigIntegerNode) {
        return node.bigIntegerValue();
    } else if (node instanceof BooleanNode) {
        return new Boolean(node.asBoolean());
    } else if (node instanceof DecimalNode) {
        return node.decimalValue();
    } else if (node instanceof DoubleNode || node instanceof FloatNode) {
        return node.asDouble();
    } else if (node instanceof IntNode || node instanceof LongNode || node instanceof ShortNode) {
        return node.asLong();
    }/*  ww  w. jav a 2  s . c o m*/
    return node.asText();
}

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   ww w  .j av  a 2 s  .  com*/
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:net.sf.morph.reflect.reflectors.BaseReflector.java

private boolean isReflectableInternal(Class reflectedType) {
    initialize();/*from  w  ww  .j av  a2  s  .com*/

    if (reflectedType == null) {
        throw new ReflectionException(
                "Cannot determine if a null reflectedType is reflectable; please supply a reflectedType to the "
                        + getClass().getName() + ".isReflectable method");
    }

    // try to pull the isReflectable information from the cache
    if (isCachingIsReflectableCalls()) {
        Boolean isReflectable = (Boolean) getReflectableCallCache().get(reflectedType);
        if (isReflectable != null) {
            return isReflectable.booleanValue();
        }
    }

    try {
        boolean isReflectable = isReflectableImpl(reflectedType);
        if (isCachingIsReflectableCalls()) {
            getReflectableCallCache().put(reflectedType, new Boolean(isReflectable));
        }
        return isReflectable;
    } catch (ReflectionException e) {
        throw e;
    } catch (Exception e) {
        if (e instanceof RuntimeException && !isWrappingRuntimeExceptions()) {
            throw (RuntimeException) e;
        }
        throw new ReflectionException(
                "Unable to determine if class '" + reflectedType.getClass().getName() + "' is reflectable", e);
    }
}

From source file:net.swas.explorer.httpprofile.DOProfile.java

/**
 * Retrieves URL of specific resource/*from w  w  w.j  a  v a  2s  .  c o m*/
 * @param resource resource is leaf node of application profile
 * @return URL
 * @throws SQLException 
 */
public String getUrlByResource(String resource) throws SQLException {

    String leafNode = resource;
    Boolean check = new Boolean(true);
    List<String> urlString = new ArrayList<String>();
    urlString.add(leafNode);

    while (check) {

        String sql_qry = "select parentid from pairs where name=?";
        PreparedStatement stmt = (PreparedStatement) cdb.prepareQuery(sql_qry);
        stmt.setString(1, resource);
        ResultSet rs = cdb.executeQuery(stmt);
        rs.next();
        int parentid = rs.getInt("parentid");

        if (parentid == 0) {
            check = false;
            break;
        }
        String sqlqry = "select name from pairs where id=?";
        PreparedStatement pstmt = (PreparedStatement) cdb.prepareQuery(sqlqry);
        pstmt.setLong(1, parentid);
        rs = cdb.executeQuery(pstmt);
        rs.next();

        String parentname = rs.getString("name");
        System.out.println("parent of " + resource + " is " + parentid + " with " + parentname);
        urlString.add(parentname);
        resource = parentname;
    }
    String url = "http://";
    for (int i = urlString.size() - 1; i >= 0; i--) {
        if (i == 0) {
            url = url + urlString.get(i);
        } else {
            url = url + urlString.get(i) + "/";
        }
    }
    System.out.println(url);
    return url;
}

From source file:com.htm.test.TaskParentInterfaceTest.java

/**
 * Test the creation of a task instance.</br>
 * In the corresponding task model all properties are set (priority, skipable etc.).
 * For assigning people to the task instance only logical people groups are used.
 *
 * @throws HumanTaskManagerException/* w  w w.ja  va 2s.c  o m*/
 */
@Test
public void createTaskInstance() throws HumanTaskManagerException {

    try {
        dataAccessRepository.beginTx();

        /* Set the the user name and password in the security context of spring */
        initSecurityContext(TASK_INITIATOR_USER_ID, TASK_INITIATOR_PASSWORD);

        /* Time before creation required for assertions */
        long timeBeforeTiCreation = Calendar.getInstance().getTimeInMillis();

        Timestamp expirationTime = new Timestamp(Calendar.getInstance().getTimeInMillis() + 5000);
        TaskParentInterface partenInterface = this.taskParentInterface;
        /* Create task instance */
        String tiid = partenInterface.createTaskInstance(TaskParentConnectorDummy.TASK_PARENT_ID,
                getCorrelationPropertyDummies(), TASK_MODEL_DUMMY_NAME_1, TASK_INSTANCE_DUMMY_NAME1,
                getInputDataDummy(), getAttachmentDummies(), expirationTime);
        /* Time after creation required for assertions */
        long timeAfterTiCreation = Calendar.getInstance().getTimeInMillis();

        ITaskModel taskModel = dataAccessRepository.getHumanTaskModel(TASK_MODEL_DUMMY_NAME_1);
        ITaskInstance resultTaskInstance = dataAccessRepository.getTaskInstance(tiid);

        /*
        * Assertions
        */
        assertEquals(TASK_INSTANCE_DUMMY_NAME1, resultTaskInstance.getName());
        assertEquals(ETaskInstanceState.READY, resultTaskInstance.getStatus());
        /*
        * Since we don't know exact time when the task instance was
        * transitioned to the READY state (i.e. activated) we have can only
        * specify an interval (it's the same with createdOn).
        */
        long activationTime = resultTaskInstance.getActivationTime().getTime();

        assertTrue(timeBeforeTiCreation <= activationTime && activationTime <= timeAfterTiCreation);
        long createdOnTime = resultTaskInstance.getCreatedOn().getTime();
        assertTrue(timeBeforeTiCreation <= createdOnTime && createdOnTime <= timeAfterTiCreation);
        assertEquals(expirationTime.getTime(), resultTaskInstance.getExpirationTime().getTime());

        assertEquals(TaskParentConnectorDummy.TASK_PARENT_ID, resultTaskInstance.getTaskParentId());

        /*
        * Priority, startBy, completeBy and skipable is determined while
        * task instance creation using xpath expressions. xpath expressions
        * are defined in the methods getPriorityQuery, getSkipableQuery
        * etc. in the class TaskInstanceDummyProvider. The evaluation
        * context is defined in the class TaskParentContextDummy
        */
        assertEquals("Compare priority.", Integer.valueOf(TaskParentContextDummy.PRIORITY).intValue(),
                resultTaskInstance.getPriority());
        try {
            assertEquals(XPathUtils.getTimestampFromString(TaskParentContextDummy.STARTBY),
                    resultTaskInstance.getStartBy());
        } catch (Exception e) {
            fail(e.getMessage());
        }
        try {
            assertEquals(XPathUtils.getTimestampFromString(TaskParentContextDummy.COMPLETEBY),
                    resultTaskInstance.getCompleteBy());
        } catch (Exception e) {
            fail(e.getMessage());
        }
        assertEquals(new Boolean(TaskParentContextDummy.SKIPABLE), resultTaskInstance.isSkipable());

        assertTrue(resultTaskInstance.getInput() instanceof Map<?, ?>);
        assertInputDummies(getInputDataDummy(), (Map<?, ?>) resultTaskInstance.getInput());

        /* The values for the presentation data that were set in the task model should be set here */
        assertEquals(taskModel.getPresentationModel().getTitle(), resultTaskInstance.getPresentationName());
        assertEquals(taskModel.getPresentationModel().getSubject(),
                resultTaskInstance.getPresentationSubject());
        assertEquals(taskModel.getPresentationModel().getDescription(),
                resultTaskInstance.getPresentationDescription());
        /*
        * The users are determined while task instance creation using xpath
        * expressions. The expressions are defined in the methods
        * getBusinessAdminQuery, getExcludedOwnerQuery etc. of this class.
        * The evaluation context is defined in getInputDataDummy
        */
        assertEquals(TASK_INITIATOR_USER_ID, resultTaskInstance.getTaskInitiator());
        assertUsers(getExpectedBusinessAdministrators(), resultTaskInstance.getBusinessAdministrators());
        assertUsers(getExpectedTaskStakeholders(), resultTaskInstance.getTaskStakeholders());
        /* potential owners are employees without interns */
        assertUsers(getExpectedPotentialOwners(), resultTaskInstance.getPotentialOwners());

        assertAttachments(TASK_INITIATOR_USER_ID, getAttachmentDummies(), resultTaskInstance.getAttachments());
        assertCorrelationProperties(getCorrelationPropertyDummies(),
                resultTaskInstance.getCorrelationProperties());

        assertEquals(ETaskInstanceState.READY, resultTaskInstance.getStatus());

        dataAccessRepository.commitTx();
    } catch (HumanTaskManagerException e) {
        dataAccessRepository.rollbackTx();
        throw e;
    } finally {
        dataAccessRepository.close();
    }
}

From source file:com.mockey.plugin.RequestInspectorDefinedByJson.java

/**
 * Based on type, method will extra validation rules and evaluate the
 * keyValues mapping.//from  w  w w .  j  av  a 2  s.  c o  m
 * 
 * @param type
 *            - Valid values are RULE_FOR_HEADERS or RULE_FOR_PARAMETERS
 * @param keyValues
 *            - An array of possible values associated to a key
 * @see #RULE_FOR_HEADERS
 * @see #RULE_FOR_PARAMETERS
 */
private void analyze(RequestRuleType ruleType, Map<String, String[]> keyValues) {

    // Validate parameters.
    try {

        // FOR PARAMETERs and HEADERs
        JSONArray parameterArray = this.json.getJSONArray(ruleType.toString());

        for (int i = 0; i < parameterArray.length(); i++) {
            JSONObject jsonRule = parameterArray.getJSONObject(i);

            this.totalRuleCount++;
            try {
                RequestRule requestRule = new RequestRule(jsonRule, ruleType);
                this.rulesDefinedForType.put(ruleType, new Boolean(true));
                if (RequestRuleType.RULE_TYPE_FOR_BODY.equals(ruleType)) {
                    String[] values = keyValues.get(RequestRuleType.RULE_TYPE_FOR_BODY.toString());
                    if (requestRule.evaluate(values)) {
                        addErrorMessage(ruleType, requestRule);
                    } else {
                        this.validRuleCount++;
                    }
                } else if (RequestRuleType.RULE_TYPE_FOR_URL.equals(ruleType)) {
                    String[] values = keyValues.get(RequestRuleType.RULE_TYPE_FOR_URL.toString());
                    if (requestRule.evaluate(values)) {
                        addErrorMessage(ruleType, requestRule);
                    } else {
                        this.validRuleCount++;
                    }
                } else {
                    // For HEADERS and PARAMETERS
                    if (requestRule.getKey() != null && requestRule.getKey().contains("*")) {
                        // We treat this as a wild-card.
                        Iterator<String> allKeys = keyValues.keySet().iterator();
                        List<String> allValues = new ArrayList<String>();
                        while (allKeys.hasNext()) {
                            String key = allKeys.next();
                            String[] vals = keyValues.get(key);
                            for (String v : vals) {
                                allValues.add(v);
                            }
                        }
                        // Get ALL values from all parameters, and evaluate. 
                        if (requestRule.evaluate(allValues.toArray(new String[allValues.size()]))) {
                            addErrorMessage(ruleType, requestRule);
                        } else {
                            this.validRuleCount++;
                        }
                    } else {
                        // We have non-null, and non-empty keys.
                        // Apply specific rules.
                        // Keys in RULES and INCOMING maps should 
                        // be case insensitive!
                        Iterator<String> allKeys = keyValues.keySet().iterator();
                        while (allKeys.hasNext()) {
                            String key = allKeys.next();
                            if (key.equalsIgnoreCase(requestRule.getKey())) {
                                String[] values = keyValues.get(key);
                                if (requestRule.evaluate(values)) {
                                    addErrorMessage(ruleType, requestRule);
                                } else {
                                    this.validRuleCount++;
                                }
                            }

                        }
                    }
                }

            } catch (RequestRuleException e) {
                addErrorMessage(ruleType, "Invalid JSON rule setup. " + e.getMessage());
            }

        }

    } catch (JSONException e) {

        // Not necessarily an error. Could be missing
        logger.debug(
                "Request Inspection JSON rules does not have rule defined for '" + ruleType.toString() + "'");
    }

}

From source file:org.openregistry.core.domain.jpa.JpaDisclosureSettingsForAddressImpl.java

/**
 * @see org.openregistry.core.domain.DisclosureSettingsForAddress#recalculate(java.lang.String, org.openregistry.core.service.DisclosureRecalculationStrategy)
 *///from  ww  w.  j a va2 s  .co m
public void recalculate(String disclosureCode,
        DisclosureRecalculationStrategy disclosureRecalculationStrategy) {
    Map<PropertyNames, Object> newValuesMap = new HashMap<PropertyNames, Object>();
    newValuesMap
            .put(PropertyNames.ADDRESS_LINES_IND,
                    new Boolean(this.addressLinesPublic
                            && disclosureRecalculationStrategy.isAddressLinesPublic(disclosureCode,
                                    this.addressType.getDescription(), this.affiliationType.getDescription())));
    newValuesMap.put(PropertyNames.ADDRESS_LINES_DATE, this.addressLinesDate);
    newValuesMap
            .put(PropertyNames.BUILDING_IND,
                    new Boolean(this.addressBuildingPublic
                            && disclosureRecalculationStrategy.isAddressBuildingPublic(disclosureCode,
                                    this.addressType.getDescription(), this.affiliationType.getDescription())));
    newValuesMap.put(PropertyNames.BUILDING_DATE, this.addressBuildingDate);
    newValuesMap
            .put(PropertyNames.REGION_IND,
                    new Boolean(this.addressRegionPublic
                            && disclosureRecalculationStrategy.isAddressRegionPublic(disclosureCode,
                                    this.addressType.getDescription(), this.affiliationType.getDescription())));
    newValuesMap.put(PropertyNames.REGION_DATE, this.addressRegionDate);
    this.initFromProperties(newValuesMap);
}

From source file:net.sf.ginp.setup.SetupManagerImpl.java

/**
 * @see net.sf.ginp.setup.SetupManager#validPicturesLoc(java.lang.String)
 *///from w  w  w.j  a  va  2s  . c o  m
public final Boolean validPicturesLoc(final String path) {
    File pathDir = new File(path);

    if (!pathDir.isDirectory()) {
        return new Boolean(false);
    }

    if (!pathDir.canWrite()) {
        return new Boolean(false);
    }

    if (!pathDir.canRead()) {
        return new Boolean(false);
    }

    return new Boolean(true);
}

From source file:PureImmediateStereo.java

public void init() {
    setLayout(new BorderLayout());

    // Preferred to use Stereo
    GraphicsConfigTemplate3D gct = new GraphicsConfigTemplate3D();
    gct.setStereo(GraphicsConfigTemplate3D.PREFERRED);

    GraphicsConfiguration config = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
            .getBestConfiguration(gct);//from  ww  w .  j a  v a  2s  . c  o  m

    canvas = new Canvas3D(config);
    Map map = canvas.queryProperties();

    stereoSupport = canvas.getStereoAvailable();

    if (stereoSupport) {
        System.out.println(
                "This machine support stereo, you should see a red cone on the left and green cone on the right.");
        // User can overide the above default behavior using
        // java3d property.
        String str = System.getProperty("j3d.sharedstereozbuffer", defaultSharedStereoZbuffer);
        sharedStereoZbuffer = (new Boolean(str)).booleanValue();
    } else {
        System.out.println("Stereo is not support, you should only see the left red cone.");
    }

    if (!canvas.getDoubleBufferAvailable()) {
        System.out.println("Double buffer is not support !");
    }

    // we must stop the Renderer in PureImmediate mode
    canvas.stopRenderer();
    add("Center", canvas);

    // Create the universe and viewing branch
    u = new SimpleUniverse(canvas);

    // This will move the ViewPlatform back a bit so the
    // objects in the scene can be viewed.
    u.getViewingPlatform().setNominalViewingTransform();

    // Start a new thread that will continuously render
    (new Thread(this)).start();
}