예제 #1
0
 public OclRoot getFeature(String name) {
   if (name.equals("boundNames")) {
     HashSet boundNames = tree.getBoundNames(node);
     HashSet result = new HashSet();
     Iterator iter = boundNames.iterator();
     while (iter.hasNext()) {
       String s = (String) iter.next();
       result.add(new OclString((String) s));
     }
     return new OclSet(result);
   } else if (name.equals("subnodes")) {
     SubnodeCollector sc = new SubnodeCollector(node);
     node.apply(sc);
     return new OclSet(sc.subnodes);
   } else if (name.equals("supernodes")) {
     HashSet result = new HashSet();
     Node parent = node.parent();
     while (parent != null) {
       result.add(new SableOclAnyImpl(parent, tree));
       parent = parent.parent();
     }
     return new OclSet(result);
   } else {
     return super.getFeature(name);
   }
 }
예제 #2
0
 public void makeConstraint(String constraintString)
     throws OclParserException, OclTypeException, IOException {
   // System.out.println("Loaded constraint:");
   // System.out.println(constraintString);
   // System.out.println("Parsing constraint.");
   OclTree constraintTree = OclTree.createTree(constraintString, modelfacade);
   constraintTree.setNameCreator(namecreator);
   // System.out.println("Type checking constraint.");
   constraintTree.assureTypes();
   // System.out.println("Normalizing.");
   constraintTree.applyDefaultNormalizations();
   // System.out.println("Generating Code.");
   CodeFragment[] frags = jcg.getCode(constraintTree);
   for (int j = 0; j < frags.length; j++) {
     String ct = frags[j].getConstrainedType();
     SortedFragments sf = (SortedFragments) (codefragments.get(ct));
     if (sf == null) codefragments.put(ct, new SortedFragments(frags[j]));
     else sf.addFragment(frags[j]);
   }
 }