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.sun.faces.config.ManagedBeanFactory.java

private Class getValueClassConsideringPrimitives(String valueClass) throws ClassNotFoundException {
    Class valueType = java.lang.String.class;
    if (null != valueClass && 0 < valueClass.length()) {
        if (valueClass.equals(Boolean.TYPE.getName())) {
            valueType = Boolean.TYPE;
        } else if (valueClass.equals(Byte.TYPE.getName())) {
            valueType = Byte.TYPE;
        } else if (valueClass.equals(Double.TYPE.getName())) {
            valueType = Double.TYPE;
        } else if (valueClass.equals(Float.TYPE.getName())) {
            valueType = Float.TYPE;
        } else if (valueClass.equals(Integer.TYPE.getName())) {
            valueType = Integer.TYPE;
        } else if (valueClass.equals(Character.TYPE.getName())) {
            valueType = Character.TYPE;
        } else if (valueClass.equals(Short.TYPE.getName())) {
            valueType = Short.TYPE;
        } else if (valueClass.equals(Long.TYPE.getName())) {
            valueType = Long.TYPE;
        } else {/* w w  w. j ava 2  s  .  com*/
            valueType = Util.loadClass(valueClass, this);
        }
    }
    return valueType;
}

From source file:ca.sqlpower.architect.swingui.TestPlayPen.java

/**
  * Returns true if an instance of the given property type is of a mutable class.
  * Throws an exception if it lacks a case for the given type.
  * /*from   w  w w.  ja v  a 2s.c  om*/
  * @param property The property that should be checked for mutability.
  */
private boolean isPropertyInstanceMutable(PropertyDescriptor property) {
    if (property.getPropertyType() == String.class) {
        return false;
    } else if (Enum.class.isAssignableFrom(property.getPropertyType())) {
        return false;
    } else if (property.getPropertyType() == Boolean.class || property.getPropertyType() == Boolean.TYPE) {
        return false;
    } else if (property.getPropertyType() == Double.class || property.getPropertyType() == Double.TYPE) {
        return false;
    } else if (property.getPropertyType() == Integer.class || property.getPropertyType() == Integer.TYPE) {
        return false;
    } else if (property.getPropertyType() == Color.class) {
        return false;
    } else if (property.getPropertyType() == Font.class) {
        return false;
    } else if (property.getPropertyType() == Set.class) {
        return true;
    } else if (property.getPropertyType() == List.class) {
        return true;
    } else if (property.getPropertyType() == Point.class) {
        return true;
    } else {
        throw new RuntimeException("This test case lacks a value for " + property.getName() + " (type "
                + property.getPropertyType().getName() + ") in isPropertyInstanceMutable()");
    }
}

From source file:com.nikonhacker.gui.EmulatorUI.java

/**
 * Method circumventing package access to setKeepHidden() method of BasicSplitPaneUI
 * @param splitPane/*from  ww w . j a va 2  s  . c  om*/
 * @param keepHidden
 * @author taken from http://java-swing-tips.googlecode.com/svn/trunk/OneTouchExpandable/src/java/example/MainPanel.java
 */
