/** * Get the location of a <code>Parameters</code> object, returning * {@link Location#UNKNOWN} if no location could be found. * * @param param * @return the location * @since 2.1.8 */ public static Location getLocation(Parameters param) { Location loc = null; if (param instanceof Locatable) { loc = ((Locatable)param).getLocation(); } return loc == null ? Location.UNKNOWN : loc; }
result = new SitemapParameters.LocatedHashMap(((Locatable) expressions).getLocation(), size); } else { result = new HashMap(size);
/** * Build a <code>Parameters</code> object from a Map of named <code>VariableResolver</code>s and * a list of Maps used for resolution. * * @return a fully resolved <code>Parameters</code>. */ public static Parameters buildParameters(Map expressions, InvokeContext context, Map objectModel) throws PatternException { Location location; if (expressions instanceof Locatable) { location = ((Locatable) expressions).getLocation(); } else { location = Location.UNKNOWN; } if (expressions == null || expressions.size() == 0 && location.equals(Location.UNKNOWN)) { return Parameters.EMPTY_PARAMETERS; } SitemapParameters result = new SitemapParameters(location); Iterator iter = expressions.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); result.setParameter( ((VariableResolver) entry.getKey()).resolve(context, objectModel), ((VariableResolver) entry.getValue()).resolve(context, objectModel) ); } return result; }