Package org.openiaml.emf.properties

Source Code of org.openiaml.emf.properties.IterateOverAll

/**
*
*/
package org.openiaml.emf.properties;

import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;

/**
* Iterates over the root element and eAllContents and accumulates
* a value.
*
* @author jmwright
*
*/
public abstract class IterateOverAll extends DefaultPropertyInvestigator {

  public IterateOverAll(String name, IEMFElementSelector selector) {
    super(name, selector);
  }

  public Object evaluate(EObject root) {
    int result = get(root);
    TreeIterator<EObject> it = root.eAllContents();
    while (it.hasNext()) {
      EObject next = it.next();
      if (ignoreClass(next.eClass()))
        continue;
     
      result += get(next);
    }
    return result;
  }
 
  /**
   * Get the property value for just the current object.
   */
  public abstract int get(EObject obj);
 
}
TOP

Related Classes of org.openiaml.emf.properties.IterateOverAll

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.