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:com.nfwork.dbfound.json.JSONDynaBean.java

protected boolean isDynaAssignable(Class dest, Class src) {
    boolean assignable = dest.isAssignableFrom(src);
    assignable = (dest == Boolean.TYPE && src == Boolean.class) ? true : assignable;
    assignable = (dest == Byte.TYPE && src == Byte.class) ? true : assignable;
    assignable = (dest == Character.TYPE && src == Character.class) ? true : assignable;
    assignable = (dest == Short.TYPE && src == Short.class) ? true : assignable;
    assignable = (dest == Integer.TYPE && src == Integer.class) ? true : assignable;
    assignable = (dest == Long.TYPE && src == Long.class) ? true : assignable;
    assignable = (dest == Float.TYPE && src == Float.class) ? true : assignable;
    assignable = (dest == Double.TYPE && src == Double.class) ? true : assignable;

    if (src == Double.TYPE || Double.class.isAssignableFrom(src)) {
        assignable = (isByte(dest) || isShort(dest) || isInteger(dest) || isLong(dest) || isFloat(dest)) ? true
                : assignable;//from w  w  w  .  j  av  a 2  s .  co  m
    }
    if (src == Float.TYPE || Float.class.isAssignableFrom(src)) {
        assignable = (isByte(dest) || isShort(dest) || isInteger(dest) || isLong(dest)) ? true : assignable;
    }
    if (src == Long.TYPE || Long.class.isAssignableFrom(src)) {
        assignable = (isByte(dest) || isShort(dest) || isInteger(dest)) ? true : assignable;
    }
    if (src == Integer.TYPE || Integer.class.isAssignableFrom(src)) {
        assignable = (isByte(dest) || isShort(dest)) ? true : assignable;
    }
    if (src == Short.TYPE || Short.class.isAssignableFrom(src)) {
        assignable = (isByte(dest)) ? true : assignable;
    }

    return assignable;
}

From source file:org.openflexo.antar.binding.TypeUtils.java

public static boolean isBoolean(Type type) {
    if (type == null) {
        return false;
    }//from   w w w. j  av  a 2 s  .c  o m
    return type.equals(Boolean.class) || type.equals(Boolean.TYPE);
}

From source file:nz.co.senanque.validationengine.ConvertUtils.java

public static Object getPrimitiveTypeForNull(Class<?> clazz) {
    if (clazz.equals(Long.TYPE)) {
        return 0L;
    } else if (clazz.equals(Integer.TYPE)) {
        return 0;
    } else if (clazz.equals(Float.TYPE)) {
        return 0.0F;
    } else if (clazz.equals(Double.TYPE)) {
        return 0.0D;
    } else if (clazz.equals(Boolean.TYPE)) {
        return false;
    }//ww  w .  j a v  a2 s .com
    return null;
}

From source file:com.sf.ddao.orm.RSMapperFactoryRegistry.java

