Package org.jboss.metatype.api.values

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


public class PropertyMapToPropertiesValueAdapter extends AbstractPropertyMapAdapter
        implements PropertyAdapter<PropertyMap, PropertyDefinitionMap>
{
    public void populateMetaValueFromProperty(PropertyMap propMap, MetaValue metaValue, PropertyDefinitionMap propDefMap)
    {
        PropertiesMetaValue propertiesValue = (PropertiesMetaValue)metaValue;
        for (String mapMemberPropName : propMap.getMap().keySet())
        {
            Property mapMemberProp = propMap.get(mapMemberPropName);
            propertiesValue.setProperty(mapMemberProp.getName(), ((PropertySimple)mapMemberProp).getStringValue());
        }
    }
View Full Code Here


        }
    }

    public MetaValue convertToMetaValue(PropertyMap propMap, PropertyDefinitionMap propDefMap, MetaType metaType)
    {
        PropertiesMetaValue propertiesValue = new PropertiesMetaValue();
        populateMetaValueFromProperty(propMap, propertiesValue, propDefMap);
        return propertiesValue;
    }
View Full Code Here

    public void populatePropertyFromMetaValue(PropertyMap propMap, MetaValue metaValue, PropertyDefinitionMap propDefMap)
    {
        if (metaValue == null)
            return;
        PropertiesMetaValue propertiesValue = (PropertiesMetaValue)metaValue;
        Set<String> mapMemberPropNames = new HashSet();
        for (Object key : propertiesValue.keySet())
            mapMemberPropNames.add((String)key);
        // There won't be any keys when loading a Configuration for the first time.
        for (String mapMemberPropName : mapMemberPropNames)
        {
            // We assume the PropertyMap is an "open map", since that's what PropertiesMetaValue maps to.
            PropertySimple mapMemberProp = propMap.getSimple(mapMemberPropName);
            // Create a PropertySimple and populate it.
            if (mapMemberProp == null)
            {
                mapMemberProp = new PropertySimple(mapMemberPropName, propertiesValue.getProperty(mapMemberPropName));
                propMap.put(mapMemberProp);
            }
        }
    }
View Full Code Here

      assertNotNull(mo);
     
      ManagedProperty p = mo.getProperty("name");
      CompositeValue c = (CompositeValue) p.getValue();
      assertNotNull(c);
      PropertiesMetaValue properties = (PropertiesMetaValue) c.get("keyPropertyList");
      properties.put("v", "value5");

      // Assert xml information
      PersistedManagedObject restoredElement = restore(mo);
      assertNotNull(restoredElement);
     
View Full Code Here

      getLog().debug("nameAsProperties default: "+defaultValue);
      Properties p = new Properties();
      p.setProperty("domain", "domain1");
      p.setProperty("key1", "value1");
      p.setProperty("key2", "value2");
      PropertiesMetaValue expected = new PropertiesMetaValue(p);
      assertEquals(expected, defaultValue);     
   }
View Full Code Here

      for(int n = 0; n < pairs.length; n ++)
      {
         String[] kv = pairs[n].split("=");
         props.put(kv[0], kv[1]);
      }
      PropertiesMetaValue metaValue = new PropertiesMetaValue(props);
      return metaValue;
   }
View Full Code Here

         }
         return array;
      }
      else if (metaType.isProperties())
      {
         PropertiesMetaValue propsValue = (PropertiesMetaValue) metaValue;
         return unwrapProperties(propsValue, type);
      }
      else if (metaType.isComposite())
      {
         CompositeValue compositeValue = (CompositeValue)metaValue;
View Full Code Here

         return null;
      if((value instanceof Hashtable) == false)
         throw new IllegalArgumentException("PropertiesMetaType requires a java.lang.Properties value, value.class: "+value.getClass());

      Hashtable pvalue = (Hashtable) value;
      PropertiesMetaValue pmv = new PropertiesMetaValue();
      for(Object key : pvalue.keySet())
      {
         if ((key instanceof String) == false)
            throw new IllegalArgumentException("key("+key+") is not a String");
         String skey = (String) key;
         Object ovalue = pvalue.get(skey);
         if ((key instanceof String) == false)
            throw new IllegalArgumentException("value for key("+key+") is not a String, value.class: "+ovalue.getClass());
         String svalue = (String) ovalue;
         pmv.setProperty(skey, svalue);
      }
      return pmv;
   }
View Full Code Here

   @Override
   public MetaValue createMetaValue(MetaType metaType, ObjectName object)
   {
      String[] itemNames = {"domain", "keyPropertyList"};
      PropertiesMetaValue keyValues = new PropertiesMetaValue();
      for(Object key : object.getKeyPropertyList().keySet())
      {
         Object value = object.getKeyProperty((String)key);
         keyValues.put(key, value);
      }
      MetaValue[] itemValues = {SimpleValueSupport.wrap(object.getDomain()), keyValues};
      CompositeValueSupport mv = new CompositeValueSupport(ObjectNameTypeBuilder.META_TYPE,
            itemNames, itemValues);
      return mv;
View Full Code Here

   @Override
   public MetaValue createMetaValue(MetaType metaType, ObjectName object)
   {
      String domain = object.getDomain();
      Map<String, String> props = object.getKeyPropertyList();
      PropertiesMetaValue map = PropertiesMetaValue.wrap(props);
      map.put("domain", domain);
      return map;
   }
View Full Code Here

TOP

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

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.