Package org.jboss.metatype.api.types

Examples of org.jboss.metatype.api.types.SimpleMetaType


      return false;
    }
   
    MetaType type = v1.getMetaType();
    if (v1 instanceof SimpleValue && type instanceof SimpleMetaType) {
      SimpleMetaType st = (SimpleMetaType)type;
      SimpleValue sv = wrap(st, v2);
      return sv.compareTo((SimpleValue)v1) == 0;
    }
    return false;
  }
View Full Code Here


    return new EnumValueSupport(type, value);
  }
 
  public static SimpleValue wrap(MetaType type, String value) {
    if (type instanceof SimpleMetaType) {
      SimpleMetaType st = (SimpleMetaType)type;
     
      if (SimpleMetaType.BIGDECIMAL.equals(st)) {
        return new SimpleValueSupport(st, new BigDecimal(value));
      } else if (SimpleMetaType.BIGINTEGER.equals(st)) {
        return new SimpleValueSupport(st, new BigInteger(value));
View Full Code Here

      ExtendedPropertyMetadata extended = new ExtendedPropertyMetadata(metadata.getName(), metadata.getType(), description, metadata.getValue());
      return ManagedPropertyUtil.convert(extended);
    }
   
    DefaultFieldsImpl fields = new DefaultFieldsImpl(metadata.getName());
    SimpleMetaType metaType = SimpleMetaType.resolve(metadata.getType());
    fields.setMetaType(metaType);   
    if (metadata.getValue() != null && metadata.getValue().trim().length() > 0) {
      fields.setField(Fields.DEFAULT_VALUE, ManagedUtil.wrap(metaType, metadata.getValue()));
    }
   
View Full Code Here

            // A null value is the easiest case - just set the SimpleMetaValue's inner value to null.
            simpleValueSupport.setValue(null);
            return;
        }
        // String value is non-null, so we can massage it into the proper type for the SimpleMetaValue's inner value.
        SimpleMetaType simpleMetaType = simpleValueSupport.getMetaType();
        Serializable innerValue;
        if (simpleMetaType.equals(SimpleMetaType.STRING) || simpleMetaType.equals(SimpleMetaType.NAMEDOBJECT))
            innerValue = propSimpleValue;
        else if (simpleMetaType.equals(SimpleMetaType.BOOLEAN) || simpleMetaType.equals(SimpleMetaType.BOOLEAN_PRIMITIVE))
            innerValue = Boolean.valueOf(propSimpleValue);
        else if (simpleMetaType.equals(SimpleMetaType.BYTE) || simpleMetaType.equals(SimpleMetaType.BYTE_PRIMITIVE))
            innerValue = Byte.valueOf(propSimpleValue);
        else if (simpleMetaType.equals(SimpleMetaType.CHARACTER) || simpleMetaType.equals(SimpleMetaType.CHARACTER_PRIMITIVE))
        {
            if (propSimpleValue.length() != 1)
                throw new IllegalStateException("String value '" + propSimpleValue + " cannot be converted to a character.");
            innerValue = propSimpleValue.charAt(0);
        }
        else if (simpleMetaType.equals(SimpleMetaType.DOUBLE) || simpleMetaType.equals(SimpleMetaType.DOUBLE_PRIMITIVE))
            innerValue = Double.valueOf(propSimpleValue);
        else if (simpleMetaType.equals(SimpleMetaType.FLOAT) || simpleMetaType.equals(SimpleMetaType.FLOAT_PRIMITIVE))
            innerValue = Float.valueOf(propSimpleValue);
        else if (simpleMetaType.equals(SimpleMetaType.INTEGER) || simpleMetaType.equals(SimpleMetaType.INTEGER_PRIMITIVE))
            innerValue = Integer.valueOf(propSimpleValue);
        else if (simpleMetaType.equals(SimpleMetaType.LONG) || simpleMetaType.equals(SimpleMetaType.LONG_PRIMITIVE))
            innerValue = Long.valueOf(propSimpleValue);
        else if (simpleMetaType.equals(SimpleMetaType.SHORT) || simpleMetaType.equals(SimpleMetaType.SHORT_PRIMITIVE))
            innerValue = Short.valueOf(propSimpleValue);
        else
            throw new IllegalStateException("Unsupported MetaType: " + simpleMetaType);
        simpleValueSupport.setValue(innerValue);
    }