private void setKeepHidden(JSplitPane splitPane, boolean keepHidden) {
    if (splitPane.getUI() instanceof BasicSplitPaneUI) {
        try {
            Method setKeepHidden = BasicSplitPaneUI.class.getDeclaredMethod("setKeepHidden",
                    new Class<?>[] { Boolean.TYPE }); //boolean.class });
            setKeepHidden.setAccessible(true);
            setKeepHidden.invoke(splitPane.getUI(), new Object[] { keepHidden });
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

From source file:javadz.beanutils.ConvertUtilsBean.java

/**
 * Register array converters./*from  w  w  w  . ja v a2s.c o  m*/
 *
 * @param throwException <code>true</code> if the converters should
 * throw an exception when a conversion error occurs, otherwise <code>
 * <code>false</code> if a default value should be used.
 * @param defaultArraySize The size of the default array value for array converters
 * (N.B. This values is ignored if <code>throwException</code> is <code>true</code>).
 * Specifying a value less than zero causes a <code>null<code> value to be used for
 * the default.
 */
private void registerArrays(boolean throwException, int defaultArraySize) {

    // Primitives
    registerArrayConverter(Boolean.TYPE, new BooleanConverter(), throwException, defaultArraySize);
    registerArrayConverter(Byte.TYPE, new ByteConverter(), throwException, defaultArraySize);
    registerArrayConverter(Character.TYPE, new CharacterConverter(), throwException, defaultArraySize);
    registerArrayConverter(Double.TYPE, new DoubleConverter(), throwException, defaultArraySize);
    registerArrayConverter(Float.TYPE, new FloatConverter(), throwException, defaultArraySize);
    registerArrayConverter(Integer.TYPE, new IntegerConverter(), throwException, defaultArraySize);
    registerArrayConverter(Long.TYPE, new LongConverter(), throwException, defaultArraySize);
    registerArrayConverter(Short.TYPE, new ShortConverter(), throwException, defaultArraySize);

    // Standard
    registerArrayConverter(BigDecimal.class, new BigDecimalConverter(), throwException, defaultArraySize);
    registerArrayConverter(BigInteger.class, new BigIntegerConverter(), throwException, defaultArraySize);
    registerArrayConverter(Boolean.class, new BooleanConverter(), throwException, defaultArraySize);
    registerArrayConverter(Byte.class, new ByteConverter(), throwException, defaultArraySize);
    registerArrayConverter(Character.class, new CharacterConverter(), throwException, defaultArraySize);
    registerArrayConverter(Double.class, new DoubleConverter(), throwException, defaultArraySize);
    registerArrayConverter(Float.class, new FloatConverter(), throwException, defaultArraySize);
    registerArrayConverter(Integer.class, new IntegerConverter(), throwException, defaultArraySize);
    registerArrayConverter(Long.class, new LongConverter(), throwException, defaultArraySize);
    registerArrayConverter(Short.class, new ShortConverter(), throwException, defaultArraySize);
    registerArrayConverter(String.class, new StringConverter(), throwException, defaultArraySize);

    // Other
    registerArrayConverter(Class.class, new ClassConverter(), throwException, defaultArraySize);
    registerArrayConverter(java.util.Date.class, new DateConverter(), throwException, defaultArraySize);
    registerArrayConverter(Calendar.class, new DateConverter(), throwException, defaultArraySize);
    registerArrayConverter(File.class, new FileConverter(), throwException, defaultArraySize);
    registerArrayConverter(java.sql.Date.class, new SqlDateConverter(), throwException, defaultArraySize);
    registerArrayConverter(java.sql.Time.class, new SqlTimeConverter(), throwException, defaultArraySize);
    registerArrayConverter(Timestamp.class, new SqlTimestampConverter(), throwException, defaultArraySize);
    registerArrayConverter(URL.class, new URLConverter(), throwException, defaultArraySize);

}

From source file:com.sun.faces.config.ManagedBeanFactory.java

private Object getConvertedValueConsideringPrimitives(Object value, Class valueType) throws FacesException {
    if (null != value && null != valueType) {
        if (valueType == Boolean.TYPE || valueType == java.lang.Boolean.class) {
            value = Boolean.valueOf(value.toString().toLowerCase());
        } else if (valueType == Byte.TYPE || valueType == java.lang.Byte.class) {
            value = new Byte(value.toString());
        } else if (valueType == Double.TYPE || valueType == java.lang.Double.class) {
            value = new Double(value.toString());
        } else if (valueType == Float.TYPE || valueType == java.lang.Float.class) {
            value = new Float(value.toString());
        } else if (valueType == Integer.TYPE || valueType == java.lang.Integer.class) {
            value = new Integer(value.toString());
        } else if (valueType == Character.TYPE || valueType == java.lang.Character.class) {
            value = new Character(value.toString().charAt(0));
        } else if (valueType == Short.TYPE || valueType == java.lang.Short.class) {
            value = new Short(value.toString());
        } else if (valueType == Long.TYPE || valueType == java.lang.Long.class) {
            value = new Long(value.toString());
        } else if (valueType == String.class) {
        } else if (!valueType.isAssignableFrom(value.getClass())) {
            throw new FacesException(
                    Util.getExceptionMessageString(Util.MANAGED_BEAN_TYPE_CONVERSION_ERROR_ID, new Object[] {
                            value.toString(), value.getClass(), valueType, managedBean.getManagedBeanName() }));

        }/*from  w ww .j  a  v a  2s .  co  m*/
    }
    return value;
}

From source file:ResultSetIterator.java

/**
 * Convert a <code>ResultSet</code> column into an object.  Simple 
 * implementations could just call <code>rs.getObject(index)</code> while
 * more complex implementations could perform type manipulation to match 
 * the column's type to the bean property type.
 * //from www  .  j  a va  2 s  .c  o m
 * <p>
 * This implementation calls the appropriate <code>ResultSet</code> getter 
 * method for the given property type to perform the type conversion.  If 
 * the property type doesn't match one of the supported 
 * <code>ResultSet</code> types, <code>getObject</code> is called.
 * </p>
 * 
 * @param rs The <code>ResultSet</code> currently being processed.  It is
 * positioned on a valid row before being passed into this method.
 * 
 * @param index The current column index being processed.
 * 
 * @param propType The bean property type that this column needs to be
 * converted into.
 * 
 * @throws SQLException if a database access error occurs
 * 
 * @return The object from the <code>ResultSet</code> at the given column
 * index after optional type processing or <code>null</code> if the column
 * value was SQL NULL.
 */
protected Object processColumn(ResultSet rs, int index, Class propType) throws SQLException {

    if (!propType.isPrimitive() && rs.getObject(index) == null) {
        return null;
    }

    if (propType.equals(String.class)) {
        return rs.getString(index);

    } else if (propType.equals(Integer.TYPE) || propType.equals(Integer.class)) {
        return new Integer(rs.getInt(index));

    } else if (propType.equals(Boolean.TYPE) || propType.equals(Boolean.class)) {
        return new Boolean(rs.getBoolean(index));

    } else if (propType.equals(Long.TYPE) || propType.equals(Long.class)) {
        return new Long(rs.getLong(index));

    } else if (propType.equals(Double.TYPE) || propType.equals(Double.class)) {
        return new Double(rs.getDouble(index));

    } else if (propType.equals(Float.TYPE) || propType.equals(Float.class)) {
        return new Float(rs.getFloat(index));

    } else if (propType.equals(Short.TYPE) || propType.equals(Short.class)) {
        return new Short(rs.getShort(index));

    } else if (propType.equals(Byte.TYPE) || propType.equals(Byte.class)) {
        return new Byte(rs.getByte(index));

    } else if (propType.equals(Timestamp.class)) {
        return rs.getTimestamp(index);

    } else {
        return rs.getObject(index);
    }

}

From source file:org.talend.designer.core.ui.AbstractMultiPageTalendEditor.java

/**
 * Calculates the contents of page 2 when the it is activated.
 *///from w ww. j  av a  2 s.  c o  m
@Override
protected void pageChange(final int newPageIndex) {
    super.pageChange(newPageIndex);
    setName();
    if (newPageIndex == 1) {
        // TDI-25866:In case select a component and switch to the code page,need clean its componentSetting view
        IComponentSettingsView viewer = (IComponentSettingsView) PlatformUI.getWorkbench()
                .getActiveWorkbenchWindow().getActivePage().findView(IComponentSettingsView.ID);

        if (viewer != null) {
            viewer.cleanDisplay();
        }
        if (codeEditor instanceof ISyntaxCheckableEditor) {
            moveCursorToSelectedComponent();

            /*
             * Belowing method had been called at line 331 within the generateCode method, as soon as code
             * generated.
             */
            // ((ISyntaxCheckableEditor) codeEditor).validateSyntax();
        }

        codeSync();
        updateCodeEditorContent();
        changeContextsViewStatus(true);
    } else if (newPageIndex == 0 && (jobletEditor == getEditor(oldPageIndex))) {
        covertJobscriptOnPageChange();
        changeContextsViewStatus(true);
    } else if (jobletEditor == getEditor(newPageIndex)) {
        ICreateXtextProcessService convertJobtoScriptService = CorePlugin.getDefault()
                .getCreateXtextProcessService();

        try {
            final String scriptValue = convertJobtoScriptService.convertJobtoScript(getProcess().saveXmlFile());
            IFile file = (IFile) jobletEditor.getEditorInput().getAdapter(IResource.class);
            ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(scriptValue.getBytes());
            if (file.exists()) {
                jobletEditor.getDocumentProvider().getDocument(jobletEditor.getEditorInput()).set(scriptValue);
                boolean isReadjob = ((JobEditorInput) getEditor(0).getEditorInput()).checkReadOnly();

                IProxyRepositoryFactory rFactory = ProxyRepositoryFactory.getInstance();
                if (isReadjob || rFactory.isUserReadOnlyOnCurrentProject()) {
                    IDocumentProvider provider = jobletEditor.getDocumentProvider();
                    Class p = provider.getClass();
                    Class[] type = new Class[1];
                    type[0] = Boolean.TYPE;
                    Object[] para = new Object[1];
                    para[0] = Boolean.TRUE;
                    Method method = p.getMethod("setReadOnly", type);
                    method.invoke(provider, para);
                }

                IAction action = jobletEditor.getAction("FoldingRestore"); //$NON-NLS-1$
                action.run();
                jobletEditor.doSave(null);
            } else {
                file.create(byteArrayInputStream, true, null);
            }
            if (propertyListener == null) {
                propertyListener = new IPropertyListener() {

                    @Override
                    public void propertyChanged(Object source, int propId) {
                        if (source instanceof IEditorPart && ((IEditorPart) source).isDirty()) {
                            getProcess().setProcessModified(true);
                            getProcess().setNeedRegenerateCode(true);
                        }
                    }

                };
                jobletEditor.addPropertyListener(propertyListener);
            }

        } catch (PartInitException e) {
            ExceptionHandler.process(e);
        } catch (CoreException e) {
            ExceptionHandler.process(e);
        } catch (IOException e) {
            ExceptionHandler.process(e);
        } catch (SecurityException e) {
            ExceptionHandler.process(e);
        } catch (NoSuchMethodException e) {
            ExceptionHandler.process(e);
        } catch (IllegalArgumentException e) {
            ExceptionHandler.process(e);
        } catch (IllegalAccessException e) {
            ExceptionHandler.process(e);
        } catch (InvocationTargetException e) {
            ExceptionHandler.process(e);
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        }
        changeContextsViewStatus(false);
    }
    oldPageIndex = getActivePage();
}

From source file:org.gradle.model.internal.manage.schema.extract.ManagedProxyClassGenerator.java

private void putCanCallSettersFieldValueOnStack(MethodVisitor methodVisitor, Type generatedType) {
    putFieldValueOnStack(methodVisitor, generatedType, CAN_CALL_SETTERS_FIELD_NAME, Boolean.TYPE);
}

From source file:javadz.beanutils.LazyDynaBean.java

/**
 * Is an object of the source class assignable to the destination class?
 *
 * @param dest Destination class/*from  www  . ja  v a 2s.c om*/
 * @param source Source class
 * @return <code>true<code> if the source class is assignable to the
 * destination class, otherwise <code>false</code>
 */
protected boolean isAssignable(Class dest, Class source) {

    if (dest.isAssignableFrom(source) || ((dest == Boolean.TYPE) && (source == Boolean.class))
            || ((dest == Byte.TYPE) && (source == Byte.class))
            || ((dest == Character.TYPE) && (source == Character.class))
            || ((dest == Double.TYPE) && (source == Double.class))
            || ((dest == Float.TYPE) && (source == Float.class))
            || ((dest == Integer.TYPE) && (source == Integer.class))
            || ((dest == Long.TYPE) && (source == Long.class))
            || ((dest == Short.TYPE) && (source == Short.class))) {
        return (true);
    } else {
        return (false);
    }

}

From source file:com.aimfire.gallery.GalleryActivity.java

/**
 * Override Activity lifecycle method./*from w  w  w.  j  av  a2s  .co  m*/
 */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.activity_gallery, menu);

    if (mViewPager != null) {
        shareUpdate(mViewPager.getCurrentItem());
    }

    /*
    * To show icon (instead of only text) in action bar overflow
    */
    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) {
            if (BuildConfig.DEBUG)
                if (VERBOSE)
                    Log.e(TAG, "onCreateOptionsMenu", e);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    return super.onCreateOptionsMenu(menu);
}