Package org.jboss.metatype.api.types

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


  public void build(DeploymentUnit unit, Set<String> outputs, Map<String, ManagedObject> managedObjects) throws DeploymentException {
    if (isBuildManagedObject()) {
      ManagedObject mo = managedObjects.get(TranslatorMetaDataGroup.class.getName());
      if (mo != null) {
        ManagedProperty translators = mo.getProperty("translators"); //$NON-NLS-1$
        MetaType propType = translators.getMetaType();
        if (propType.isCollection()) {
          CollectionValue value = (CollectionValue) translators.getValue();
          if (value != null) {
            for (MetaValue element:value.getElements()) {
              ManagedObject translator = (ManagedObject)((GenericValue)element).getValue();
              managedObjects.put(translator.getName(), translator);
View Full Code Here


  public static boolean sameValue(MetaValue v1, String v2) {
    if (v1 == null || v2 == null) {
      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;
    }
View Full Code Here

    return metaValue;
 
 
  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$
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);
       }
       throw new IllegalArgumentException(prop+ " is not a simple type"); //$NON-NLS-1$
     }
View Full Code Here

 
 
  public static Properties getPropertiesValue(ManagedCommon mc, String prop) {
     ManagedProperty mp = mc.getProperty(prop);
     if (mp != null) {
       MetaType metaType = mp.getMetaType();
       if (metaType.isProperties()) {
         return (PropertiesMetaValue)mp.getValue();
       }
       else if (metaType.isComposite()) {
        Properties props = new Properties();
        MapCompositeValueSupport map = (MapCompositeValueSupport) mp.getValue();
        MapCompositeMetaType type = map.getMetaType();
        for (String key : type.keySet()) {
          MetaValue value = map.get(key);
View Full Code Here

 
 
  public static <T> void getCollectionValue(ManagedCommon mc, String prop, Collection<T> list, Class<T> expectedType) {
     ManagedProperty mp = mc.getProperty(prop);
     if (mp != null) {
       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()));
View Full Code Here

     
      Map<String, ManagedProperty> managedProperties = mc.getProperties();
      for (ManagedProperty mp: managedProperties.values()) {
        MetaValue value = mp.getValue();
        if (value != null) {
          MetaType type = value.getMetaType();
          if (type.isSimple()) {
            PropertiesUtils.setBeanProperty(t, mp.getMappedName(), ((SimpleValue)value).getValue());
          }
          else if (type.isPrimitive()) {
            PropertiesUtils.setBeanProperty(t, mp.getMappedName(), ((SimpleValue)value).getValue());
          }
          else if (type.isEnum()) {
            PropertiesUtils.setBeanProperty(t, mp.getMappedName(), ((org.jboss.metatype.api.values.EnumValue)value).getValue());
          }
          else if (type.isProperties()) {
           
          }
          else if (type.isComposite()) {
            if (value instanceof MapCompositeValueSupport) {
              HashMap<String, String> myValue = (HashMap<String, String>)MetaValueFactory.getInstance().unwrap(value);
             
              if (mp.getMappedName().equals("JAXBProperties")) { //$NON-NLS-1$
                List<PropertyMetadata> props = new ArrayList<PropertyMetadata>();
                for (String key:myValue.keySet()) {
                  props.add(new PropertyMetadata(key, myValue.get(key)));
                }
                PropertiesUtils.setBeanProperty(t, mp.getMappedName(), props);
              }
              else {
                PropertiesUtils.setBeanProperty(t, mp.getMappedName(), myValue);
              }
            }
          }
          else if (type.isCollection()) {
            List list = new ArrayList();

            MetaType elementType = ((CollectionMetaType) type).getElementType();
            if (elementType == AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE) {
              List<ManagedObject> managedObjects = (List<ManagedObject>) MetaValueFactory.getInstance().unwrap(value);
              for (ManagedObject mo : managedObjects) {
                list.add(buildAO(mo, mo.getAttachment().getClass()));
              }
            }
            else if (elementType == SimpleMetaType.STRING) {
              list.addAll((List<String>) MetaValueFactory.getInstance().unwrap(value));
            }
            else if (elementType.isComposite()) {
              list.addAll((List)MetaValueFactory.getInstance().unwrap(value));
            }
            else {
              throw new TeiidRuntimeException("unsupported type"); //$NON-NLS-1$
            }
View Full Code Here

    return usedBufferSpace;
  }

  private void getRequestCollectionValue(MetaValue pValue, Collection<RequestMetadata> list) throws Exception {
    MetaType metaType = pValue.getMetaType();
    if (metaType.isCollection()) {
      for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
        if (value.getMetaType().isComposite()) {
          RequestMetadata request = unwrapRequestMetaValue(value);
          list.add(request);
        } else {
View Full Code Here

      }
    }
  }

  private void getResultsCollectionValue(MetaValue pValue, Collection<ArrayList<String>> list) throws Exception {
    MetaType metaType = pValue.getMetaType();
    if (metaType.isCollection()) {
      for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
        if (value.getMetaType().isCollection()) {
          ArrayList<String> row = new ArrayList<String>();
          MetaValue[] metaValueArray = ((CollectionValueSupport)value).getElements();
          for (MetaValue cell : metaValueArray){
View Full Code Here

      }
    }
  }

  private void getResultsCollectionValueForMatViewRefresh(MetaValue pValue, Collection<ArrayList<String>> list) throws Exception {
    MetaType metaType = pValue.getMetaType();
    for (MetaValue value : ((CollectionValueSupport) pValue).getElements()) {
      if (value.getMetaType().isCollection()) {
        ArrayList<String> row = new ArrayList<String>();
        MetaValue[] metaValueArray = ((CollectionValueSupport)value).getElements();
        for (MetaValue cell : metaValueArray){
View Full Code Here

TOP

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

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.