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.apache.catalina.mbeans.ConnectorMBean.java
/** * Set Client authentication info/*w w w. jav a 2s.c o m*/ * * @exception Exception if an MBean cannot be created or registered */ public void setClientAuth(boolean clientAuth) throws Exception { Class coyoteConnectorCls = Class.forName("org.apache.coyote.tomcat4.CoyoteConnector"); if (coyoteConnectorCls.isInstance(this.resource)) { // get factory Method meth1 = coyoteConnectorCls.getMethod("getFactory", null); Object factory = meth1.invoke(this.resource, null); Class coyoteServerSocketFactoryCls = Class .forName("org.apache.coyote.tomcat4.CoyoteServerSocketFactory"); if (coyoteServerSocketFactoryCls.isInstance(factory)) { // set clientAuth Class partypes2[] = new Class[1]; partypes2[0] = Boolean.TYPE; Method meth2 = coyoteServerSocketFactoryCls.getMethod("setClientAuth", partypes2); Object arglist2[] = new Object[1]; arglist2[0] = new Boolean(clientAuth); meth2.invoke(factory, arglist2); } } }
From source file:org.cocoa4android.util.sbjson.SBJsonWriter.java
/** * //from ww w . ja v a 2s .c o m * @param clazz * @return */ public static boolean isBoolean(Class<?> clazz) { return (clazz != null) && ((Boolean.TYPE.isAssignableFrom(clazz)) || (Boolean.class.isAssignableFrom(clazz))); }
From source file:nl.strohalm.cyclos.services.settings.LocalSettingsHandler.java
@Override protected Map<String, Converter<?>> createConverters() { final Map<String, Converter<?>> localConverters = new LinkedHashMap<String, Converter<?>>(); localConverters.put("applicationName", CoercionConverter.instance(String.class)); localConverters.put("applicationUsername", CoercionConverter.instance(String.class)); localConverters.put("rootUrl", CoercionConverter.instance(String.class)); localConverters.put("language", CoercionConverter.instance(Language.class)); localConverters.put("numberLocale", CoercionConverter.instance(NumberLocale.class)); localConverters.put("precision", CoercionConverter.instance(Precision.class)); localConverters.put("highPrecision", CoercionConverter.instance(Precision.class)); localConverters.put("decimalInputMethod", CoercionConverter.instance(DecimalInputMethod.class)); localConverters.put("datePattern", CoercionConverter.instance(DatePattern.class)); localConverters.put("timePattern", CoercionConverter.instance(TimePattern.class)); localConverters.put("timeZone", TimeZoneConverter.instance()); localConverters.put("containerUrl", CoercionConverter.instance(String.class)); localConverters.put("maxIteratorResults", CoercionConverter.instance(Integer.TYPE)); localConverters.put("maxPageResults", CoercionConverter.instance(Integer.TYPE)); localConverters.put("maxAjaxResults", CoercionConverter.instance(Integer.TYPE)); localConverters.put("maxUploadSize", CoercionConverter.instance(Integer.TYPE)); localConverters.put("maxUploadUnits", CoercionConverter.instance(FileUnits.class)); localConverters.put("maxImageWidth", CoercionConverter.instance(Integer.TYPE)); localConverters.put("maxImageHeight", CoercionConverter.instance(Integer.TYPE)); localConverters.put("maxThumbnailWidth", CoercionConverter.instance(Integer.TYPE)); localConverters.put("maxThumbnailHeight", CoercionConverter.instance(Integer.TYPE)); localConverters.put("referenceLevels", CoercionConverter.instance(Integer.TYPE)); localConverters.put("smsEnabled", CoercionConverter.instance(Boolean.TYPE)); localConverters.put("csvUseHeader", CoercionConverter.instance(Boolean.TYPE)); localConverters.put("csvRecordSeparator", CoercionConverter.instance(CsvRecordSeparator.class)); localConverters.put("csvValueSeparator", CoercionConverter.instance(CsvValueSeparator.class)); localConverters.put("csvStringQuote", CoercionConverter.instance(CsvStringQuote.class)); localConverters.put("cyclosId", CoercionConverter.instance(String.class)); localConverters.put("sendSmsWebServiceUrl", CoercionConverter.instance(String.class)); localConverters.put("smsChannelName", CoercionConverter.instance(String.class)); localConverters.put("smsCustomFieldId", IdConverter.instance()); localConverters.put("transactionNumber.prefix", CoercionConverter.instance(String.class)); localConverters.put("transactionNumber.padLength", CoercionConverter.instance(Integer.TYPE)); localConverters.put("transactionNumber.suffix", CoercionConverter.instance(String.class)); localConverters.put("emailRequired", CoercionConverter.instance(Boolean.TYPE)); localConverters.put("emailUnique", CoercionConverter.instance(Boolean.TYPE)); localConverters.put("brokeringExpirationPeriod.number", CoercionConverter.instance(Integer.class)); localConverters.put("brokeringExpirationPeriod.field", CoercionConverter.instance(Field.class)); localConverters.put("deleteMessagesOnTrashAfter.number", CoercionConverter.instance(Integer.class)); localConverters.put("deleteMessagesOnTrashAfter.field", CoercionConverter.instance(Field.class)); localConverters.put("deletePendingRegistrationsAfter.number", CoercionConverter.instance(Integer.class)); localConverters.put("deletePendingRegistrationsAfter.field", CoercionConverter.instance(Field.class)); localConverters.put("memberSortOrder", CoercionConverter.instance(SortOrder.class)); localConverters.put("memberResultDisplay", CoercionConverter.instance(MemberResultDisplay.class)); localConverters.put("adDescriptionFormat", CoercionConverter.instance(TextFormat.class)); localConverters.put("messageFormat", CoercionConverter.instance(TextFormat.class)); localConverters.put("schedulingHour", CoercionConverter.instance(Integer.TYPE)); localConverters.put("schedulingMinute", CoercionConverter.instance(Integer.TYPE)); localConverters.put("transferListenerClass", CoercionConverter.instance(String.class)); localConverters.put("maxChargebackTime.number", CoercionConverter.instance(Integer.class)); localConverters.put("maxChargebackTime.field", CoercionConverter.instance(Field.class)); localConverters.put("chargebackDescription", CoercionConverter.instance(String.class)); localConverters.put("showCountersInAdCategories", CoercionConverter.instance(Boolean.TYPE)); return localConverters; }
From source file:com.medallia.spider.api.DynamicInputImpl.java
/** * Method used to parse values for the methods declared in {@link Input}. *///from w w w.j av a 2s . c o m public <X> X getInput(String name, Class<X> type, AnnotatedElement anno) { // Special case for file uploads if (type.isAssignableFrom(UploadedFile.class)) return type.cast(fileUploads.get(name)); // Also support just getting the bytes from a file without the name if (type.isArray() && type.getComponentType() == Byte.TYPE) { UploadedFile uploadedFile = fileUploads.get(name); return uploadedFile != null ? type.cast(uploadedFile.getBytes()) : null; } if (type.isArray() && anno.isAnnotationPresent(Input.MultiValued.class)) { // return type is an array; grab all Object o = inputParams.get(name); return type.cast(parseMultiValue(type, o, anno)); } String v = Strings.extract(inputParams.get(name)); // boolean is used for checkboxes, and false is encoded as a missing value if (type == Boolean.class || type == Boolean.TYPE) { @SuppressWarnings("unchecked") X x = (X) Boolean.valueOf(v != null && !"false".equalsIgnoreCase(v)); return x; } // the remaining types have proper null values if (v == null) return null; return cast(parseSingleValue(type, v, anno, inputArgParsers)); }
From source file:org.kuali.kfs.sys.context.DocumentSerializabilityTest.java
/** * Determines if the given class represents one of the eight Java primitives * @param clazz the class to check// w w w . j av a 2 s . c o m * @return true if the class represents a byte, short, int, long, char, double, float, or boolean; false otherwise */ protected boolean isPrimitive(Class<?> clazz) { return Byte.TYPE.isAssignableFrom(clazz) || Short.TYPE.isAssignableFrom(clazz) || Integer.TYPE.isAssignableFrom(clazz) || Long.TYPE.isAssignableFrom(clazz) || Float.TYPE.isAssignableFrom(clazz) || Double.TYPE.isAssignableFrom(clazz) || Character.TYPE.isAssignableFrom(clazz) || Boolean.TYPE.isAssignableFrom(clazz); }
From source file:org.wso2.carbon.analytics.message.tracer.handler.modules.ActivityInHandler.java
@SuppressWarnings("unchecked") private void buildSoapMessage(MessageContext messageContext) throws AxisFault { try {//from w ww . j a v a 2s . co m Class cls = Class.forName( MessageTracerConstants.ORG_APACHE_SYNAPSE_TRANSPORT_PASSTHRU_UTIL_RELAY_UTILS_CLASS_NAME); Class[] paramClasses = new Class[] { MessageContext.class, Boolean.TYPE }; Method method = cls.getMethod(MessageTracerConstants.BUILD_MESSAGE_METHOD_NAME, paramClasses); method.invoke(null, messageContext, false); } catch (ClassNotFoundException ignore) { LOG.warn(ignore); } catch (Exception e) { throw new AxisFault("Error in building input message: " + e.getMessage(), e); } }
From source file:org.hyperic.lather.util.Latherize.java
public void latherize(boolean xDocletStyle, String outPackage, Class fClass, OutputStream os) throws LatherizeException, IOException { final String INDENT = " "; PrintWriter pWriter;//from ww w. ja v a 2 s. c o m DynaProperty[] dProps; WrapDynaBean dBean; DynaClass dClass; Object beanInstance; String className, lClassName; try { beanInstance = fClass.newInstance(); } catch (IllegalAccessException exc) { throw new LatherizeException("Illegal access trying to create " + "new instance"); } catch (InstantiationException exc) { throw new LatherizeException("Unable to instantiate: " + exc.getMessage()); } dBean = new WrapDynaBean(beanInstance); dClass = dBean.getDynaClass(); dProps = dClass.getDynaProperties(); pWriter = new PrintWriter(os); className = fClass.getName(); className = className.substring(className.lastIndexOf(".") + 1); lClassName = "Lather" + className; pWriter.println("package " + outPackage + ";"); pWriter.println(); pWriter.println("import " + LatherValue.class.getName() + ";"); pWriter.println("import " + LatherRemoteException.class.getName() + ";"); pWriter.println("import " + LatherKeyNotFoundException.class.getName() + ";"); pWriter.println("import " + fClass.getName() + ";"); pWriter.println(); pWriter.println("public class " + lClassName); pWriter.println(" extends LatherValue"); pWriter.println("{"); for (int i = 0; i < dProps.length; i++) { pWriter.print(" "); if (!this.isLatherStyleProp(dProps[i])) { pWriter.print("// "); } pWriter.println("private static final String " + this.makePropVar(dProps[i]) + " = \"" + dProps[i].getName() + "\";"); } pWriter.println(); pWriter.println(" public " + lClassName + "(){"); pWriter.println(" super();"); pWriter.println(" }"); pWriter.println(); pWriter.println(" public " + lClassName + "(" + className + " v){"); pWriter.println(" super();"); pWriter.println(); for (int i = 0; i < dProps.length; i++) { String propVar = this.makePropVar(dProps[i]); String getter = "v." + this.makeGetter(dProps[i]) + "()"; if (!this.isLatherStyleProp(dProps[i])) { continue; } if (xDocletStyle) { String lName; lName = dProps[i].getName(); lName = lName.substring(0, 1).toLowerCase() + lName.substring(1); pWriter.println(INDENT + "if(v." + lName + "HasBeenSet()){"); pWriter.print(" "); } if (dProps[i].getType().equals(String.class)) { pWriter.println(INDENT + "this.setStringValue(" + propVar + ", " + getter + ");"); } else if (dProps[i].getType().equals(Integer.TYPE)) { pWriter.println(INDENT + "this.setIntValue(" + propVar + ", " + getter + ");"); } else if (dProps[i].getType().equals(Integer.class)) { pWriter.println(INDENT + "this.setIntValue(" + propVar + ", " + getter + ".intValue());"); } else if (dProps[i].getType().equals(Long.TYPE)) { pWriter.println(INDENT + "this.setDoubleValue(" + propVar + ", (double)" + getter + ");"); } else if (dProps[i].getType().equals(Long.class)) { pWriter.println( INDENT + "this.setDoubleValue(" + propVar + ", (double)" + getter + ".longValue());"); } else if (dProps[i].getType().equals(Boolean.TYPE)) { pWriter.println(INDENT + "this.setIntValue(" + propVar + ", " + getter + " ? 1 : 0);"); } else if (dProps[i].getType().equals(Boolean.class)) { pWriter.println( INDENT + "this.setIntValue(" + propVar + ", " + getter + ".booleanValue() ? 1 : 0);"); } else if (dProps[i].getType().equals(Double.TYPE)) { pWriter.println(INDENT + "this.setDoubleValue(" + propVar + ", " + getter + ");"); } else if (dProps[i].getType().equals(Double.class)) { pWriter.println(INDENT + "this.setDoubleValue(" + propVar + ", " + getter + ".doubleValue());"); } else if (dProps[i].getType().equals(byte[].class)) { pWriter.println(INDENT + "this.setByteAValue(" + propVar + ", " + getter + ");"); } else { pWriter.println(INDENT + "this.setObjectValue(" + "DONT KNOW HOW TO HANDLE THIS, " + getter + ");"); } if (xDocletStyle) { pWriter.println(INDENT + "}"); pWriter.println(); } } pWriter.println(" }"); pWriter.println(); pWriter.println(" public " + className + " get" + className + "(){"); pWriter.println(INDENT + className + " r = new " + className + "();"); pWriter.println(); for (int i = 0; i < dProps.length; i++) { String propVar = this.makePropVar(dProps[i]); String setter = "r." + this.makeSetter(dProps[i]) + "("; if (!this.isLatherStyleProp(dProps[i])) { continue; } if (xDocletStyle) { pWriter.println(INDENT + "try {"); pWriter.print(" "); } pWriter.print(INDENT + setter); if (dProps[i].getType().equals(String.class)) { pWriter.println("this.getStringValue(" + propVar + "));"); } else if (dProps[i].getType().equals(Integer.TYPE)) { pWriter.println("this.getIntValue(" + propVar + "));"); } else if (dProps[i].getType().equals(Integer.class)) { pWriter.println("new Integer(this.getIntValue(" + propVar + ")));"); } else if (dProps[i].getType().equals(Long.TYPE)) { pWriter.println("(long)this.getDoubleValue(" + propVar + "));"); } else if (dProps[i].getType().equals(Long.class)) { pWriter.println("new Long((long)this.getDoubleValue(" + propVar + ")));"); } else if (dProps[i].getType().equals(Boolean.TYPE)) { pWriter.println("this.getIntValue(" + propVar + ") == 1 ? " + "true : false);"); } else if (dProps[i].getType().equals(Boolean.class)) { pWriter.println("this.getIntValue(" + propVar + ") == 1 ? " + "Boolean.TRUE : Boolean.FALSE);"); } else if (dProps[i].getType().equals(Double.TYPE)) { pWriter.println("this.getDoubleValue(" + propVar + "));"); } else if (dProps[i].getType().equals(Double.class)) { pWriter.println("new Double(this.getDoubleValue(" + propVar + ")));"); } else if (dProps[i].getType().equals(byte[].class)) { pWriter.println("this.getByteAValue(" + propVar + "));"); } else { pWriter.println("DONT KNOW HOW TO HANDLE " + propVar + "));"); } if (xDocletStyle) { pWriter.println(INDENT + "} catch(LatherKeyNotFoundException " + "exc){}"); pWriter.println(); } } pWriter.println(INDENT + "return r;"); pWriter.println(" }"); pWriter.println(); pWriter.println(" protected void validate()"); pWriter.println(" throws LatherRemoteException"); pWriter.println(" {"); if (!xDocletStyle) { pWriter.println(" try { "); pWriter.println(" this.get" + className + "();"); pWriter.println(" } catch(LatherKeyNotFoundException e){"); pWriter.println(" throw new LatherRemoteException(\"" + "All values not set\");"); pWriter.println(" }"); } pWriter.println(" }"); pWriter.println("}"); pWriter.flush(); }
From source file:org.seedstack.seed.core.internal.application.ConfigurationMembersInjector.java
@SuppressWarnings("unchecked") private void writeArrayField(T instance) { ConfigurationConverter<?> converter; Class<?> componentType = field.getType().getComponentType(); converter = findConverter(instance, componentType); String[] values = configuration.getStringArray(annotation.value()); if ((values == null || values.length == 0) && annotation.defaultValue().length > 0) { values = annotation.defaultValue(); }/*from w w w . j av a 2 s . com*/ if (values != null && values.length > 0) { if (componentType.isPrimitive()) { if (componentType == Short.TYPE) { writeField(instance, convertToShortValues(values, (ConfigurationConverter<Short>) converter)); } if (componentType == Integer.TYPE) { writeField(instance, convertToIntegerValues(values, (ConfigurationConverter<Integer>) converter)); } if (componentType == Boolean.TYPE) { writeField(instance, convertToBooleanValues(values, (ConfigurationConverter<Boolean>) converter)); } if (componentType == Byte.TYPE) { writeField(instance, convertToByteValues(values, (ConfigurationConverter<Byte>) converter)); } if (componentType == Long.TYPE) { writeField(instance, convertToLongValues(values, (ConfigurationConverter<Long>) converter)); } if (componentType == Float.TYPE) { writeField(instance, convertToFloatValues(values, (ConfigurationConverter<Float>) converter)); } if (componentType == Double.TYPE) { writeField(instance, convertToDoubleValues(values, (ConfigurationConverter<Double>) converter)); } if (componentType == Character.TYPE) { writeField(instance, convertToCharacterValues(values, (ConfigurationConverter<Character>) converter)); } } else { Object[] convertedValues; try { convertedValues = (Object[]) Array.newInstance(field.getType().getComponentType(), values.length); } catch (Exception e) { throw SeedException.wrap(e, ApplicationErrorCode.UNABLE_TO_INSTANTIATE_CONFIGURATION_ARRAY); } for (int i = 0; i < values.length; i++) { convertedValues[i] = converter.convert(values[i]); } writeField(instance, convertedValues); } } else { LOGGER.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, annotation.value()); } }
From source file:org.gradle.internal.reflect.JavaReflectionUtil.java
public static Class<?> getWrapperTypeForPrimitiveType(Class<?> type) { if (type == Character.TYPE) { return Character.class; } else if (type == Boolean.TYPE) { return Boolean.class; } else if (type == Long.TYPE) { return Long.class; } else if (type == Integer.TYPE) { return Integer.class; } else if (type == Short.TYPE) { return Short.class; } else if (type == Byte.TYPE) { return Byte.class; } else if (type == Float.TYPE) { return Float.class; } else if (type == Double.TYPE) { return Double.class; }/*from w w w. j ava 2 s. c o m*/ throw new IllegalArgumentException( String.format("Don't know the wrapper type for primitive type %s.", type)); }
From source file:org.more.webui.components.upload.Upload.java
public boolean getAllowMulti() { return this.getProperty(Propertys.allowMulti.name()).valueTo(Boolean.TYPE); }