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:education.library.member.GenMember.java

/**
 * Sets onTime.//from w w w  .  j av a2 s.  c  o  m
 * 
 * @param onTime
 *            onTime
 */
public void setOnTime(boolean onTime) {
    setOnTime(new Boolean(onTime));
}

From source file:edu.illinois.enforcemop.examples.apache.pool.MethodCallPoolableObjectFactory.java

public boolean validateObject(final Object obj) {
    final MethodCall call = new MethodCall("validateObject", obj);
    methodCalls.add(call);//  w  w  w  . ja va2s  . c o m
    if (validateObjectFail) {
        throw new PrivateException("validateObject");
    }
    final boolean r = valid;
    call.returned(new Boolean(r));
    return r;
}

From source file:modelibra.designer.metaproperty.GenMetaProperty.java

/**
 * Sets increment./*ww w .ja  va  2 s  .  c o  m*/
 * 
 * @param increment
 *            increment
 */
public void setIncrement(boolean increment) {
    setIncrement(new Boolean(increment));
}

From source file:pl.softech.eav.domain.frame.FrameFactoryTest.java

@Test
@Transactional//w ww .j  a va  2  s.  com
public void testAttributes() {

    MyObject object = new MyObject(categoryRepository.findByIdentifier(cmis.getComputerCategory()), "MAUI");

    object.addValue(attributeRepository.findByIdentifier(new AttributeIdentifier("model")),
            new StringValue("Studio15"));

    object.addValue(attributeRepository.findByIdentifier(new AttributeIdentifier("os")),
            new DictionaryEntryValue(dictionaryEntryRepository.findByIdentifier(cmis.getWin7())));

    object.addValue(attributeRepository.findByIdentifier(new AttributeIdentifier("os")),
            new DictionaryEntryValue(dictionaryEntryRepository.findByIdentifier(cmis.getLinux())));

    object.addValue(attributeRepository.findByIdentifier(new AttributeIdentifier("for_sale")),
            new BooleanValue(false));

    Computer computer = frameFactory.frame(Computer.class, object);

    Assert.assertEquals("Studio15", computer.getModel());

    Assert.assertEquals(new Boolean(false), computer.isForSale());

    Assert.assertNull(computer.getDrive());

    List<String> oses = new LinkedList<>(
            Collections2.transform(computer.getOs(), new Function<DictionaryEntry, String>() {
                @Override
                public String apply(DictionaryEntry input) {
                    return input.getName();
                }
            }));

    Collections.sort(oses);

    Assert.assertEquals(2, oses.size());

    Iterator<String> it = oses.iterator();
    Assert.assertEquals("Linux", it.next());
    Assert.assertEquals("Windows 7", it.next());

    computer.setModel("Studio17");
    Assert.assertEquals("Studio17", computer.getModel());

    Assert.assertNull(computer.getVideo());
    computer.setVideo("Intel Acc");
    Assert.assertEquals("Intel Acc", computer.getVideo());
    computer.setVideo(null);
    Assert.assertNull(computer.getVideo());

    computer.setForSale(true);
    Assert.assertEquals(new Boolean(true), computer.isForSale());

    computer.addOs(dictionaryEntryRepository.findByIdentifier(cmis.getSolaris()));

    oses = new LinkedList<>(Collections2.transform(computer.getOs(), new Function<DictionaryEntry, String>() {
        @Override
        public String apply(DictionaryEntry input) {
            return input.getName();
        }
    }));

    Assert.assertEquals(3, oses.size());
    Collections.sort(oses);
    it = oses.iterator();
    Assert.assertEquals("Linux", it.next());
    Assert.assertEquals("Solaris", it.next());
    Assert.assertEquals("Windows 7", it.next());
}

From source file:com.sshtools.common.ui.SshToolsApplicationPanel.java

/**
 * Set an actions visible state//from   w ww.j a v  a  2s.c  o m
 *
 * @param name
 * @param visible
 */

public void setActionVisible(String name, boolean visible) {

    log.debug("Setting action '" + name + "' to visibility " + visible);

    actionsVisible.put(name, new Boolean(visible));

}

From source file:com.mm.yamingapp.core.MethodDescriptor.java

