Package org.jboss.metatype.api.values

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


   public static SimpleValue createSimpleValue(SimpleMetaType type, Serializable value)
   {
      if (value == null)
         return null;

      return new SimpleValueSupport(type, value);
   }
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

        return simpleValue;
    }

    protected void setInnerValue(String propSimpleValue, MetaValue metaValue, PropertyDefinitionSimple propDefSimple)
    {
        SimpleValueSupport simpleValueSupport = (SimpleValueSupport)metaValue;
        if (propSimpleValue == null)
        {
            // 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

                property.setErrorMessage(message);

                throw new IllegalArgumentException(message);
            }

            valuesMap.put(configPropertyName, new SimpleValueSupport(
                    SimpleMetaType.STRING, valueProperty.getStringValue()));
            valuesMap.put(configPropertyName + ".type", new SimpleValueSupport(
                    SimpleMetaType.STRING, typeProperty.getStringValue()));
        }
    }
View Full Code Here

            return "ConfigProperty[" + name + "(" + type + ") : " + value + "]";
        }

        public SimpleValue getTypeDefinitionValue()
        {
            return new SimpleValueSupport(SimpleMetaType.STRING, type
                    .getTypeName());
        }
View Full Code Here

                    .getTypeName());
        }

        public SimpleValue getValueDefinitionValue()
        {
            return new SimpleValueSupport(type.getMetaType(), value);
        }
View Full Code Here

public class SimpleMetaValueMeasurementAdapter implements MeasurementAdapter {
    private final Log LOG = LogFactory.getLog(SimpleMetaValueMeasurementAdapter.class);

    public void setMeasurementData(MeasurementReport report, MetaValue metaValue, MeasurementScheduleRequest request,
        MeasurementDefinition measurementDefinition) {
        SimpleValueSupport simpleValue = (SimpleValueSupport) metaValue;
        DataType dataType = measurementDefinition.getDataType();
        switch (dataType) {
        case MEASUREMENT:
            try {
                MeasurementDataNumeric dataNumeric = new MeasurementDataNumeric(request, new Double(simpleValue
                    .getValue().toString()));
                report.addData(dataNumeric);
            } catch (NumberFormatException e) {
                LOG.warn("Measurement request: " + request.getName()
                    + " did not return a numeric value from the Profile Service", e);
            }
            break;
        case TRAIT:
            MeasurementDataTrait dataTrait = new MeasurementDataTrait(request, String.valueOf(simpleValue.getValue()));
            report.addData(dataTrait);
            break;
        default:
            throw new IllegalStateException("Unsupported measurement data type: " + dataType);
View Full Code Here

     
      CompositeValue composite = (CompositeValue) p.getValue();
     
      Map<String, MetaValue> valueMap = new HashMap<String, MetaValue>();
      valueMap.put("optionalName",
            new SimpleValueSupport(SimpleMetaType.STRING, "changed"));
      valueMap.put("integer", new SimpleValueSupport(
            SimpleMetaType.INTEGER_PRIMITIVE, 111));

      //
      p.setValue(new CompositeValueSupport(composite.getMetaType(), valueMap));
View Full Code Here

      createComponentTest("QueueTemplate", propValues, getName(), type, jndiName);
      ManagedComponent queue = activeView.getComponent("testCreateQueue", type);
      assertNotNull(queue);
      assertEquals("testCreateQueue", queue.getName());
      log.info(queue.getProperties().keySet());
      assertEquals("downCacheSize", queue.getProperty("downCacheSize").getValue(), new SimpleValueSupport(SimpleMetaType.INTEGER_PRIMITIVE, 1999));

      ManagedProperty serverPeer = queue.getProperty("serverPeer");
      assertNotNull(serverPeer);
      MetaType serverPeerType = serverPeer.getMetaType();
      assertEquals(SimpleMetaType.STRING, serverPeerType);
View Full Code Here

      createComponentTest("QueueTemplate", propValues, getName(), type, jndiName);
      ManagedComponent queue = activeView.getComponent("testCreateQueueWithNullDLQ", type);
      assertNotNull(queue);
      assertEquals("testCreateQueueWithNullDLQ", queue.getName());
      log.info(queue.getProperties().keySet());
      assertEquals("downCacheSize", queue.getProperty("downCacheSize").getValue(), new SimpleValueSupport(SimpleMetaType.INTEGER_PRIMITIVE, 1999));

      ManagedProperty serverPeer = queue.getProperty("serverPeer");
      assertNotNull(serverPeer);
      MetaType serverPeerType = serverPeer.getMetaType();
      assertEquals(SimpleMetaType.STRING, serverPeerType);
View Full Code Here

TOP

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

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.