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:com.icesoft.faces.component.ext.taglib.Util.java

public static void addVisible(String visible, UIComponent panel) {
    if (visible != null) {
        if (isValueReference(visible)) {
            ValueBinding vb = Util.getValueBinding(visible);
            panel.setValueBinding("visible", vb);
        } else {/*from w ww.  jav a 2  s  .  c  om*/
            Boolean boolVisible = new Boolean(visible);
            panel.getAttributes().put("visible", boolVisible);

        }
    }
}

From source file:com.projity.util.ClassUtils.java

/**
 * Convert a Double to an Object of a given class
 * @param value Double value to convert//from ww w. ja va 2  s.  c o m
 * @param clazz Class the class to convert to
 * @return new object of the given class
 * @throws IllegalArgumentException if the value is not convertible to the class
 */
public static Object doubleToObject(Double value, Class clazz) {
    if (clazz == Boolean.class)
        return new Boolean(value.doubleValue() != 0.0);
    else if (clazz == Byte.class)
        return new Byte(value.byteValue());
    else if (clazz == Short.class)
        return new Short(value.shortValue());
    else if (clazz == Integer.class)
        return new Integer(value.intValue());
    else if (clazz == Long.class)
        return new Long(value.longValue());
    else if (clazz == Float.class)
        return new Float(value.floatValue());
    else if (clazz == Double.class)
        return value;
    else if (clazz == Money.class)
        return Money.getInstance(value.doubleValue());
    else if (clazz == Duration.class)
        return Duration.getInstanceFromDouble(value);
    else if (clazz == Work.class)
        return Work.getWorkInstanceFromDouble(value);

    throw new IllegalArgumentException("Class " + clazz + " cannot be converted from a Double");
}

From source file:com.sun.syndication.propono.blogclient.atomprotocol.AtomEntry.java

Entry copyToRomeEntry(ClientEntry entry) {
    if (id != null) {
        entry.setId(id);/*from   w  ww.j a va 2  s .  c o m*/
    }
    entry.setTitle(title);
    if (author != null) {
        com.sun.syndication.feed.atom.Person person = new com.sun.syndication.feed.atom.Person();
        person.setName(author.getName());
        person.setEmail(author.getEmail());
        person.setUrl(author.getUrl());
        List authors = new ArrayList();
        authors.add(person);
        entry.setAuthors(authors);
    }
    if (content != null) {
        com.sun.syndication.feed.atom.Content romeContent = new com.sun.syndication.feed.atom.Content();
        romeContent.setValue(content.getValue());
        romeContent.setType(content.getType());
        List contents = new ArrayList();
        contents.add(romeContent);
        entry.setContents(contents);
    }
    if (categories != null) {
        List romeCats = new ArrayList();
        for (Iterator iter = categories.iterator(); iter.hasNext();) {
            BlogEntry.Category cat = (BlogEntry.Category) iter.next();
            com.sun.syndication.feed.atom.Category romeCategory = new com.sun.syndication.feed.atom.Category();
            romeCategory.setTerm(cat.getId());
            romeCategory.setScheme(cat.getUrl());
            romeCategory.setLabel(cat.getName());
            romeCats.add(romeCategory);
        }
        entry.setCategories(romeCats);
    }
    entry.setPublished((publicationDate == null) ? new Date() : publicationDate);
    entry.setModified((modificationDate == null) ? new Date() : modificationDate);

    List modules = new ArrayList();
    AppModule control = new AppModuleImpl();
    control.setDraft(new Boolean(draft));
    modules.add(control);
    entry.setModules(modules);

    return entry;
}

From source file:com.trailmagic.image.util.ImagesParserImpl.java