/**
 * Converts a parameter from JSON into a Java Object.
 * /*ww  w  .  j a va  2s .c om*/
 * @return TODO
 */
// TODO(damonkohler): This signature is a bit weird (auto-refactored). The obvious alternative
// would be to work on one supplied parameter and return the converted parameter. However, that's
// problematic because you lose the ability to call the getXXX methods on the JSON array.
@VisibleForTesting
static Object convertParameter(final JSONArray parameters, int index, Type type)
        throws JSONException, RpcError {
    try {
        // We must handle null and numbers explicitly because we cannot magically cast them. We
        // also need to convert implicitly from numbers to bools.
        if (parameters.isNull(index)) {
            return null;
        } else if (type == Boolean.class) {
            try {
                return parameters.getBoolean(index);
            } catch (JSONException e) {
                return new Boolean(parameters.getInt(index) != 0);
            }
        } else if (type == Long.class) {
            return parameters.getLong(index);
        } else if (type == Double.class) {
            return parameters.getDouble(index);
        } else if (type == Integer.class) {
            return parameters.getInt(index);
        } else {
            // Magically cast the parameter to the right Java type.
            return ((Class<?>) type).cast(parameters.get(index));
        }
    } catch (ClassCastException e) {
        throw new RpcError(
                "Argument " + (index + 1) + " should be of type " + ((Class<?>) type).getSimpleName() + ".");
    }
}

From source file:MDIApp.java

/*************************************************************************
 * METHODS/*from   w w  w. jav  a  2  s. c  o  m*/
 *************************************************************************/

public MDIApp() {
    super("Java Media Player");

    // Add the desktop pane
    setLayout(new BorderLayout());
    desktop = new JDesktopPane();
    desktop.setDoubleBuffered(true);
    add("Center", desktop);
    setMenuBar(createMenuBar());
    setSize(640, 480);
    setVisible(true);

    try {
        UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
    } catch (Exception e) {
        System.err.println("Could not initialize java.awt Metal lnf");
    }
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent we) {
            System.exit(0);
        }
    });

    Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, new Boolean(true));
}

From source file:org.hbird.business.commanding.CommandingChainTest.java

/**
 * Tests storage route for the parameter in-memory buffer (id 'cr3') 
 * Creates a test parameter and stores it in the in-memory buffer. 
 * /*from  w  w  w  .j a  va2 s  .  co m*/
 * @throws InterruptedException
 */
@Test
public void testParameterInMemoryBufferStorage() throws InterruptedException {
    //"activemq:topic:Parameters"
    Exchange exchange = new DefaultExchange(commandingChainContext);
    exchange.getIn().setBody(
            new StateParameter("TestParameter4", "Description of test parameter 4", null, new Boolean(true)));
    int parameterBufferParameterCount = parameterBuffer.getLatestParameterValue().size();
    producerTopicParameters.send(exchange);

    //Wait max ~4sec until one more message has been stored in the parameter in-memory buffer.
    for (int i = 4; parameterBuffer.getLatestParameterValue().size() < parameterBufferParameterCount + 1
            && i < 4096; i *= 2) {
        Thread.sleep(i);
    }

    assertEquals("In-memory parameter buffer contains wrong number of stored parameters.\n",
            parameterBufferParameterCount + 1, parameterBuffer.getLatestParameterValue().size());
}

From source file:com.googlecode.android_scripting.rpc.MethodDescriptor.java

/**
 * Converts a parameter from JSON into a Java Object.
 * /*from   www . j ava2s  . c o  m*/
 * @return TODO
 */
