package EDU.neu.ccs.demeter.tools.apstudio.graphedit;
import java.awt.*;
import java.io.*;
import java.util.*;
import EDU.neu.ccs.demeter.*;
import EDU.neu.ccs.demeter.common.tg.*;


import EDU.neu.ccs.demeter.*;
abstract class GlobSpec extends HostSpec {
  public GlobSpec() {
    super();
  }

    boolean match(Glob glob) {
      GlobMatcher matcher = new GlobMatcher(glob, false);
      allGlobs(matcher);
      return matcher.get_found_one();
    }
  
    /** Return true iff the globspec matches the edge from source to part. */
    boolean match(ClassName source, Part part) {
      return match(new PartGlob(source, part.get_partname(), part.get_classname()))
	  || match(new ClassGlob(part.get_classname()));
    }
    /** Return true iff the globspec matches the edge from source to sub. */
    boolean match(ClassName source, Subclass sub) {
      return match(new SubclassGlob(source, sub.get_classname()))
	  || match(new ClassGlob(sub.get_classname()));
    }
    /** Return true iff the globspec matches the edge from source to sup. */
    boolean match(ClassName source, Superclass sup) {
      return match(new SuperclassGlob(source, sup.get_classname()))
	  || match(new ClassGlob(sup.get_classname()));
    }
    /** Return true iff the globspec matches the edge. */
    boolean match(TGEdge edge) {
      TGEdgeGlobMaker m = new TGEdgeGlobMaker();
      edge.toAll(m);
      return match(m.get_return_val())
	  || match(new ClassGlob((ClassName) edge.get_dest().get_classname()));
    }
  
    /** Return a ClassGlobSpec that matches all the classes in the
	GlobSpec, or null if there are none. */
    ClassGlobSpec collectClassGlobs() {
      ClassGlobCollector c = new ClassGlobCollector();
      allClassGlobs(c);
      return c.get_spec();
    }
    /** Return a GlobSpec that matches all the edges in the GlobSpec,
	or null if there are none. */
    GlobSpec collectEdgeGlobs() {
      EdgeGlobCollector c = new EdgeGlobCollector();
      allEdgeGlobs(c);
      return c.get_spec();
    }
    /** Merge two glob specs into the union of the two. */
    GlobSpec union(GlobSpec spec) {
      if (spec == null) return this;
      GlobCollector coll = new GlobCollector(new GlobSet());
      allGlobs(coll);
      spec.allGlobs(coll);
      return coll.get_spec();
    }
    void universal_trv0_bef(UniversalVisitor _v_) {
    super.universal_trv0_bef(_v_);
    _v_.before(this);
  }
  void universal_trv0_aft(UniversalVisitor _v_) {
    _v_.after(this);
    super.universal_trv0_aft(_v_);
  }
  void universal_trv0(UniversalVisitor _v_) {
    super.universal_trv0(_v_);
  }
  void toAllSubclasses_Program_trv_bef(ClassNameTranspVisitor cntv, EdgeVisitor aev) {
    super.toAllSubclasses_Program_trv_bef(cntv, aev);
  }
  void toAllSubclasses_Program_trv_aft(ClassNameTranspVisitor cntv, EdgeVisitor aev) {
    super.toAllSubclasses_Program_trv_aft(cntv, aev);
  }
  void toAllSubclasses_Program_trv(ClassNameTranspVisitor cntv, EdgeVisitor aev) {  }
  void checkStars_ProgramBehavior_trv_bef(DummyVisitor dv) {
    super.checkStars_ProgramBehavior_trv_bef(dv);
  }
  void checkStars_ProgramBehavior_trv_aft(DummyVisitor dv) {
    super.checkStars_ProgramBehavior_trv_aft(dv);
  }
  void checkStars_ProgramBehavior_trv(DummyVisitor dv) {  }
  void __trav_getFirst_StrategyGraph_trv_bef(__V_StrategyGraph_getFirst __v0) {
    super.__trav_getFirst_StrategyGraph_trv_bef(__v0);
  }
  void __trav_getFirst_StrategyGraph_trv_aft(__V_StrategyGraph_getFirst __v0) {
    super.__trav_getFirst_StrategyGraph_trv_aft(__v0);
  }
  void __trav_getFirst_StrategyGraph_trv(java.util.BitSet nodes, __V_StrategyGraph_getFirst __v0) {  }
  void collectBypassVs_SGEdge_trv_bef(VecVisitor vv) {
    super.collectBypassVs_SGEdge_trv_bef(vv);
  }
  void collectBypassVs_SGEdge_trv_aft(VecVisitor vv) {
    super.collectBypassVs_SGEdge_trv_aft(vv);
  }
  void collectBypassVs_SGEdge_trv(VecVisitor vv) {  }
  void collectOnlyThruVs_SGEdge_trv_bef(VecVisitor vv) {
    super.collectOnlyThruVs_SGEdge_trv_bef(vv);
  }
  void collectOnlyThruVs_SGEdge_trv_aft(VecVisitor vv) {
    super.collectOnlyThruVs_SGEdge_trv_aft(vv);
  }
  void collectOnlyThruVs_SGEdge_trv(VecVisitor vv) {  }
  void collectPartGlob_SGEdge_trv_bef(VecVisitor vv) {
    super.collectPartGlob_SGEdge_trv_bef(vv);
  }
  void collectPartGlob_SGEdge_trv_aft(VecVisitor vv) {
    super.collectPartGlob_SGEdge_trv_aft(vv);
  }
  void collectPartGlob_SGEdge_trv(VecVisitor vv) {  }
  void collectSubclassGlob_SGEdge_trv_bef(VecVisitor vv) {
    super.collectSubclassGlob_SGEdge_trv_bef(vv);
  }
  void collectSubclassGlob_SGEdge_trv_aft(VecVisitor vv) {
    super.collectSubclassGlob_SGEdge_trv_aft(vv);
  }
  void collectSubclassGlob_SGEdge_trv(VecVisitor vv) {  }
  public void allGlobs(GlobVisitor v) {
    allGlobs_GlobSpec_trv(v);
  }
  void allGlobs_GlobSpec_trv_bef(GlobVisitor v) {
    super.allGlobs_GlobSpec_trv_bef(v);
    v.before(this);
  }
  void allGlobs_GlobSpec_trv_aft(GlobVisitor v) {
    super.allGlobs_GlobSpec_trv_aft(v);
  }
  void allGlobs_GlobSpec_trv(GlobVisitor v) {  }
  public void allClassGlobs(GlobVisitor v) {
    allClassGlobs_GlobSpec_trv(v);
  }
  void allClassGlobs_GlobSpec_trv_bef(GlobVisitor v) {
    super.allClassGlobs_GlobSpec_trv_bef(v);
    v.before(this);
  }
  void allClassGlobs_GlobSpec_trv_aft(GlobVisitor v) {
    super.allClassGlobs_GlobSpec_trv_aft(v);
  }
  void allClassGlobs_GlobSpec_trv(GlobVisitor v) {  }
  public void allEdgeGlobs(GlobVisitor v) {
    allEdgeGlobs_GlobSpec_trv(v);
  }
  void allEdgeGlobs_GlobSpec_trv_bef(GlobVisitor v) {
    super.allEdgeGlobs_GlobSpec_trv_bef(v);
    v.before(this);
  }
  void allEdgeGlobs_GlobSpec_trv_aft(GlobVisitor v) {
    super.allEdgeGlobs_GlobSpec_trv_aft(v);
  }
  void allEdgeGlobs_GlobSpec_trv(GlobVisitor v) {  }
}

