Package org.jboss.metatype.api.values

Examples of org.jboss.metatype.api.values.SimpleValue


    }
   
    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


 
  public static String stringValue(MetaValue v1) {
    if (v1 != null) {
      MetaType type = v1.getMetaType();
      if (type instanceof SimpleMetaType) {
        SimpleValue simple = (SimpleValue)v1;
        return simple.getValue().toString();
      }
      throw new TeiidRuntimeException("Failed to convert value to string value"); //$NON-NLS-1$
    }
    return null;
 
View Full Code Here

  public static <T> T getSimpleValue(ManagedCommon mc, String prop, Class<T> expectedType) {
     ManagedProperty mp = mc.getProperty(prop);
     if (mp != null) {
       MetaType metaType = mp.getMetaType();
       if (metaType.isSimple()) {
                SimpleValue simpleValue = (SimpleValue)mp.getValue();
                return expectedType.cast((simpleValue != null) ? simpleValue.getValue() : null);
       }
       else if (metaType.isEnum()) {
         EnumValue enumValue = (EnumValue)mp.getValue();
         return expectedType.cast((enumValue != null) ? enumValue.getValue() : null);
       }
View Full Code Here

       MetaType metaType = mp.getMetaType();
       if (metaType.isCollection()) {
         CollectionValue collectionValue = (CollectionValue)mp.getValue();
         for(MetaValue value:collectionValue.getElements()) {
           if (value.getMetaType().isSimple()) {
             SimpleValue simpleValue = (SimpleValue)value;
             list.add(expectedType.cast(simpleValue.getValue()));
           }
           else {
             throw new IllegalArgumentException(prop+ " is not a simple type"); //$NON-NLS-1$
           }
         }
View Full Code Here

            {
                MetaType metaType = managedProp.getMetaType();
                Object value;
                if (metaType.isSimple())
                {
                    SimpleValue simpleValue = (SimpleValue)managedProp.getValue();
                    value = simpleValue.getValue();
                }
                else if (metaType.isEnum())
                {
                    EnumValue enumValue = (EnumValue)managedProp.getValue();
                    value = enumValue.getValue();
View Full Code Here

        propSimple.setValue(value);
    }

    public MetaValue convertToMetaValue(PropertySimple propSimple, PropertyDefinitionSimple propDefSimple, MetaType metaType)
    {
        SimpleValue simpleValue = new SimpleValueSupport((SimpleMetaType)metaType, null);
        populateMetaValueFromProperty(propSimple, simpleValue, propDefSimple);
        return simpleValue;
    }
View Full Code Here

  public static String stringValue(MetaValue v1) throws Exception {
    if (v1 != null) {
      MetaType type = v1.getMetaType();
      if (type instanceof SimpleMetaType) {
        SimpleValue simple = (SimpleValue) v1;
        return simple.getValue().toString();
      }
      throw new Exception("Failed to convert value to string value"); //$NON-NLS-1$
    }
    return null;
  }
View Full Code Here

  public static Boolean booleanValue(MetaValue v1) throws Exception {
    if (v1 != null) {
      MetaType type = v1.getMetaType();
      if (type instanceof SimpleMetaType) {
        SimpleValue simple = (SimpleValue) v1;
        return Boolean.valueOf(simple.getValue().toString());
      }
      throw new Exception("Failed to convert value to boolean value"); //$NON-NLS-1$
    }
    return null;
  }
View Full Code Here

  public static Double doubleValue(MetaValue v1) throws Exception {
    if (v1 != null) {
      MetaType type = v1.getMetaType();
      if (type instanceof SimpleMetaType) {
        SimpleValue simple = (SimpleValue) v1;
        return Double.valueOf(simple.getValue().toString());
      }
      throw new Exception("Failed to convert value to double value"); //$NON-NLS-1$
    }
    return null;
  }
View Full Code Here

 
  public static Long longValue(MetaValue v1) throws Exception {
    if (v1 != null) {
      MetaType type = v1.getMetaType();
      if (type instanceof SimpleMetaType) {
        SimpleValue simple = (SimpleValue) v1;
        return Long.valueOf(simple.getValue().toString());
      }
      throw new Exception("Failed to convert value to long value"); //$NON-NLS-1$
    }
    return null;
  }
View Full Code Here

TOP

Related Classes of org.jboss.metatype.api.values.SimpleValue

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.