Example usage for java.lang Boolean TYPE

List of usage examples for java.lang Boolean TYPE

Introduction

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

Prototype

Class TYPE

To view the source code for java.lang Boolean TYPE.

Click Source Link

Document

The Class object representing the primitive type boolean.

Usage

From source file:org.ow2.proactive_grid_cloud_portal.cli.cmd.rm.LockNodeCommand.java

@Override
public void execute(ApplicationContext currentContext) throws CLIException {
    HttpPost request = new HttpPost(currentContext.getResourceUrl("node/lock"));
    QueryStringBuilder queryStringBuilder = new QueryStringBuilder();
    for (String nodeUrl : nodeUrls) {
        queryStringBuilder.add("nodeurls", nodeUrl);
    }//from   w ww. j a  v  a  2 s.  c o  m
    request.setEntity(queryStringBuilder.buildEntity(APPLICATION_FORM_URLENCODED));
    HttpResponseWrapper response = execute(request, currentContext);
    if (statusCode(OK) == statusCode(response)) {
        boolean successful = readValue(response, Boolean.TYPE, currentContext);
        resultStack(currentContext).push(successful);
        if (successful) {
            writeLine(currentContext, "Node(s) locked successfully.");
        } else {
            writeLine(currentContext, "Cannot lock node(s).");
        }
    } else {
        handleError("An error occurred while locking nodes:", response, currentContext);
    }

}

From source file:org.ow2.proactive_grid_cloud_portal.cli.cmd.rm.UnlockNodeCommand.java

@Override
public void execute(ApplicationContext currentContext) throws CLIException {
    HttpPost request = new HttpPost(currentContext.getResourceUrl("node/unlock"));
    QueryStringBuilder queryStringBuilder = new QueryStringBuilder();
    for (String nodeUrl : nodeUrls) {
        queryStringBuilder.add("nodeurls", nodeUrl);
    }/* w  w  w . ja v  a 2 s  .c  o  m*/
    request.setEntity(queryStringBuilder.buildEntity(APPLICATION_FORM_URLENCODED));
    HttpResponseWrapper response = execute(request, currentContext);
    if (statusCode(OK) == statusCode(response)) {
        boolean success = readValue(response, Boolean.TYPE, currentContext);
        resultStack(currentContext).push(success);
        if (success) {
            writeLine(currentContext, "Node(s) unlocked successfully.");
        } else {
            writeLine(currentContext, "Cannot unlock node(s).");
        }
    } else {
        handleError("An error occurred while unlocking nodes:", response, currentContext);
    }

}

From source file:org.ow2.proactive_grid_cloud_portal.cli.cmd.rm.RemoveNodeCommand.java

@Override
public void execute(ApplicationContext currentContext) throws CLIException {
    HttpPost request = new HttpPost(currentContext.getResourceUrl("node/remove"));
    QueryStringBuilder queryStringBuilder = new QueryStringBuilder();
    queryStringBuilder.add("url", nodeUrl);
    if (currentContext.isForced()) {
        preempt = true;// ww w .j a va 2  s .  c om
    }
    if (preempt) {
        queryStringBuilder.add("preempt", TRUE.toString());
    }
    request.setEntity(queryStringBuilder.buildEntity(APPLICATION_FORM_URLENCODED));
    HttpResponseWrapper response = execute(request, currentContext);
    if (statusCode(OK) == statusCode(response)) {
        boolean successful = readValue(response, Boolean.TYPE, currentContext);
        resultStack(currentContext).push(successful);
        if (successful) {
            writeLine(currentContext, "Node('%s') successfully removed.", nodeUrl);
        } else {
            writeLine(currentContext, "Cannot remove node: '%s'", nodeUrl);
        }
    } else {
        handleError("An error occurred while removing node:", response, currentContext);
    }
}

From source file:airlift.util.AirliftUtil.java

/**
 * Creates the bean utils bean./*from   w  w w . j  ava 2  s  . c o m*/
 *
 * @param _allowedDateTimePatterns the _allowed date time patterns
 * @param _timeZone the _time zone
 * @return BeansUtilsBean
 */