private void processCharacterData(String characterData, String currentElt) throws SAXException {
    if (m_inImage) {
        if (m_inManifestation) {
            if ("name".equals(currentElt)) {
                m_manifestation.setName(characterData);
            } else if ("height".equals(currentElt)) {
                m_manifestation.setHeight(Integer.parseInt(characterData));
            } else if ("width".equals(currentElt)) {
                m_manifestation.setWidth(Integer.parseInt(characterData));
            } else if ("format".equals(currentElt)) {
                m_manifestation.setFormat(characterData);
            } else if ("original".equals(currentElt)) {
                m_manifestation.setOriginal(new Boolean(characterData).booleanValue());
            }/* w w w. j  av a2  s .co  m*/
        } else if (m_inPhotoData) {
            Photo photo = (Photo) m_image;
            if ("roll-name".equals(currentElt)) {
                //                    photo.setRoll(getRollByName(characterData));
                // XXX: we should just use ImageGroup for this normally
                // so make sure the roll exists as an IG, then
                // XXX: borked if we don't have owner yet
                synchronized (hibernateTemplate) {
                    hibernateTemplate.flush();
                }

                m_photoRoll = imageGroupRepository.getRollByOwnerAndName(m_image.getOwner(),
                        characterData.trim());
                if (m_photoRoll == null) {
                    s_logger.info("No roll by the given name and owner "
                            + "found processing photo data, throwing" + " exception.");
                    throw new SAXException("Invalid or no roll name " + "specified: " + characterData
                            + " (for owner " + m_image.getOwner() + ")");
                }

            } else if ("frame-number".equals(currentElt)) {
                m_photoFrameNum = characterData;
            } else if ("notes".equals(currentElt)) {
                photo.setNotes(characterData);
            } else if ("capture-date".equals(currentElt)) {
                // XXX: use DateFormat
                SimpleDateFormat format = new SimpleDateFormat(DATE_PATTERN);
                try {
                    photo.setCaptureDate(format.parse(characterData));
                } catch (ParseException e) {
                    s_logger.warn("Error parsing capture-date: " + e.getMessage());
                }
            }
        } else {
            if ("name".equals(currentElt)) {
                m_image.setName(characterData);
            } else if ("display-name".equals(currentElt)) {
                m_image.setDisplayName(characterData);
            } else if ("caption".equals(currentElt)) {
                m_image.setCaption(characterData);
            } else if ("copyright".equals(currentElt)) {
                m_image.setCopyright(characterData);
            } else if ("creator".equals(currentElt)) {
                m_image.setCreator(characterData);
            } else if ("owner".equals(currentElt)) {
                String ownerName = characterData;
                m_image.setOwner(userRepository.getByScreenName(ownerName));
            } else if ("number".equals(currentElt)) {
                m_image.setNumber(new Integer(characterData));
            }
        }
    } else if (m_inRoll) {
        if ("name".equals(currentElt)) {
            m_roll.setName(characterData);
        } else if ("display-name".equals(currentElt)) {
            m_roll.setDisplayName(characterData);
        } else if ("description".equals(currentElt)) {
            m_roll.setDescription(characterData);
        } else if ("owner".equals(currentElt)) {
            String ownerName = characterData;
            m_roll.setOwner(userRepository.getByScreenName(ownerName));
            s_logger.debug("set roll " + m_roll.getName() + " owner to: " + m_roll.getOwner());
        }
    }
}

From source file:hermes.providers.messages.MessageImpl.java

public void setBooleanProperty(String arg0, boolean arg1) throws JMSException {
    header.put(arg0, new Boolean(arg1));
}

From source file:org.motechproject.mobile.omi.service.OMIServiceImplTest.java

@Test
public void testSendMessage() {
    System.out.println("sendMessage");

    MessageRequest msgReq1 = new MessageRequestImpl();
    msgReq1.setDateFrom(new Date());
    msgReq1.setDateTo(new Date());
    msgReq1.setId(19000000001l);//from  w  w  w.  java 2 s .c o m
    msgReq1.setTryNumber(1);
    msgReq1.setMessageType(MessageType.TEXT);
    msgReq1.setRecipientName("Tester");
    msgReq1.setRecipientNumber("000000000000");
    msgReq1.setStatus(MStatus.QUEUED);

    GatewayRequestImpl gwReq = new GatewayRequestImpl();
    gwReq.setGatewayRequestDetails(new GatewayRequestDetailsImpl());
    HashMap<Boolean, Set<GatewayResponse>> respMap = new HashMap<Boolean, Set<GatewayResponse>>();
    respMap.put(new Boolean(true), new HashSet<GatewayResponse>());

    expect(mockCore.createLanguageDAO()).andReturn(mockLangDao);
    expect(mockLangDao.getByCode((String) anyObject())).andReturn(new LanguageImpl());
    expect(mockCore.createMessageRequestDAO()).andReturn(mockRequestDao);

    expectLastCall();

    expect(mockRequestDao.save((MessageRequest) anyObject())).andReturn(new MessageRequestImpl());

    expect(mockStore.constructMessage((MessageRequest) anyObject(), (Language) anyObject())).andReturn(gwReq);
    expect(mockOMP.createMessagingService()).andReturn(mockMobileMessagingService);
    expect(mockMobileMessagingService.sendMessage((GatewayRequest) anyObject())).andReturn(respMap);

    expectLastCall();

    expect(mockRequestDao.save((MessageRequest) anyObject())).andReturn(new MessageRequestImpl());

    expectLastCall();

    replay(mockStore, mockOMP, mockMobileMessagingService, mockCore, mockRequestDao);
    instance.sendMessage(msgReq1);
    verify(mockStore, mockOMP, mockMobileMessagingService, mockCore, mockRequestDao);
}

From source file:edu.indiana.d2i.sloan.ui.LoginSuccessAction.java

