List of usage examples for java.lang Boolean TYPE
Class TYPE
To view the source code for java.lang Boolean TYPE.
Click Source Link
From source file:org.pentaho.ui.xul.binding.BindingUtil.java
private static Class getObjectClassOrType(Object o) { if (o instanceof Boolean) { return Boolean.TYPE; } else if (o instanceof Integer) { return Integer.TYPE; } else if (o instanceof Float) { return Float.TYPE; } else if (o instanceof Double) { return Double.TYPE; } else if (o instanceof Short) { return Short.TYPE; } else if (o instanceof Long) { return Long.TYPE; } else {//from w ww . j av a 2 s. c o m return o.getClass(); } }
From source file:Main.java
/** * renderArray returns an array similar to a List. If the array type is an * object they are rendered with "render(object)" for each. If the array * type is a primitive each element is added directly to the string buffer * collecting the result.//from w w w .j a va 2 s .co m * * @param o * @param objectClass * @return */ private static StringBuffer renderArray(Object o, Class<?> objectClass) { Class<?> componentType = objectClass.getComponentType(); StringBuffer sb = new StringBuffer(ARRAY_PREFIX); if (componentType.isPrimitive() == false) { Object[] oa = (Object[]) o; for (int i = 0; i < oa.length; i++) { if (i > 0) { sb.append(ELEMENT_SEPARATOR); } sb.append(render(oa[i])); } } else { if (Boolean.TYPE.equals(componentType)) { boolean[] ba = (boolean[]) o; for (int i = 0; i < ba.length; i++) { if (i > 0) { sb.append(ELEMENT_SEPARATOR); } sb.append(ba[i]); } } else if (Integer.TYPE.equals(componentType)) { int[] ia = (int[]) o; for (int i = 0; i < ia.length; i++) { if (i > 0) { sb.append(ELEMENT_SEPARATOR); } sb.append(ia[i]); } } else if (Long.TYPE.equals(componentType)) { long[] ia = (long[]) o; for (int i = 0; i < ia.length; i++) { if (i > 0) { sb.append(ELEMENT_SEPARATOR); } sb.append(ia[i]); } } else if (Double.TYPE.equals(componentType)) { double[] ia = (double[]) o; for (int i = 0; i < ia.length; i++) { if (i > 0) { sb.append(ELEMENT_SEPARATOR); } sb.append(ia[i]); } } else if (Float.TYPE.equals(componentType)) { float[] ia = (float[]) o; for (int i = 0; i < ia.length; i++) { if (i > 0) { sb.append(ELEMENT_SEPARATOR); } sb.append(ia[i]); } } else if (Character.TYPE.equals(componentType)) { char[] ia = (char[]) o; for (int i = 0; i < ia.length; i++) { if (i > 0) { sb.append(ELEMENT_SEPARATOR); } sb.append(ia[i]); } } else if (Short.TYPE.equals(componentType)) { short[] ia = (short[]) o; for (int i = 0; i < ia.length; i++) { if (i > 0) { sb.append(ELEMENT_SEPARATOR); } sb.append(ia[i]); } } else if (Byte.TYPE.equals(componentType)) { byte[] ia = (byte[]) o; for (int i = 0; i < ia.length; i++) { if (i > 0) { sb.append(ELEMENT_SEPARATOR); } sb.append(ia[i]); } } } sb.append(ARRAY_SUFFIX); return sb; }
From source file:com.github.jknack.handlebars.helper.MethodHelper.java
/** * Wrap (if possible) a primitive type to their wrapper. * * @param type The candidate type./* w w w .jav a 2 s.c o m*/ * @return A wrapper for the primitive type or the original type. */ private static Class<?> wrap(final Class<?> type) { if (type.isPrimitive()) { if (type == Integer.TYPE) { return Integer.class; } else if (type == Boolean.TYPE) { return Boolean.class; } else if (type == Character.TYPE) { return Character.class; } else if (type == Double.TYPE) { return Double.class; } else if (type == Long.TYPE) { return Long.class; } else if (type == Float.TYPE) { return Float.class; } else if (type == Short.TYPE) { return Short.class; } else if (type == Byte.TYPE) { return Byte.class; } } return type; }
From source file:org.jboss.dashboard.database.hibernate.LOBHelper.java
public void oracleNullSafeSet(PreparedStatement statement, Object value, int index, ValueWriter vw) throws HibernateException, SQLException { try {/*from w ww .j a va 2 s . co m*/ // Invoke by reflection the Oracle classes Class oracleBlobClass = Class.forName(ORACLE_CLASS); Method createTempMethod = getMethod(oracleBlobClass, ORACLE_TEMP_METHOD, Connection.class, Boolean.TYPE, Integer.TYPE); Field durationSession = oracleBlobClass.getField(ORACLE_DURATION__SESSION); Object arglist[] = new Object[3]; Connection conn = statement.getConnection(); arglist[0] = conn; arglist[1] = Boolean.TRUE; arglist[2] = durationSession.get(null); Object tempBlob = null; // Needed to avoid JBoss AS class loading issues... Class connClassInCurrentClassLoader = Class.forName(conn.getClass().getName()); // Direct Oracle connection if (Class.forName(ORACLE_JDBC_ORACLE_CONNECTION).isAssignableFrom(connClassInCurrentClassLoader)) { tempBlob = createTempMethod.invoke(null, arglist); // null is valid because of static method } // JBoss AS data source wrapper connection. else if (WrappedConnection.class.isAssignableFrom(connClassInCurrentClassLoader)) { arglist[0] = ReflectionUtils.invokeMethod(conn, "getUnderlyingConnection", null); tempBlob = createTempMethod.invoke(null, arglist); // null is valid because of static method } // C3P0 pool managed connection. else if (NewProxyConnection.class.isAssignableFrom(connClassInCurrentClassLoader)) { NewProxyConnection castCon = (NewProxyConnection) conn; arglist[0] = C3P0ProxyConnection.RAW_CONNECTION; tempBlob = castCon.rawConnectionOperation(createTempMethod, C3P0ProxyConnection.RAW_CONNECTION, arglist); } // Apache's DBCP pool managed connection. else if (PoolableConnection.class.isAssignableFrom(connClassInCurrentClassLoader)) { arglist[0] = ((PoolableConnection) statement.getConnection()).getDelegate(); tempBlob = createTempMethod.invoke(null, arglist); // null is valid because of static method } else { boolean throwException = true; //check if we are running in websphere try { String wasConnectionWrapper = "com.ibm.ws.rsadapter.jdbc.WSJdbcConnection"; Class wasConnectionWrapperClass = Class.forName(wasConnectionWrapper); if (wasConnectionWrapperClass.isAssignableFrom(connClassInCurrentClassLoader)) { String helperClass = "com.ibm.websphere.rsadapter.WSCallHelper"; Class helper = Class.forName(helperClass); Method nativeConnMethod = helper.getMethod("getNativeConnection", new Class[] { Object.class }); Connection nativeConn = (Connection) nativeConnMethod.invoke(null, conn); if (Class.forName(ORACLE_JDBC_ORACLE_CONNECTION).isAssignableFrom(nativeConn.getClass())) { arglist[0] = nativeConn; tempBlob = createTempMethod.invoke(null, arglist); throwException = false; } } } catch (Throwable e) { e.printStackTrace(); // do nothing } if (throwException) { throw new HibernateException("JDBC connection object must be a oracle.jdbc.OracleConnection " + "a " + WrappedConnection.class.getName() + "a " + PoolableConnection.class.getName() + "or a " + NewProxyConnection.class.getName() + ". Connection class is " + connClassInCurrentClassLoader.getName()); } } Method openMethod = getMethod(oracleBlobClass, ORACLE_OPEN_METHOD, Integer.TYPE, null, null); Field fieldReadWrite = oracleBlobClass.getField(ORACLE_MODE__READWRITE); arglist = new Object[1]; arglist[0] = fieldReadWrite.get(null); //null is valid because of static field openMethod.invoke(tempBlob, arglist); Method getOutputStreamMethod = oracleBlobClass.getDeclaredMethod(ORACLE_GET_BINARY_OUTPUT_STREAM, null); OutputStream os = (OutputStream) getOutputStreamMethod.invoke(tempBlob, null); try { vw.writeValue(os, value); os.flush(); } finally { os.close(); } Method closeMethod = oracleBlobClass.getDeclaredMethod(ORACLE_CLOSE, null); closeMethod.invoke(tempBlob, null); statement.setBlob(index, (Blob) tempBlob); } catch (Exception e) { throw new HibernateException("Error in oracleNullSafeSet", e); } }
From source file:nl.strohalm.cyclos.controls.reports.members.transactions.MembersReportHandler.java
public BeanBinder<MembersTransactionsReportDTO> getDataBinder() { if (binder == null) { BeanBinder<MembersTransactionsReportDTO> temp; final ReferenceConverter<AccountType> accountTypeConverter = ReferenceConverter .instance(AccountType.class); final ReferenceConverter<PaymentFilter> paymentFilterConverter = ReferenceConverter .instance(PaymentFilter.class); final ReferenceConverter<MemberGroup> memberGroupConverter = ReferenceConverter .instance(MemberGroup.class); temp = BeanBinder.instance(MembersTransactionsReportDTO.class); temp.registerBinder("memberName", PropertyBinder.instance(Boolean.TYPE, "memberName")); temp.registerBinder("brokerUsername", PropertyBinder.instance(Boolean.TYPE, "brokerUsername")); temp.registerBinder("brokerName", PropertyBinder.instance(Boolean.TYPE, "brokerName")); temp.registerBinder("accountTypes", SimpleCollectionBinder.instance(AccountType.class, "accountTypes", accountTypeConverter)); temp.registerBinder("memberGroups", SimpleCollectionBinder.instance(MemberGroup.class, "memberGroups", memberGroupConverter)); temp.registerBinder("period", DataBinderHelper.periodBinder(settings, "period")); // Transactions related binding temp.registerBinder("transactionsPaymentFilters", SimpleCollectionBinder.instance(PaymentFilter.class, "transactionsPaymentFilters", paymentFilterConverter)); temp.registerBinder("incomingTransactions", PropertyBinder.instance(Boolean.TYPE, "incomingTransactions")); temp.registerBinder("outgoingTransactions", PropertyBinder.instance(Boolean.TYPE, "outgoingTransactions")); temp.registerBinder("includeNoTraders", PropertyBinder.instance(Boolean.TYPE, "includeNoTraders")); temp.registerBinder("detailsLevel", PropertyBinder.instance(MembersTransactionsReportDTO.DetailsLevel.class, "detailsLevel")); binder = temp;//from w w w .j a v a 2 s . c o m } return binder; }
From source file:nl.strohalm.cyclos.controls.members.bulk.MemberBulkGenerateCardAction.java
@Override protected void formAction(final ActionContext context) throws Exception { final MemberBulkActionsForm form = context.getForm(); final MapBean bean = form.getGenerateCard(); final FullTextMemberQuery query = getDataBinder().readFromString(form.getQuery()); final boolean generateForPending = CoercionHelper.coerce(Boolean.TYPE, bean.get("generateForPending")); final boolean generateForActive = CoercionHelper.coerce(Boolean.TYPE, bean.get("generateForActive")); final BulkMemberActionResultVO results = cardService.bulkGenerateNewCard(query, generateForPending, generateForActive);// www.j a v a2 s. co m context.sendMessage("member.bulkActions.cardGenerated", results.getChanged(), results.getUnchanged()); // Clear the generate card parameters form.getGenerateCard().clear(); }
From source file:nl.strohalm.cyclos.controls.members.bulk.MemberBulkChangeBrokerAction.java
@Override protected void formAction(final ActionContext context) throws Exception { final MemberBulkActionsForm form = context.getForm(); // Read the user input final MapBean bean = form.getChangeBroker(); final FullTextMemberQuery query = getDataBinder().readFromString(form.getQuery()); final Member newBroker = elementService.load(CoercionHelper.coerce(Long.class, bean.get("newBroker"))); final boolean suspendCommission = CoercionHelper.coerce(Boolean.TYPE, bean.get("suspendCommission")); final String comments = StringUtils.trimToNull((String) bean.get("comments")); final BulkMemberActionResultVO results = brokeringService.bulkChangeMemberBroker(query, newBroker, suspendCommission, comments); context.sendMessage("member.bulkActions.brokerChanged", results.getChanged(), results.getUnchanged(), newBroker.getName());//from w w w. j a va 2 s.c o m // Clear the change broker parameters form.getChangeBroker().clear(); }
From source file:com.alibaba.doris.admin.service.impl.ValueParseUtil.java
/** * ?String ?:/*from w w w .ja v a2 s. co m*/ * * <pre> * short, int, long, float : 0 * char, byte: 0 * String: null * Map, List: null * Integer, Long, Float : null * Date: null * array: null * </pre> * * @param strValue * @param clazz * @return */ @SuppressWarnings("unchecked") public static <T> T parseStringValue(String strValue, Class<T> clazz, boolean autoDefault) { if (DEF_NULL.equals(strValue)) { if (!clazz.isPrimitive()) { return null; } if (autoDefault) { return (T) getInternalDefaultValue(clazz); } else { return null; } } if (DEF_EMPTY.equals(strValue)) { if (clazz.isArray()) { return (T) Array.newInstance(clazz.getComponentType(), 0); } if (Map.class.isAssignableFrom(clazz)) { return (T) Collections.EMPTY_MAP; } if (List.class.isAssignableFrom(clazz)) { return (T) new ArrayList<Object>(); } if (Set.class.isAssignableFrom(clazz)) { return (T) new HashSet<Object>(); } if (String.class.equals(clazz)) { return (T) StringUtils.EMPTY; } if (Character.TYPE.equals(clazz) || Character.class.equals(clazz)) { return (T) Character.valueOf(' '); } if (autoDefault) { return (T) getInternalDefaultValue(clazz); } else { return null; } } if (StringUtils.isBlank(strValue)) {// ? if (autoDefault) { return (T) getInternalDefaultValue(clazz); } else { return null; } } else { if (String.class.equals(clazz)) { return (T) strValue; } if (Short.TYPE.equals(clazz) || Short.class.equals(clazz)) { return (T) Short.valueOf(strValue); } if (Integer.TYPE.equals(clazz) || Integer.class.equals(clazz)) { return (T) Integer.valueOf(strValue); } if (Long.TYPE.equals(clazz) || Long.class.equals(clazz)) { return (T) Long.valueOf(strValue); } if (Boolean.TYPE.equals(clazz) || Boolean.class.equals(clazz)) { return (T) Boolean.valueOf(strValue); } if (Float.TYPE.equals(clazz) || Float.class.equals(clazz)) { return (T) Float.valueOf(strValue); } if (Double.TYPE.equals(clazz) || Double.class.equals(clazz)) { return (T) Double.valueOf(strValue); } if (Byte.TYPE.equals(clazz) || Byte.class.equals(clazz)) { return (T) Byte.valueOf(strValue); } if (Character.TYPE.equals(clazz) || Character.class.equals(clazz)) { return (T) Character.valueOf(strValue.charAt(0)); } if (clazz.isArray()) { final Class<?> componentType = clazz.getComponentType(); // String[] if (String.class.equals(componentType)) { return (T) StringUtils.split(strValue, ','); } // ?char[] if (Character.TYPE.equals(componentType)) { return (T) strValue.toCharArray(); } if (Character.class.equals(componentType)) { final char[] tmp = strValue.toCharArray(); final Character[] result = new Character[tmp.length]; for (int i = 0; i < result.length; i++) { result[i] = tmp[i]; } return (T) result; } if (Byte.TYPE.equals(componentType) || Byte.class.equals(componentType)) { return (T) (strValue == null ? null : strValue.getBytes()); } } } return null; }
From source file:org.kordamp.ezmorph.primitive.BooleanMorpher.java
public Class<?> morphsTo() { return Boolean.TYPE; }
From source file:com.l2jfree.config.L2Properties.java
@SuppressWarnings("unchecked") public Object getProperty(Class<?> expectedType, ConfigProperty configProperty) { final String name = configProperty.name(); final String defaultValue = configProperty.value(); if (expectedType == Boolean.class || expectedType == Boolean.TYPE) { return getBool(name, defaultValue); } else if (expectedType == Long.class || expectedType == Long.TYPE) { return getLong(name, defaultValue); } else if (expectedType == Integer.class || expectedType == Integer.TYPE) { return getInteger(name, defaultValue); } else if (expectedType == Short.class || expectedType == Short.TYPE) { return getShort(name, defaultValue); } else if (expectedType == Byte.class || expectedType == Byte.TYPE) { return getByte(name, defaultValue); } else if (expectedType == Double.class || expectedType == Double.TYPE) { return getDouble(name, defaultValue); } else if (expectedType == Float.class || expectedType == Float.TYPE) { return getFloat(name, defaultValue); } else if (expectedType == String.class) { return getString(name, defaultValue); } else if (expectedType.isEnum()) { return getEnum(name, (Class<? extends Enum>) expectedType, defaultValue); } else {//from w ww. j a v a 2 s . co m throw new IllegalStateException(); } }