// TODO(damonkohler): This signature is a bit weird (auto-refactored). The obvious alternative
// would be to work on one supplied parameter and return the converted parameter. However, that's
// problematic because you lose the ability to call the getXXX methods on the JSON array.
@VisibleForTesting
static Object convertParameter(final JSONArray parameters, int index, Type type)
        throws JSONException, RpcError {
    try {
        // We must handle null and numbers explicitly because we cannot magically cast them. We
        // also need to convert implicitly from numbers to bools.
        if (parameters.isNull(index)) {
            return null;
        } else if (type == Boolean.class) {
            try {
                return parameters.getBoolean(index);
            } catch (JSONException e) {
                return new Boolean(parameters.getInt(index) != 0);
            }
        } else if (type == Long.class) {
            return parameters.getLong(index);
        } else if (type == Double.class) {
            return parameters.getDouble(index);
        } else if (type == Integer.class) {
            return parameters.getInt(index);
        } else if (type == Intent.class) {
            return buildIntent(parameters.getJSONObject(index));
        } else {
            // Magically cast the parameter to the right Java type.
            return ((Class<?>) type).cast(parameters.get(index));
        }
    } catch (ClassCastException e) {
        throw new RpcError(
                "Argument " + (index + 1) + " should be of type " + ((Class<?>) type).getSimpleName() + ".");
    }
}

From source file:org.dspace.app.webui.cris.controller.ResearcherPageDetailsController.java

@Override
public ModelAndView handleDetails(HttpServletRequest request, HttpServletResponse response) throws Exception {
    log.debug("Start handleRequest");
    Map<String, Object> model = new HashMap<String, Object>();

    Integer objectId = extractEntityId(request);
    if (objectId == -1) {
        response.sendError(HttpServletResponse.SC_NOT_FOUND, "Researcher page not found");
        return null;
    }/*from   w  ww. ja v  a  2 s  . c o  m*/

    ResearcherPage researcher = null;
    try {

        researcher = ((ApplicationService) applicationService).get(ResearcherPage.class, objectId);

    } catch (NumberFormatException e) {
    }

    if (researcher == null) {
        response.sendError(HttpServletResponse.SC_NOT_FOUND, "Researcher page not found");
        return null;
    }

    Context context = UIUtil.obtainContext(request);
    EPerson currUser = context.getCurrentUser();

    boolean isAdmin = AuthorizeManager.isAdmin(context);

    if (isAdmin || (currUser != null
            && (researcher.getEpersonID() != null && currUser.getID() == researcher.getEpersonID()))) {
        model.put("researcher_page_menu", new Boolean(true));
        model.put("authority_key", ResearcherPageUtils.getPersistentIdentifier(researcher));

        if (isAdmin) {
            AuthorityDAO dao = AuthorityDAOFactory.getInstance(context);
            long pendingItems = dao.countIssuedItemsByAuthorityValueInAuthority(RPAuthority.RP_AUTHORITY_NAME,
                    ResearcherPageUtils.getPersistentIdentifier(researcher));
            model.put("pendingItems", new Long(pendingItems));
        }
    }

    else if ((researcher.getStatus() == null || researcher.getStatus().booleanValue() == false)) {
        if (context.getCurrentUser() != null || Authenticate.startAuthentication(context, request, response)) {
            // Log the error
            log.info(LogManager.getHeader(context, "authorize_error",
                    "Only system administrator can access to disabled researcher page"));

            JSPManager.showAuthorizeError(request, response,
                    new AuthorizeException("Only system administrator can access to disabled researcher page"));
        }
        return null;
    }

    if (subscribeService != null) {
        boolean subscribed = subscribeService.isSubscribed(currUser, researcher);
        model.put("subscribed", subscribed);
        EPerson eperson = EPerson.findByNetid(context, researcher.getSourceID());
        if (eperson != null) {
            model.put("subscriptions", subscribeService.getSubscriptions(eperson));
        }
    }

    ModelAndView mvc = null;

    try {
        mvc = super.handleDetails(request, response);
    } catch (RuntimeException e) {
        log.error(e.getMessage(), e);
        return null;
    }

    mvc.getModel().putAll(model);
    mvc.getModel().put("researcher", researcher);
    mvc.getModel().put("exportscitations", ConfigurationManager.getProperty("exportcitation.options"));
    mvc.getModel().put("showStatsOnlyAdmin",
            ConfigurationManager.getBooleanProperty(SolrLogger.CFG_STAT_MODULE, "authorization.admin"));

    // Fire usage event.
    request.setAttribute("sectionid", StatsConfig.DETAILS_SECTION);
    new DSpace().getEventService()
            .fireEvent(new UsageEvent(UsageEvent.Action.VIEW, request, context, researcher));

    log.debug("end servlet handleRequest");

    return mvc;
}