Package org.jboss.metatype.api.values

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


  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));
      } else if (SimpleMetaType.BOOLEAN.equals(st)) {
        return new SimpleValueSupport(st, Boolean.valueOf(value));
      } else if (SimpleMetaType.BOOLEAN_PRIMITIVE.equals(st)) {
        return new SimpleValueSupport(st, Boolean.valueOf(value).booleanValue());
      } else if (SimpleMetaType.BYTE.equals(st)) {
        return new SimpleValueSupport(st, new Byte(value.getBytes()[0]));
      } else if (SimpleMetaType.BYTE_PRIMITIVE.equals(st)) {
        return new SimpleValueSupport(st, value.getBytes()[0]);
      } else if (SimpleMetaType.CHARACTER.equals(st)) {
        return new SimpleValueSupport(st, new Character(value.charAt(0)));
      } else if (SimpleMetaType.CHARACTER_PRIMITIVE.equals(st)) {
        return new SimpleValueSupport(st,value.charAt(0));
      } else if (SimpleMetaType.DATE.equals(st)) {
        try {
          return new SimpleValueSupport(st, SimpleDateFormat.getInstance().parse(value));
        } catch (ParseException e) {
          throw new TeiidRuntimeException(e, IntegrationPlugin.Util.getString("failed_to_convert", type.getClassName())); //$NON-NLS-1$
        }
      } else if (SimpleMetaType.DOUBLE.equals(st)) {
        return new SimpleValueSupport(st, Double.valueOf(value));
      } else if (SimpleMetaType.DOUBLE_PRIMITIVE.equals(st)) {
        return new SimpleValueSupport(st, Double.parseDouble(value));
      } else if (SimpleMetaType.FLOAT.equals(st)) {
        return new SimpleValueSupport(st, Float.parseFloat(value));
      } else if (SimpleMetaType.FLOAT_PRIMITIVE.equals(st)) {
        return new SimpleValueSupport(st, Float.valueOf(value));
      } else if (SimpleMetaType.INTEGER.equals(st)) {
        return new SimpleValueSupport(st, Integer.valueOf(value));
      } else if (SimpleMetaType.INTEGER_PRIMITIVE.equals(st)) {
        return new SimpleValueSupport(st, Integer.parseInt(value));
      } else if (SimpleMetaType.LONG.equals(st)) {
        return new SimpleValueSupport(st, Long.valueOf(value));
      } else if (SimpleMetaType.LONG_PRIMITIVE.equals(st)) {
        return new SimpleValueSupport(st, Long.parseLong(value));
      } else if (SimpleMetaType.SHORT.equals(st)) {
        return new SimpleValueSupport(st, Short.valueOf(value));
      } else if (SimpleMetaType.SHORT_PRIMITIVE.equals(st)) {
        return new SimpleValueSupport(st, Short.parseShort(value));
      } else if (SimpleMetaType.STRING.equals(st)) {
        return new SimpleValueSupport(st,value);
      }
    }
    throw new TeiidRuntimeException(IntegrationPlugin.Util.getString("failed_to_convert", type.getClassName())); //$NON-NLS-1$
  }
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

      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));
      } else if (SimpleMetaType.BOOLEAN.equals(st)) {
        return new SimpleValueSupport(st, Boolean.valueOf(value));
      } else if (SimpleMetaType.BOOLEAN_PRIMITIVE.equals(st)) {
        return new SimpleValueSupport(st, Boolean.valueOf(value)
            .booleanValue());
      } else if (SimpleMetaType.BYTE.equals(st)) {
        return new SimpleValueSupport(st, new Byte(value.getBytes()[0]));
      } else if (SimpleMetaType.BYTE_PRIMITIVE.equals(st)) {
        return new SimpleValueSupport(st, value.getBytes()[0]);
      } else if (SimpleMetaType.CHARACTER.equals(st)) {
        return new SimpleValueSupport(st,
            new Character(value.charAt(0)));
      } else if (SimpleMetaType.CHARACTER_PRIMITIVE.equals(st)) {
        return new SimpleValueSupport(st, value.charAt(0));
      } else if (SimpleMetaType.DATE.equals(st)) {
        try {
          return new SimpleValueSupport(st, SimpleDateFormat
              .getInstance().parse(value));
        } catch (ParseException e) {
          throw new Exception(
              "Failed to convert value to SimpleValue", e); //$NON-NLS-1$
        }
      } else if (SimpleMetaType.DOUBLE.equals(st)) {
        return new SimpleValueSupport(st, Double.valueOf(value));
      } else if (SimpleMetaType.DOUBLE_PRIMITIVE.equals(st)) {
        return new SimpleValueSupport(st, Double.parseDouble(value));
      } else if (SimpleMetaType.FLOAT.equals(st)) {
        return new SimpleValueSupport(st, Float.parseFloat(value));
      } else if (SimpleMetaType.FLOAT_PRIMITIVE.equals(st)) {
        return new SimpleValueSupport(st, Float.valueOf(value));
      } else if (SimpleMetaType.INTEGER.equals(st)) {
        return new SimpleValueSupport(st, Integer.valueOf(value));
      } else if (SimpleMetaType.INTEGER_PRIMITIVE.equals(st)) {
        return new SimpleValueSupport(st, Integer.parseInt(value));
      } else if (SimpleMetaType.LONG.equals(st)) {
        return new SimpleValueSupport(st, Long.valueOf(value));
      } else if (SimpleMetaType.LONG_PRIMITIVE.equals(st)) {
        return new SimpleValueSupport(st, Long.parseLong(value));
      } else if (SimpleMetaType.SHORT.equals(st)) {
        return new SimpleValueSupport(st, Short.valueOf(value));
      } else if (SimpleMetaType.SHORT_PRIMITIVE.equals(st)) {
        return new SimpleValueSupport(st, Short.parseShort(value));
      } else if (SimpleMetaType.STRING.equals(st)) {
        return new SimpleValueSupport(st, value);
      }
    }
    throw new Exception("Failed to convert value to SimpleValue"); //$NON-NLS-1$
  }
