Example usage for java.lang Boolean valueOf

List of usage examples for java.lang Boolean valueOf

Introduction

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

Prototype

public static Boolean valueOf(String s) 

Source Link

Document

Returns a Boolean with a value represented by the specified string.

Usage

From source file:com.etcc.csc.presentation.action.GetTollTagRetrieveVehicleAction.java

public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    DynaActionForm actionForm = (DynaActionForm) form;
    String vehicleIndex = request.getParameter("vehicleIndex");
    TagDTO tagDTO = retrieveVehicle(vehicleIndex, request);
    if (request.getAttribute("deleteAllowed") != null)
        request.removeAttribute("deleteAllowed");

    actionForm.set("licensePlate", tagDTO.getLicPlate());
    actionForm.set("licensePlateState", tagDTO.getLicState());
    actionForm.set("tempLicensePlate", Boolean.valueOf(tagDTO.isTemporaryLicPlate()));
    if (tagDTO.isTemporaryLicPlate()) {
        actionForm.set("tempLicensePlateExpireDate",
                new SimpleDateFormat("MM/dd/yyyy").format(tagDTO.getPlateExpirDate().getTime()));
    }// ww  w .j ava 2 s. c om
    actionForm.set("vehicleYear", tagDTO.getVehicleYear());
    actionForm.set("vehicleColor", tagDTO.getVehicleColor());
    actionForm.set("vehicleMake", tagDTO.getVehicleMake());
    actionForm.set("vehicleModel", tagDTO.getVehicleModel());
    actionForm.set("vehicleClassCode", tagDTO.getVehicleClassCode());
    actionForm.set("deleteVehicle", Boolean.valueOf(false));
    actionForm.set("vehicleIndexToModify", vehicleIndex);

    if (StringUtils.isEmpty(tagDTO.getTagId())) {
        System.out.println(
                "hi in gettolltag retrive vehilcle,tag value" + tagDTO.getTagId() + "deleteAllowed=yes");
        request.setAttribute("deleteAllowed", new String("yes"));
    } else if (Integer.parseInt(tagDTO.getTagId()) > 0) {
        System.out.println(
                "hi in gettolltag retrive vehilcle,tag value" + tagDTO.getTagId() + "deleteAllowed=no");
        request.setAttribute("deleteAllowed", new String("no"));
    }

    request.setAttribute("vehicleIndex", vehicleIndex);
    StateInterface si = (StateInterface) DelegateFactory.create(DelegateEnum.STATE_DELEGATE);
    VehicleInterface vi = (VehicleInterface) DelegateFactory.create(DelegateEnum.VEHICLE_DELEGATE);
    String localeStr = SessionUtil.getStrutsLocaleLang(request);
    request.setAttribute("states", si.getStates());
    Collection vehicleClasses = vi.getVehicleClasses(localeStr);
    request.setAttribute("vehicleClasses", vehicleClasses);
    setVehicleClassDesc((Map) request.getSession().getAttribute("savedVehicles"), vehicleClasses);

    return mapping.findForward("success");
}

From source file:com.mapviewer.business.UserRequestManager.java

/**
 * Generates a new menu depending on the request.
 *
 *
 * @param {HttpServletRequest} request/*from   w  w w.ja  va 2s  .c o  m*/
 * @param {HttpSession} session
 * @return Treenode
 */
public static TreeNode createNewRootMenu(HttpServletRequest request, HttpSession session)
        throws XMLFilesException {
    String solicitudWCS = request.getParameter("isWCS");//Indicates if the request is WCS or normal WMS
    String[] levelsSelected = null;
    if (Boolean.valueOf(solicitudWCS)) {
        //if it is wcs then we look for the parameter valoresDropDown
        //This is done becuase data can't be send directly throught get
        //in case we had three levels then ajax.js needs to be modified. 

        levelsSelected = StringAndNumbers.strArrayFromStringColon(request.getParameter("valoresDropDown"));
    } else {
        //if the request is not wcs then we obtain the layers that the user selected. 

        levelsSelected = request.getParameterValues("dropDownLevels");
    }
    //Obtain the menu of the user that is in session. 
    TreeNode rootMenu = (TreeNode) session.getAttribute("MenuDelUsuario");

    String[] selectedValues = ConvertionTools.convertObjectArrayToStringArray(levelsSelected);

    LayerMenuManagerSingleton menuManager = LayerMenuManagerSingleton.getInstance();
    boolean update = menuManager.refreshTree(false);//Search for any update on the XML files

    //If is the first time the user access the webpage then we 
    // return the default menu. 
    if (rootMenu == null || selectedValues == null || update) {
        rootMenu = menuManager.getRootMenu();
    }
    //If something goes wrong updating the menu, we return the default menu
    try {

        if (selectedValues != null) {
            rootMenu = HtmlTools.actualizaMenu(selectedValues, rootMenu);
        }

    } catch (Exception e) {
        System.out.println("ERROR!!!!! Building the menu in UserRequestmananger" + e.getMessage());
        rootMenu = menuManager.getRootMenu();
    }

    session.setAttribute("MenuDelUsuario", rootMenu);
    return rootMenu;
}

