Example usage for java.lang Boolean booleanValue

List of usage examples for java.lang Boolean booleanValue

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public boolean booleanValue() 

Source Link

Document

Returns the value of this Boolean object as a boolean primitive.

Usage

From source file:cn.caimatou.canting.utils.http.asynchttp.RetryHandler.java

@Override
public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
    boolean retry = true;

    Boolean b = (Boolean) context.getAttribute(ExecutionContext.HTTP_REQ_SENT);
    boolean sent = (b != null && b.booleanValue());

    if (executionCount > maxRetries) {
        // Do not retry if over max retry count
        retry = false;/*from w  w  w . j a v a 2  s. c o m*/
    } else if (isInList(exceptionBlacklist, exception)) {
        // immediately cancel retry if the error is blacklisted
        retry = false;
    } else if (isInList(exceptionWhitelist, exception)) {
        // immediately retry if error is whitelisted
        retry = true;
    } else if (!sent) {
        // for most other errors, retry only if request hasn't been fully sent yet
        retry = true;
    }

    if (retry) {
        // resend all idempotent requests
        HttpUriRequest currentReq = (HttpUriRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST);
        String requestType = currentReq.getMethod();
        retry = !requestType.equals("POST");
    }

    if (retry) {
        SystemClock.sleep(RETRY_SLEEP_TIME_MILLIS);
    } else {
        exception.printStackTrace();
    }

    return retry;
}

From source file:com.cyclopsgroup.waterview.web.ProcessFormValve.java

/**
 * Overwrite or implement method invoke()
 *
 * @see com.cyclopsgroup.waterview.spi.Valve#invoke(com.cyclopsgroup.waterview.RuntimeData, com.cyclopsgroup.waterview.spi.PipelineContext)
 *//*from  w w w  .  j av a 2s  . c  o  m*/
public void invoke(RuntimeData data, PipelineContext pc) throws Exception {
    Parameters params = data.getParameters();
    String formId = params.getString("form_id");
    Form form = null;
    if (StringUtils.isNotEmpty(formId)) {
        form = (Form) data.getSessionContext().get(formId);
    }

    if (form == null) {
        pc.invokeNextValve(data);
        return;
    }

    boolean hasError = false;
    Field[] fields = form.getFields();
    for (int i = 0; i < fields.length; i++) {
        Field field = fields[i];
        field.setValue(params.getString(field.getName()));
        field.validate();
        if (field.isPassword()) {
            field.setValue(StringUtils.EMPTY);
        }
        if (!hasError && field.isInvalid()) {
            hasError = true;
        }
    }
    if (hasError) {
        if (params.getBoolean("force_validation")) {
            fail(data, pc);
            return;
        }
    }
    pc.invokeNextValve(data);
    Boolean formInvalid = (Boolean) data.getRequestContext().get("formInvalid");
    if (formInvalid != null && formInvalid.booleanValue()) {
        Properties formErrors = (Properties) data.getRequestContext().get("formErrors");
        for (Iterator i = formErrors.keySet().iterator(); i.hasNext();) {
            String fieldName = (String) i.next();
            String errorMessage = formErrors.getProperty(fieldName);
            Field field = form.getField(fieldName);
            if (field != null) {
                field.setInvalid(true);
                if (StringUtils.isEmpty(errorMessage)) {
                    field.setErrorMessage("Invalid field value ");
                } else {
                    field.setErrorMessage(errorMessage);
                }
            }
        }
        if (params.getBoolean("force_validation")) {
            fail(data, pc);
        }
    }
}

From source file:com.elephant.http.RetryHandler.java

@Override
public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
    boolean retry = true;

    Boolean b = (Boolean) context.getAttribute(ExecutionContext.HTTP_REQ_SENT);
    boolean sent = (b != null && b.booleanValue());

    if (executionCount > maxRetries) {
        // Do not retry if over max retry count
        retry = false;// ww w  .  j  a v a 2  s. co  m
    } else if (isInList(exceptionBlacklist, exception)) {
        // immediately cancel retry if the error is blacklisted
        retry = false;
    } else if (isInList(exceptionWhitelist, exception)) {
        // immediately retry if error is whitelisted
        retry = true;
    } else if (!sent) {
        // for most other errors, retry only if request hasn't been fully
        // sent yet
        retry = true;
    }

    if (retry) {
        // resend all idempotent requests
        HttpUriRequest currentReq = (HttpUriRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST);
        String requestType = currentReq.getMethod();
        retry = !requestType.equals("POST");
    }

    if (retry) {
        SystemClock.sleep(RETRY_SLEEP_TIME_MILLIS);
    } else {
        exception.printStackTrace();
    }

    return retry;
}

From source file:com.vdisk.net.session.RetryHandler.java