View Full Code Here

      assertNotNull(configProperty);
      MetaValue value = configProperty.getValue();
      assertTrue("MapCompositeMetaType", value.getMetaType() instanceof MapCompositeMetaType);
     
      MapCompositeValueSupport cValue = (MapCompositeValueSupport) value;
      cValue.put("testKey", new SimpleValueSupport(SimpleMetaType.STRING, "testValue"));
     
      mgtView.updateComponent(dsMC);

      mgtView = getManagementView();
      dsMC = getManagedComponent(mgtView, compType, jndiName);
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

  
   protected CompositeValue createCompositeValue(Boolean read, Boolean write, Boolean create)
   {
      Map<String, MetaValue> map = new HashMap<String, MetaValue>();
     
      map.put("read", new SimpleValueSupport(SimpleMetaType.BOOLEAN, read));
      map.put("write", new SimpleValueSupport(SimpleMetaType.BOOLEAN, write));
      map.put("create", new SimpleValueSupport(SimpleMetaType.BOOLEAN, create));
     
      return new CompositeValueSupport(composite, map);
   }
View Full Code Here

   @Override
   public MetaValue createMetaValue(MetaType metaType, ConnectionFactoryControl control)
   {
      CompositeValueSupport cvs = new CompositeValueSupport(TYPE);
      cvs.set("name", new SimpleValueSupport(SimpleMetaType.STRING, control.getName()));
      List<org.hornetq.api.core.Pair<TransportConfiguration, TransportConfiguration>> pairs = control.getStaticConnectors();
      StringBuffer liveTransportClassNames = new StringBuffer();
      StringBuffer liveTransportParams = new StringBuffer();
      StringBuffer backupTransportClassNames = new StringBuffer();
      StringBuffer backupTransportParams = new StringBuffer();
      for (Pair<TransportConfiguration, TransportConfiguration> pair : pairs)
      {
         if (pair.a != null)
         {
            TransportConfiguration live = pair.a;
            if(liveTransportClassNames.length() > 0)
            {
               liveTransportClassNames.append(",");
            }
            liveTransportClassNames.append(live.getFactoryClassName());

            Map<String, Object> params = live.getParams();
            liveTransportParams.append("{");
            for (Map.Entry<String, Object> stringObjectEntry : params.entrySet())
            {
               if(liveTransportParams.length() > 1)
               {
                  liveTransportParams.append(",");
               }
               liveTransportParams.append(stringObjectEntry.getKey()).append("=").append(stringObjectEntry.getValue());
            }
            liveTransportParams.append("}");
         }

         if (pair.b != null)
         {
            TransportConfiguration backUp = pair.b;
            if(backupTransportClassNames.length() > 0)
            {
               backupTransportClassNames.append(",");
            }
            backupTransportClassNames.append(backUp.getFactoryClassName());

            Map<String, Object> params = backUp.getParams();
            backupTransportParams.append("{");
            for (Map.Entry<String, Object> stringObjectEntry : params.entrySet())
            {
               if(backupTransportParams.length() > 1)
               {
                  backupTransportParams.append(",");
               }
               backupTransportParams.append(stringObjectEntry.getKey()).append("=").append(stringObjectEntry.getValue());
            }
            backupTransportParams.append("}");
         }

      }
      cvs.set("liveTransportClassNames", new SimpleValueSupport(SimpleMetaType.STRING, liveTransportClassNames));
      cvs.set("liveTransportParams", new SimpleValueSupport(SimpleMetaType.STRING, liveTransportParams));
      cvs.set("backupTransportClassNames", new SimpleValueSupport(SimpleMetaType.STRING, backupTransportClassNames));
      cvs.set("backupTransportParams", new SimpleValueSupport(SimpleMetaType.STRING, backupTransportParams));
      cvs.set("Bindings", new SimpleValueSupport(SimpleMetaType.STRING, getJndiString(control.getJNDIBindings())));
      cvs.set("DiscoveryAddress", new SimpleValueSupport(SimpleMetaType.STRING, control.getDiscoveryAddress()));
      cvs.set("DiscoveryPort", new SimpleValueSupport(SimpleMetaType.STRING, control.getDiscoveryPort()));
      cvs.set("DiscoveryRefreshTimeout", new SimpleValueSupport(SimpleMetaType.STRING, control.getDiscoveryRefreshTimeout()));
      cvs.set("DiscoveryInitialWaitTimeout", new SimpleValueSupport(SimpleMetaType.STRING, control.getDiscoveryInitialWaitTimeout()));
      cvs.set("ClientID", new SimpleValueSupport(SimpleMetaType.STRING, control.getClientID()));
      cvs.set("DupsOKBatchSize", new SimpleValueSupport(SimpleMetaType.STRING, control.getDupsOKBatchSize()));
      cvs.set("TransactionBatchSize", new SimpleValueSupport(SimpleMetaType.STRING, control.getTransactionBatchSize()));
      cvs.set("ClientFailureCheckPeriod", new SimpleValueSupport(SimpleMetaType.STRING, control.getClientFailureCheckPeriod()));
      cvs.set("ConnectionTTL", new SimpleValueSupport(SimpleMetaType.STRING, control.getConnectionTTL()));
      cvs.set("CallTimeout", new SimpleValueSupport(SimpleMetaType.STRING, control.getCallTimeout()));
      cvs.set("ConsumerWindowSize", new SimpleValueSupport(SimpleMetaType.STRING, control.getConfirmationWindowSize()));
      cvs.set("ConsumerMaxRate", new SimpleValueSupport(SimpleMetaType.STRING, control.getConsumerMaxRate()));
      cvs.set("ConfirmationWindowSize", new SimpleValueSupport(SimpleMetaType.STRING, control.getConfirmationWindowSize()));
      cvs.set("ProducerMaxRate", new SimpleValueSupport(SimpleMetaType.STRING, control.getProducerMaxRate()));
      cvs.set("ProducerWindowSize", new SimpleValueSupport(SimpleMetaType.STRING, control.getProducerWindowSize()));
      cvs.set("CacheLargeMessagesClient", new SimpleValueSupport(SimpleMetaType.STRING, control.isCacheLargeMessagesClient()));
      cvs.set("MinLargeMessageSize", new SimpleValueSupport(SimpleMetaType.STRING, control.getMinLargeMessageSize()));
      cvs.set("BlockOnNonDurableSend", new SimpleValueSupport(SimpleMetaType.STRING, control.isBlockOnNonDurableSend()));
      cvs.set("BlockOnAcknowledge", new SimpleValueSupport(SimpleMetaType.STRING, control.isBlockOnAcknowledge()));
      cvs.set("BlockOnDurableSend", new SimpleValueSupport(SimpleMetaType.STRING, control.isBlockOnDurableSend()));
      cvs.set("AutoGroup", new SimpleValueSupport(SimpleMetaType.STRING, control.isAutoGroup()));
      cvs.set("PreAcknowledge", new SimpleValueSupport(SimpleMetaType.STRING, control.isPreAcknowledge()));
      cvs.set("MaxRetryInterval", new SimpleValueSupport(SimpleMetaType.STRING, control.getMaxRetryInterval()));
      cvs.set("RetryIntervalMultiplier", new SimpleValueSupport(SimpleMetaType.STRING, control.getRetryIntervalMultiplier()));
      cvs.set("ReconnectAttempts", new SimpleValueSupport(SimpleMetaType.STRING, control.getReconnectAttempts()));
      cvs.set("FailoverOnServerShutdown", new SimpleValueSupport(SimpleMetaType.STRING, control.isFailoverOnServerShutdown()));
      cvs.set("ScheduledThreadPoolMaxSize", new SimpleValueSupport(SimpleMetaType.STRING, control.getScheduledThreadPoolMaxSize()));
      cvs.set("ThreadPoolMaxSize", new SimpleValueSupport(SimpleMetaType.STRING, control.getThreadPoolMaxSize()));
      cvs.set("GroupID", new SimpleValueSupport(SimpleMetaType.STRING, control.getGroupID()));
      cvs.set("InitialMessagePacketSize", new SimpleValueSupport(SimpleMetaType.STRING, control.getInitialMessagePacketSize()));
      cvs.set("UseGlobalPools", new SimpleValueSupport(SimpleMetaType.STRING, control.isUseGlobalPools()));
      cvs.set("RetryInterval", new SimpleValueSupport(SimpleMetaType.STRING, control.getRetryInterval()));
      cvs.set("ConnectionLoadBalancingPolicyClassName", new SimpleValueSupport(SimpleMetaType.STRING, control.getConnectionLoadBalancingPolicyClassName()));
      return cvs;
   }