/**
 * retrieve access token, refresh token and user info from WS IS
 *//*  w  ww.ja v  a 2  s  .c o m*/
@Override
public String execute() {
    String token = (String) ActionContext.getContext().getSession().get(Constants.SESSION_TOKEN);
    if (token == null) {
        try {
            OAuthAuthzResponse authzResponse = OAuthAuthzResponse.oauthCodeAuthzResponse(getServletRequest());
            String authzCode = authzResponse.getCode();
            if (authzCode == null) {
                logger.error("OAuth2 provider returned empty authorization code.");
                addActionError("OAuth2 provider returned empty authorization code.");
                return ERROR;
            }

            // set SSL
            if (!disableSSL())
                return ERROR;

            // get access token
            String webAppContext = getServerContext();
            String redirectUrl = webAppContext + "/LoginSuccessAction";
            OAuthClientRequest tokenRequest = OAuthClientRequest
                    .tokenLocation(PortalConfiguration.getOAuth2TokenEndpoint())
                    .setGrantType(GrantType.AUTHORIZATION_CODE)
                    .setClientId(PortalConfiguration.getOAuth2ClientID())
                    .setClientSecret(PortalConfiguration.getOAuth2ClientSecrete()).setRedirectURI(redirectUrl)
                    .setCode(authzCode).buildBodyMessage();

            OAuth2Client tokenClient = new OAuth2Client(new URLConnectionClient());
            OAuthClientResponse tokenResponse = tokenClient.accessToken(tokenRequest);
            String accessToken = tokenResponse.getParam(Constants.OAUTH2_ACCESS_TOKEN);
            String refreshToken = tokenResponse.getParam(Constants.OAUTH2_REFRESH_TOKEN);
            Long expireInSec = Long.valueOf(tokenResponse.getParam(Constants.OAUTH2_EXPIRE));

            // get user info

            // token relative stuffs
            session.put(Constants.SESSION_TOKEN, accessToken);
            session.put(Constants.SESSION_REFRESH_TOKEN, refreshToken);
            session.put(Constants.SESSION_TOKEN_EXPIRE_SEC, expireInSec);

            if (logger.isDebugEnabled()) {
                logger.debug("Access Token from Oauth2:" + accessToken);
            }

            // request userinfo
            OAuthClientRequest userInfoRequest = OAuthUserInfoRequest
                    .userInfoLocation(PortalConfiguration.getOAuth2UserinfoEndpoint())
                    .setClientId(PortalConfiguration.getOAuth2ClientID())
                    .setClientSecret(PortalConfiguration.getOAuth2ClientSecrete()).setAccessToken(accessToken)
                    .buildBodyMessage();
            OAuth2Client userInfoClient = new OAuth2Client(new URLConnectionClient());
            OAuthClientResponse userInfoResponse = userInfoClient.userInfo(userInfoRequest);
            String userName = userInfoResponse.getParam("authorized_user");

            if (userName == null || "".equals(userName)) {
                String errMsg = "Cannot obtain username from Oauth2";
                logger.error(errMsg);
                addActionError(errMsg);
                return ERROR;
            }

            if (logger.isDebugEnabled()) {
                logger.debug("Username from Oauth2:" + userName);
            }

            // user name
            session.put(Constants.SESSION_USERNAME, userName);

            // session cookie
            httpResponse.addCookie(new Cookie(Constants.SESSION_EXIST_BEFORE, "true")); // username
            session.put(Constants.SESSION_EXIST_BEFORE, new Boolean(false));

            return SUCCESS;
        } catch (OAuthProblemException e) {
            logger.error(e.getError(), e);
            addActionError(e.getError());
            return ERROR;
        } catch (OAuthSystemException e) {
            logger.error(e.getMessage(), e);
            addActionError(e.getMessage());
            return ERROR;
        } catch (IOException e) {
            logger.error(e.getMessage(), e);
            addActionError(e.getMessage());
            return ERROR;
        }
    }
    return SUCCESS;
}

From source file:gov.nist.appvet.toolmgr.ToolServiceAdapter.java

