Package org.jboss.metatype.api.values

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


      // Properties
      ManagedProperty allThreadIds = mo.getProperty("allThreadIds");
      assertNotNull(allThreadIds);
      MetaValue allThreadIdsMV = allThreadIds.getValue();
      assertTrue("allThreadIds is Array", allThreadIdsMV instanceof ArrayValue);
      ArrayValue idsArray = ArrayValue.class.cast(allThreadIdsMV);
      assertTrue(idsArray.getLength() > 10);
      SimpleValue tid0SV = SimpleValue.class.cast(idsArray.getValue(0));
      ManagedProperty currentThreadCpuTime = mo.getProperty("currentThreadCpuTime");
      assertNotNull(currentThreadCpuTime);
      long x = (Long) metaValueFactory.unwrap(currentThreadCpuTime.getValue());
      assertTrue(x > 1000);
      ManagedProperty currentThreadUserTime = mo.getProperty("currentThreadUserTime");
View Full Code Here


               String n = value.getValue().toString();
               matches = name.equals(n);
            }
            else if(type.isArray())
            {
               ArrayValue value = (ArrayValue) prop.getValue();
               for(Object n : value)
               {
                  if(name.equals(n.toString()))
                  {
                     matches = true;
View Full Code Here

         Serializable value = ((GenericValue)metaValue).getValue();
         return getValue(metaType, type, value);
      }
      else if (metaType.isArray())
      {
         ArrayValue arrayValue = (ArrayValue)metaValue;
         if (type == null)
            type = getTypeInfo(metaType, arrayValue.getValue());
         Object array = newArrayInstance(type, arrayValue.getLength());
         for (int i = 0; i < Array.getLength(array); i++)
         {
            Object element = arrayValue.getValue(i);
            if (element instanceof MetaValue)
               element = unwrapMetaValue((MetaValue)element, type, array);
            else if (element != null && element.getClass().isArray())
               element = unwrapArray(array, element);
View Full Code Here

         Serializable value = ((GenericValue)metaValue).getValue();
         return getValue(metaType, type, value);
      }
      else if (metaType.isArray())
      {
         ArrayValue arrayValue = (ArrayValue)metaValue;
         if (type == null)
            type = getTypeInfo(metaType, arrayValue.getValue());
         Object array = newArrayInstance(type, arrayValue.getLength());
         for (int i = 0; i < Array.getLength(array); i++)
         {
            Object element = arrayValue.getValue(i);
            if (element instanceof MetaValue)
               element = unwrapMetaValue((MetaValue)element, type, array);
            else if (element != null && element.getClass().isArray())
               element = unwrapArray(array, element);
View Full Code Here

         {
            ArrayMetaType amt = (ArrayMetaType) propType;
            MetaType etype = amt.getElementType();
            if (etype == AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE)
            {
               ArrayValue avalue = (ArrayValue) prop.getValue();
               int length = avalue != null ? avalue.getLength() : 0;
               for(int n = 0; n < length; n ++)
                  processGenericValue((GenericValue) avalue.getValue(n), md);
            }
         }
         else if (propType.isCollection())
         {
            CollectionMetaType amt = (CollectionMetaType) propType;
            MetaType etype = amt.getElementType();
            if (etype == AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE)
            {
               CollectionValue avalue = (CollectionValue) prop.getValue();
               if(avalue != null)
               {
                  MetaValue[] elements = avalue.getElements();
                  for(int n = 0; n < avalue.getSize(); n ++)
                  {
                     GenericValue gv = (GenericValue) elements[n];
                     ManagedObject propMO = (ManagedObject) gv.getValue();
                     if(propMO != null)
                        processManagedObject(propMO, md);
View Full Code Here

               String n = value.getValue().toString();
               matches = name.equals(n);
            }
            else if(type.isArray())
            {
               ArrayValue value = (ArrayValue) prop.getValue();
               for(Object n : value)
               {
                  if(name.equals(n.toString()))
                  {
                     matches = true;
View Full Code Here

         {
            ArrayMetaType amt = (ArrayMetaType) propType;
            MetaType etype = amt.getElementType();
            if (etype == AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE)
            {
               ArrayValue avalue = (ArrayValue) prop.getValue();
               int length = avalue != null ? avalue.getLength() : 0;
               for(int n = 0; n < length; n ++)
                  processGenericValue((GenericValue) avalue.getValue(n), md);
            }
         }
         else if (propType.isCollection())
         {
            CollectionMetaType amt = (CollectionMetaType) propType;
            MetaType etype = amt.getElementType();
            if (etype == AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE)
            {
               CollectionValue avalue = (CollectionValue) prop.getValue();
               if(avalue != null)
               {
                  MetaValue[] elements = avalue.getElements();
                  for(int n = 0; n < avalue.getSize(); n ++)
                  {
                     GenericValue gv = (GenericValue) elements[n];
                     ManagedObject propMO = (ManagedObject) gv.getValue();
                     if(propMO != null)
                        processManagedObject(propMO, md);
View Full Code Here

            value = simpleValue.getValue();
        } else if (metaValue.getMetaType().isEnum()) {
            EnumValue enumValue = (EnumValue) metaValue;
            value = enumValue.getValue();
        } else if (metaValue.getMetaType().isArray()) {
            ArrayValue arrayValue = (ArrayValue) metaValue;
            value = arrayValue.getValue();
        } else if (metaValue.getMetaType().isCollection()) {
            CollectionValue collectionValue = (CollectionValue) metaValue;
            List<Object> list = new ArrayList<Object>();
            for (MetaValue element : collectionValue.getElements()) {
                list.add(getInnerValue(element));
View Full Code Here

     
      assertNotNull(restored.getProperties());
      assertEquals(3, restored.getProperties().size());
     
      // Test 1D
      ArrayValue test1D = (ArrayValue) restored.getProperty("test1D").getValue();
      assertNotNull(test1D);
     
      char[] unwrapped1D = (char[]) getMVF().unwrap(test1D);
      assertNotNull(unwrapped1D);
      assertTrue(Arrays.equals(init1D(), unwrapped1D));
     
      // Test 2D
      ArrayValue test2D = (ArrayValue) restored.getProperty("test2D").getValue();
      assertNotNull(test2D);
      assertEquals(2, test2D.getMetaType().getDimension());
     
      char[][] unwrapped2D = (char[][]) getMVF().unwrap(test2D);
      assertNotNull(unwrapped2D);
      assertEquals(2, unwrapped2D.length);
      assertEquals('a', unwrapped2D[0][0]);
      assertEquals('f', unwrapped2D[1][1]);

      // Test 3D
      ArrayValue test3D = (ArrayValue) restored.getProperty("test3D").getValue();
      assertNotNull(test3D);
      assertEquals(3, test3D.getMetaType().getDimension());

      char[][][] unwrapped3D = (char[][][]) getMVF().unwrap(test3D);
      assertNotNull(unwrapped3D);
     
      assertEquals(3, unwrapped3D[0].length);
View Full Code Here

      assertNotNull(mo);
     
      ManagedProperty p = mo.getProperty("charArray");
      assertNotNull(p);
     
      ArrayValue a = (ArrayValue) p.getValue();
      assertNotNull(a);
     
      SimpleValueSupport svs = (SimpleValueSupport) a.getValue(1);
      assertNotNull(svs);
      svs.setValue('H');
     
      PersistedManagedObject restored = restore(mo);
      assertNotNull(restored);
     
      //
      mo = update(new TestMetaData(), restored);
     
      p = mo.getProperty("charArray");
      assertNotNull(p);
     
      a = (ArrayValue) p.getValue();
      assertNotNull(a);
     
      assertEquals('H', ((SimpleValue) a.getValue(1)).getValue());
   }
View Full Code Here

TOP

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

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.