View Full Code Here

   {
      CompositeValueSupport cvs = new CompositeValueSupport(ADDRESS_SETTINGS_TYPE);
      if (val[0] instanceof JMSQueueConfiguration)
      {
         JMSQueueConfiguration queueConfiguration = (JMSQueueConfiguration) val[0];
         cvs.set("name", new SimpleValueSupport(SimpleMetaType.STRING, queueConfiguration.getName()));
         cvs.set("jndiBindings", new SimpleValueSupport(SimpleMetaType.STRING, getJndiString(queueConfiguration.getBindings())));
      }
      else
      {
         TopicConfiguration topicConfiguration = (TopicConfiguration) val[0];
         cvs.set("name", new SimpleValueSupport(SimpleMetaType.STRING, topicConfiguration.getName()));
         cvs.set("jndiBindings", new SimpleValueSupport(SimpleMetaType.STRING, getJndiString(topicConfiguration.getBindings())));
      }
      AddressSettingsInfo addressSettings = (AddressSettingsInfo) val[1];
      cvs.set("dla", new SimpleValueSupport(SimpleMetaType.STRING, addressSettings.getDeadLetterAddress()));
      cvs.set("expiryAddress", new SimpleValueSupport(SimpleMetaType.STRING, addressSettings.getExpiryAddress()));
      cvs.set("maxSize", new SimpleValueSupport(SimpleMetaType.INTEGER_PRIMITIVE, addressSettings.getMaxSizeBytes()));
      cvs.set("pageSize", new SimpleValueSupport(SimpleMetaType.INTEGER_PRIMITIVE, addressSettings.getPageSizeBytes()));
      cvs.set("maxDeliveryAttempts", new SimpleValueSupport(SimpleMetaType.INTEGER_PRIMITIVE, addressSettings.getMaxDeliveryAttempts()));
      cvs.set("redeliveryDelay", new SimpleValueSupport(SimpleMetaType.LONG_PRIMITIVE, addressSettings.getRedeliveryDelay()));
      cvs.set("lastValueQueue", new SimpleValueSupport(SimpleMetaType.BOOLEAN_PRIMITIVE, addressSettings.isLastValueQueue()));
      cvs.set("redistributionDelay", new SimpleValueSupport(SimpleMetaType.LONG_PRIMITIVE, addressSettings.getRedistributionDelay()));
      cvs.set("sendToDLAOnNoRoute", new SimpleValueSupport(SimpleMetaType.BOOLEAN_PRIMITIVE, addressSettings.isSendToDLAOnNoRoute()));
      cvs.set("addressFullMessagePolicy", new SimpleValueSupport(SimpleMetaType.STRING, addressSettings.getAddressFullMessagePolicy()));
      if(val.length == 3)
      {
         ArrayList<MetaValue> tmp = new ArrayList<MetaValue>();
         RoleInfo[] roles = (RoleInfo[]) val[2];
         for (RoleInfo role : roles)
         {
            CompositeValueSupport cvs2 = new CompositeValueSupport(SECURITY_TYPE);
            cvs2.set("name", new SimpleValueSupport(SimpleMetaType.STRING, role.getName()));
            cvs2.set("send", new SimpleValueSupport(SimpleMetaType.BOOLEAN_PRIMITIVE, role.isSend()));
            cvs2.set("consume", new SimpleValueSupport(SimpleMetaType.BOOLEAN_PRIMITIVE, role.isConsume()));
            cvs2.set("createDurableQueue", new SimpleValueSupport(SimpleMetaType.BOOLEAN_PRIMITIVE, role.isCreateDurableQueue()));
            cvs2.set("deleteDurableQueue", new SimpleValueSupport(SimpleMetaType.BOOLEAN_PRIMITIVE, role.isDeleteDurableQueue()));
            cvs2.set("createNonDurableQueue", new SimpleValueSupport(SimpleMetaType.BOOLEAN_PRIMITIVE, role.isCreateNonDurableQueue()));
            cvs2.set("deleteNonDurableQueue", new SimpleValueSupport(SimpleMetaType.BOOLEAN_PRIMITIVE, role.isDeleteNonDurableQueue()));
            cvs2.set("manage", new SimpleValueSupport(SimpleMetaType.BOOLEAN_PRIMITIVE, role.isManage()));
            tmp.add(cvs2);
         }
         MetaValue[] elements = new MetaValue[tmp.size()];
         tmp.toArray(elements);
         CollectionValueSupport sec = new CollectionValueSupport(TYPE, elements);
View Full Code Here

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

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