public static org.apache.commons.beanutils.BeanUtilsBean createBeanUtilsBean(String[] _allowedDateTimePatterns,
        java.util.TimeZone _timeZone) {
    org.apache.commons.beanutils.converters.SqlDateConverter sqlDateConverter = new org.apache.commons.beanutils.converters.SqlDateConverter();
    sqlDateConverter.setPatterns(_allowedDateTimePatterns);
    sqlDateConverter.setTimeZone(_timeZone);

    org.apache.commons.beanutils.converters.DateConverter dateConverter = new org.apache.commons.beanutils.converters.DateConverter();
    dateConverter.setPatterns(_allowedDateTimePatterns);
    dateConverter.setTimeZone(_timeZone);

    org.apache.commons.beanutils.converters.SqlTimestampConverter sqlTimestampConverter = new org.apache.commons.beanutils.converters.SqlTimestampConverter();
    sqlTimestampConverter.setPatterns(_allowedDateTimePatterns);
    sqlTimestampConverter.setTimeZone(_timeZone);

    //registering "" (empty string) as a true value to support checkboxes with
    //the value attribute not being set.  Setting the value
    //atrribute wil make the value visible on the form.  This may
    //not be desired for a simple yes-no option hence the need to
    //register "" as true.
    String[] trueStrings = { "yes", "y", "true", "on", "1", "" };
    String[] falseStrings = { "no", "n", "false", "off", "0" };
    org.apache.commons.beanutils.converters.BooleanConverter booleanConverter = new org.apache.commons.beanutils.converters.BooleanConverter(
            trueStrings, falseStrings, Boolean.FALSE);

    org.apache.commons.beanutils.ConvertUtilsBean convertUtilsBean = new org.apache.commons.beanutils.ConvertUtilsBean();
    convertUtilsBean.register(sqlDateConverter, java.sql.Date.class);
    convertUtilsBean.register(dateConverter, java.util.Date.class);
    convertUtilsBean.register(sqlTimestampConverter, java.sql.Timestamp.class);
    convertUtilsBean.register(booleanConverter, Boolean.class);
    convertUtilsBean.register(booleanConverter, Boolean.TYPE);

    return new org.apache.commons.beanutils.BeanUtilsBean(convertUtilsBean);
}

From source file:org.lunarray.model.descriptor.builder.annotation.util.RenderDefaultsUtil.java

/**
 * Fills the defaults.// w  w  w  . ja  v a  2  s . co  m
 */
private RenderDefaultsUtil() {
    this.renderDefaults = new HashMap<Class<?>, RenderType>();
    this.renderDefaults.put(Calendar.class, RenderType.DATE_PICKER);
    this.renderDefaults.put(Date.class, RenderType.DATE_PICKER);
    this.renderDefaults.put(java.sql.Date.class, RenderType.DATE_PICKER);
    this.renderDefaults.put(String.class, RenderType.TEXT);
    this.renderDefaults.put(Integer.class, RenderType.TEXT);
    this.renderDefaults.put(Double.class, RenderType.TEXT);
    this.renderDefaults.put(Float.class, RenderType.TEXT);
    this.renderDefaults.put(Long.class, RenderType.TEXT);
    this.renderDefaults.put(Byte.class, RenderType.TEXT);
    this.renderDefaults.put(Short.class, RenderType.TEXT);
    this.renderDefaults.put(Character.class, RenderType.TEXT);
    this.renderDefaults.put(Integer.TYPE, RenderType.TEXT);
    this.renderDefaults.put(Double.TYPE, RenderType.TEXT);
    this.renderDefaults.put(Float.TYPE, RenderType.TEXT);
    this.renderDefaults.put(Long.TYPE, RenderType.TEXT);
    this.renderDefaults.put(Byte.TYPE, RenderType.TEXT);
    this.renderDefaults.put(Short.TYPE, RenderType.TEXT);
    this.renderDefaults.put(Character.TYPE, RenderType.TEXT);
    this.renderDefaults.put(BigDecimal.class, RenderType.TEXT);
    this.renderDefaults.put(BigInteger.class, RenderType.TEXT);
    this.renderDefaults.put(Boolean.class, RenderType.CHECKBOX);
    this.renderDefaults.put(Boolean.TYPE, RenderType.CHECKBOX);
}

From source file:org.seasar.mayaa.impl.util.ObjectUtil.java