public static RowMapperFactory getScalarMapper(final Type itemType, final int idx, boolean req) {
    if (itemType == String.class) {
        return new ScalarRMF() {
            public Object map(ResultSet rs) throws SQLException {
                return rs.getString(idx);
            }/*from w  ww .  j a va 2s  . com*/
        };
    }
    if (itemType == Integer.class || itemType == Integer.TYPE) {
        return new ScalarRMF() {
            public Object map(ResultSet rs) throws SQLException {
                return rs.getInt(idx);
            }
        };
    }
    if (itemType == URL.class) {
        return new ScalarRMF() {
            public Object map(ResultSet rs) throws SQLException {
                return rs.getURL(idx);
            }
        };
    }
    if (itemType == BigInteger.class) {
        return new ScalarRMF() {
            public Object map(ResultSet rs) throws SQLException {
                final BigDecimal res = rs.getBigDecimal(idx);
                return res == null ? null : res.toBigInteger();
            }
        };
    }
    if (itemType == BigDecimal.class) {
        return new ScalarRMF() {
            public Object map(ResultSet rs) throws SQLException {
                return rs.getBigDecimal(idx);
            }
        };
    }
    if (itemType == InputStream.class) {
        return new ScalarRMF() {
            public Object map(ResultSet rs) throws SQLException {
                return rs.getBinaryStream(idx);
            }
        };
    }
    if (itemType == Boolean.class || itemType == Boolean.TYPE) {
        return new ScalarRMF() {
            public Object map(ResultSet rs) throws SQLException {
                return rs.getBoolean(idx);
            }
        };
    }
    if (itemType == Blob.class) {
        return new ScalarRMF() {
            public Object map(ResultSet rs) throws SQLException {
                return rs.getBlob(idx);
            }
        };
    }
    if (itemType == java.sql.Date.class || itemType == java.util.Date.class) {
        return new ScalarRMF() {
            public Object map(ResultSet rs) throws SQLException {
                return rs.getTimestamp(idx);
            }
        };
    }
    if (itemType instanceof Class) {
        final Class itemClass = (Class) itemType;
        final ColumnMapper columnMapper = ColumnMapperRegistry.lookup(itemClass);
        if (columnMapper != null) {
            return new ScalarRMF() {
                public Object map(ResultSet rs) throws SQLException {
                    return columnMapper.map(rs, idx);
                }
            };
        }
        final Converter converter = ConvertUtils.lookup(itemClass);
        if (converter != null) {
            return new ScalarRMF() {
                public Object map(ResultSet rs) throws SQLException {
                    String s = rs.getString(idx);
                    if (s == null) {
                        return null;
                    }
                    return converter.convert(itemClass, s);
                }
            };
        }
        if (Enum.class.isAssignableFrom((Class<?>) itemType)) {
            return new ScalarRMF() {
                public Object map(ResultSet rs) throws SQLException {
                    String s = rs.getString(idx);
                    if (s == null) {
                        return null;
                    }
                    //noinspection unchecked
                    return Enum.valueOf((Class<Enum>) itemType, s);
                }
            };
        }
    }
    if (req) {
        throw new IllegalArgumentException("no mapping defined for " + itemType);
    }
    return null;
}

From source file:in.hatimi.nosh.support.CmdLineManager.java

private boolean injectBoolean(Object target, Field field, Boolean value) {
    if (field.getType().equals(Boolean.class) || field.getType().equals(Boolean.TYPE)) {
        return injectImpl(target, field, value);
    }/*w w  w  .ja  va2s .  c o  m*/
    return false;
}

From source file:com.haulmont.cuba.core.config.ConfigUtil.java

/**
 * Get the plain get method associated with a configuration interface
 * method. This is the unparameterized getter associated with the same
 * field as the specified configuration method. For example,
 * isDisabled() might be returned for the method
 * addDisabledListener().// w  ww  .  j a  v  a2  s. c o m
 *
 * @param configInterface The configuration interface.
 * @param method          The method.
 * @return The plain get method, or else null.
 */
public static Method getGetMethod(Class<?> configInterface, Method method) {
    Method getMethod = null;
    String methodName = method.getName();
    Matcher matcher;
    if ((matcher = ACCESS_RE.matcher(methodName)).matches()
            || (matcher = LISTENER_RE.matcher(methodName)).matches()) {
        String prop = matcher.group(2);
        try {
            getMethod = configInterface.getMethod("get" + prop);
        } catch (NoSuchMethodException ex) {
            Class<?> methodType = getMethodType(method);
            try {
                getMethod = configInterface.getMethod("get" + prop, methodType);
            } catch (NoSuchMethodException ex2) {
                if (Boolean.TYPE.equals(methodType)) {
                    try {
                        getMethod = configInterface.getMethod("is" + prop);
                    } catch (NoSuchMethodException ex3) {
                        try {
                            getMethod = configInterface.getMethod("is" + prop, methodType);
                        } catch (NoSuchMethodException ex4) {
                            // nothing
                        }
                    }
                }
            }
        }
    }
    return getMethod;
}

From source file:org.more.webui.components.upload.Upload.java