public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
    boolean retry = true;

    Log.d("Test", "retry count->" + executionCount);

    Boolean b = (Boolean) context.getAttribute(ExecutionContext.HTTP_REQ_SENT);
    boolean sent = (b != null && b.booleanValue());

    if (executionCount > maxRetries) {
        // Do not retry if over max retry count
        retry = false;//from w w  w.jav  a2 s . c om
    } else if (exceptionBlacklist.contains(exception.getClass())) {
        // immediately cancel retry if the error is blacklisted
        retry = false;
    } else if (exceptionWhitelist.contains(exception.getClass())) {
        // immediately retry if error is whitelisted
        retry = true;
    } else if (!sent) {
        // for most other errors, retry only if request hasn't been fully sent yet
        retry = true;
    }

    if (retry) {
        // resend all idempotent requests
        HttpUriRequest currentReq = (HttpUriRequest) context.getAttribute(ExecutionContext.HTTP_REQUEST);

        Log.d("Test", "HttpUriRequest:" + currentReq);
        if (currentReq != null) {
            String requestType = currentReq.getMethod();
            retry = !requestType.equals("POST") && !requestType.equals("PUT");
        }

    }

    if (retry) {
        SystemClock.sleep(RETRY_SLEEP_TIME_MILLIS);
    } else {
        exception.printStackTrace();
    }

    return retry;
}

From source file:com.tonbeller.wcf.convert.BooleanConverter.java

/**
 * sets the selected attribute of the DOM element. If a modelReference
 * is specified, it must point to a boolean bean-property that will be updated.
 *
 * @param fmt Formatter for i18n string-object conversion
 * @param params parameters of http request
 * @param elem the target element./*  ww w  .  j  av a2s.  co m*/
 * @param bean the target bean
 */
public void convert(Formatter fmt, Map params, Map fileParams, Element elem, Object bean)
        throws FormatException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {

    int state = isSelected(elem, params);
    if (state == UNKNOWN)
        return;

    // was the checkbox checked?
    Boolean value = new Boolean(state == TRUE);

    // set into elem and bean
    DomUtils.removeAttribute(elem, "error");
    Item.setSelected(elem, value.booleanValue());

    // update bean
    String modelReference = Item.getModelReference(elem);
    if (bean != null && modelReference.length() > 0)
        PropertyUtils.setProperty(bean, Item.getModelReference(elem), value);
}

From source file:com.glaf.activiti.delegate.CancelAllTask.java

@Override
public void execute(ActivityExecution execution) throws Exception {
    logger.debug("----------------------------------------------------");
    logger.debug("------------------CancelAllTask---------------------");
    logger.debug("----------------------------------------------------");

    boolean executable = true;

    if (conditionExpression != null) {
        Object value = conditionExpression.getValue(execution);
        if (value != null) {
            logger.debug("condition:" + value);
            if (value instanceof Boolean) {
                Boolean b = (Boolean) value;
                executable = b.booleanValue();
            }//from ww w  . j a  v a2 s.  c  om
        }
    }

    if (!executable) {
        logger.debug("???false??");
        return;
    }

    String processInstanceId = execution.getProcessInstanceId();
    CommandContext commandContext = Context.getCommandContext();
    TaskQueryImpl taskQuery = new TaskQueryImpl();
    taskQuery.processInstanceId(processInstanceId);
    Page page = new Page(0, 10000);
    taskQuery.setFirstResult(page.getFirstResult());
    taskQuery.setMaxResults(page.getMaxResults());
    List<Task> tasks = commandContext.getTaskEntityManager().findTasksByQueryCriteria(taskQuery);
    if (tasks != null && !tasks.isEmpty()) {
        if (includes != null && includes.getValue(execution) != null) {
            String x_includes = (String) includes.getValue(execution);
            logger.debug("includes:" + x_includes);
            if (StringUtils.isNotEmpty(x_includes)) {
                if (StringUtils.equals(x_includes, "ALL")) {

                } else {
                    List<String> list = StringTools.split(x_includes);
                    for (String taskDefKey : list) {
                        for (Task task : tasks) {
                            if (StringUtils.equals(task.getTaskDefinitionKey(), taskDefKey)) {

                            }
                        }
                    }
                }
            }
        }
    }

    String name = null;
    if (outcomeVar != null) {
        name = (String) outcomeVar.getValue(execution);
    }

    if (name == null) {
        name = Constants.OUTCOME;
    }
    String outcome = (String) execution.getVariable(name);
    if (outcome != null) {
        PvmTransition transition = execution.getActivity().findOutgoingTransition(outcome);
        if (transition != null) {
            execution.take(transition);
        }
    } else {
        PvmTransition defaultOutgoingTransition = execution.getActivity().getOutgoingTransitions().get(0);
        execution.take(defaultOutgoingTransition);
    }

}

