Beispiel #1
0
 private void testToCtlFormula(String expected, Formula f) {
   try {
     assertEquals(FormulaParser.instance().parse(expected), f.toCtlFormula());
   } catch (FormatException e) {
     fail(e.getMessage());
   }
 }
 /**
  * Loads the named objects from a zip file, using the prepared map from names to zip entries.
  * Returns a map from names to {@link AspectGraph}s.
  *
  * @param file the file to read from
  * @param graphs the mapping from object names to zip entries
  */
 private Map<String, AspectGraph> loadObjects(
     ResourceKind kind, ZipFile file, Map<String, ZipEntry> graphs) throws IOException {
   FileType filter = kind.getFileType();
   Map<String, AspectGraph> result = new HashMap<String, AspectGraph>();
   for (Map.Entry<String, ZipEntry> graphEntry : graphs.entrySet()) {
     String graphName = filter.stripExtension(graphEntry.getKey());
     InputStream in = file.getInputStream(graphEntry.getValue());
     try {
       AttrGraph xmlGraph = GxlIO.instance().loadGraph(in);
       /*
        * For backward compatibility, we set the role and name of the
        * graph.
        */
       xmlGraph.setRole(kind.getGraphRole());
       xmlGraph.setName(createQualName(graphName).toString());
       addLayout(file, graphEntry.getKey(), xmlGraph);
       AspectGraph graph = xmlGraph.toAspectGraph();
       /* Store the graph */
       result.put(graphName, graph);
     } catch (FormatException exc) {
       throw new IOException(
           String.format("Format error while loading '%s':\n%s", graphName, exc.getMessage()),
           exc);
     } catch (IOException exc) {
       throw new IOException(
           String.format("Error while loading '%s':\n%s", graphName, exc.getMessage()), exc);
     }
   }
   return result;
 }
 /**
  * Creates a rule name from the remainder of a JAR/ZIP entry name. The '/'-separators are
  * interpreted as rule name hierarchy.
  *
  * @param restName The entry name to convert; non-null
  * @return The resulting rule name; non-null
  */
 private QualName createQualName(String restName) throws IOException {
   StringBuilder result = new StringBuilder();
   File nameAsFile = new File(RULE.stripExtension(restName));
   result.append(nameAsFile.getName());
   while (nameAsFile.getParent() != null) {
     nameAsFile = nameAsFile.getParentFile();
     result.insert(0, QualName.SEPARATOR);
     result.insert(0, nameAsFile.getName());
   }
   try {
     return new QualName(result.toString());
   } catch (FormatException e) {
     throw new IOException(e.getMessage());
   }
 }