Package javax.jmi.reflect

Examples of javax.jmi.reflect.RefObject


    Collection objects = container.refAllOfType();
    // Get only objects wich aren't component of another object
    Iterator iter = objects.iterator();
    while(iter.hasNext())
    {
      RefObject object = (RefObject)iter.next();
      //System.out.println("  check '" + object + "'.");
      if(object.refImmediateComposite()==null)
      {
        //System.out.println("     --->  added " + object.refMetaObject().refGetValue("name") );
        // Add if not already found
        if(!roots.contains(object))
        {
View Full Code Here


   * @return List
   */
  protected String[] getPropertyType( Object bean, String propertyName )
    throws NotFoundException
  {
    RefObject propDesc = getPropertyMetaClass(bean, propertyName);
    return getFullTypeFromMetaClass( propDesc );
  }
View Full Code Here

   * @throws NotFoundException if the property doesn't exist on the bean.
   */
  protected String[] getEnumType( Object bean, String propertyName )
    throws NotFoundException
  {
    RefObject propDesc = getPropertyMetaClass(bean, propertyName);
    if(! (propDesc instanceof EnumerationType) )
      return null;
    return getFullTypeFromMetaClass( propDesc );
  }
View Full Code Here

    throws NotFoundException
  {
    if( propertyName == null )
      throw new IllegalArgumentException("propertyName should be set.");

    RefObject ref = (RefObject)bean;
    RefObject descriptor = ref.refMetaObject();
    // Lookup the property descriptor.
    // Lookup the attribute with the requested name,
    // return the type pointed by the attribute.
    Iterator propertyIter = ((Collection)descriptor.refGetValue("contents")).iterator();
    while(propertyIter.hasNext())
    {
      RefObject attribute = (RefObject)propertyIter.next();
      if( propertyName.equals( attribute.refGetValue( "name" ) ) )
      {
        return (RefObject)attribute.refGetValue("type");
      }
    }

    throw new NotFoundException("No property '" + propertyName + "' in '" + descriptor.getClass().getName() + "'.");
  }
View Full Code Here

  protected String[] getFullTypeFromMetaClass( RefObject metaclass )
  {
    List res = new ArrayList();

    res.add( metaclass.refGetValue("name") );
    RefObject parent = (RefObject)metaclass.refGetValue("container" );
    //System.out.println("metaclass.refOutermostPackage()='" + metaclass.refOutermostPackage().getClass().getName() + "'." );
    while( parent !=null  )
    {
      //System.out.println("metaclass.refOutermostPackage()='" + metaclass.refOutermostPackage().getClass().getName() + "'." );
      //System.out.println("parent='" + parent.getClass().getName() + "'." );
      String name = (String)parent.refGetValue("name");

      // Don't put the last one
      parent = (RefObject)parent.refGetValue("container" );
      if( parent == null )
        break;
      //System.out.println("add '" + name + "'." );
      res.addname );
    }
View Full Code Here

    RefPackage pack = getRefPackageByType( proptype );
    RefEnum enumValue = null;
    // next one throw InvalidNameException
    enumValue = pack.refGetEnum(enumTypeName, value);

    RefObject obj = (RefObject)bean;
    obj.refSetValue( property, enumValue);
  }
View Full Code Here

  {
//System.out.println(" stereotypes " + stereotypes);
    Iterator iter = stereotypes.iterator();
    while(iter.hasNext())
    {
      RefObject stereotypeElement = (RefObject)iter.next();
      //System.out.println( " stereotype check '" + stereotypeElement.refGetValue("baseClass") + "'" );
      if(stereotype.equals(stereotypeElement.refGetValue("name")))
      {
        return stereotypeElement;
      }
    } // end loop
View Full Code Here

   * @return List
   * @roseuid 3F26F5400197
   */
  public Collection getStereotypes(Object object)
  {
    RefObject modelElement = (RefObject)object;

    Collection stereotypes = (Collection)modelElement.refGetValue("stereotype");
    return new StereotypeNamesCollection(object, stereotypes);
  }
View Full Code Here

   * @param stereotype
   */
  protected void addStereotype(Object object, String stereotype)
    throws ModelException
  {
    RefObject modelElement = (RefObject)object;

    Collection currentStereotypes = (Collection)modelElement.refGetValue("stereotype");
    // Check if it already exist as registered to object.
    if(lookupStereotype(currentStereotypes, stereotype)!=null)
    {
      return;
    }

    // Don't exist, lookup for a Stereotype element declaration, and
    // attach it to object.
    RefObject newStereotype = lookupStereotypeDeclaration(object, stereotype);
    currentStereotypes.add(newStereotype);
  }
View Full Code Here

   * @roseuid 3F26F54001BF
   */
  protected RefObject lookupStereotypeDeclaration(Object object, String stereotypeName)
    throws ModelException
  {
    RefObject modelElement = (RefObject)object;

    // Get factory
    RefClass stereotypeFactory = modelElement.refOutermostPackage().refPackage("Core").
      refClass("Stereotype");
    // Get all Core.Stereotype
    Collection registeredStereotypes = stereotypeFactory.refAllOfClass();

    // Get the baseClass
    String baseClass = (String)modelElement.refClass().refMetaObject().refGetValue("name");

    // Lookup for a matching concept
    Iterator iter = registeredStereotypes.iterator();
    while(iter.hasNext())
    {
      RefObject stereotypeElement = (RefObject)iter.next();
      //System.out.println( " stereotype check '" + stereotypeElement.refGetValue("baseClass") + "'" );
      if(stereotypeName.equals(stereotypeElement.refGetValue("name")))
      {
        Collection baseClasses = (Collection)stereotypeElement.refGetValue("baseClass");
        // Also check the baseClass
        if(baseClasses.contains(baseClass))
        {
          return stereotypeElement;
        }
      }
    } // end loop

    // Not found, create it and populate it.
    RefObject stereotype = null;
    try
    {
      stereotype = (RefObject)createInstance("Core.Stereotype");
    }
    catch(InstantiationException ex)
    {
      throw new ModelException(ex);
    }
    stereotype.refSetValue("name", stereotypeName);
    Collection baseClasses = (Collection)stereotype.refGetValue("baseClass");
    baseClasses.add(baseClass);
    // Attach stereotype to first model, if any
    Collection models = getAllOfClass("Model_Management.Model");
    if(models.size()>0)
    {
      stereotype.refSetValue("namespace", models.iterator().next());

    }
    return stereotype;
  }
View Full Code Here

TOP

Related Classes of javax.jmi.reflect.RefObject

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.