@Test(expectedExceptions = {ScriptBuilderException.class}) public void testReAssignment() throws ScriptBuilderException { ScriptBuilder b = new ScriptBuilder(100, new DefaultModel()); ErrorReporter r; try { Script scr = b.build("namespace foo; @N[1,1] : tiny;"); System.out.println(scr.getVMs()); } catch (ScriptBuilderException ex) { System.out.println(ex); r = ex.getErrorReporter(); Assert.assertEquals(r.getErrors().size(), 1); throw ex; } }
public Script build(File f) throws ScriptBuilderException { int k = f.getAbsolutePath().hashCode(); if (dates.containsKey(k) && dates.get(k) == f.lastModified() && cache.containsKey(f.getPath())) { LOGGER.debug("get '" + f.getName() + "' from the cache"); return cache.get(f.getPath()); } LOGGER.debug(f.getName() + " is built from the file"); dates.put(k, f.lastModified()); String name = f.getName(); try { Script v = build(new ANTLRFileStream(f.getAbsolutePath())); if (!name.equals(v.getlocalName() + Script.EXTENSION)) { throw new ScriptBuilderException("Script '" + v.getlocalName() + "' must be declared in a file named '" + v.getlocalName() + Script.EXTENSION); } cache.put(f.getPath(), v); return v; } catch (IOException e) { throw new ScriptBuilderException(e.getMessage(), e); } }
ScriptBuilder { public Script build(File f) throws ScriptBuilderException { int k = f.getAbsolutePath().hashCode(); if (dates.containsKey(k) && dates.get(k) == f.lastModified() && cache.containsKey(f.getPath())) { LOGGER.debug("get '" + f.getName() + "' from the cache"); return cache.get(f.getPath()); } LOGGER.debug(f.getName() + " is built from the file"); dates.put(k, f.lastModified()); String name = f.getName(); try { Script v = build(new ANTLRFileStream(f.getAbsolutePath())); if (!name.equals(v.getlocalName() + Script.EXTENSION)) { throw new ScriptBuilderException("Script '" + v.getlocalName() + "' must be declared in a file named '" + v.getlocalName() + Script.EXTENSION); } cache.put(f.getPath(), v); return v; } catch (IOException e) { throw new ScriptBuilderException(e.getMessage(), e); } } }
ScriptBuilder { public Script build(File f) throws ScriptBuilderException { int k = f.getAbsolutePath().hashCode(); if (dates.containsKey(k) && dates.get(k) == f.lastModified() && cache.containsKey(f.getPath())) { LOGGER.debug("get '" + f.getName() + "' from the cache"); return cache.get(f.getPath()); } LOGGER.debug(f.getName() + " is built from the file"); dates.put(k, f.lastModified()); String name = f.getName(); try { Script v = build(new ANTLRFileStream(f.getAbsolutePath())); if (!name.equals(v.getlocalName() + Script.EXTENSION)) { throw new ScriptBuilderException("Script '" + v.getlocalName() + "' must be declared in a file named '" + v.getlocalName() + Script.EXTENSION); } cache.put(f.getPath(), v); return v; } catch (IOException e) { throw new ScriptBuilderException(e.getMessage(), e); } } ScriptBuilder(Model mo);  ScriptBuilder(final int cacheSize, Model mo); }
ScriptBuilder { public Script build(File f) throws ScriptBuilderException { int k = f.getAbsolutePath().hashCode(); if (dates.containsKey(k) && dates.get(k) == f.lastModified() && cache.containsKey(f.getPath())) { LOGGER.debug("get '" + f.getName() + "' from the cache"); return cache.get(f.getPath()); } LOGGER.debug(f.getName() + " is built from the file"); dates.put(k, f.lastModified()); String name = f.getName(); try { Script v = build(new ANTLRFileStream(f.getAbsolutePath())); if (!name.equals(v.getlocalName() + Script.EXTENSION)) { throw new ScriptBuilderException("Script '" + v.getlocalName() + "' must be declared in a file named '" + v.getlocalName() + Script.EXTENSION); } cache.put(f.getPath(), v); return v; } catch (IOException e) { throw new ScriptBuilderException(e.getMessage(), e); } } ScriptBuilder(Model mo);  ScriptBuilder(final int cacheSize, Model mo); Includes getIncludes(); void setIncludes(Includes incs); Script build(File f); Script build(String description); void setErrorReporterBuilder(ErrorReporterBuilder b); NamingService<VM> getNamingServiceVMs(); NamingService<Node> getNamingServiceNodes(); TemplateFactory getTemplateFactory(); void setTemplateFactory(TemplateFactory f); ConstraintsCatalog getConstraintsCatalog(); void setConstraintsCatalog(ConstraintsCatalog c); }
ScriptBuilder { public Script build(File f) throws ScriptBuilderException { int k = f.getAbsolutePath().hashCode(); if (dates.containsKey(k) && dates.get(k) == f.lastModified() && cache.containsKey(f.getPath())) { LOGGER.debug("get '" + f.getName() + "' from the cache"); return cache.get(f.getPath()); } LOGGER.debug(f.getName() + " is built from the file"); dates.put(k, f.lastModified()); String name = f.getName(); try { Script v = build(new ANTLRFileStream(f.getAbsolutePath())); if (!name.equals(v.getlocalName() + Script.EXTENSION)) { throw new ScriptBuilderException("Script '" + v.getlocalName() + "' must be declared in a file named '" + v.getlocalName() + Script.EXTENSION); } cache.put(f.getPath(), v); return v; } catch (IOException e) { throw new ScriptBuilderException(e.getMessage(), e); } } ScriptBuilder(Model mo);  ScriptBuilder(final int cacheSize, Model mo); Includes getIncludes(); void setIncludes(Includes incs); Script build(File f); Script build(String description); void setErrorReporterBuilder(ErrorReporterBuilder b); NamingService<VM> getNamingServiceVMs(); NamingService<Node> getNamingServiceNodes(); TemplateFactory getTemplateFactory(); void setTemplateFactory(TemplateFactory f); ConstraintsCatalog getConstraintsCatalog(); void setConstraintsCatalog(ConstraintsCatalog c); static final int DEFAULT_CACHE_SIZE; static final Logger LOGGER; static final String EXTENSION; }