public STGroupDir(String dirName, char delimiterStartChar, char delimiterStopChar) { super(delimiterStartChar, delimiterStopChar); this.groupDirName = dirName; File dir = new File(dirName); if ( dir.exists() && dir.isDirectory() ) { // we found the directory and it'll be file based try { root = dir.toURI().toURL(); } catch (MalformedURLException e) { throw new STException("can't load dir "+dirName, e); } if ( verbose ) System.out.println("STGroupDir("+dirName+") found at "+root); } else { ClassLoader cl = Thread.currentThread().getContextClassLoader(); root = cl.getResource(dirName); if ( root==null ) { cl = this.getClass().getClassLoader(); root = cl.getResource(dirName); } if ( verbose ) System.out.println("STGroupDir("+dirName+") found via CLASSPATH at "+root); if ( root==null ) { throw new IllegalArgumentException("No such directory: "+ dirName); } } }
ResourcesException errorOpenGroupFile(STException e) { return logException(new ResourcesException(e, "", "", ERROR_OPEN_GROUP_FILE), ERROR_OPEN_GROUP_FILE_MESSAGE, e.getMessage()); }
public STGroupFile(String fileName, char delimiterStartChar, char delimiterStopChar) { super(delimiterStartChar, delimiterStopChar); if ( !fileName.endsWith(GROUP_FILE_EXTENSION) ) { throw new IllegalArgumentException("Group file names must end in .stg: "+fileName); } //try { File f = new File(fileName); if ( f.exists() ) { try { url = f.toURI().toURL(); } catch (MalformedURLException e) { throw new STException("can't load group file "+fileName, e); } if ( verbose ) System.out.println("STGroupFile(" + fileName + ") == file "+f.getAbsolutePath()); } else { // try in classpath url = getURL(fileName); if ( url==null ) { throw new IllegalArgumentException("No such group file: "+ fileName); } if ( verbose ) System.out.println("STGroupFile(" + fileName + ") == url "+url); } this.fileName = fileName; }
public STGroupDir(String dirName, char delimiterStartChar, char delimiterStopChar) { super(delimiterStartChar, delimiterStopChar); this.groupDirName = dirName; File dir = new File(dirName); if ( dir.exists() && dir.isDirectory() ) { // we found the directory and it'll be file based try { root = dir.toURI().toURL(); } catch (MalformedURLException e) { throw new STException("can't load dir "+dirName, e); } if ( verbose ) System.out.println("STGroupDir("+dirName+") found at "+root); } else { ClassLoader cl = Thread.currentThread().getContextClassLoader(); root = cl.getResource(dirName); if ( root==null ) { cl = this.getClass().getClassLoader(); root = cl.getResource(dirName); } if ( verbose ) System.out.println("STGroupDir("+dirName+") found via CLASSPATH at "+root); if ( root==null ) { throw new IllegalArgumentException("No such directory: "+ dirName); } } }
public STGroupDir(String dirName, char delimiterStartChar, char delimiterStopChar) { super(delimiterStartChar, delimiterStopChar); this.groupDirName = dirName; File dir = new File(dirName); if ( dir.exists() && dir.isDirectory() ) { // we found the directory and it'll be file based try { root = dir.toURI().toURL(); } catch (MalformedURLException e) { throw new STException("can't load dir "+dirName, e); } // System.out.println("found "+dirName+" at "+root); } else { ClassLoader cl = Thread.currentThread().getContextClassLoader(); root = cl.getResource(dirName); if ( root==null ) { cl = this.getClass().getClassLoader(); root = cl.getResource(dirName); } // System.out.println("found "+dirName+" via CLASSPATH at "+root); if ( root==null ) { throw new IllegalArgumentException("No such directory: "+ dirName); } } }
public STGroupFile(String fileName, char delimiterStartChar, char delimiterStopChar) { super(delimiterStartChar, delimiterStopChar); if ( !fileName.endsWith(GROUP_FILE_EXTENSION) ) { throw new IllegalArgumentException("Group file names must end in .stg: "+fileName); } //try { File f = new File(fileName); if ( f.exists() ) { try { url = f.toURI().toURL(); } catch (MalformedURLException e) { throw new STException("can't load group file "+fileName, e); } if ( verbose ) System.out.println("STGroupFile(" + fileName + ") == file "+f.getAbsolutePath()); } else { // try in classpath url = getURL(fileName); if ( url==null ) { throw new IllegalArgumentException("No such group file: "+ fileName); } if ( verbose ) System.out.println("STGroupFile(" + fileName + ") == url "+url); } this.fileName = fileName; }
public STGroupDir(String dirName, char delimiterStartChar, char delimiterStopChar) { super(delimiterStartChar, delimiterStopChar); this.groupDirName = dirName; File dir = new File(dirName); if ( dir.exists() && dir.isDirectory() ) { // we found the directory and it'll be file based try { root = dir.toURI().toURL(); } catch (MalformedURLException e) { throw new STException("can't load dir "+dirName, e); } if ( verbose ) System.out.println("STGroupDir("+dirName+") found at "+root); } else { ClassLoader cl = Thread.currentThread().getContextClassLoader(); root = cl.getResource(dirName); if ( root==null ) { cl = this.getClass().getClassLoader(); root = cl.getResource(dirName); } if ( verbose ) System.out.println("STGroupDir("+dirName+") found via CLASSPATH at "+root); if ( root==null ) { throw new IllegalArgumentException("No such directory: "+ dirName); } } }
public STGroupFile(String fileName, char delimiterStartChar, char delimiterStopChar) { super(delimiterStartChar, delimiterStopChar); if ( !fileName.endsWith(GROUP_FILE_EXTENSION) ) { throw new IllegalArgumentException("Group file names must end in .stg: "+fileName); } //try { File f = new File(fileName); if ( f.exists() ) { try { url = f.toURI().toURL(); } catch (MalformedURLException e) { throw new STException("can't load group file "+fileName, e); } if ( verbose ) System.out.println("STGroupFile(" + fileName + ") == file "+f.getAbsolutePath()); } else { // try in classpath url = getURL(fileName); if ( url==null ) { throw new IllegalArgumentException("No such group file: "+ fileName); } if ( verbose ) System.out.println("STGroupFile(" + fileName + ") == url "+url); } this.fileName = fileName; }
public STGroupDir(String dirName, char delimiterStartChar, char delimiterStopChar) { super(delimiterStartChar, delimiterStopChar); this.groupDirName = dirName; File dir = new File(dirName); if ( dir.exists() && dir.isDirectory() ) { // we found the directory and it'll be file based try { root = dir.toURI().toURL(); } catch (MalformedURLException e) { throw new STException("can't load dir "+dirName, e); } if ( verbose ) System.out.println("STGroupDir("+dirName+") found at "+root); } else { ClassLoader cl = Thread.currentThread().getContextClassLoader(); root = cl.getResource(dirName); if ( root==null ) { cl = this.getClass().getClassLoader(); root = cl.getResource(dirName); } if ( verbose ) System.out.println("STGroupDir("+dirName+") found via CLASSPATH at "+root); if ( root==null ) { throw new IllegalArgumentException("No such directory: "+ dirName); } } }
public STGroupDir(String dirName, char delimiterStartChar, char delimiterStopChar) { super(delimiterStartChar, delimiterStopChar); this.groupDirName = dirName; File dir = new File(dirName); if ( dir.exists() && dir.isDirectory() ) { // we found the directory and it'll be file based try { root = dir.toURI().toURL(); } catch (MalformedURLException e) { throw new STException("can't load dir "+dirName, e); } if ( verbose ) System.out.println("STGroupDir("+dirName+") found at "+root); } else { ClassLoader cl = Thread.currentThread().getContextClassLoader(); root = cl.getResource(dirName); if ( root==null ) { cl = this.getClass().getClassLoader(); root = cl.getResource(dirName); } if ( verbose ) System.out.println("STGroupDir("+dirName+") found via CLASSPATH at "+root); if ( root==null ) { throw new IllegalArgumentException("No such directory: "+ dirName); } } }
public STGroupDir(String dirName, char delimiterStartChar, char delimiterStopChar) { super(delimiterStartChar, delimiterStopChar); this.groupDirName = dirName; File dir = new File(dirName); if ( dir.exists() && dir.isDirectory() ) { // we found the directory and it'll be file based try { root = dir.toURI().toURL(); } catch (MalformedURLException e) { throw new STException("can't load dir "+dirName, e); } if ( verbose ) System.out.println("STGroupDir("+dirName+") found at "+root); } else { ClassLoader cl = Thread.currentThread().getContextClassLoader(); root = cl.getResource(dirName); if ( root==null ) { cl = this.getClass().getClassLoader(); root = cl.getResource(dirName); } if ( verbose ) System.out.println("STGroupDir("+dirName+") found via CLASSPATH at "+root); if ( root==null ) { throw new IllegalArgumentException("No such directory: "+ dirName); } } }
public STGroupFile(String fileName, char delimiterStartChar, char delimiterStopChar) { super(delimiterStartChar, delimiterStopChar); if ( !fileName.endsWith(".stg") ) { throw new IllegalArgumentException("Group file names must end in .stg: "+fileName); } //try { File f = new File(fileName); if ( f.exists() ) { try { url = f.toURI().toURL(); } catch (MalformedURLException e) { throw new STException("can't load group file "+fileName, e); } if ( verbose ) System.out.println("STGroupFile(" + fileName + ") == "+f.getAbsolutePath()); } else { // try in classpath url = getURL(fileName); if ( url==null ) { throw new IllegalArgumentException("No such group file: "+ fileName); } if ( verbose ) System.out.println("STGroupFile(" + fileName + ") == "+url); } this.fileName = fileName; }
public STGroupFile(String fileName, char delimiterStartChar, char delimiterStopChar) { super(delimiterStartChar, delimiterStopChar); if ( !fileName.endsWith(GROUP_FILE_EXTENSION) ) { throw new IllegalArgumentException("Group file names must end in .stg: "+fileName); } //try { File f = new File(fileName); if ( f.exists() ) { try { url = f.toURI().toURL(); } catch (MalformedURLException e) { throw new STException("can't load group file "+fileName, e); } if ( verbose ) System.out.println("STGroupFile(" + fileName + ") == file "+f.getAbsolutePath()); } else { // try in classpath url = getURL(fileName); if ( url==null ) { throw new IllegalArgumentException("No such group file: "+ fileName); } if ( verbose ) System.out.println("STGroupFile(" + fileName + ") == url "+url); } this.fileName = fileName; }
public STGroupDir(String dirName, char delimiterStartChar, char delimiterStopChar) { super(delimiterStartChar, delimiterStopChar); this.groupDirName = dirName; File dir = new File(dirName); if ( dir.exists() && dir.isDirectory() ) { // we found the directory and it'll be file based try { root = dir.toURI().toURL(); } catch (MalformedURLException e) { throw new STException("can't load dir "+dirName, e); } if ( verbose ) System.out.println("STGroupDir("+dirName+") found at "+root); } else { ClassLoader cl = Thread.currentThread().getContextClassLoader(); root = cl.getResource(dirName); if ( root==null ) { cl = this.getClass().getClassLoader(); root = cl.getResource(dirName); } if ( verbose ) System.out.println("STGroupDir("+dirName+") found via CLASSPATH at "+root); if ( root==null ) { throw new IllegalArgumentException("No such directory: "+ dirName); } } }
public STGroupFile(String fileName, char delimiterStartChar, char delimiterStopChar) { super(delimiterStartChar, delimiterStopChar); if ( !fileName.endsWith(GROUP_FILE_EXTENSION) ) { throw new IllegalArgumentException("Group file names must end in .stg: "+fileName); } //try { File f = new File(fileName); if ( f.exists() ) { try { url = f.toURI().toURL(); } catch (MalformedURLException e) { throw new STException("can't load group file "+fileName, e); } if ( verbose ) System.out.println("STGroupFile(" + fileName + ") == file "+f.getAbsolutePath()); } else { // try in classpath url = getURL(fileName); if ( url==null ) { throw new IllegalArgumentException("No such group file: "+ fileName); } if ( verbose ) System.out.println("STGroupFile(" + fileName + ") == url "+url); } this.fileName = fileName; }
public STGroupFile(String fileName, char delimiterStartChar, char delimiterStopChar) { super(delimiterStartChar, delimiterStopChar); if ( !fileName.endsWith(GROUP_FILE_EXTENSION) ) { throw new IllegalArgumentException("Group file names must end in .stg: "+fileName); } //try { File f = new File(fileName); if ( f.exists() ) { try { url = f.toURI().toURL(); } catch (MalformedURLException e) { throw new STException("can't load group file "+fileName, e); } if ( verbose ) System.out.println("STGroupFile(" + fileName + ") == file "+f.getAbsolutePath()); } else { // try in classpath url = getURL(fileName); if ( url==null ) { throw new IllegalArgumentException("No such group file: "+ fileName); } if ( verbose ) System.out.println("STGroupFile(" + fileName + ") == url "+url); } this.fileName = fileName; }
public STGroupFile(String fileName, char delimiterStartChar, char delimiterStopChar) { super(delimiterStartChar, delimiterStopChar); if ( !fileName.endsWith(GROUP_FILE_EXTENSION) ) { throw new IllegalArgumentException("Group file names must end in .stg: "+fileName); } //try { File f = new File(fileName); if ( f.exists() ) { try { url = f.toURI().toURL(); } catch (MalformedURLException e) { throw new STException("can't load group file "+fileName, e); } if ( verbose ) System.out.println("STGroupFile(" + fileName + ") == file "+f.getAbsolutePath()); } else { // try in classpath url = getURL(fileName); if ( url==null ) { throw new IllegalArgumentException("No such group file: "+ fileName); } if ( verbose ) System.out.println("STGroupFile(" + fileName + ") == url "+url); } this.fileName = fileName; }
protected void reportMessageAndThrowSTException(TokenStream tokens, Token templateToken, Parser parser, RecognitionException re) { if ( re.token.getType() == STLexer.EOF_TYPE ) { String msg = "premature EOF"; group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg); } else if ( re instanceof NoViableAltException) { String msg = "'"+re.token.getText()+"' came as a complete surprise to me"; group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg); } else if ( tokens.index() == 0 ) { // couldn't parse anything String msg = "this doesn't look like a template: \""+tokens+"\""; group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg); } else if ( tokens.LA(1) == STLexer.LDELIM ) { // couldn't parse expr String msg = "doesn't look like an expression"; group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg); } else { String msg = parser.getErrorMessage(re, parser.getTokenNames()); group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg); } throw new STException(); // we have reported the error, so just blast out }
protected void reportMessageAndThrowSTException(TokenStream tokens, Token templateToken, Parser parser, RecognitionException re) { if ( re.token.getType() == STLexer.EOF_TYPE ) { String msg = "premature EOF"; group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg); } else if ( re instanceof NoViableAltException) { String msg = "'"+re.token.getText()+"' came as a complete surprise to me"; group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg); } else if ( tokens.index() == 0 ) { // couldn't parse anything String msg = "this doesn't look like a template: \""+tokens+"\""; group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg); } else if ( tokens.LA(1) == STLexer.LDELIM ) { // couldn't parse expr String msg = "doesn't look like an expression"; group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg); } else { String msg = parser.getErrorMessage(re, parser.getTokenNames()); group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg); } throw new STException(); // we have reported the error, so just blast out }
protected void reportMessageAndThrowSTException(TokenStream tokens, Token templateToken, Parser parser, RecognitionException re) { if ( re.token.getType() == STLexer.EOF_TYPE ) { String msg = "premature EOF"; group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg); } else if ( re instanceof NoViableAltException) { String msg = "'"+re.token.getText()+"' came as a complete surprise to me"; group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg); } else if ( tokens.index() == 0 ) { // couldn't parse anything String msg = "this doesn't look like a template: \""+tokens+"\""; group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg); } else if ( tokens.LA(1) == STLexer.LDELIM ) { // couldn't parse expr String msg = "doesn't look like an expression"; group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg); } else { String msg = parser.getErrorMessage(re, parser.getTokenNames()); group.errMgr.compileTimeError(ErrorType.SYNTAX_ERROR, templateToken, re.token, msg); } throw new STException(); // we have reported the error, so just blast out }