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:loon.LGame.java
private static Class<?> getType(Object o) { 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 Long) { return Long.TYPE; } else if (o instanceof Short) { return Short.TYPE; } else if (o instanceof Short) { return Short.TYPE; } else if (o instanceof Boolean) { return Boolean.TYPE; } else {/* w ww. j av a2 s .c o m*/ return o.getClass(); } }
From source file:org.dhatim.javabean.BeanUtils.java
/** * Create the bean setter method instance for this visitor. * * @param setterName The setter method name. * @param setterParamType// w w w .ja va 2s .co m * @return The bean setter method. */ public static Method createSetterMethod(String setterName, Object bean, Class<?> setterParamType) { Method beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, setterParamType); // Try it as a list... if (beanSetterMethod == null && List.class.isAssignableFrom(setterParamType)) { String setterNamePlural = setterName + "s"; // Try it as a List using the plural name... beanSetterMethod = ClassUtil.getSetterMethod(setterNamePlural, bean, setterParamType); if (beanSetterMethod == null) { // Try it as an array using the non-plural name... } } // Try it as a primitive... if (beanSetterMethod == null && Integer.class.isAssignableFrom(setterParamType)) { beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, Integer.TYPE); } if (beanSetterMethod == null && Long.class.isAssignableFrom(setterParamType)) { beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, Long.TYPE); } if (beanSetterMethod == null && Float.class.isAssignableFrom(setterParamType)) { beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, Float.TYPE); } if (beanSetterMethod == null && Double.class.isAssignableFrom(setterParamType)) { beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, Double.TYPE); } if (beanSetterMethod == null && Character.class.isAssignableFrom(setterParamType)) { beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, Character.TYPE); } if (beanSetterMethod == null && Short.class.isAssignableFrom(setterParamType)) { beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, Short.TYPE); } if (beanSetterMethod == null && Byte.class.isAssignableFrom(setterParamType)) { beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, Byte.TYPE); } if (beanSetterMethod == null && Boolean.class.isAssignableFrom(setterParamType)) { beanSetterMethod = ClassUtil.getSetterMethod(setterName, bean, Boolean.TYPE); } return beanSetterMethod; }
From source file:net.jetrix.config.ChannelsRuleSet.java
public void addRuleInstances(Digester digester) { digester.addCallMethod("tetrinet-channels/motd", "setMessageOfTheDay", 0); // default game settings digester.addObjectCreate("tetrinet-channels/default-settings", "net.jetrix.config.Settings"); digester.addSetNext("tetrinet-channels/default-settings", "setDefaultSettings", "net.jetrix.config.Settings"); // channel settings digester.addObjectCreate("*/channel/settings", "net.jetrix.config.Settings"); digester.addSetNext("*/channel/settings", "setSettings", "net.jetrix.config.Settings"); // any game settings digester.addCallMethod("*/starting-level", "setStartingLevel", 0, new Class[] { Integer.TYPE }); digester.addCallMethod("*/lines-per-level", "setLinesPerLevel", 0, new Class[] { Integer.TYPE }); digester.addCallMethod("*/level-increase", "setLevelIncrease", 0, new Class[] { Integer.TYPE }); digester.addCallMethod("*/lines-per-special", "setLinesPerSpecial", 0, new Class[] { Integer.TYPE }); digester.addCallMethod("*/special-added", "setSpecialAdded", 0, new Class[] { Integer.TYPE }); digester.addCallMethod("*/special-capacity", "setSpecialCapacity", 0, new Class[] { Integer.TYPE }); digester.addCallMethod("*/classic-rules", "setClassicRules", 0, new Class[] { Boolean.TYPE }); digester.addCallMethod("*/average-levels", "setAverageLevels", 0, new Class[] { Boolean.TYPE }); digester.addCallMethod("*/same-blocks", "setSameBlocks", 0, new Class[] { Boolean.TYPE }); // block occurancy digester.addObjectCreate("*/block-occurancy", Occurancy.class.getName()); digester.addCallMethod("*/block-occurancy", "normalize", 0, (Class[]) null); digester.addSetNext("*/block-occurancy", "setBlockOccurancy", Occurancy.class.getName()); for (Block block : Block.values()) { digester.addRule("*/block-occurancy/" + block.getCode(), new OccurancyRule<Block>(digester, block)); }//ww w .j ava2 s.c o m // special occurancy digester.addObjectCreate("*/special-occurancy", Occurancy.class.getName()); digester.addCallMethod("*/special-occurancy", "normalize", 0, (Class[]) null); digester.addSetNext("*/special-occurancy", "setSpecialOccurancy", Occurancy.class.getName()); for (Special special : Special.values()) { digester.addRule("*/special-occurancy/" + special.getCode(), new OccurancyRule<Special>(digester, special)); } digester.addCallMethod("*/sudden-death/time", "setSuddenDeathTime", 0, new Class[] { Integer.TYPE }); digester.addCallMethod("*/sudden-death/message", "setSuddenDeathMessage", 0); digester.addCallMethod("*/sudden-death/delay", "setSuddenDeathDelay", 0, new Class[] { Integer.TYPE }); digester.addCallMethod("*/sudden-death/lines-added", "setSuddenDeathLinesAdded", 0, new Class[] { Integer.TYPE }); // channel configuration digester.addObjectCreate("*/channel", "net.jetrix.config.ChannelConfig"); digester.addSetNext("*/channel", "addChannel", "net.jetrix.config.ChannelConfig"); digester.addCallMethod("*/channel", "setName", 1); digester.addCallParam("*/channel", 0, "name"); digester.addRule("*/channel/speed", new Rule(digester) { public void body(String text) throws Exception { getDigester().push(Speed.valueOf(text.toUpperCase())); } public void end() throws Exception { getDigester().pop(); } }); digester.addSetNext("*/channel/speed", "setSpeed"); digester.addCallMethod("*/channel/password", "setPassword", 0); digester.addCallMethod("*/channel/access-level", "setAccessLevel", 0, new Class[] { Integer.TYPE }); digester.addCallMethod("*/channel/idle", "setIdleAllowed", 0, new Class[] { Boolean.TYPE }); digester.addCallMethod("*/channel/visible", "setVisible", 0, new Class[] { Boolean.TYPE }); digester.addCallMethod("*/channel/description", "setDescription", 0); digester.addCallMethod("*/channel/topic", "setTopic", 0); digester.addCallMethod("*/channel/max-players", "setMaxPlayers", 0, new Class[] { Integer.TYPE }); digester.addCallMethod("*/channel/max-spectators", "setMaxSpectators", 0, new Class[] { Integer.TYPE }); digester.addCallMethod("*/channel/winlist", "setWinlistId", 1); digester.addCallParam("*/channel/winlist", 0, "name"); // filter configuration digester.addObjectCreate("*/filter", "net.jetrix.config.FilterConfig"); digester.addSetNext("*/filter", "addFilter", "net.jetrix.config.FilterConfig"); digester.addCallMethod("*/filter", "setName", 1); digester.addCallParam("*/filter", 0, "name"); digester.addCallMethod("*/filter", "setClassname", 1); digester.addCallParam("*/filter", 0, "class"); digester.addCallMethod("*/filter/param", "setParameter", 2); digester.addCallParam("*/filter/param", 0, "name"); digester.addCallParam("*/filter/param", 1, "value"); // filter definitions digester.addCallMethod("tetrinet-channels/filter-definitions/alias", "addFilterAlias", 2); digester.addCallParam("tetrinet-channels/filter-definitions/alias", 0, "name"); digester.addCallParam("tetrinet-channels/filter-definitions/alias", 1, "class"); // winlists digester.addObjectCreate("tetrinet-channels/winlists/winlist", "net.jetrix.config.WinlistConfig"); digester.addSetNext("tetrinet-channels/winlists/winlist", "addWinlist", "net.jetrix.config.WinlistConfig"); digester.addCallMethod("tetrinet-channels/winlists/winlist", "setName", 1); digester.addCallParam("tetrinet-channels/winlists/winlist", 0, "name"); digester.addCallMethod("tetrinet-channels/winlists/winlist", "setClassname", 1); digester.addCallParam("tetrinet-channels/winlists/winlist", 0, "class"); digester.addCallMethod("tetrinet-channels/winlists/winlist/param", "setParameter", 2); digester.addCallParam("tetrinet-channels/winlists/winlist/param", 0, "name"); digester.addCallParam("tetrinet-channels/winlists/winlist/param", 1, "value"); }
From source file:stroom.util.AbstractCommandLineTool.java
private Object getAsType(final PropertyDescriptor descriptor) { final Class<?> propertyClass = descriptor.getPropertyType(); if (propertyClass.equals(String.class)) { return map.get(descriptor.getName()); }// www.j a v a2 s . c o m if (propertyClass.equals(Boolean.class) || propertyClass.equals(Boolean.TYPE)) { return Boolean.parseBoolean(map.get(descriptor.getName())); } if (propertyClass.equals(Integer.class) || propertyClass.equals(Integer.TYPE)) { return Integer.parseInt(map.get(descriptor.getName())); } if (propertyClass.equals(Long.class) || propertyClass.equals(Long.TYPE)) { return Long.parseLong(map.get(descriptor.getName())); } throw new RuntimeException( "AbstractCommandLineTool does not know about properties of type " + propertyClass); }
From source file:io.coala.guice.config.ConfigMembersInjector.java
@Override public void injectMembers(final T instance) { final InjectConfig injectConfigAnnotation = field.getAnnotation(InjectConfig.class); final String configurationParameterName = injectConfigAnnotation.name(); try {/*from w w w . java 2 s .c om*/ final Class<?> type = this.field.getType(); if (type == Integer.TYPE) { if (this.configuration.containsKey(configurationParameterName)) { this.field.setInt(instance, this.configuration.getInt(configurationParameterName)); } else { LOG.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); this.field.setInt(instance, injectConfigAnnotation.defaultIntValue()); } } else if (type == Boolean.TYPE) { if (this.configuration.containsKey(configurationParameterName)) { this.field.setBoolean(instance, this.configuration.getBoolean(configurationParameterName)); } else { LOG.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); this.field.setBoolean(instance, injectConfigAnnotation.defaultBooleanValue()); } } else if (type == Short.TYPE) { if (configuration.containsKey(configurationParameterName)) { this.field.setShort(instance, this.configuration.getShort(configurationParameterName)); } else { LOG.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); this.field.setShort(instance, injectConfigAnnotation.defaultShortValue()); } } else if (type == Byte.TYPE) { if (configuration.containsKey(configurationParameterName)) { this.field.setByte(instance, this.configuration.getByte(configurationParameterName)); } else { LOG.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); this.field.setByte(instance, injectConfigAnnotation.defaultByteValue()); } } else if (type == Long.TYPE) { if (this.configuration.containsKey(configurationParameterName)) { this.field.setLong(instance, this.configuration.getLong(configurationParameterName)); } else { LOG.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); this.field.setLong(instance, injectConfigAnnotation.defaultLongValue()); } } else if (type == Float.TYPE) { if (this.configuration.containsKey(configurationParameterName)) { this.field.setFloat(instance, this.configuration.getFloat(configurationParameterName)); } else { LOG.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); this.field.setFloat(instance, injectConfigAnnotation.defaultFloatValue()); } } else if (type == Double.TYPE) { if (configuration.containsKey(configurationParameterName)) { this.field.setDouble(instance, this.configuration.getDouble(configurationParameterName)); } else { LOG.debug(NO_PROPERTY_FOUND_LOG_MESSAGE, configurationParameterName); this.field.setDouble(instance, injectConfigAnnotation.defaultDoubleValue()); } } else if (type == Character.TYPE) { if (configuration.containsKey(configurationParameterName)) { this.field.setChar(instance, this.configuration.getString(configurationParameterName).charAt(0)); } } else { final Object property = getProperty(configurationParameterName, injectConfigAnnotation); this.field.set(instance, property); } } catch (final Throwable ex) { LOG.error("Problem injecting configuration", ex); } }
From source file:nl.strohalm.cyclos.controls.ads.categories.EditAdCategoryAction.java
public DataBinder<AdCategory> getDataBinder() { if (dataBinder == null) { final BeanBinder<AdCategory> binder = BeanBinder.instance(AdCategory.class); binder.registerBinder("id", PropertyBinder.instance(Long.class, "id", IdConverter.instance())); binder.registerBinder("parent", PropertyBinder.instance(AdCategory.class, "parent", ReferenceConverter.instance(AdCategory.class))); binder.registerBinder("name", PropertyBinder.instance(String.class, "name")); binder.registerBinder("active", PropertyBinder.instance(Boolean.TYPE, "active")); binder.registerBinder("order", PropertyBinder.instance(Integer.class, "order")); dataBinder = binder;/*from w w w.j a v a2 s. co m*/ } return dataBinder; }
From source file:com.sf.ddao.factory.param.ParameterHelper.java
public static void bind(PreparedStatement preparedStatement, int idx, Object param, Class<?> clazz, Context context) throws SQLException { if (clazz == Integer.class || clazz == Integer.TYPE) { preparedStatement.setInt(idx, (Integer) param); } else if (clazz == String.class) { preparedStatement.setString(idx, (String) param); } else if (clazz == Long.class || clazz == Long.TYPE) { preparedStatement.setLong(idx, (Long) param); } else if (clazz == Boolean.class || clazz == Boolean.TYPE) { preparedStatement.setBoolean(idx, (Boolean) param); } else if (BigInteger.class.isAssignableFrom(clazz)) { BigInteger bi = (BigInteger) param; preparedStatement.setBigDecimal(idx, new BigDecimal(bi)); } else if (Timestamp.class.isAssignableFrom(clazz)) { preparedStatement.setTimestamp(idx, (Timestamp) param); } else if (Date.class.isAssignableFrom(clazz)) { if (!java.sql.Date.class.isAssignableFrom(clazz)) { param = new java.sql.Date(((Date) param).getTime()); }/*from w ww .jav a2 s. c om*/ preparedStatement.setDate(idx, (java.sql.Date) param); } else if (BoundParameter.class.isAssignableFrom(clazz)) { ((BoundParameter) param).bindParam(preparedStatement, idx, context); } else { throw new SQLException("Unimplemented type mapping for " + clazz); } }
From source file:net.sf.qooxdoo.rpc.RemoteCallUtils.java
/** * Converts JSON types to "normal" java types. * * @param obj the object to convert (must not be * <code>null</code>, but can be * <code>JSONObject.NULL</code>). * @param targetType the desired target type (must not be * <code>null</code>). * * @return the converted object./*from w ww . jav a2s.c om*/ * * @exception IllegalArgumentException thrown if the desired * conversion is not possible. */ public Object toJava(Object obj, Class targetType) { try { if (obj == JSONObject.NULL) { if (targetType == Integer.TYPE || targetType == Double.TYPE || targetType == Boolean.TYPE || targetType == Long.TYPE || targetType == Float.TYPE) { // null does not work for primitive types throw new Exception(); } return null; } if (obj instanceof JSONArray) { Class componentType; if (targetType == null || targetType == Object.class) { componentType = null; } else { componentType = targetType.getComponentType(); } JSONArray jsonArray = (JSONArray) obj; int length = jsonArray.length(); Object retVal = Array.newInstance((componentType == null ? Object.class : componentType), length); for (int i = 0; i < length; ++i) { Array.set(retVal, i, toJava(jsonArray.get(i), componentType)); } return retVal; } if (obj instanceof JSONObject) { JSONObject jsonObject = (JSONObject) obj; JSONArray names = jsonObject.names(); if (targetType == Map.class || targetType == HashMap.class || targetType == null || targetType == Object.class) { HashMap retVal = new HashMap(); if (names != null) { int length = names.length(); String name; for (int i = 0; i < length; ++i) { name = names.getString(i); retVal.put(name, toJava(jsonObject.get(name), null)); } } return retVal; } Object bean; String requestedTypeName = jsonObject.optString("class", null); if (requestedTypeName != null) { Class clazz = resolveClassHint(requestedTypeName, targetType); if (clazz == null || !targetType.isAssignableFrom(clazz)) { throw new Exception(); } bean = clazz.newInstance(); // TODO: support constructor parameters } else { bean = targetType.newInstance(); } if (names != null) { int length = names.length(); String name; PropertyDescriptor desc; for (int i = 0; i < length; ++i) { name = names.getString(i); if (!"class".equals(name)) { desc = PropertyUtils.getPropertyDescriptor(bean, name); if (desc != null && desc.getWriteMethod() != null) { PropertyUtils.setSimpleProperty(bean, name, toJava(jsonObject.get(name), desc.getPropertyType())); } } } } return bean; } if (targetType == null || targetType == Object.class) { return obj; } Class actualTargetType; Class sourceType = obj.getClass(); if (targetType == Integer.TYPE) { actualTargetType = Integer.class; } else if (targetType == Boolean.TYPE) { actualTargetType = Boolean.class; } else if ((targetType == Double.TYPE || targetType == Double.class) && Number.class.isAssignableFrom(sourceType)) { return new Double(((Number) obj).doubleValue()); // TODO: maybe return obj directly if it's a Double } else if ((targetType == Float.TYPE || targetType == Float.class) && Number.class.isAssignableFrom(sourceType)) { return new Float(((Number) obj).floatValue()); } else if ((targetType == Long.TYPE || targetType == Long.class) && Number.class.isAssignableFrom(sourceType)) { return new Long(((Number) obj).longValue()); } else { actualTargetType = targetType; } if (!actualTargetType.isAssignableFrom(sourceType)) { throw new Exception(); } return obj; } catch (IllegalArgumentException e) { throw e; } catch (Exception e) { throw new IllegalArgumentException("Cannot convert " + (obj == null ? null : obj.getClass().getName()) + " to " + (targetType == null ? null : targetType.getName())); } }
From source file:org.javelin.sws.ext.bind.internal.BuiltInMappings.java
/** * @param patterns/*w w w .j a v a 2 s . c o m*/ */ public static <T> void initialize(Map<Class<?>, TypedPattern<?>> patterns, Map<QName, TypedPattern<?>> patternsForTypeQNames) { // see: com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl<T> and inner // com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.StringImpl<T> implementations // we have two places where XSD -> Java mapping is defined: // - JAX-RPC 1.1, section 4.2.1 Simple Types // - JAXB 2, section 6.2.2 Atomic Datatype // XML Schema (1.0) Part 2: Datatypes Second Edition, or/and // W3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes // conversion of primitive types should be base on "Lexical Mapping" of simple types defined in XSD part 2 // 3.2 Special Built-in Datatypes (#special-datatypes) // 3.2.1 anySimpleType (#anySimpleType) // 3.2.2 anyAtomicType (#anyAtomicType) // 3.3 Primitive Datatypes (#built-in-primitive-datatypes) // 3.3.1 string (#string) { SimpleContentPattern<String> pattern = SimpleContentPattern.newValuePattern(SweJaxbConstants.XSD_STRING, String.class); patterns.put(pattern.getJavaType(), pattern); patternsForTypeQNames.put(pattern.getSchemaType(), pattern); } // 3.3.2 boolean (#boolean) { SimpleContentPattern<Boolean> pattern = SimpleContentPattern .newValuePattern(SweJaxbConstants.XSD_BOOLEAN, Boolean.class); patterns.put(Boolean.TYPE, pattern); patterns.put(pattern.getJavaType(), pattern); patternsForTypeQNames.put(pattern.getSchemaType(), pattern); pattern.setFormatter(new Formatter<Boolean>() { @Override public String print(Boolean object, Locale locale) { return Boolean.toString(object); } @Override public Boolean parse(String text, Locale locale) throws ParseException { // TODO: should allow "true", "false", "1", "0" return Boolean.parseBoolean(text); } }); } // 3.3.3 decimal (#decimal) { SimpleContentPattern<BigDecimal> pattern = SimpleContentPattern .newValuePattern(SweJaxbConstants.XSD_DECIMAL, BigDecimal.class); patterns.put(pattern.getJavaType(), pattern); patternsForTypeQNames.put(pattern.getSchemaType(), pattern); pattern.setFormatter(new Formatter<BigDecimal>() { @Override public String print(BigDecimal object, Locale locale) { return object.toPlainString(); } @Override public BigDecimal parse(String text, Locale locale) throws ParseException { // TODO: should allow (\+|-)?([0-9]+(\.[0-9]*)?|\.[0-9]+) return new BigDecimal(text); } }); } // 3.3.4 float (#float) { SimpleContentPattern<Float> pattern = SimpleContentPattern.newValuePattern(SweJaxbConstants.XSD_FLOAT, Float.class); patterns.put(Float.TYPE, pattern); patterns.put(pattern.getJavaType(), pattern); patternsForTypeQNames.put(pattern.getSchemaType(), pattern); pattern.setFormatter(new Formatter<Float>() { @Override public String print(Float object, Locale locale) { return Float.toString(object); } @Override public Float parse(String text, Locale locale) throws ParseException { // TODO: should allow (\+|-)?([0-9]+(\.[0-9]*)?|\.[0-9]+)([Ee](\+|-)?[0-9]+)?|(\+|-)?INF|NaN return Float.parseFloat(text); } }); } // 3.3.5 double (#double) { SimpleContentPattern<Double> pattern = SimpleContentPattern.newValuePattern(SweJaxbConstants.XSD_DOUBLE, Double.class); patterns.put(Double.TYPE, pattern); patterns.put(pattern.getJavaType(), pattern); patternsForTypeQNames.put(pattern.getSchemaType(), pattern); pattern.setFormatter(new Formatter<Double>() { @Override public String print(Double object, Locale locale) { return Double.toString(object); } @Override public Double parse(String text, Locale locale) throws ParseException { // TODO: should allow (\+|-)?([0-9]+(\.[0-9]*)?|\.[0-9]+)([Ee](\+|-)?[0-9]+)?|(\+|-)?INF|NaN return Double.parseDouble(text); } }); } // 3.3.6 duration (#duration) // 3.3.7 dateTime (#dateTime) { SimpleContentPattern<DateTime> pattern = SimpleContentPattern .newValuePattern(SweJaxbConstants.XSD_DATETIME, DateTime.class); patterns.put(pattern.getJavaType(), pattern); patternsForTypeQNames.put(pattern.getSchemaType(), pattern); pattern.setFormatter(new Formatter<DateTime>() { private final DateTimeFormatter DTMS = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZZ"); private final DateTimeFormatter DT = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ssZZ"); private final DateTimeFormatter DTZMS = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); private final DateTimeFormatter DTZ = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss'Z'"); @Override public DateTime parse(String text, Locale locale) throws ParseException { return null; } @Override public String print(DateTime object, Locale locale) { if (object.getMillisOfSecond() == 0) { return object.getZone() == DateTimeZone.UTC ? DTZ.print(object) : DT.print(object); } else { return object.getZone() == DateTimeZone.UTC ? DTZMS.print(object) : DTMS.print(object); } } }); } // 3.3.8 time (#time) { SimpleContentPattern<DateTime> pattern = SimpleContentPattern.newValuePattern(SweJaxbConstants.XSD_TIME, DateTime.class); patternsForTypeQNames.put(pattern.getSchemaType(), pattern); pattern.setFormatter(new Formatter<DateTime>() { private final DateTimeFormatter TMS = DateTimeFormat.forPattern("HH:mm:ss.SSS"); private final DateTimeFormatter T = DateTimeFormat.forPattern("HH:mm:ss"); @Override public DateTime parse(String text, Locale locale) throws ParseException { return null; } @Override public String print(DateTime object, Locale locale) { // TODO: should allow (([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]+)?|(24:00:00(\.0+)?))(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))? if (object.getMillisOfSecond() == 0) return T.print(object); else return TMS.print(object); } }); } // 3.3.9 date (#date) { SimpleContentPattern<DateTime> pattern = SimpleContentPattern.newValuePattern(SweJaxbConstants.XSD_DATE, DateTime.class); patternsForTypeQNames.put(pattern.getSchemaType(), pattern); pattern.setFormatter(new Formatter<DateTime>() { private final DateTimeFormatter DT = DateTimeFormat.forPattern("yyyy-MM-ddZZ"); private final DateTimeFormatter DTZ = DateTimeFormat.forPattern("yyyy-MM-dd'Z'"); @Override public DateTime parse(String text, Locale locale) throws ParseException { return null; } @Override public String print(DateTime object, Locale locale) { return object.getZone() == DateTimeZone.UTC ? DTZ.print(object) : DT.print(object); } }); } // 3.3.10 gYearMonth (#gYearMonth) // 3.3.11 gYear (#gYear) // 3.3.12 gMonthDay (#gMonthDay) // 3.3.13 gDay (#gDay) // 3.3.14 gMonth (#gMonth) // 3.3.15 hexBinary (#hexBinary) // 3.3.16 base64Binary (#base64Binary) // 3.3.17 anyURI (#anyURI) // 3.3.18 QName (#QName) // 3.3.19 NOTATION (#NOTATION) // 3.4 Other Built-in Datatypes (#ordinary-built-ins) // 3.4.1 normalizedString (#normalizedString) // 3.4.2 token (#token) // 3.4.3 language (#language) // 3.4.4 NMTOKEN (#NMTOKEN) // 3.4.5 NMTOKENS (#NMTOKENS) // 3.4.6 Name (#Name) // 3.4.7 NCName (#NCName) // 3.4.8 ID (#ID) // 3.4.9 IDREF (#IDREF) // 3.4.10 IDREFS (#IDREFS) // 3.4.11 ENTITY (#ENTITY) // 3.4.12 ENTITIES (#ENTITIES) // 3.4.13 integer (#integer) // 3.4.14 nonPositiveInteger (#nonPositiveInteger) // 3.4.15 negativeInteger (#negativeInteger) // 3.4.16 long (#long) { SimpleContentPattern<Long> pattern = SimpleContentPattern.newValuePattern(SweJaxbConstants.XSD_LONG, Long.class); patterns.put(Long.TYPE, pattern); patterns.put(pattern.getJavaType(), pattern); patternsForTypeQNames.put(pattern.getSchemaType(), pattern); pattern.setFormatter(new Formatter<Long>() { @Override public String print(Long object, Locale locale) { return Long.toString(object); } @Override public Long parse(String text, Locale locale) throws ParseException { return Long.parseLong(text); } }); } // 3.4.17 int (#int) { SimpleContentPattern<Integer> pattern = SimpleContentPattern.newValuePattern(SweJaxbConstants.XSD_INT, Integer.class); patterns.put(Integer.TYPE, pattern); patterns.put(pattern.getJavaType(), pattern); patternsForTypeQNames.put(pattern.getSchemaType(), pattern); pattern.setFormatter(new Formatter<Integer>() { @Override public String print(Integer object, Locale locale) { return Integer.toString(object); } @Override public Integer parse(String text, Locale locale) throws ParseException { return Integer.parseInt(text); } }); } // 3.4.18 short (#short) { SimpleContentPattern<Short> pattern = SimpleContentPattern.newValuePattern(SweJaxbConstants.XSD_SHORT, Short.class); patterns.put(Short.TYPE, pattern); patterns.put(pattern.getJavaType(), pattern); patternsForTypeQNames.put(pattern.getSchemaType(), pattern); pattern.setFormatter(new Formatter<Short>() { @Override public String print(Short object, Locale locale) { return Short.toString(object); } @Override public Short parse(String text, Locale locale) throws ParseException { return Short.parseShort(text); } }); } // 3.4.19 byte (#byte) { SimpleContentPattern<Byte> pattern = SimpleContentPattern.newValuePattern(SweJaxbConstants.XSD_BYTE, Byte.class); patterns.put(Byte.TYPE, pattern); patterns.put(pattern.getJavaType(), pattern); patternsForTypeQNames.put(pattern.getSchemaType(), pattern); pattern.setFormatter(new Formatter<Byte>() { @Override public String print(Byte object, Locale locale) { return Byte.toString(object); } @Override public Byte parse(String text, Locale locale) throws ParseException { return Byte.parseByte(text); } }); } // 3.4.20 nonNegativeInteger (#nonNegativeInteger) // 3.4.21 unsignedLong (#unsignedLong) // 3.4.22 unsignedInt (#unsignedInt) // 3.4.23 unsignedShort (#unsignedShort) // 3.4.24 unsignedByte (#unsignedByte) // 3.4.25 positiveInteger (#positiveInteger) // 3.4.26 yearMonthDuration (#yearMonthDuration) // 3.4.27 dayTimeDuration (#dayTimeDuration) // 3.4.28 dateTimeStamp (#dateTimeStamp) // other simple types // JAXB2 (static): /* class [B class char class java.awt.Image class java.io.File class java.lang.Character class java.lang.Class class java.lang.Void class java.math.BigDecimal class java.math.BigInteger class java.net.URI class java.net.URL class java.util.Calendar class java.util.Date class java.util.GregorianCalendar class java.util.UUID class javax.activation.DataHandler class javax.xml.datatype.Duration class javax.xml.datatype.XMLGregorianCalendar class javax.xml.namespace.QName interface javax.xml.transform.Source class void */ // JAXB2 (additional mappings available at runtime): /* * class com.sun.xml.bind.api.CompositeStructure * class java.lang.Object * class javax.xml.bind.JAXBElement */ }
From source file:org.ow2.proactive_grid_cloud_portal.cli.cmd.rm.RemoveNodeSourceCommand.java
public void execute(ApplicationContext currentContext) throws CLIException { if (currentContext.isForced()) { preempt = true;//from w w w .ja v a 2s . c o m } HttpPost request = new HttpPost(currentContext.getResourceUrl("nodesource/remove")); QueryStringBuilder queryStringBuilder = new QueryStringBuilder(); queryStringBuilder.add("name", nodeSource).add("preempt", Boolean.toString(preempt)); request.setEntity(queryStringBuilder.buildEntity(APPLICATION_FORM_URLENCODED)); HttpResponseWrapper response = execute(request, currentContext); if (statusCode(response) == statusCode(OK)) { boolean success = readValue(response, Boolean.TYPE, currentContext); resultStack(currentContext).push(success); if (success) { writeLine(currentContext, "Node source '%s' deleted successfully.", nodeSource); } else { writeLine(currentContext, "Cannot delete node source: %s.", nodeSource); } } else { handleError(String.format("An error occurred while deleting node source: %s", nodeSource), response, currentContext); } }