Package modTransf.rules.core

Source Code of modTransf.rules.core.ArgumentsIterator

//Source file: H:\\temp\\generated\\modTransf\\rules\\core\\TopRuleDomainIterator.java

package modTransf.rules.core;

import modTransf.engine.Arguments;
import java.util.List;
import java.util.Iterator;
import modTransf.engine.RuleContext;
import modTransf.model.ModelException;
import modTransf.engine.TransformationException;
import java.util.ArrayList;
import modTransf.engine.ArrayArguments;

/**
* An iterator on TopRule Domains.
* This iterator is used to iterate all possible Arguments solutions on domains.
*/
public class ArgumentsIterator extends MultiSetIterator
{

  /**
   * @param domains
   */
  public ArgumentsIterator(TemplateDescriptorList domains, RuleContext context)
    throws TransformationException
  {
    super(computeArgSets(domains, context));
  }


  /**
   * Extract the list of possible arguments from domains.
   * @param domains RuleActionsList
   * @param context RuleContext
   * @throws TransformationException
   * @return List
   */
  static private List computeArgSets(TemplateDescriptorList domains, RuleContext context)
    throws TransformationException
  {
    List argSets = new ArrayList();
    // Compute the list of possible args
    try
    {
      Iterator iter = domains.iterator();
      while(iter.hasNext())
      {
        Domain domain = (Domain)iter.next();
        if(domain.isSourceDomain(context)) // source model
        {
          argSets.add(context.getTransformation().getModels().getAllOfClass(domain.
            getModelName(), domain.getType()));
        }
        else // dst model
        {
          argSets.add(null);
        }
      }
    }
    catch(ModelException ex)
    {
      throw new TransformationException(ex);
    }
    return argSets;
  }

  /**
   * @param sets
   */
  public ArgumentsIterator(List sets)
  {
    super(sets);
  }

  /**
   * @return Arguments
   */
  public List next()
  {
    return nextArguments();
  }

  /**
   * @return Arguments
   */
  public Arguments nextArguments()
  {
    return new ArrayArguments(computeNextResult());
  }
}
TOP

Related Classes of modTransf.rules.core.ArgumentsIterator

TOP
Copyright © 2018 www.massapi.com. 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.