public I18nExpWithArgsExpression(String text, Map<String, InternationalizedStringExpression> resourceLiterals, String exp) throws JellyException { this.text = text; this.resourceLiterals = resourceLiterals; innerExpression = JellyClassLoaderTearOff.EXPRESSION_FACTORY.createExpression(exp); }
public I18nExpWithArgsExpression(String text, Map<String, InternationalizedStringExpression> resourceLiterals, String exp) throws JellyException { this.text = text; this.resourceLiterals = resourceLiterals; innerExpression = JellyClassLoaderTearOff.EXPRESSION_FACTORY.createExpression(exp); }
public InternationalizedStringExpression(ResourceBundle resourceBundle, String text) throws JellyException { this.resourceBundle = resourceBundle; this.expressionText = text; if(!text.startsWith("%")) throw new JellyException(text+" doesn't start with %"); text = text.substring(1); int idx = text.indexOf('('); if(idx<0) { // no arguments key = text; arguments = EMPTY_ARGUMENTS; return; } List<Expression> args = new ArrayList<Expression>(); key = text.substring(0,idx); text = text.substring(idx+1); // at this point text="arg,arg)" while(text.length()>0) { String token = tokenize(text); args.add(JellyClassLoaderTearOff.EXPRESSION_FACTORY.createExpression(token)); text = text.substring(token.length()+1); } this.arguments = args.toArray(new Expression[args.size()]); }
public InternationalizedStringExpression(ResourceBundle resourceBundle, String text) throws JellyException { this.resourceBundle = resourceBundle; this.expressionText = text; if(!text.startsWith("%")) throw new JellyException(text+" doesn't start with %"); text = text.substring(1); int idx = text.indexOf('('); if(idx<0) { // no arguments key = text; arguments = EMPTY_ARGUMENTS; return; } List<Expression> args = new ArrayList<Expression>(); key = text.substring(0,idx); text = text.substring(idx+1); // at this point text="arg,arg)" while(text.length()>0) { String token = tokenize(text); args.add(JellyClassLoaderTearOff.EXPRESSION_FACTORY.createExpression(token)); text = text.substring(token.length()+1); } this.arguments = args.toArray(new Expression[args.size()]); }
public Expression createExpression(final String text) throws JellyException { if(text.startsWith("%")) { // this is a message resource reference return createI18nExp(text); } else { Matcher m = RESOURCE_LITERAL_STRING.matcher(text); if(m.find()) { // contains the resource literal, so pre-process them. final StringBuilder buf = new StringBuilder(); final Map<String,InternationalizedStringExpression> resourceLiterals = new HashMap<String,InternationalizedStringExpression>(); int e=0; do { // copy the text preceding the match buf.append(text.substring(e,m.start())); String varName = "__resourceLiteral__"+resourceLiterals.size()+"__"; InternationalizedStringExpression exp = createI18nExp(unquote(m.group())); resourceLiterals.put(varName,exp); // replace the literal by the evaluation buf.append(varName).append(".evaluate(context)"); e = m.end(); } while(m.find()); buf.append(text.substring(e)); return new I18nExpWithArgsExpression(text, resourceLiterals, buf.toString()); } return JellyClassLoaderTearOff.EXPRESSION_FACTORY.createExpression(text); } }
public Expression createExpression(final String text) throws JellyException { if(text.startsWith("%")) { // this is a message resource reference return createI18nExp(text); } else { Matcher m = RESOURCE_LITERAL_STRING.matcher(text); if(m.find()) { // contains the resource literal, so pre-process them. final StringBuilder buf = new StringBuilder(); final Map<String,InternationalizedStringExpression> resourceLiterals = new HashMap<String,InternationalizedStringExpression>(); int e=0; do { // copy the text preceding the match buf.append(text.substring(e,m.start())); String varName = "__resourceLiteral__"+resourceLiterals.size()+"__"; InternationalizedStringExpression exp = createI18nExp(unquote(m.group())); resourceLiterals.put(varName,exp); // replace the literal by the evaluation buf.append(varName).append(".evaluate(context)"); e = m.end(); } while(m.find()); buf.append(text.substring(e)); return new I18nExpWithArgsExpression(text, resourceLiterals, buf.toString()); } return JellyClassLoaderTearOff.EXPRESSION_FACTORY.createExpression(text); } }
return factory.createExpression(text.substring(2, endIndex)); answer.addExpression(factory.createExpression(expr.toString())); expr.delete(0, expr.length()); ++cur;
return factory.createExpression(text.substring(2, endIndex)); answer.addExpression(factory.createExpression(expr.toString())); expr.delete(0, expr.length()); ++cur;
return factory.createExpression(text.substring(2, endIndex)); answer.addExpression(factory.createExpression(expr.toString())); expr.delete(0, expr.length()); ++cur;
return factory.createExpression(text.substring(2, endIndex)); answer.addExpression(factory.createExpression(expr.toString())); expr.delete(0, expr.length()); ++cur;
public TagLibrary load(String nsUri) { if(owner.parent!=null) { // parent first TagLibrary tl = owner.parent.loadTearOff(JellyClassLoaderTearOff.class).getTagLibrary(nsUri); if(tl!=null) return tl; } String taglibBasePath = trimHeadSlash(nsUri); try { URL res = owner.loader.getResource(taglibBasePath +"/taglib"); if(res!=null) return new CustomTagLibrary(createContext(),owner.loader,nsUri,taglibBasePath); } catch (IllegalArgumentException e) { // if taglibBasePath doesn't even look like an URL, getResource throws IllegalArgumentException. // see http://old.nabble.com/bug-1.331-to26145963.html } // support URIs like "this:it" or "this:instance". Note that "this" URI itself is registered elsewhere if (nsUri.startsWith("this:")) try { return new ThisTagLibrary(EXPRESSION_FACTORY.createExpression(nsUri.substring(5))); } catch (JellyException e) { throw new IllegalArgumentException("Illegal expression in the URI: "+nsUri,e); } if (nsUri.equals("jelly:stapler")) return new StaplerTagLibrary(); return NO_SUCH_TAGLIBRARY; // "not found" is also cached. } });