From source file:com.dongfang.net.http.RetryHandler.java

@Override
public boolean retryRequest(IOException exception, int retriedTimes, HttpContext context) {
    boolean retry = true;

    if (exception == null || context == null) {
        return false;
    }/* ww  w.  java  2  s . c  om*/

    Boolean b = (Boolean) context.getAttribute(ExecutionContext.HTTP_REQ_SENT);
    boolean sent = (b != null && b.booleanValue());

    if (retriedTimes > maxRetries) {
        retry = false;
    } else if (exceptionBlackList.contains(exception.getClass())) {
        retry = false;
    } else if (exceptionWhiteList.contains(exception.getClass())) {
        retry = true;
    } else if (!sent) {
        retry = true;
    }

    if (retry) {
        try {
            Object currRequest = context.getAttribute(ExecutionContext.HTTP_REQUEST);
            if (currRequest != null) {
                if (currRequest instanceof HttpRequestBase) {
                    HttpRequestBase requestBase = (HttpRequestBase) currRequest;
                    retry = "GET".equals(requestBase.getMethod());
                } else if (currRequest instanceof RequestWrapper) {
                    RequestWrapper requestWrapper = (RequestWrapper) currRequest;
                    retry = "GET".equals(requestWrapper.getMethod());
                }
            } else {
                retry = false;
                ULog.e("retry error, curr request is null");
            }
        } catch (Throwable e) {
            retry = false;
            ULog.e("retry error", e);
        }
    }

    if (retry) {
        SystemClock.sleep(RETRY_SLEEP_INTERVAL); // sleep a while and retry http request again.
    }

    return retry;
}

From source file:com.ecyrd.jspwiki.parser.VariableContent.java

/**
 *   Evaluates the variable and returns the contents. 
 *   /*from  www .  j a  va2 s .  c  o  m*/
 *   @return The rendered value of the variable.
 */
public String getValue() {
    String result = "";
    WikiDocument root = (WikiDocument) getDocument();

    if (root == null) {
        // See similar note in PluginContent
        return m_varName;
    }

    WikiContext context = root.getContext();

    if (context == null)
        return "No WikiContext available: INTERNAL ERROR";

    Boolean wysiwygEditorMode = (Boolean) context.getVariable(RenderingManager.WYSIWYG_EDITOR_MODE);

    if (wysiwygEditorMode != null && wysiwygEditorMode.booleanValue()) {
        result = "[" + m_varName + "]";
    } else {
        try {
            result = context.getEngine().getVariableManager().parseAndGetValue(context, m_varName);
        } catch (NoSuchVariableException e) {
            result = JSPWikiMarkupParser.makeError("No such variable: " + e.getMessage()).getText();
        }
    }

    return StringEscapeUtils.escapeXml(result);
}

From source file:com.google.acre.script.JSFile.java

public JSFile(Scriptable scope, String filename, Boolean is_binary) {
    _scope = scope;//from w  w  w . j ava2s .c o m
    _filename = filename;
    _is_binary = is_binary.booleanValue();
    _costCollector = CostCollector.getInstance();
}

From source file:com.android.idtt.http.RetryHandler.java

@Override
public boolean retryRequest(IOException exception, int retriedTimes, HttpContext context) {
    boolean retry = true;

    Boolean b = (Boolean) context.getAttribute(ExecutionContext.HTTP_REQ_SENT);
    boolean sent = (b != null && b.booleanValue());

    if (retriedTimes > maxRetries) {
        // ?5/*from   w w  w.j ava 2 s. c o  m*/
        retry = false;
    } else if (exceptionBlackList.contains(exception.getClass())) {
        // ??
        retry = false;
    } else if (exceptionWhiteList.contains(exception.getClass())) {
        retry = true;
    } else if (!sent) {
        retry = true;
    }

    if (retry) {
        try {
            Object currRequest = context.getAttribute(ExecutionContext.HTTP_REQUEST);
            if (currRequest != null) {
                if (currRequest instanceof HttpRequestBase) {
                    HttpRequestBase requestBase = (HttpRequestBase) currRequest;
                    retry = requestBase != null && "GET".equals(requestBase.getMethod());
                } else if (currRequest instanceof RequestWrapper) {
                    RequestWrapper requestWrapper = (RequestWrapper) currRequest;
                    retry = requestWrapper != null && "GET".equals(requestWrapper.getMethod());
                }
            } else {
                LogUtils.e("retry error, curr request is null");
            }
        } catch (Exception e) {
            retry = false;
            LogUtils.e("retry error", e);
        }
    }

    if (retry) {
        //1???
        SystemClock.sleep(RETRY_SLEEP_INTERVAL);
    } else {
        LogUtils.e(exception.getMessage(), exception);
    }

    return retry;
}