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:cn.edu.zafu.corepage.base.BaseActivity.java

@Override
public boolean onMenuOpened(int featureId, Menu menu) {
    if (featureId == Window.FEATURE_ACTION_BAR && menu != null) {
        if (menu.getClass().getSimpleName().equals("MenuBuilder")) {
            try {
                Method m = menu.getClass().getDeclaredMethod("setOptionalIconsVisible", Boolean.TYPE);
                m.setAccessible(true);// w  ww  .  jav a2 s. c  o  m
                m.invoke(menu, true);
            } catch (NoSuchMethodException e) {
                e.printStackTrace();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
    return super.onMenuOpened(featureId, menu);
}

From source file:example.luojing.androidsourceanalysis.ViewPager.java

/**
 * sdk>=7??ViewGroup.setChildrenDrawingOrderEnabled,????View
 *//*from   w w w . ja va 2s  .c o  m*/
void setChildrenDrawingOrderEnabledCompat(boolean enable) {
    if (Build.VERSION.SDK_INT >= 7) {
        //mSetChildrenDrawingOrderEnabledMethod
        if (mSetChildrenDrawingOrderEnabled == null) {
            try {
                mSetChildrenDrawingOrderEnabled = ViewGroup.class
                        .getDeclaredMethod("setChildrenDrawingOrderEnabled", new Class[] { Boolean.TYPE });
            } catch (NoSuchMethodException e) {
                Log.e(TAG, "Can't find setChildrenDrawingOrderEnabled", e);
            }
        }
        try {
            mSetChildrenDrawingOrderEnabled.invoke(this, enable);
        } catch (Exception e) {
            Log.e(TAG, "Error changing children drawing order", e);
        }
    }
}

From source file:com.forrestguice.suntimeswidget.SuntimesActivity.java

/**
 * from http://stackoverflow.com/questions/18374183/how-to-show-icons-in-overflow-menu-in-actionbar
 *///from   w  ww.  j a  va  2  s . c om
private void forceActionBarIcons(Menu menu) {
    if (menu != null) {
        if (menu.getClass().getSimpleName().equals("MenuBuilder")) {
            try {
                Method m = menu.getClass().getDeclaredMethod("setOptionalIconsVisible", Boolean.TYPE);
                m.setAccessible(true);
                m.invoke(menu, true);

            } catch (Exception e) {
                Log.e("SuntimesActivity", "failed to set show overflow icons", e);
            }
        }
    }
}

From source file:com.forrestguice.suntimeswidget.SuntimesUtils.java

/**
 * from http://stackoverflow.com/questions/18374183/how-to-show-icons-in-overflow-menu-in-actionbar
 *//*from w  w w. ja va 2s  .com*/
public static void forceActionBarIcons(Menu menu) {
    if (menu != null) {
        if (menu.getClass().getSimpleName().equals("MenuBuilder")) {
            try {
                Method m = menu.getClass().getDeclaredMethod("setOptionalIconsVisible", Boolean.TYPE);
                m.setAccessible(true);
                m.invoke(menu, true);

            } catch (Exception e) {
                Log.e("SuntimesActivity", "failed to set show overflow icons", e);
            }
        }
    }
}

From source file:org.kuali.rice.kns.datadictionary.validation.AttributeValidatingTypeServiceBase.java

private Object getAttributeValue(PropertyDescriptor propertyDescriptor, String attributeValue) {
    Object attributeValueObject = null;
    if (propertyDescriptor != null && attributeValue != null) {
        Class<?> propertyType = propertyDescriptor.getPropertyType();
        if (String.class.equals(propertyType)) {
            // it's already a String
            attributeValueObject = attributeValue;
        } // KULRICE-6808: Kim Role Maintenance - Custom boolean role qualifier values are not being converted properly
        else if (Boolean.class.equals(propertyType) || Boolean.TYPE.equals(propertyType)) {
            attributeValueObject = Truth.strToBooleanIgnoreCase(attributeValue);
        } else {//from w w  w. j  ava  2 s  .c o m
            // try to create one with KRADUtils for other misc data types
            attributeValueObject = KRADUtils.createObject(propertyType, new Class[] { String.class },
                    new Object[] { attributeValue });
            // if that didn't work, we'll get a null back
            if (attributeValueObject == null) {
                // this doesn't seem like a great option, since we know the property isn't of type String
                attributeValueObject = attributeValue;
            }
        }
    }
    return attributeValueObject;
}

From source file:org.romaframework.core.schema.SchemaHelper.java

/**
 * Resolve class object for java types.//from  w  w  w  .java 2  s. co  m
 * 
 * @param iEntityName
 *          Java type name
 * @return Class object if found, otherwise null
 */
public static Class<?> getClassForJavaTypes(String iEntityName) {
    if (iEntityName.equals("String"))
        return String.class;
    else if (iEntityName.equals("Integer"))
        return Integer.class;
    else if (iEntityName.equals("int"))
        return Integer.TYPE;
    else if (iEntityName.equals("Long"))
        return Long.class;
    else if (iEntityName.equals("long"))
        return Long.TYPE;
    else if (iEntityName.equals("Short"))
        return Short.class;
    else if (iEntityName.equals("short"))
        return Short.TYPE;
    else if (iEntityName.equals("Boolean"))
        return Boolean.class;
    else if (iEntityName.equals("boolean"))
        return Boolean.TYPE;
    else if (iEntityName.equals("BigDecimal"))
        return BigDecimal.class;
    else if (iEntityName.equals("Float"))
        return Float.class;
    else if (iEntityName.equals("float"))
        return Float.TYPE;
    else if (iEntityName.equals("Double"))
        return Double.class;
    else if (iEntityName.equals("Number"))
        return Number.class;
    else if (iEntityName.equals("double"))
        return Double.TYPE;
    else if (iEntityName.equals("Character"))
        return Character.class;
    else if (iEntityName.equals("char"))
        return Character.TYPE;
    else if (iEntityName.equals("Byte"))
        return Byte.class;
    else if (iEntityName.equals("byte"))
        return Byte.TYPE;
    else if (iEntityName.equals("Object"))
        return Object.class;
    else if (iEntityName.equals("Collection"))
        return Collection.class;
    else if (iEntityName.equals("List"))
        return List.class;
    else if (iEntityName.equals("Set"))
        return Set.class;
    else if (iEntityName.equals("Map"))
        return Map.class;
    else if (iEntityName.equals("Date"))
        return Date.class;
    else if (iEntityName.equals("Map$Entry"))
        return Map.Entry.class;
    else if (iEntityName.equals("HashMap$Entry"))
        return Map.Entry.class;
    else if (iEntityName.equals("LinkedHashMap$Entry"))
        return Map.Entry.class;
    return null;
}

From source file:org.symptomcheck.capstone.ui.MainActivityOld.java

@Override
public boolean onMenuOpened(int featureId, Menu menu) {
    if (featureId == Window.FEATURE_ACTION_BAR && menu != null) {
        if (menu.getClass().getSimpleName().equals("MenuBuilder")) {
            try {
                Method m = menu.getClass().getDeclaredMethod("setOptionalIconsVisible", Boolean.TYPE);
                m.setAccessible(true);//ww  w .  ja  va  2s  .  c o m
                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:org.kuali.rice.krad.uif.util.ObjectPropertyUtils.java

/**
 * Infer the read method based on method name.
 * //from ww w .  j a  va2 s . c o  m
 * @param beanClass The bean class.
 * @param propertyName The property name.
 * @return The read method for the property.
 */
private static Method getReadMethodByName(Class<?> beanClass, String propertyName) {

    try {
        return beanClass
                .getMethod("get" + Character.toUpperCase(propertyName.charAt(0)) + propertyName.substring(1));
    } catch (SecurityException e) {
        // Ignore
    } catch (NoSuchMethodException e) {
        // Ignore
    }

    try {
        Method readMethod = beanClass
                .getMethod("is" + Character.toUpperCase(propertyName.charAt(0)) + propertyName.substring(1));

        if (readMethod.getReturnType() == Boolean.class || readMethod.getReturnType() == Boolean.TYPE) {
            return readMethod;
        }
    } catch (SecurityException e) {
        // Ignore
    } catch (NoSuchMethodException e) {
        // Ignore
    }

    return null;
}

From source file:org.kuali.rice.kns.util.FieldUtils.java

/**
 * Uses reflection to get the property names of the business object, then checks for the property name as a key in the passed
 * map. If found, takes the value from the map and sets the business object property.
 *
 * @param bo/*from w  w w.jav a 2 s.  c o m*/
 * @param fieldValues
 * @param propertyNamePrefix this value will be prepended to all property names in the returned unformattable values map
 * @return Cached Values from any formatting failures
 */
public static Map populateBusinessObjectFromMap(BusinessObject bo, Map<String, ?> fieldValues,
        String propertyNamePrefix) {
    Map cachedValues = new HashMap();
    MessageMap errorMap = GlobalVariables.getMessageMap();

    try {
        for (Iterator<String> iter = fieldValues.keySet().iterator(); iter.hasNext();) {
            String propertyName = iter.next();

            if (propertyName.endsWith(KRADConstants.CHECKBOX_PRESENT_ON_FORM_ANNOTATION)) {
                // since checkboxes do not post values when unchecked, this code detects whether a checkbox was unchecked, and
                // sets the value to false.
                if (StringUtils.isNotBlank((String) fieldValues.get(propertyName))) {
                    String checkboxName = StringUtils.removeEnd(propertyName,
                            KRADConstants.CHECKBOX_PRESENT_ON_FORM_ANNOTATION);
                    String checkboxValue = (String) fieldValues.get(checkboxName);
                    if (checkboxValue == null) {
                        // didn't find a checkbox value, assume that it is unchecked
                        if (isPropertyWritable(bo, checkboxName)) {
                            Class type = ObjectUtils.easyGetPropertyType(bo, checkboxName);
                            if (type == Boolean.TYPE || type == Boolean.class) {
                                // ASSUMPTION: unchecked means false
                                ObjectUtils.setObjectProperty(bo, checkboxName, type, "false");
                            }
                        }
                    }
                }
                // else, if not null, then it has a value, and we'll let the rest of the code handle it when the param is processed on
                // another iteration (may be before or after this iteration).
            } else if (isPropertyWritable(bo, propertyName) && fieldValues.get(propertyName) != null) {
                // if the field propertyName is a valid property on the bo class
                Class type = ObjectUtils.easyGetPropertyType(bo, propertyName);
                try {
                    Object fieldValue = fieldValues.get(propertyName);
                    ObjectUtils.setObjectProperty(bo, propertyName, type, fieldValue);
                } catch (FormatException e) {
                    cachedValues.put(propertyNamePrefix + propertyName, fieldValues.get(propertyName));
                    errorMap.putError(propertyNamePrefix + propertyName, e.getErrorKey(), e.getErrorArgs());
                }
            }
        }
    } catch (IllegalAccessException e) {
        LOG.error("unable to populate business object" + e.getMessage());
        throw new RuntimeException(e.getMessage(), e);
    } catch (InvocationTargetException e) {
        LOG.error("unable to populate business object" + e.getMessage());
        throw new RuntimeException(e.getMessage(), e);
    } catch (NoSuchMethodException e) {
        LOG.error("unable to populate business object" + e.getMessage());
        throw new RuntimeException(e.getMessage(), e);
    }

    return cachedValues;
}

From source file:org.apache.oodt.cas.cli.util.CmdLineUtils.java

public static List<?> convertToType(List<String> values, Class<?> type)
        throws MalformedURLException, ClassNotFoundException, InstantiationException, IllegalAccessException {
    if (type.equals(File.class)) {
        List<Object> files = new LinkedList<Object>();
        for (String value : values) {
            files.add(new File(value));
        }/*  w  w  w . ja v  a  2s. c  o m*/
        return files;
    } else if (type.equals(Boolean.class) || type.equals(Boolean.TYPE)) {
        List<Object> booleans = new LinkedList<Object>();
        for (String value : values) {
            booleans.add(value.toLowerCase().trim().equals("true"));
        }
        return booleans;
    } else if (type.equals(URL.class)) {
        List<Object> urls = new LinkedList<Object>();
        for (String value : values) {
            urls.add(new URL(value));
        }
        return urls;
    } else if (type.equals(Class.class)) {
        List<Object> classes = new LinkedList<Object>();
        for (String value : values) {
            classes.add(Class.forName(value));
        }
        return classes;
    } else if (type.equals(List.class)) {
        List<Object> lists = new LinkedList<Object>();
        lists.add(values);
        return lists;
    } else if (type.equals(Integer.class) || type.equals(Integer.TYPE)) {
        List<Object> ints = new LinkedList<Object>();
        for (String value : values) {
            ints.add(Integer.valueOf(value));
        }
        return ints;
    } else if (type.equals(Long.class) || type.equals(Long.TYPE)) {
        List<Object> longs = new LinkedList<Object>();
        for (String value : values) {
            longs.add(Long.valueOf(value));
        }
        return longs;
    } else if (type.equals(Double.class) || type.equals(Double.TYPE)) {
        List<Object> doubles = new LinkedList<Object>();
        for (String value : values) {
            doubles.add(new Double(value));
        }
        return doubles;
    } else if (type.equals(String.class)) {
        StringBuilder combinedString = new StringBuilder("");
        for (String value : values) {
            combinedString.append(value).append(" ");
        }
        return Lists.newArrayList(combinedString.toString().trim());
    } else {
        List<Object> objects = new LinkedList<Object>();
        for (String value : values) {
            Object object = Class.forName(value).newInstance();
            if (!type.isAssignableFrom(object.getClass())) {
                throw new RuntimeException(
                        object.getClass() + " is not a valid" + " type or sub-type of " + type);
            }
            objects.add(object);
        }
        return objects;
    }
}