From source file:gobblin.runtime.listeners.EmailNotificationJobListener.java

@Override
public void onJobCompletion(JobContext jobContext) {
    JobState jobState = jobContext.getJobState();
    boolean alertEmailEnabled = Boolean
            .valueOf(jobState.getProp(ConfigurationKeys.ALERT_EMAIL_ENABLED_KEY, Boolean.toString(false)));
    boolean notificationEmailEnabled = Boolean.valueOf(
            jobState.getProp(ConfigurationKeys.NOTIFICATION_EMAIL_ENABLED_KEY, Boolean.toString(false)));

    // Send out alert email if the maximum number of consecutive failures is reached
    if (jobState.getState() == JobState.RunningState.FAILED) {
        int failures = jobState.getPropAsInt(ConfigurationKeys.JOB_FAILURES_KEY, 0);
        int maxFailures = jobState.getPropAsInt(ConfigurationKeys.JOB_MAX_FAILURES_KEY,
                ConfigurationKeys.DEFAULT_JOB_MAX_FAILURES);
        if (alertEmailEnabled && failures >= maxFailures) {
            try {
                EmailUtils.sendJobFailureAlertEmail(jobState.getJobName(), jobState.toString(), failures,
                        jobState);/*from   www  .  j  av a  2  s .com*/
            } catch (EmailException ee) {
                LOGGER.error("Failed to send job failure alert email for job " + jobState.getJobId(), ee);
            }
            return;
        }
    }

    if (notificationEmailEnabled) {
        try {
            EmailUtils.sendJobCompletionEmail(jobState.getJobId(), jobState.toString(),
                    jobState.getState().toString(), jobState);
        } catch (EmailException ee) {
            LOGGER.error("Failed to send job completion notification email for job " + jobState.getJobId(), ee);
        }
    }
}

From source file:net.anthonypoon.ngram.rollingregression.RollingRegressionReducer.java

@Override
protected void setup(Context context) throws IOException, InterruptedException {
    range = Integer.valueOf(context.getConfiguration().get("range", "3"));
    lowbound = Integer.valueOf(context.getConfiguration().get("lowbound"));
    upbound = Integer.valueOf(context.getConfiguration().get("upbound"));
    threshold = Integer.valueOf(context.getConfiguration().get("threshold", "0"));
    positiveOnly = Boolean.valueOf(context.getConfiguration().get("positive-only", "false"));
}

From source file:com.asual.summer.core.util.ClassUtils.java

public static Object newInstance(String clazz, Object... parameters)
        throws SecurityException, ClassNotFoundException {
    Class<?>[] classParameters = new Class[parameters == null ? 0 : parameters.length];
    for (int i = 0; i < classParameters.length; i++) {
        classParameters[i] = parameters[i].getClass();
    }/*from   w w  w  .  j a  v a 2s .c o m*/
    Object instance = null;
    try {
        instance = Class.forName(clazz).getConstructor(classParameters)
                .newInstance(parameters == null ? new Object[] {} : parameters.length);
    } catch (Exception e) {
        Constructor<?>[] constructors = Class.forName(clazz).getConstructors();
        for (Constructor<?> constructor : constructors) {
            Class<?>[] types = constructor.getParameterTypes();
            if (types.length == parameters.length) {
                Object[] params = new Object[parameters.length];
                for (int i = 0; i < parameters.length; i++) {
                    if (types[i] == boolean.class || types[i] == Boolean.class) {
                        params[i] = Boolean.valueOf(parameters[i].toString());
                    } else if (types[i] == int.class || types[i] == Integer.class) {
                        params[i] = Integer.valueOf(parameters[i].toString());
                    } else {
                        params[i] = types[i].cast(parameters[i]);
                    }
                }
                try {
                    instance = constructor.newInstance(params);
                    break;
                } catch (Exception ex) {
                    continue;
                }
            }
        }
    }
    return instance;
}