protected static Class loadPrimitiveClass(String className) {
    if (StringUtil.isEmpty(className)) {
        throw new IllegalArgumentException();
    }/*from  w w  w .j  av  a2  s  .c o  m*/
    if ("short".equals(className)) {
        return Short.TYPE;
    } else if ("int".equals(className)) {
        return Integer.TYPE;
    } else if ("long".equals(className)) {
        return Long.TYPE;
    } else if ("float".equals(className)) {
        return Float.TYPE;
    } else if ("double".equals(className)) {
        return Double.TYPE;
    } else if ("byte".equals(className)) {
        return Byte.TYPE;
    } else if ("char".equals(className)) {
        return Character.TYPE;
    } else if ("boolean".equals(className)) {
        return Boolean.TYPE;
    } else if ("void".equals(className)) {
        return Void.TYPE;
    }
    return null;
}

From source file:foundation.stack.datamill.configuration.impl.Classes.java

public static boolean isAssignable(Class<?> clazz, final Class<?> toClass) {
    if (toClass == null) {
        return false;
    }//  w  ww  . j  ava2  s  .  co  m

    if (clazz == null) {
        return !toClass.isPrimitive();
    }

    if (clazz.isPrimitive() && !toClass.isPrimitive()) {
        clazz = primitiveToWrapper(clazz);
        if (clazz == null) {
            return false;
        }
    }
    if (toClass.isPrimitive() && !clazz.isPrimitive()) {
        clazz = wrapperToPrimitive(clazz);
        if (clazz == null) {
            return false;
        }
    }

    if (clazz.equals(toClass)) {
        return true;
    }
    if (clazz.isPrimitive()) {
        if (!toClass.isPrimitive()) {
            return false;
        }
        if (Integer.TYPE.equals(clazz)) {
            return Long.TYPE.equals(toClass) || Float.TYPE.equals(toClass) || Double.TYPE.equals(toClass);
        }
        if (Long.TYPE.equals(clazz)) {
            return Float.TYPE.equals(toClass) || Double.TYPE.equals(toClass);
        }
        if (Boolean.TYPE.equals(clazz)) {
            return false;
        }
        if (Double.TYPE.equals(clazz)) {
            return false;
        }
        if (Float.TYPE.equals(clazz)) {
            return Double.TYPE.equals(toClass);
        }
        if (Character.TYPE.equals(clazz)) {
            return Integer.TYPE.equals(toClass) || Long.TYPE.equals(toClass) || Float.TYPE.equals(toClass)
                    || Double.TYPE.equals(toClass);
        }
        if (Short.TYPE.equals(clazz)) {
            return Integer.TYPE.equals(toClass) || Long.TYPE.equals(toClass) || Float.TYPE.equals(toClass)
                    || Double.TYPE.equals(toClass);
        }
        if (Byte.TYPE.equals(clazz)) {
            return Short.TYPE.equals(toClass) || Integer.TYPE.equals(toClass) || Long.TYPE.equals(toClass)
                    || Float.TYPE.equals(toClass) || Double.TYPE.equals(toClass);
        }
        // should never get here
        return false;
    }

    return toClass.isAssignableFrom(clazz);
}

From source file:de.micromata.genome.util.strings.converter.StandardStringConverter.java

