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.openspaces.rest.utils.ControllerUtils.java
public static Object convertPropertyToPrimitiveType(String object, Class type, String propKey) { if (type.equals(Long.class) || type.equals(Long.TYPE)) return Long.valueOf(object); if (type.equals(Boolean.class) || type.equals(Boolean.TYPE)) return Boolean.valueOf(object); if (type.equals(Integer.class) || type.equals(Integer.TYPE)) return Integer.valueOf(object); if (type.equals(Byte.class) || type.equals(Byte.TYPE)) return Byte.valueOf(object); if (type.equals(Short.class) || type.equals(Short.TYPE)) return Short.valueOf(object); if (type.equals(Float.class) || type.equals(Float.TYPE)) return Float.valueOf(object); if (type.equals(Double.class) || type.equals(Double.TYPE)) return Double.valueOf(object); if (type.isEnum()) return Enum.valueOf(type, object); if (type.equals(String.class) || type.equals(Object.class)) return String.valueOf(object); if (type.equals(java.util.Date.class)) { try {//from w ww . j a va2 s . co m return simpleDateFormat.parse(object); } catch (ParseException e) { throw new RestException( "Unable to parse date [" + object + "]. Make sure it matches the format: " + date_format); } } //unknown type throw new UnsupportedTypeException("Non primitive type when converting property [" + propKey + "]:" + type); }
From source file:pe.com.mmh.sisgap.utils.BasicDynaBean.java
/** * Return the value of a simple property with the specified name. * * @param name Name of the property whose value is to be retrieved * * @exception IllegalArgumentException if there is no property * of the specified name//from w ww . j a v a2 s.c o m */ public Object get(String name) { // Return any non-null value for the specified property Object value = values.get(name); if (value != null) { return (value); } // Return a null value for a non-primitive property Class type = getDynaProperty(name).getType(); if (!type.isPrimitive()) { return (value); } // Manufacture default values for primitive properties if (type == Boolean.TYPE) { return (Boolean.FALSE); } else if (type == Byte.TYPE) { return (new Byte((byte) 0)); } else if (type == Character.TYPE) { return (new Character((char) 0)); } else if (type == Double.TYPE) { return (new Double((double) 0.0)); } else if (type == Float.TYPE) { return (new Float((float) 0.0)); } else if (type == Integer.TYPE) { return (new Integer((int) 0)); } else if (type == Long.TYPE) { return (new Long((int) 0)); } else if (type == Short.TYPE) { return (new Short((short) 0)); } else { return (null); } }
From source file:org.hyperic.hq.product.jmx.MBeanUtil.java
private static void initConverters() { addConverter(Object.class, new Converter() { public Object convert(String param) { return param; }//from w w w . j av a 2 s . c om }); addConverter(Short.class, new Converter() { public Object convert(String param) { return Short.valueOf(param); } }); addConverter(Integer.class, new Converter() { public Object convert(String param) { return Integer.valueOf(param); } }); addConverter(Long.class, new Converter() { public Object convert(String param) { return Long.valueOf(param); } }); addConverter(Double.class, new Converter() { public Object convert(String param) { return Double.valueOf(param); } }); addConverter(Boolean.class, new Converter() { public Object convert(String param) { return Boolean.valueOf(param); } }); addConverter(File.class, new Converter() { public Object convert(String param) { return new File(param); } }); addConverter(URL.class, new Converter() { public Object convert(String param) { try { return new URL(param); } catch (MalformedURLException e) { throw invalid(param, e); } } }); addConverter(ObjectName.class, new Converter() { public Object convert(String param) { try { return new ObjectName(param); } catch (MalformedObjectNameException e) { throw invalid(param, e); } } }); addConverter(List.class, new ListConverter() { public Object convert(String[] params) { return Arrays.asList(params); } }); addConverter(String[].class, new ListConverter() { public Object convert(String[] params) { return params; } }); addConverter(Long[].class, new ListConverter() { public Object convert(String[] params) { Long[] args = new Long[params.length]; for (int i = 0; i < params.length; i++) { args[i] = Long.valueOf(params[i]); } return args; } }); addConverter(Integer[].class, new ListConverter() { public Object convert(String[] params) { Integer[] args = new Integer[params.length]; for (int i = 0; i < params.length; i++) { args[i] = Integer.valueOf(params[i]); } return args; } }); addConverter(Double[].class, new ListConverter() { public Object convert(String[] params) { Double[] args = new Double[params.length]; for (int i = 0; i < params.length; i++) { args[i] = Double.valueOf(params[i]); } return args; } }); addConverter(Short[].class, new ListConverter() { public Object convert(String[] params) { Short[] args = new Short[params.length]; for (int i = 0; i < params.length; i++) { args[i] = Short.valueOf(params[i]); } return args; } }); addConverter(Boolean[].class, new ListConverter() { public Object convert(String[] params) { Boolean[] args = new Boolean[params.length]; for (int i = 0; i < params.length; i++) { args[i] = Boolean.valueOf(params[i]); } return args; } }); addConverter(long[].class, new ListConverter() { public Object convert(String[] params) { long[] args = new long[params.length]; for (int i = 0; i < params.length; i++) { args[i] = Long.parseLong(params[i]); } return args; } }); addConverter(int[].class, new ListConverter() { public Object convert(String[] params) { int[] args = new int[params.length]; for (int i = 0; i < params.length; i++) { args[i] = Integer.parseInt(params[i]); } return args; } }); addConverter(double[].class, new ListConverter() { public Object convert(String[] params) { double[] args = new double[params.length]; for (int i = 0; i < params.length; i++) { args[i] = Double.parseDouble(params[i]); } return args; } }); addConverter(short[].class, new ListConverter() { public Object convert(String[] params) { short[] args = new short[params.length]; for (int i = 0; i < params.length; i++) { args[i] = Short.parseShort(params[i]); } return args; } }); addConverter(boolean[].class, new ListConverter() { public Object convert(String[] params) { boolean[] args = new boolean[params.length]; for (int i = 0; i < params.length; i++) { args[i] = params[i].equals("true") ? true : false; } return args; } }); Class[][] aliases = { { String.class, Object.class }, { Short.TYPE, Short.class }, { Integer.TYPE, Integer.class }, { Long.TYPE, Long.class }, { Double.TYPE, Double.class }, { Boolean.TYPE, Boolean.class }, }; for (int i = 0; i < aliases.length; i++) { addConverter(aliases[i][0], aliases[i][1]); } }
From source file:android.support.v7.internal.view.menu.MenuItemWrapperICS.java
public void setExclusiveCheckable(boolean checkable) { try {// w ww. j a v a2s .c o m if (mSetExclusiveCheckableMethod == null) { mSetExclusiveCheckableMethod = mWrappedObject.getClass().getDeclaredMethod("setExclusiveCheckable", Boolean.TYPE); } mSetExclusiveCheckableMethod.invoke(mWrappedObject, checkable); } catch (Exception e) { Log.w(LOG_TAG, "Error while calling setExclusiveCheckable", e); } }
From source file:org.apache.jcs.config.PropertySetter.java
/** * Convert <code>val</code> a String parameter to an object of a given * type./*from w w w. j a va 2 s . co m*/ * @param val * @param type * @return Object */ protected Object convertArg(String val, Class type) { if (val == null) { return null; } String v = val.trim(); if (String.class.isAssignableFrom(type)) { return val; } else if (Integer.TYPE.isAssignableFrom(type)) { return new Integer(v); } else if (Long.TYPE.isAssignableFrom(type)) { return new Long(v); } else if (Boolean.TYPE.isAssignableFrom(type)) { if ("true".equalsIgnoreCase(v)) { return Boolean.TRUE; } else if ("false".equalsIgnoreCase(v)) { return Boolean.FALSE; } } return null; }
From source file:com.googlecode.psiprobe.Tomcat70ContainerAdaptor.java
@Override protected JspCompilationContext createJspCompilationContext(String name, boolean isErrPage, Options opt, ServletContext sctx, JspRuntimeContext jrctx, ClassLoader cl) { JspCompilationContext jcctx;/*from w w w .j av a 2 s .c o m*/ try { jcctx = new JspCompilationContext(name, opt, sctx, null, jrctx); } catch (NoSuchMethodError err) { /* * The above constructor's signature changed in Tomcat 7.0.16: * http://svn.apache.org/viewvc?view=revision&revision=1124719 * * If we reach this point, we are running on a prior version of * Tomcat 7 and must use reflection to create this object. */ try { jcctx = (JspCompilationContext) ConstructorUtils.invokeConstructor(JspCompilationContext.class, new Object[] { name, false, opt, sctx, null, jrctx }, new Class[] { String.class, Boolean.TYPE, Options.class, ServletContext.class, JspServletWrapper.class, JspRuntimeContext.class }); } catch (NoSuchMethodException ex) { throw new RuntimeException(ex); } catch (IllegalAccessException ex) { throw new RuntimeException(ex); } catch (InvocationTargetException ex) { throw new RuntimeException(ex); } catch (InstantiationException ex) { throw new RuntimeException(ex); } } if (cl != null) { jcctx.setClassLoader(cl); } return jcctx; }
From source file:org.seasar.mayaa.impl.util.ObjectUtil.java
/** * ??????????//w w w .j av a 2 s . c om * ??????????????? * * @param expectedClass ???? * @param value ?? * @return ?? (expectedClass?) */ public static Object convert(Class expectedClass, Object value) { if (Object.class.equals(expectedClass) || (value != null && expectedClass.isAssignableFrom(value.getClass()))) { return value; } if (String.class.equals(expectedClass)) { return (value != null) ? value.toString() : null; } if (Boolean.class.equals(expectedClass) || Boolean.TYPE.equals(expectedClass)) { if (value instanceof Boolean) { return value; } return Boolean.valueOf(ObjectUtil.booleanValue(value, false)); } Converter converter = ConvertUtils.lookup(expectedClass); if (converter != null) { if (value != null) { return converter.convert(expectedClass, value); } if (expectedClass.isPrimitive() || Number.class.isAssignableFrom(expectedClass)) { if (BigInteger.class.isAssignableFrom(expectedClass)) { return BigInteger.ZERO; } else if (BigDecimal.class.isAssignableFrom(expectedClass)) { return BigDecimal.valueOf(0); } return converter.convert(expectedClass, value); } } return value; }
From source file:javadz.beanutils.ConvertUtilsBean.java
/** * Sets the default value for Boolean conversions. * @param newDefaultBoolean The default Boolean value * @deprecated Register replacement converters for Boolean.TYPE and * Boolean.class instead//from www . j av a 2s . c om */ public void setDefaultBoolean(boolean newDefaultBoolean) { defaultBoolean = (newDefaultBoolean ? Boolean.TRUE : Boolean.FALSE); register(new BooleanConverter(defaultBoolean), Boolean.TYPE); register(new BooleanConverter(defaultBoolean), Boolean.class); }
From source file:com.evolveum.polygon.connector.googleapps.GroupHandler.java
public static ObjectClassInfo getGroupClassInfo() { // @formatter:off /* GROUP from https://devsite.googleplex.com/admin-sdk/directory/v1/reference/groups#resource {/*from w w w . ja v a 2 s. c o m*/ "kind": "admin#directory#group", "id": string, "etag": etag, "email": string, "name": string, "directMembersCount": long, "description": string, "adminCreated": boolean, "aliases": [ string ], "nonEditableAliases": [ string ] } */ // @formatter:on ObjectClassInfoBuilder builder = new ObjectClassInfoBuilder(); builder.setType(ObjectClass.GROUP_NAME); // email builder.addAttributeInfo(Name.INFO); builder.addAttributeInfo(AttributeInfoBuilder.build(NAME_ATTR)); builder.addAttributeInfo(PredefinedAttributeInfos.DESCRIPTION); // Read-only builder.addAttributeInfo(AttributeInfoBuilder.define(ADMIN_CREATED_ATTR, Boolean.TYPE).setUpdateable(false) .setCreateable(false).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(ALIASES_ATTR).setUpdateable(false).setCreateable(false) .setMultiValued(true).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(NON_EDITABLE_ALIASES_ATTR).setUpdateable(false) .setCreateable(false).setMultiValued(true).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(DIRECT_MEMBERS_COUNT_ATTR, Long.TYPE) .setUpdateable(false).setCreateable(false).build()); // Virtual Attribute builder.addAttributeInfo( AttributeInfoBuilder.define(MEMBERS_ATTR).setMultiValued(true).setReturnedByDefault(false).build()); builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_allowExternalMembers).build()); builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_allowGoogleCommunication).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_allowWebPosting).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_archiveOnly).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_customFooterText).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_customReplyTo).build()); builder.addAttributeInfo(AttributeInfoBuilder .define(GoogleAppsConnector.SETTING_defaultMessageDenyNotificationText).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_description).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_email).build()); builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_includeCustomFooter).build()); builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_includeInGlobalAddressList).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_isArchived).build()); builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_maxMessageBytes, Integer.TYPE).build()); builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_membersCanPostAsTheGroup).build()); builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_messageDisplayFont).build()); builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_messageModerationLevel).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_name).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_replyTo).build()); builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_sendMessageDenyNotification).build()); builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_showInGroupDirectory).build());//rizeno builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_spamModerationLevel).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_whoCanAdd).build()); builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_whoCanContactOwner).build());//rizeno builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_whoCanInvite).build()); builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_whoCanJoin).build());//rizeno builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_whoCanLeaveGroup).build()); builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_whoCanPostMessage).build());//rizeno builder.addAttributeInfo(AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_whoCanViewGroup).build());//rizeno builder.addAttributeInfo( AttributeInfoBuilder.define(GoogleAppsConnector.SETTING_whoCanViewMembership).build());//rizeno return builder.build(); }
From source file:fragment.web.SupportControllerTest.java
@Test public void testSupportRouting() throws Exception { logger.debug("Testing routing....Started"); DispatcherTestServlet servlet = this.getServletInstance(); Method expected = locateMethod(controller.getClass(), "listTickets", new Class[] { Tenant.class, String.class, String.class, Boolean.TYPE, String.class, String.class, String.class, int.class, String.class, ModelMap.class }); Method handler = servlet.recognize(getRequestTemplate(HttpMethod.GET, "/support/tickets")); Assert.assertEquals(expected, handler); expected = locateMethod(controller.getClass(), "createTicket", new Class[] { String.class, ModelMap.class }); handler = servlet.recognize(getRequestTemplate(HttpMethod.GET, "/support/tickets/create")); Assert.assertEquals(expected, handler); expected = locateMethod(controller.getClass(), "createTicket", new Class[] { String.class, HttpServletRequest.class, TicketForm.class, ModelMap.class }); handler = servlet.recognize(getRequestTemplate(HttpMethod.POST, "/support/tickets/create")); Assert.assertEquals(expected, handler); expected = locateMethod(controller.getClass(), "viewTicket", new Class[] { Tenant.class, String.class, String.class, ModelMap.class }); handler = servlet.recognize(getRequestTemplate(HttpMethod.GET, "/support/tickets/view")); Assert.assertEquals(expected, handler); expected = locateMethod(controller.getClass(), "createNewComment", new Class[] { Tenant.class, TicketCommentForm.class, String.class, String.class, ModelMap.class }); handler = servlet.recognize(getRequestTemplate(HttpMethod.POST, "/support/tickets/{ticketId}/comment")); Assert.assertEquals(expected, handler); expected = locateMethod(controller.getClass(), "editTicket", new Class[] { Tenant.class, String.class, String.class, String.class, String.class, String.class, HttpServletRequest.class, TicketForm.class, ModelMap.class }); handler = servlet.recognize(getRequestTemplate(HttpMethod.POST, "/support/tickets/edit")); Assert.assertEquals(expected, handler); expected = locateMethod(controller.getClass(), "closeTicket", new Class[] { Tenant.class, String.class, HttpServletRequest.class, TicketForm.class, ModelMap.class }); handler = servlet.recognize(getRequestTemplate(HttpMethod.POST, "/support/tickets/close")); Assert.assertEquals(expected, handler); logger.debug("Testing routing.... Done"); }