From source file:org.cleverbus.admin.web.console.ConsoleController.java

@RequestMapping("/console")
public String showConsole(@ModelAttribute("model") ModelMap model) {

    // this variable is set only if monitoring is switched on
    final String state = System.getProperty(JAVAMELODY_DISABLED);

    final Boolean monitoring = StringUtils.isEmpty(state) || Boolean.valueOf(state).equals(Boolean.TRUE);
    model.addAttribute("javamelody", monitoring);

    return VIEW_NAME;
}

From source file:com.watchrabbit.crawler.driver.util.AngularLoadingStrategy.java

@Override
public Predicate<WebDriver> hasFinishedProcessing() {
    return driver -> Boolean.valueOf(((JavascriptExecutor) driver).executeScript(ANGULAR_GUARD).toString());
}

From source file:net.cloudkit.enterprises.infrastructure.freemarker.method.CurrencyMethod.java

@SuppressWarnings("rawtypes")
public Object exec(List arguments) {
    if ((arguments != null) && (!arguments.isEmpty()) && (arguments.get(0) != null)
            && (StringUtils.isNotEmpty(arguments.get(0).toString()))) {
        boolean bool1 = false;
        boolean bool2 = false;
        if (arguments.size() == 2) {
            if (arguments.get(1) != null) {
                bool1 = Boolean.valueOf(arguments.get(1).toString()).booleanValue();
            }//  ww w .  ja va2s. c  om
        } else if (arguments.size() > 2) {
            if (arguments.get(1) != null) {
                bool1 = Boolean.valueOf(arguments.get(1).toString()).booleanValue();
            }
            if (arguments.get(2) != null) {
                bool2 = Boolean.valueOf(arguments.get(2).toString()).booleanValue();
            }
        }

        // BigDecimal.setScale()??
        // setScale(1)?????
        // setScale(1, BigDecimal.ROUND_DOWN)??2.35??2.3
        // setScale(1, BigDecimal.ROUND_UP)??2.35??2.4
        // setScale(1, BigDecimal.ROUND_HALF_UP)?2.35??2.4
        // setScale(1, BigDecimal.ROUND_HALF_DOWN)?2.35??2.35??
        BigDecimal localBigDecimal = new BigDecimal(arguments.get(0).toString());
        // newScale:PriceScale 2, roundingMode:PriceRoundType BigDecimal.ROUND_HALF_UP
        String str = localBigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).toString();
        // currencySign
        if (bool1) {
            str = "" + str;
        }
        // currencyUnit
        if (bool2) {
            str = str + "";
        }
        return new SimpleScalar(str);
    }
    return null;
}

From source file:org.jdal.aop.config.SerializableProxyBeanDefinitionDecorator.java

public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
    boolean proxyTargetClass = true;
    if (node instanceof Element) {
        Element ele = (Element) node;
        if (ele.hasAttribute(PROXY_TARGET_CLASS)) {
            proxyTargetClass = Boolean.valueOf(ele.getAttribute(PROXY_TARGET_CLASS));
        }/*from  w  w w .  ja v a2 s  . c o m*/
    }

    // Register the original bean definition
    BeanDefinitionHolder holder = SerializableProxyUtils.createSerializableProxy(definition,
            parserContext.getRegistry(), proxyTargetClass);
    String targetBeanName = SerializableProxyUtils.getTargetBeanName(definition.getBeanName());
    parserContext.getReaderContext().fireComponentRegistered(
            new BeanComponentDefinition(definition.getBeanDefinition(), targetBeanName));
    return holder;
}

From source file:com.googlecode.jtiger.modules.ecside.core.bean.TableDefaults.java

static Boolean isBufferView(TableModel model, Boolean bufferView) {
    if (bufferView == null) {
        return Boolean.valueOf(model.getPreferences().getPreference(PreferencesConstants.TABLE_BUFFER_VIEW));
    }/* w w w  . java2s. c o  m*/

    return bufferView;
}