View Full Code Here

  }

  public static SimpleValue wrap(MetaType type, String value)
      throws Exception {
    if (type instanceof SimpleMetaType) {
      SimpleMetaType st = (SimpleMetaType) type;

      if (SimpleMetaType.BIGDECIMAL.equals(st)) {
        return new SimpleValueSupport(st, new BigDecimal(value));
      } else if (SimpleMetaType.BIGINTEGER.equals(st)) {
        return new SimpleValueSupport(st, new BigInteger(value));
View Full Code Here

    {
        metaTypeInstances.clear();

        metaTypeInstances.put(GENERIC_TYPE, new GenericMetaType("String", "Just something"));
        SimpleValue simpleValue = SimpleValueSupport.wrap("SimpleValue");
        SimpleMetaType simpleMetaType = simpleValue.getMetaType();
        metaTypeInstances.put(SIMPLE_TYPE, simpleMetaType);
        CompositeMetaType compositeMetaType = new MutableCompositeMetaType("String", "Just something");
        metaTypeInstances.put(COMPOSITE_TYPE, compositeMetaType);
        CompositeMetaType mapCompositeMetaType = new MapCompositeMetaType(SimpleMetaType.STRING);
        metaTypeInstances.put(MAP_COMPOSITE_TYPE, mapCompositeMetaType);
View Full Code Here

            // A null value is the easiest case - just set the SimpleMetaValue's inner value to null.
            simpleValueSupport.setValue(null);
            return;
        }
        // String value is non-null, so we can massage it into the proper type for the SimpleMetaValue's inner value.
        SimpleMetaType simpleMetaType = simpleValueSupport.getMetaType();
        Serializable innerValue;
        if (simpleMetaType.equals(SimpleMetaType.STRING) || simpleMetaType.equals(SimpleMetaType.NAMEDOBJECT))
            innerValue = propSimpleValue;
        else if (simpleMetaType.equals(SimpleMetaType.BOOLEAN) || simpleMetaType.equals(SimpleMetaType.BOOLEAN_PRIMITIVE))
            innerValue = Boolean.valueOf(propSimpleValue);
        else if (simpleMetaType.equals(SimpleMetaType.BYTE) || simpleMetaType.equals(SimpleMetaType.BYTE_PRIMITIVE))
            innerValue = Byte.valueOf(propSimpleValue);
        else if (simpleMetaType.equals(SimpleMetaType.CHARACTER) || simpleMetaType.equals(SimpleMetaType.CHARACTER_PRIMITIVE))
        {
            if (propSimpleValue.length() != 1)
                throw new IllegalStateException("String value '" + propSimpleValue + " cannot be converted to a character.");
            innerValue = propSimpleValue.charAt(0);
        }
        else if (simpleMetaType.equals(SimpleMetaType.DOUBLE) || simpleMetaType.equals(SimpleMetaType.DOUBLE_PRIMITIVE))
            innerValue = Double.valueOf(propSimpleValue);
        else if (simpleMetaType.equals(SimpleMetaType.FLOAT) || simpleMetaType.equals(SimpleMetaType.FLOAT_PRIMITIVE))
            innerValue = Float.valueOf(propSimpleValue);
        else if (simpleMetaType.equals(SimpleMetaType.INTEGER) || simpleMetaType.equals(SimpleMetaType.INTEGER_PRIMITIVE))
            innerValue = Integer.valueOf(propSimpleValue);
        else if (simpleMetaType.equals(SimpleMetaType.LONG) || simpleMetaType.equals(SimpleMetaType.LONG_PRIMITIVE))
            innerValue = Long.valueOf(propSimpleValue);
        else if (simpleMetaType.equals(SimpleMetaType.SHORT) || simpleMetaType.equals(SimpleMetaType.SHORT_PRIMITIVE))
            innerValue = Short.valueOf(propSimpleValue);
        else
            throw new IllegalStateException("Unsupported MetaType: " + simpleMetaType);
        simpleValueSupport.setValue(innerValue);
    }
View Full Code Here

         throw new Exception("Unhandled OpenType: "+type);
      return metaType;
   }
   static SimpleMetaType getMetaType(SimpleType type)
   {
      SimpleMetaType metaType = null;
      if(type == SimpleType.BOOLEAN)
         metaType = SimpleMetaType.BOOLEAN;
      else if(type == SimpleType.BYTE)
         metaType = SimpleMetaType.BYTE;
      else if(type == SimpleType.CHARACTER)
View Full Code Here

   {
      for (int i = 0; i < types.length; i++)
      {
         getLog().debug("serialization: " + types[i].getClassName() + " original=" + types[i]);
         byte[] bytes = serialize(types[i]);
         SimpleMetaType result = (SimpleMetaType) deserialize(bytes);
         getLog().debug("serialization: " + types[i].getClassName() + " result  =" + types[i]);

         assertTrue("Should resolve to same object after serialization " + types[i], types[i] == result);
      }
   }
View Full Code Here

   public void testBytePrimitives()
      throws Exception
   {
      assertEquals(SimpleMetaType.BYTE_PRIMITIVE, SimpleMetaType.isSimpleType(byte.class.getName()));
      SimpleMetaType byteType = SimpleMetaType.resolve("byte");
      assertNotNull(byteType);
      assertEquals(SimpleMetaType.BYTE_PRIMITIVE, byteType);
      assertTrue(byteType.isPrimitive());
      Serializable one = (byte) 1;
      log.debug("one.class: "+one.getClass());
      SimpleValue byte1p = SimpleValueSupport.wrap((byte)1);
      SimpleValue byte1p2 = SimpleValueSupport.wrap((byte)1);
      assertEquals(SimpleMetaType.BYTE_PRIMITIVE, byte1p.getMetaType());
View Full Code Here

TOP

Related Classes of org.jboss.metatype.api.types.SimpleMetaType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.