public boolean getShowProgress() {
    return this.getProperty(Propertys.showProgress.name()).valueTo(Boolean.TYPE);
}

From source file:nl.strohalm.cyclos.controls.customization.fields.EditCustomFieldAction.java

@SuppressWarnings("unchecked")
public DataBinder<AdCustomField> getAdCustomFieldBinder() {
    final BeanBinder<AdCustomField> adFieldBinder = (BeanBinder<AdCustomField>) getBasicDataBinder(
            CustomField.Nature.AD);/*from w w  w.j a  v  a 2s. c  o m*/
    adFieldBinder.registerBinder("showInSearch", PropertyBinder.instance(Boolean.TYPE, "showInSearch"));
    adFieldBinder.registerBinder("indexed", PropertyBinder.instance(Boolean.TYPE, "indexed"));
    adFieldBinder.registerBinder("visibility",
            PropertyBinder.instance(AdCustomField.Visibility.class, "visibility"));
    return adFieldBinder;
}

From source file:im.vector.activity.MXCActionBarActivity.java

@Override
public boolean onMenuOpened(int featureId, Menu menu) {
    // display the menu icon with the text
    if (((featureId == Window.FEATURE_ACTION_BAR) || ((featureId == Window.FEATURE_OPTIONS_PANEL)))
            && menu != null) {/*w  ww .ja va2 s  .co  m*/
        if (menu.getClass().getSimpleName().equals("MenuBuilder")) {
            try {
                Method m = menu.getClass().getDeclaredMethod("setOptionalIconsVisible", Boolean.TYPE);
                m.setAccessible(true);
                m.invoke(menu, true);
            } catch (NoSuchMethodException e) {
                //Log.e(TAG, "onMenuOpened", e);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
    return super.onMenuOpened(featureId, menu);
}

From source file:gov.nih.nci.cabig.caaers.web.search.CommandToSQL.java

private static AbstractQuery buildAbstractQuery(SearchTargetObject targetObject,
        List<AdvancedSearchCriteriaParameter> criteriaParameters, String tableAliasForInterventions)
        throws Exception {
    String queryClassName = targetObject.getQueryClassName();
    AbstractQuery query = (AbstractQuery) Class.forName(queryClassName).newInstance();

    List<String> objectsToJoin = new ArrayList<String>();
    List<String> objectsInView = new ArrayList<String>();

    String[] hqlElements = StringUtils.split(query.getBaseQueryString());

    int etIndex = ArrayUtils.indexOf(hqlElements, invokeField(query, targetObject.getTableAlias()));
    hqlElements[etIndex] = invokeField(query, targetObject.getTableAlias());
    String associtedObjectsInQueryString = "";
    // check the objects selected in results , and add those objects to query .. 
    for (DependentObject dObject : targetObject.getDependentObject()) {
        List<ViewColumn> viewColumns = dObject.getViewColumn();
        for (ViewColumn viewColumn : viewColumns) {
            if (viewColumn.isSelected()) {
                if (!dObject.getClassName().equals(targetObject.getClassName())) {
                    if (!objectsInView.contains(dObject.getClassName())) {
                        objectsInView.add(dObject.getClassName());
                        if (tableAliasForInterventions != null
                                && dObject.getClassName().equals(INTERVENTION_CLASS_NAME)) {
                            associtedObjectsInQueryString = associtedObjectsInQueryString + " , "
                                    + invokeField(query, tableAliasForInterventions);
                        } else {
                            associtedObjectsInQueryString = associtedObjectsInQueryString + " , "
                                    + invokeField(query, dObject.getTableAlias());
                        }//  w ww  . j a v a2 s.  c o m

                    }
                }
            }
        }
    }
    // build base query 
    if (!associtedObjectsInQueryString.equals("")) {
        associtedObjectsInQueryString = associtedObjectsInQueryString + " from ";
        hqlElements[etIndex + 1] = associtedObjectsInQueryString;
        String newQuery = StringUtils.join(hqlElements, " ");
        query.modifyQueryString(newQuery);
    }

    // now we need to check which objects are in search criteria  , if objects are in search criteria they will be joined 
    for (AdvancedSearchCriteriaParameter parameter : criteriaParameters) {
        if (parameter.getAttributeName() != null) {
            DependentObject dobj = AdvancedSearchUiUtil.getDependentObjectByName(targetObject,
                    parameter.getObjectName());
            if (!dobj.getClassName().equals(targetObject.getClassName())) {
                if (!objectsToJoin.contains(dobj.getClassName())) {
                    String joinMethodName = "";
                    if (dobj.getJoinByMethod().equals(INTERVENTION_JOIN_INXML)
                            && tableAliasForInterventions != null
                            && dobj.getClassName().equals(INTERVENTION_CLASS_NAME)) {
                        joinMethodName = interventionJoinMethodMap().get(tableAliasForInterventions);
                    } else {
                        joinMethodName = dobj.getJoinByMethod();
                    }
                    invokeMethod(query, joinMethodName, new Class[0], new Object[0]);
                    objectsToJoin.add(dobj.getClassName());
                }
            }
        }

    }

    //if objectsInView  are part of objectsToJoin we are fine ..
    // if objectsInView are not part of objectsToJoin , means - we need to outerjoin/join on these objects based on <outer-join-required>..
    // method with "outer" prfix shud exist
    for (String viewObj : objectsInView) {
        if (!objectsToJoin.contains(viewObj)) {
            DependentObject dobj = AdvancedSearchUiUtil.getDependentObjectByName(targetObject, viewObj);
            if (dobj.isOuterJoinRequired()) {
                invokeMethod(query, OUTER_JOIN_PREFIX + dobj.getJoinByMethod(), new Class[0], new Object[0]);
            } else {
                String joinMethodName = "";
                if (dobj.getJoinByMethod().equals(INTERVENTION_JOIN_INXML) && tableAliasForInterventions != null
                        && dobj.getClassName().equals(INTERVENTION_CLASS_NAME)) {
                    joinMethodName = interventionJoinMethodMap().get(tableAliasForInterventions);
                } else {
                    joinMethodName = dobj.getJoinByMethod();
                }

                invokeMethod(query, joinMethodName, new Class[0], new Object[0]);
            }
        }
        // sometimes view attributes needs some default filtering also , like study identifiers ..
        DependentObject dobj1 = AdvancedSearchUiUtil.getDependentObjectByName(targetObject, viewObj);
        List<ViewColumn> vcs = dobj1.getViewColumn();
        for (ViewColumn vc : vcs) {
            if (vc.isSelected() && vc.getFilterMethod() != null) {
                invokeMethod(query, vc.getFilterMethod(), new Class[0], new Object[0]);
            }
        }
    }

    // add filters 
    for (AdvancedSearchCriteriaParameter parameter : criteriaParameters) {
        if (parameter.getAttributeName() != null) {
            String filterMethodName = parameter.getFilterByMethodInQueryClass();
            if (parameter.getAttributeName().equals(STUDY_THERAPY_CODE_FIELD_NAME)) {
                filterMethodName = interventionFilterMethodMap().get(tableAliasForInterventions);
            }

            Class[] par = new Class[2];
            Object[] obj = new Object[2];
            if (parameter.getDataType().equals("String")) {
                par[0] = String.class;
                obj[0] = parameter.getValue();
            } else if (parameter.getDataType().equals("Integer")) {
                par[0] = Integer.class;
                obj[0] = Integer.parseInt(parameter.getValue());
            } else if (parameter.getDataType().equals("boolean")) {
                par[0] = Boolean.TYPE;
                obj[0] = Boolean.parseBoolean(parameter.getValue());
            } else {
                continue;
            }
            par[1] = String.class;
            obj[1] = parameter.getPredicate();
            //Method mthd = query.getClass().getMethod(filterMethodName,par);
            //mthd.invoke(query,obj);
            invokeMethod(query, filterMethodName, par, obj);
        }
    }

    return query;
}