public boolean has(String name) { if (!context.hasConstId(name, true)) { if(strict){ throw new PaxmlRuntimeException("Unknown const name: " + name); } return true; } return true; }
public boolean has(String name) { if (!context.hasConstId(name, true)) { if(strict){ throw new PaxmlRuntimeException("Unknown const name: " + name); } return true; } return true; }
/** * Check if an id exists in current context. * * @param id * the id * @param searchParent * true to search the parent context, false not to. * @return true if exists, false if not. */ public static boolean hasConst(String id, boolean searchParent) { return Context.getCurrentContext().hasConstId(id, searchParent); }
/** * Check if an id exists in current context. * * @param id * the id * @param searchParent * true to search the parent context, false not to. * @return true if exists, false if not. */ public static boolean hasConst(String id, boolean searchParent) { return Context.getCurrentContext().hasConstId(id, searchParent); }
/** * Check the existence of an data object. * * @param id * the id * @param searchParent * true to search in parent contexts, false not to. * @return true if exists, false if not */ public boolean hasConstId(String id, boolean searchParent) { if (idConstsMap.containsKey(id)) { return true; } if (searchParent && parent != null) { return parent.hasConstId(id, searchParent); } return false; }
/** * Check the existence of an data object. * * @param id * the id * @param searchParent * true to search in parent contexts, false not to. * @return true if exists, false if not */ public boolean hasConstId(String id, boolean searchParent) { if (idConstsMap.containsKey(id)) { return true; } if (searchParent && parent != null) { return parent.hasConstId(id, searchParent); } return false; }
/** * {@inheritDoc} */ @Override protected Object doExecute(Context context) { String id = getIdExpression().getId(context); if (context.hasConstId(id, true)) { // now we do not allow empty Object existing = context.getConst(id, true); if (!UtilFunctions.isEmpty(existing)) { return null; } } return super.doExecute(context); }
/** * {@inheritDoc} */ public ChildrenResultList visit(Context context, Object obj, Object propertyName, int index, Object propertyValue) { // set the loop vars and remember the previous status final boolean varExists = context.hasConstId(varName, false); final Object oldVar = varExists ? context.removeConst(varName) : null; context.addConst(varName, varName, propertyValue, true); final boolean indexExists = context.hasConstId(indexVarName, false); final Object oldIndex = indexExists ? context.removeConst(indexVarName) : null; context.addConst(indexVarName, indexVarName, index, true); final boolean varNameExists = context.hasConstId(varNameText, false); final Object oldVarName = varNameExists ? context.removeConst(varNameText) : null; context.addConst(varNameText, varNameText, propertyName, true); ChildrenResultList list = executeChildren(context); // restore the previous status context.removeConst(varName); if (varExists) { context.addConst(varName, varName, oldVar, true); } context.removeConst(indexVarName); if (indexExists) { context.addConst(indexVarName, indexVarName, oldIndex, true); } context.removeConst(varNameText); if (varNameExists) { context.addConst(varNameText, varNameText, oldVarName, true); } return list; }
/** * {@inheritDoc} */ public ChildrenResultList visit(Context context, Object obj, Object propertyName, int index, Object propertyValue) { // set the loop vars and remember the previous status final boolean varExists = context.hasConstId(varName, false); final Object oldVar = varExists ? context.removeConst(varName) : null; context.addConst(varName, varName, propertyValue, true); final boolean indexExists = context.hasConstId(indexVarName, false); final Object oldIndex = indexExists ? context.removeConst(indexVarName) : null; context.addConst(indexVarName, indexVarName, index, true); final boolean varNameExists = context.hasConstId(varNameText, false); final Object oldVarName = varNameExists ? context.removeConst(varNameText) : null; context.addConst(varNameText, varNameText, propertyName, true); ChildrenResultList list = executeChildren(context); // restore the previous status context.removeConst(varName); if (varExists) { context.addConst(varName, varName, oldVar, true); } context.removeConst(indexVarName); if (indexExists) { context.addConst(indexVarName, indexVarName, oldIndex, true); } context.removeConst(varNameText); if (varNameExists) { context.addConst(varNameText, varNameText, oldVarName, true); } return list; }
/** * {@inheritDoc} */ @Override protected Object doExecute(Context context) { String id = getIdExpression().getId(context); if (context.hasConstId(id, true)) { // now we do not allow empty Object existing = context.getConst(id, true); if (!UtilFunctions.isEmpty(existing)) { return null; }else{ // #10, remove existing empty value so that later it will be rewritten by the default value context.removeConst(id); } } return super.doExecute(context); }