public ToolServiceAdapter(File configFile) {
    if (!configFile.exists()) {
        log.error("Test service config file " + configFile.getName() + " does not exist.");
        return;/*from w  ww  . jav a  2s . co m*/
    }
    XmlUtil xml = new XmlUtil(configFile);
    final String configFileName = configFile.getName();

    // Tool configuration
    name = xml.getXPathValue("/ToolServiceAdapter/Description/Name");
    checkNullString(configFileName, "name", name);
    id = xml.getXPathValue("/ToolServiceAdapter/Description/Id");
    checkNullString(configFileName, "id", id);
    vendorName = xml.getXPathValue("/ToolServiceAdapter/Description/VendorName");
    webSite = xml.getXPathValue("/ToolServiceAdapter/Description/VendorWebsite");
    // Report configuration  
    final String reportFileTypeString = xml.getXPathValue("/ToolServiceAdapter/Description/ReportFile");
    checkNullString(configFileName, "reportFileTypeString", reportFileTypeString);
    reportFileType = ReportFileType.getFileType(reportFileTypeString);
    reportName = getReportName();

    // Protocol config
    final String protocolName = xml.getXPathValue("/ToolServiceAdapter/Protocol/Type");
    checkNullString(configFileName, "protocolName", protocolName);
    protocol = Protocol.getProtocol(protocolName);
    String protocolXPath = "/ToolServiceAdapter/Protocol";
    switch (protocol) {
    case SYNCHRONOUS:
        protocolXPath += "/Synchronous";
        checkNullString(configFileName, "protocolXPath", protocolXPath);
        // HTTPRequestType
        URL = xml.getXPathValue(protocolXPath + "/Request/URL");
        checkNullString(configFileName, "URL", URL);
        method = xml.getXPathValue(protocolXPath + "/Request/Method");
        checkNullString(configFileName, "method", method);
        formParameterNames = xml.getXPathValues(protocolXPath + "/Request/Parameter/Name");
        checkNullArrayList(configFileName, "formParameterNames", formParameterNames);
        formParameterValues = xml.getXPathValues(protocolXPath + "/Request/Parameter/Value");
        checkNullArrayList(configFileName, "formParameterValues", formParameterValues);
        // HTTPResponseType
        appvetResultHeaderName = xml.getXPathValue(protocolXPath + "/Response/AppVetRiskHeaderName");
        String reportPayloadString = xml.getXPathValue(protocolXPath + "/Response/ReportPayload");
        reportPayload = new Boolean(reportPayloadString).booleanValue();
        break;
    case ASYNCHRONOUS:
        protocolXPath += "/Asynchronous";
        checkNullString(configFileName, "protocolXPath", protocolXPath);
        // HTTPRequestType
        URL = xml.getXPathValue(protocolXPath + "/Request/URL");
        checkNullString(configFileName, "URL", URL);
        method = xml.getXPathValue(protocolXPath + "/Request/Method");
        checkNullString(configFileName, "method", method);
        formParameterNames = xml.getXPathValues(protocolXPath + "/Request/Parameter/Name");
        checkNullArrayList(configFileName, "formParameterNames", formParameterNames);
        formParameterValues = xml.getXPathValues(protocolXPath + "/Request/Parameter/Value");
        checkNullArrayList(configFileName, "formParameterValues", formParameterValues);
        // HTTPResponseType (not used for asynchronous services)                  
        break;
    case PUSH:
        protocolXPath += "/Push";
        break;
    case INTERNAL:
        protocolXPath += "/Internal";
        break;
    }

    xml = null;
}

From source file:com.verisign.epp.codec.gen.EPPUtil.java

/**
 * Decode <code>Boolean</code>, by XML namespace and tag name, from an XML
 * Element. The children elements of <code>aElement</code> will be searched
 * for the specified <code>aNS</code> namespace URI and the specified
 * <code>aTagName</code>. The first XML element found will be decoded and
 * returned. If no element is found, <code>null</code> is returned.
 * /*from  w  ww. java 2  s .c  om*/
 * @param aElement
 *            XML Element to scan. For example, the element could be
 *            &ltdomain:create&gt
 * @param aNS
 *            XML namespace of the elements. For example, for domain element
 *            this is "urn:iana:xmlns:domain".
 * @param aTagName
 *            Tag name of the element including an optional namespace
 *            prefix. For example, the tag name for the domain name is
 *            "domain:name".
 * @return <code>Boolean</code> value if found; <code>null</code> otherwise.
 * @exception EPPDecodeException
 *                Error decoding <code>aElement</code>.
 */
public static Boolean decodeBoolean(Element aElement, String aNS, String aTagName) throws EPPDecodeException {
    Boolean retVal = null;
    String theVal = null;

    Element theElm = EPPUtil.getElementByTagNameNS(aElement, aNS, aTagName);

    if (theElm != null) {
        Node textNode = theElm.getFirstChild();

        // Element does have a text node?
        if (textNode != null) {
            theVal = textNode.getNodeValue();

            if (theVal.equalsIgnoreCase("true") || theVal.equals("1")) {
                retVal = new Boolean(true);
            } else {
                retVal = new Boolean(false);
            }
        } else {
            retVal = null;
        }
    }

    return retVal;
}

From source file:jetbrains.buildServer.buildTriggers.vcs.git.SNIHttpClientConnection.java

public void setInstanceFollowRedirects(boolean followRedirects) {
    this.followRedirects = new Boolean(followRedirects);
}