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.openamf.config.ConfigDigester.java
private void addAMFSerializerRules() { addObjectCreate(AMFSERIALIZER_PATH, AMFSerializerConfig.class); addSetNext(AMFSERIALIZER_PATH, "setAMFSerializerConfig", "org.openamf.config.AMFSerializerConfig"); addCallMethod(AMFSERIALIZER_PATH + "/force-lower-case-keys", "setForceLowerCaseKeys", 0, new Class[] { Boolean.TYPE }); }
From source file:org.cloudata.core.common.io.CObjectWritable.java
/** Write a {@link CWritable}, {@link String}, primitive type, or an array of * the preceding. *///from www .jav a 2 s . c o m public static void writeObject(DataOutput out, Object instance, Class declaredClass, CloudataConf conf, boolean arrayComponent) throws IOException { if (instance == null) { // null instance = new NullInstance(declaredClass, conf); declaredClass = CWritable.class; arrayComponent = false; } if (!arrayComponent) { CUTF8.writeString(out, declaredClass.getName()); // always write declared //System.out.println("Write:declaredClass.getName():" + declaredClass.getName()); } if (declaredClass.isArray()) { // array int length = Array.getLength(instance); out.writeInt(length); //System.out.println("Write:length:" + length); if (declaredClass.getComponentType() == Byte.TYPE) { out.write((byte[]) instance); } else if (declaredClass.getComponentType() == ColumnValue.class) { //ColumnValue? Deserialize? ?? ? ?? ? . writeColumnValue(out, instance, declaredClass, conf, length); } else { for (int i = 0; i < length; i++) { writeObject(out, Array.get(instance, i), declaredClass.getComponentType(), conf, !declaredClass.getComponentType().isArray()); } } } else if (declaredClass == String.class) { // String CUTF8.writeString(out, (String) instance); } else if (declaredClass.isPrimitive()) { // primitive type if (declaredClass == Boolean.TYPE) { // boolean out.writeBoolean(((Boolean) instance).booleanValue()); } else if (declaredClass == Character.TYPE) { // char out.writeChar(((Character) instance).charValue()); } else if (declaredClass == Byte.TYPE) { // byte out.writeByte(((Byte) instance).byteValue()); } else if (declaredClass == Short.TYPE) { // short out.writeShort(((Short) instance).shortValue()); } else if (declaredClass == Integer.TYPE) { // int out.writeInt(((Integer) instance).intValue()); } else if (declaredClass == Long.TYPE) { // long out.writeLong(((Long) instance).longValue()); } else if (declaredClass == Float.TYPE) { // float out.writeFloat(((Float) instance).floatValue()); } else if (declaredClass == Double.TYPE) { // double out.writeDouble(((Double) instance).doubleValue()); } else if (declaredClass == Void.TYPE) { // void } else { throw new IllegalArgumentException("Not a primitive: " + declaredClass); } } else if (declaredClass.isEnum()) { // enum CUTF8.writeString(out, ((Enum) instance).name()); } else if (CWritable.class.isAssignableFrom(declaredClass)) { // Writable if (instance.getClass() == declaredClass) { out.writeShort(TYPE_SAME); // ? ?? ? ?? //System.out.println("Write:TYPE_SAME:" + TYPE_SAME); } else { out.writeShort(TYPE_DIFF); //System.out.println("Write:TYPE_DIFF:" + TYPE_DIFF); CUTF8.writeString(out, instance.getClass().getName()); //System.out.println("Write:instance.getClass().getName():" + instance.getClass().getName()); } ((CWritable) instance).write(out); //System.out.println("Write:instance value"); } else { throw new IOException("Can't write: " + instance + " as " + declaredClass); } }
From source file:org.openide.windows.TopComponent.java
/** Create a top component. *//*from ww w . ja va 2 s . com*/ public TopComponent() { log.debug("using stand-alone GP TopComponent"); enableEvents(java.awt.AWTEvent.KEY_EVENT_MASK); // there is no reason why a top component should have a focus // => let's disable it //// if (Dependency.JAVA_SPEC.compareTo(new SpecificationVersion("1.4")) >= 0) { if (true) //// try { Method method = getClass().getMethod("setFocusable", new Class[] { Boolean.TYPE }); method.invoke(this, new Object[] { new Boolean(false) }); } catch (Exception ex) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); } //// } else { //// setRequestFocusEnabled (false); //// } // request creating of our manager - it's here to avoid // problems with recreating the connections between top components // and their managers during deserialization manager = WindowManager.getDefault().createTopComponentManager(this); }
From source file:org.onebusaway.gtfs_transformer.deferred.DeferredValueConverter.java
private boolean isPrimitiveAssignable(Class<?> expectedValueType, Class<?> actualValueType) { if (!expectedValueType.isPrimitive()) { return false; }/*from w w w . j a v a 2s . c om*/ return expectedValueType == Double.TYPE && (actualValueType == Double.class || actualValueType == Float.class) || expectedValueType == Long.TYPE && (actualValueType == Long.class || actualValueType == Integer.class || actualValueType == Short.class) || expectedValueType == Integer.TYPE && (actualValueType == Integer.class || actualValueType == Short.class) || expectedValueType == Short.TYPE && (actualValueType == Short.class) || expectedValueType == Boolean.TYPE && (actualValueType == Boolean.class); }
From source file:org.elasticsoftware.elasticactors.configuration.BackplaneConfiguration.java
@Bean(name = { "asyncUpdateExecutor" }, destroyMethod = "shutdown") public ThreadBoundExecutor createAsyncUpdateExecutor() { final int workers = env.getProperty("ea.asyncUpdateExecutor.workerCount", Integer.class, Runtime.getRuntime().availableProcessors() * 3); final int batchSize = env.getProperty("ea.asyncUpdateExecutor.batchSize", Integer.class, 20); final boolean optimizedV1Batches = env.getProperty("ea.asyncUpdateExecutor.optimizedV1Batches", Boolean.TYPE, true); return new ThreadBoundExecutorImpl( new PersistentActorUpdateEventProcessor(cassandraSession, batchSize, optimizedV1Batches), batchSize, new DaemonThreadFactory("UPDATE-EXECUTOR-WORKER"), workers); }
From source file:com.cyclopsgroup.waterview.utils.TypeUtils.java
private static Map getNonePrimitiveTypeMap() { if (nonePrimitiveTypeMap == null) { nonePrimitiveTypeMap = new Hashtable(); nonePrimitiveTypeMap.put(Boolean.TYPE, Boolean.class); nonePrimitiveTypeMap.put(Byte.TYPE, Byte.class); nonePrimitiveTypeMap.put(Character.TYPE, Character.class); nonePrimitiveTypeMap.put(Short.TYPE, Short.class); nonePrimitiveTypeMap.put(Integer.TYPE, Integer.class); nonePrimitiveTypeMap.put(Long.TYPE, Long.class); nonePrimitiveTypeMap.put(Float.TYPE, Float.class); nonePrimitiveTypeMap.put(Double.TYPE, Double.class); }//from w ww . j a v a 2 s . co m return nonePrimitiveTypeMap; }
From source file:org.apache.sling.models.impl.model.AbstractInjectableElement.java
private static Object getDefaultValue(AnnotatedElement element, Type type, InjectAnnotationProcessor2 annotationProcessor) { if (annotationProcessor != null && annotationProcessor.hasDefault()) { return annotationProcessor.getDefault(); }//from w ww . j a v a 2 s .c o m Default defaultAnnotation = element.getAnnotation(Default.class); if (defaultAnnotation == null) { return null; } Object value = null; if (type instanceof Class) { Class<?> injectedClass = (Class<?>) type; if (injectedClass.isArray()) { Class<?> componentType = injectedClass.getComponentType(); if (componentType == String.class) { value = defaultAnnotation.values(); } else if (componentType == Integer.TYPE) { value = defaultAnnotation.intValues(); } else if (componentType == Integer.class) { value = ArrayUtils.toObject(defaultAnnotation.intValues()); } else if (componentType == Long.TYPE) { value = defaultAnnotation.longValues(); } else if (componentType == Long.class) { value = ArrayUtils.toObject(defaultAnnotation.longValues()); } else if (componentType == Boolean.TYPE) { value = defaultAnnotation.booleanValues(); } else if (componentType == Boolean.class) { value = ArrayUtils.toObject(defaultAnnotation.booleanValues()); } else if (componentType == Short.TYPE) { value = defaultAnnotation.shortValues(); } else if (componentType == Short.class) { value = ArrayUtils.toObject(defaultAnnotation.shortValues()); } else if (componentType == Float.TYPE) { value = defaultAnnotation.floatValues(); } else if (componentType == Float.class) { value = ArrayUtils.toObject(defaultAnnotation.floatValues()); } else if (componentType == Double.TYPE) { value = defaultAnnotation.doubleValues(); } else if (componentType == Double.class) { value = ArrayUtils.toObject(defaultAnnotation.doubleValues()); } else { log.warn("Default values for {} are not supported", componentType); } } else { if (injectedClass == String.class) { value = defaultAnnotation.values().length == 0 ? "" : defaultAnnotation.values()[0]; } else if (injectedClass == Integer.class) { value = defaultAnnotation.intValues().length == 0 ? 0 : defaultAnnotation.intValues()[0]; } else if (injectedClass == Long.class) { value = defaultAnnotation.longValues().length == 0 ? 0l : defaultAnnotation.longValues()[0]; } else if (injectedClass == Boolean.class) { value = defaultAnnotation.booleanValues().length == 0 ? false : defaultAnnotation.booleanValues()[0]; } else if (injectedClass == Short.class) { value = defaultAnnotation.shortValues().length == 0 ? ((short) 0) : defaultAnnotation.shortValues()[0]; } else if (injectedClass == Float.class) { value = defaultAnnotation.floatValues().length == 0 ? 0f : defaultAnnotation.floatValues()[0]; } else if (injectedClass == Double.class) { value = defaultAnnotation.doubleValues().length == 0 ? 0d : defaultAnnotation.doubleValues()[0]; } else { log.warn("Default values for {} are not supported", injectedClass); } } } else { log.warn("Cannot provide default for {}", type); } return value; }
From source file:net.jetrix.servlets.SettingsAction.java
/** * Update the settings field with the value in the request. The field is * set only if the value in the request is different from the current value. * If the value is empty the field is reset to the default value. * * @param settings the Settings object to update * @param field the name of the field to update * @param request the request containing the field value *///from w w w . j ava2 s. c om private void updateSettingsField(Settings settings, String field, HttpServletRequest request) { String value = request.getParameter(field); field = field.substring(0, 1).toUpperCase() + field.substring(1); try { if (value == null || "".equals(value.trim())) { // reset the field to the default value Method method = Settings.class.getMethod("setDefault" + field, Boolean.TYPE); method.invoke(settings, Boolean.TRUE); } else { // update the field if necessary Method getter = Settings.class.getMethod("get" + field); Object oldValue = getter.invoke(settings); // find the type of the field Class type = null; Object newValue = null; if (oldValue instanceof String) { newValue = value.trim(); type = String.class; } else if (oldValue instanceof Integer) { newValue = Integer.parseInt(value.trim()); type = Integer.TYPE; } else if (oldValue instanceof Boolean) { newValue = Boolean.valueOf(value); type = Boolean.TYPE; } if (!oldValue.equals(newValue)) { // set the new value Method setter = Settings.class.getMethod("set" + field, type); setter.invoke(settings, newValue); } } } catch (Exception e) { e.printStackTrace(); } }
From source file:org.quartz.jobs.ee.jmx.JMXInvokerJob.java
public void execute(JobExecutionContext context) throws JobExecutionException { try {/*from www . jav a 2 s .c o m*/ Object[] params = null; String[] types = null; String objName = null; String objMethod = null; JobDataMap jobDataMap = context.getMergedJobDataMap(); String[] keys = jobDataMap.getKeys(); for (int i = 0; i < keys.length; i++) { String value = jobDataMap.getString(keys[i]); if ("JMX_OBJECTNAME".equalsIgnoreCase(keys[i])) { objName = value; } else if ("JMX_METHOD".equalsIgnoreCase(keys[i])) { objMethod = value; } else if ("JMX_PARAMDEFS".equalsIgnoreCase(keys[i])) { String[] paramdefs = split(value, ","); params = new Object[paramdefs.length]; types = new String[paramdefs.length]; for (int k = 0; k < paramdefs.length; k++) { String parts[] = split(paramdefs[k], ":"); if (parts.length < 2) { throw new Exception( "Invalid parameter definition: required parts missing " + paramdefs[k]); } switch (parts[0].charAt(0)) { case 'i': params[k] = new Integer(jobDataMap.getString(parts[1])); types[k] = Integer.TYPE.getName(); break; case 'I': params[k] = new Integer(jobDataMap.getString(parts[1])); types[k] = Integer.class.getName(); break; case 'l': params[k] = new Long(jobDataMap.getString(parts[1])); types[k] = Long.TYPE.getName(); break; case 'L': params[k] = new Long(jobDataMap.getString(parts[1])); types[k] = Long.class.getName(); break; case 'f': params[k] = new Float(jobDataMap.getString(parts[1])); types[k] = Float.TYPE.getName(); break; case 'F': params[k] = new Float(jobDataMap.getString(parts[1])); types[k] = Float.class.getName(); break; case 'd': params[k] = new Double(jobDataMap.getString(parts[1])); types[k] = Double.TYPE.getName(); break; case 'D': params[k] = new Double(jobDataMap.getString(parts[1])); types[k] = Double.class.getName(); break; case 's': params[k] = jobDataMap.getString(parts[1]); types[k] = String.class.getName(); break; case 'b': params[k] = new Boolean(jobDataMap.getString(parts[1])); types[k] = Boolean.TYPE.getName(); break; case 'B': params[k] = new Boolean(jobDataMap.getString(parts[1])); types[k] = Boolean.class.getName(); break; } } } } if (objName == null || objMethod == null) { throw new Exception("Required parameters missing"); } context.setResult(invoke(objName, objMethod, params, types)); } catch (Exception e) { String m = "Caught a " + e.getClass().getName() + " exception : " + e.getMessage(); getLog().error(m, e); throw new JobExecutionException(m, e, false); } }
From source file:com.snaplogic.snaps.uniteller.BaseService.java
@Override protected void process(Document document, String inputViewName) { try {/* w w w. j a va 2 s . c o m*/ AccountBean bean = account.connect(); String UFSConfigFilePath = urlEncoder.validateAndEncodeURI(bean.getConfigFilePath(), PATTERN, null) .toString(); String UFSSecurityFilePath = urlEncoder .validateAndEncodeURI(bean.getSecurityPermFilePath(), PATTERN, null).toString(); /* instantiating USFCreationClient */ Class<?> CustomUSFCreationClient = Class.forName(UFS_FOLIO_CREATION_CLIENT_PKG_URI); Constructor<?> constructor = CustomUSFCreationClient .getDeclaredConstructor(new Class[] { IUFSConfigMgr.class, IUFSSecurityMgr.class }); Object USFCreationClientObj = constructor.newInstance(CustomUFSConfigMgr.getInstance(UFSConfigFilePath), CustomUFSSecurityMgr.getInstance(UFSSecurityFilePath)); Method setAutoUpdatePsw = CustomUSFCreationClient.getDeclaredMethod("setAutoUpdatePsw", Boolean.TYPE); setAutoUpdatePsw.invoke(USFCreationClientObj, autoUpdatePsw); /* Preparing the request for USF */ Object data; if (document != null && (data = document.get()) != null) { if (data instanceof Map) { Map<String, Object> map = (Map<String, Object>) data; Class<?> UFSRequest = Class.forName(getUFSReqClassType()); Object UFSRequestObj = UFSRequest.newInstance(); Object inputFieldValue = null; Calendar cal = Calendar.getInstance(); for (Method method : UFSRequest.getDeclaredMethods()) { if (isSetter(method) && (inputFieldValue = map.get(method.getName().substring(3))) != null) { try { String paramType = method.getParameterTypes()[0].getName(); if (paramType.equalsIgnoreCase(String.class.getName())) { method.invoke(UFSRequest.cast(UFSRequestObj), String.valueOf(inputFieldValue)); } else if (paramType.equalsIgnoreCase(Double.class.getSimpleName())) { method.invoke(UFSRequest.cast(UFSRequestObj), Double.parseDouble(String.valueOf(inputFieldValue))); } else if (paramType.equalsIgnoreCase(INT)) { method.invoke(UFSRequest.cast(UFSRequestObj), Integer.parseInt(String.valueOf(inputFieldValue))); } else if (paramType.equalsIgnoreCase(Calendar.class.getName())) { try { cal.setTime(sdtf.parse(String.valueOf(inputFieldValue))); } catch (ParseException pe1) { try { cal.setTime(sdf.parse(String.valueOf(inputFieldValue))); } catch (ParseException pe) { writeToErrorView( String.format(DATE_PARSER_ERROR, DATETIME_FORMAT, DATE_FORMAT), pe.getMessage(), ERROR_RESOLUTION, pe); } } method.invoke(UFSRequest.cast(UFSRequestObj), cal); } } catch (IllegalArgumentException iae) { writeToErrorView(String.format(ILLEGAL_ARGS_EXE, method.getName()), iae.getMessage(), ERROR_RESOLUTION, iae); } catch (InvocationTargetException ite) { writeToErrorView(ite.getTargetException().getMessage(), ite.getMessage(), ERROR_RESOLUTION, ite); } } } /* Invoking the request over USFCreationClient */ Object UFSResponseObj = null; Method creationClientMethod = CustomUSFCreationClient .getMethod(getCamelCaseForMethod(resourceType), UFSRequest); try { UFSResponseObj = creationClientMethod.invoke(USFCreationClientObj, UFSRequest.cast(UFSRequestObj)); } catch (IllegalArgumentException iae) { writeToErrorView(String.format(ILLEGAL_ARGS_EXE, creationClientMethod.getName()), iae.getMessage(), ERROR_RESOLUTION, iae); } catch (InvocationTargetException ite) { writeToErrorView(ite.getTargetException().getMessage(), ite.getMessage(), ERROR_RESOLUTION, ite); } if (null != UFSResponseObj) { outputViews.write(documentUtility.newDocument(processResponseObj(UFSResponseObj))); counter.inc(); } } else { writeToErrorView(NO_DATA_ERRMSG, NO_DATA_WARNING, NO_DATA_REASON, NO_DATA_RESOLUTION); } } } catch (Exception ex) { writeToErrorView(ERRORMSG, ex.getMessage(), ERROR_RESOLUTION, ex); } }