@Override
public char getTypeChar(Object value) {
    if (value == null) {
        return ConvertedStringTypes.NULL.getShortType();
    }//from   w w w. j a v a 2 s  .co m
    Class<?> cls = value.getClass();

    if (value instanceof String) {
        return ConvertedStringTypes.STRING.getShortType();
    }

    Class<?> vclass = value.getClass();

    if (value instanceof Boolean || vclass == Boolean.TYPE) {
        return ConvertedStringTypes.BOOLEAN.getShortType();
    }
    if (value instanceof Byte || vclass == Byte.TYPE) {
        return ConvertedStringTypes.BYTE.getShortType();
    }
    if (value instanceof Short || vclass == Short.TYPE) {
        return ConvertedStringTypes.SHORT.getShortType();
    }
    if (value instanceof Integer || vclass == Integer.TYPE) {
        return ConvertedStringTypes.INTEGER.getShortType();
    }
    if (value instanceof Long || vclass == Long.TYPE) {
        return ConvertedStringTypes.LONG.getShortType();
    }
    if (value instanceof Float || vclass == Float.TYPE) {
        return ConvertedStringTypes.FLOAT.getShortType();
    }
    if (value instanceof Double || vclass == Double.TYPE) {
        return ConvertedStringTypes.DOUBLE.getShortType();
    }
    if (value instanceof Character || vclass == Character.TYPE) {
        return ConvertedStringTypes.CHAR.getShortType();
    }
    if (value instanceof Date) {
        return ConvertedStringTypes.DATE.getShortType();
    }
    if (value instanceof BigDecimal) {
        return ConvertedStringTypes.BIGDECIMAL.getShortType();
    }
    if (value instanceof Character) {
        return ConvertedStringTypes.CHAR.getShortType();
    }
    if (value instanceof byte[]) {
        return ConvertedStringTypes.BYTEARRAY.getShortType();
    }
    if (value instanceof String[]) {
        return ConvertedStringTypes.STRINGARRAY.getShortType();
    }
    if (value instanceof Long[]) {
        return ConvertedStringTypes.LONGARRAY.getShortType();
    }

    // if (value instanceof Serializable)
    // return ConvertedStringTypes.XMLOBJECT;
    return ConvertedStringTypes.CUSTOM.getShortType();
}

From source file:org.ow2.proactive_grid_cloud_portal.cli.cmd.rm.AddNodeCommand.java

@Override
public void execute(ApplicationContext currentContext) throws CLIException {
    HttpPost request = new HttpPost(currentContext.getResourceUrl("node"));
    QueryStringBuilder queryStringBuilder = new QueryStringBuilder();
    queryStringBuilder.add("nodeurl", nodeUrl);
    if (currentContext.getProperty(SET_NODE_SOURCE, String.class) != null) {
        nodeSource = currentContext.getProperty(SET_NODE_SOURCE, String.class);
    }//from   w  w  w .java 2  s . c o m
    if (nodeSource != null) {
        queryStringBuilder.add("nodesource", nodeSource);
    }
    request.setEntity(queryStringBuilder.buildEntity(APPLICATION_FORM_URLENCODED));
    HttpResponseWrapper response = execute(request, currentContext);
    if (statusCode(OK) == statusCode(response)) {
        boolean successful = readValue(response, Boolean.TYPE, currentContext);
        currentContext.resultStack().push(successful);
        if (successful) {
            writeLine(currentContext, "Node('%s') added successfully.", nodeUrl);
        } else {
            writeLine(currentContext, "Cannot add node('%s').", nodeUrl);
        }
    } else {
        handleError("An error occurred while adding the node:", response, currentContext);
    }
}

From source file:org.cloudifysource.usm.USMUtils.java

private static boolean markFileAsExecutableUsingJdk(final File file) throws USMException {
    // TODO - refactor this - just catch exception on the whole block
    logger.fine("Attempting to set file as executable using REFLECTION");
    Method method = null;
    try {/*from   w  w  w  .  ja  va 2 s. c o  m*/
        method = File.class.getMethod("setExecutable", new Class[] { Boolean.TYPE });
    } catch (final SecurityException e) {
        throw new USMException("Failed to check if file " + file.getAbsolutePath() + " is executable", e);
    } catch (final NoSuchMethodException e) {
        // ignore - this can happen
    }

    if (method == null) {
        logger.warning("setExecutable not supported by JDK. "
                + "GigaSpaces Cloudify should be executed on Java Version >= 1.6");
        return false;
    }

    try {
        final boolean retval = (Boolean) method.invoke(file, true);
        logger.fine("File " + file + " was marked as executable");
        if (!retval) {
            logger.warning(
                    "File: " + file + " is not executable. " + "Attempt to mark it as executable has failed. "
                            + "Execution of this command may not be possible");
        }
        return retval;
    } catch (final IllegalArgumentException e) {
        throw new USMException("Failed to make file " + file.getAbsolutePath() + " as executable", e);
    } catch (final IllegalAccessException e) {
        throw new USMException("Failed to make file " + file.getAbsolutePath() + " as executable", e);
    } catch (final InvocationTargetException e) {
        throw new USMException("Failed to make file " + file.getAbsolutePath() + " as executable", e);
    }
}