public static String formatLocationMessage(String message, Annotation anno) { if (anno == null) return message; return formatLocationMessage(message, anno.getLocation(), true); }
private static Location toComponentLocation(Component comp) { if (comp instanceof AbstractComponent) { Annotation anno = ((AbstractComponent) comp).getAnnotation(null, "ZKLOC"); return anno == null ? null : anno.getLocation(); } return null; }
/** Returns the annotation associated with the specified * property, or null if not available. * * @param annotName the annotation name * @param propName the property name, e.g., "value". * If null, this method returns the annotation(s) associated with the * component (rather than a particular property). */ public Annotation getAnnotation(String propName, String annotName) { if (_annots != null) { final Map<String, List<Annotation>> anmap = _annots.get(propName); if (anmap != null) { List<Annotation> ans = anmap.get(annotName); if (ans != null) { if (ans.size() == 1) return ans.get(0); //merge annotations into a single annotation final AnnotImpl ai = new AnnotImpl(annotName, null); for (Annotation an : ans) { if (ai._loc == null) ai._loc = an.getLocation(); ai.addAttributes(an); } return ai; } } } return null; }
private void processReferenceBinding(Component comp, String propName, Annotation ann) { String loadExpr = null; Map<String, String[]> args = null; for (final Iterator<Entry<String, String[]>> it = ann.getAttributes().entrySet().iterator(); it.hasNext();) { final Entry<String, String[]> entry = it.next(); final String tag = entry.getKey(); final String[] tagExpr = entry.getValue(); if ("value".equals(tag)) { loadExpr = AnnotationUtil.testString(tagExpr, ann); } else { //other unknown tag, keep as arguments if (args == null) { args = new HashMap<String, String[]>(); } args.put(tag, tagExpr); } } final Map<String, Object> parsedArgs = args == null ? null : BindEvaluatorXUtil.parseArgs(_binder.getEvaluatorX(), args); try { BinderUtil.pushContext().setCurrentLocation(ann.getLocation()); _binder.addReferenceBinding(comp, propName, loadExpr, parsedArgs); } finally { BinderUtil.popContext(); } }
: BindEvaluatorXUtil.parseArgs(_binder.getEvaluatorX(), args); try { BinderUtil.pushContext().setCurrentLocation(ann.getLocation()); _binder.addFormLoadBindings(comp, formId, loadExpr, beforeCmds.size() == 0 ? null : beforeCmds.toArray(new String[beforeCmds.size()]),
String nm = anno.getName(); try { BinderUtil.pushContext().setCurrentLocation(anno.getLocation()); if (p.startsWith("on")) { if (COMMAND_ANNO.equals(nm) || GLOBAL_COMMAND_ANNO.equals(nm)) {
: BindEvaluatorXUtil.parseArgs(_binder.getEvaluatorX(), args); try { BinderUtil.pushContext().setCurrentLocation(ann.getLocation()); _binder.addPropertyLoadBindings(comp, propName, loadExpr, beforeCmds.size() == 0 ? null : beforeCmds.toArray(new String[beforeCmds.size()]),
: BindEvaluatorXUtil.parseArgs(_binder.getEvaluatorX(), args); try { BinderUtil.pushContext().setCurrentLocation(ann.getLocation()); _binder.addFormSaveBindings(comp, formId, saveExpr, beforeCmds.size() == 0 ? null : beforeCmds.toArray(new String[beforeCmds.size()]),
: BindEvaluatorXUtil.parseArgs(_binder.getEvaluatorX(), args); try { BinderUtil.pushContext().setCurrentLocation(ann.getLocation()); _binder.addChildrenLoadBindings(comp, loadExpr, beforeCmds.size() == 0 ? null : beforeCmds.toArray(new String[beforeCmds.size()]),
: BindEvaluatorXUtil.parseArgs(_binder.getEvaluatorX(), args); try { BinderUtil.pushContext().setCurrentLocation(ann.getLocation()); _binder.addPropertySaveBindings(comp, propName, saveExpr, beforeCmds.size() == 0 ? null : beforeCmds.toArray(new String[beforeCmds.size()]),
private void processFormInit(Component comp, String formId, Annotation ann) { String initExpr = null; Map<String, String[]> args = null; for (final Iterator<Entry<String, String[]>> it = ann.getAttributes().entrySet().iterator(); it.hasNext();) { final Entry<String, String[]> entry = it.next(); final String tag = entry.getKey(); final String[] tagExpr = entry.getValue(); if ("value".equals(tag)) { initExpr = AnnotationUtil.testString(tagExpr, ann); } else { //other unknown tag, keep as arguments if (args == null) { args = new HashMap<String, String[]>(); } args.put(tag, tagExpr); } } final Map<String, Object> parsedArgs = args == null ? null : BindEvaluatorXUtil.parseArgs(_binder.getEvaluatorX(), args); try { BinderUtil.pushContext().setCurrentLocation(ann.getLocation()); _binder.addFormInitBinding(comp, formId, initExpr, parsedArgs); } finally { BinderUtil.popContext(); } }
: BindEvaluatorXUtil.parseArgs(_binder.getEvaluatorX(), args); try { BinderUtil.pushContext().setCurrentLocation(ann.getLocation()); for (String cmd : cmdExprs) { _binder.addGlobalCommandBinding(comp, propName, cmd, parsedArgs);
private void processChildrenInit(Component comp, Annotation ann, ExpressionAnnoInfo converterInfo) { String initExpr = null; Map<String, String[]> args = null; for (final Iterator<Entry<String, String[]>> it = ann.getAttributes().entrySet().iterator(); it.hasNext();) { final Entry<String, String[]> entry = it.next(); final String tag = entry.getKey(); final String[] tagExpr = entry.getValue(); if ("value".equals(tag)) { initExpr = AnnotationUtil.testString(tagExpr, ann); } else { //other unknown tag, keep as arguments if (args == null) { args = new HashMap<String, String[]>(); } args.put(tag, tagExpr); } } final Map<String, Object> parsedArgs = args == null ? null : BindEvaluatorXUtil.parseArgs(_binder.getEvaluatorX(), args); try { BinderUtil.pushContext().setCurrentLocation(ann.getLocation()); _binder.addChildrenInitBinding(comp, initExpr, parsedArgs, converterInfo == null ? getDefaultChildBindingConverter() : converterInfo.expr, converterInfo == null ? null : converterInfo.args); } finally { BinderUtil.popContext(); } }
private void processPropertyInit(Component comp, String propName, Annotation ann, ExpressionAnnoInfo converterInfo) { String initExpr = null; Map<String, String[]> args = null; for (final Iterator<Entry<String, String[]>> it = ann.getAttributes().entrySet().iterator(); it.hasNext();) { final Entry<String, String[]> entry = it.next(); final String tag = entry.getKey(); final String[] tagExpr = entry.getValue(); if ("value".equals(tag)) { initExpr = AnnotationUtil.testString(tagExpr, ann); } else { //other unknown tag, keep as arguments if (args == null) { args = new HashMap<String, String[]>(); } args.put(tag, tagExpr); } } final Map<String, Object> parsedArgs = args == null ? null : BindEvaluatorXUtil.parseArgs(_binder.getEvaluatorX(), args); try { BinderUtil.pushContext().setCurrentLocation(ann.getLocation()); _binder.addPropertyInitBinding(comp, propName, initExpr, parsedArgs, converterInfo == null ? null : converterInfo.expr, converterInfo == null ? null : converterInfo.args); } finally { BinderUtil.popContext(); } }
: BindEvaluatorXUtil.parseArgs(_binder.getEvaluatorX(), args); try { BinderUtil.pushContext().setCurrentLocation(ann.getLocation()); for (String cmd : cmdExprs) { _binder.addCommandBinding(comp, propName, cmd, parsedArgs);
showColumn = false; } else if (loc instanceof Annotation) { location = ((Annotation) loc).getLocation(); } else if (loc instanceof Location) { location = (Location) loc;
public void checkViewModel(Component comp) { final ComponentCtrl compCtrl = (ComponentCtrl) comp; for (Annotation anno : compCtrl.getAnnotations(VIEW_MODEL_ATTR)) { String nm = anno.getName(); if (ID_ANNO.equals(nm) || INIT_ANNO.equals(nm)) { continue; } try { BinderUtil.pushContext().setCurrentLocation(anno.getLocation()); _collector.addInfo(new AnnoWarnInfo(comp, VIEW_MODEL_ATTR, nm, "Unknow viewmodel annotation")); } finally { BinderUtil.popContext(); } } }
public void checkBinder(Component comp) { final ComponentCtrl compCtrl = (ComponentCtrl) comp; for (Annotation anno : compCtrl.getAnnotations(BINDER_ATTR)) { String nm = anno.getName(); if (ID_ANNO.equals(nm) || INIT_ANNO.equals(nm)) { continue; } try { BinderUtil.pushContext().setCurrentLocation(anno.getLocation()); _collector.addInfo(new AnnoWarnInfo(comp, BINDER_ATTR, nm, "Unknow binder annotation")); } finally { BinderUtil.popContext(); } } }
: BindEvaluatorXUtil.parseArgs(_binder.getEvaluatorX(), args); try { BinderUtil.pushContext().setCurrentLocation(ann.getLocation()); _binder.addChildrenLoadBindings(comp, expr, null, null, parsedArgs, converterInfo == null ? getDefaultChildBindingConverter() : converterInfo.expr,
public void checkValidationMessages(Component comp) { final ComponentCtrl compCtrl = (ComponentCtrl) comp; for (Annotation anno : compCtrl.getAnnotations(VALIDATION_MESSAGES_ATTR)) { String nm = anno.getName(); if (ID_ANNO.equals(nm) || INIT_ANNO.equals(nm)) { continue; } try { BinderUtil.pushContext().setCurrentLocation(anno.getLocation()); _collector.addInfo( new AnnoWarnInfo(comp, VALIDATION_MESSAGES_ATTR, nm, "Unknow validation messages annotation")); } finally { BinderUtil.popContext(); } } }