/** * Get the parameters for a asset name (as Object with toString()) * * @param assetName * asset name * @return the parameter of the asset name, or empty map */ public Map<String, Object> getParameters(Object assetName) { return getParameters(assetName.toString()); }
/** * Get the parameters for a asset name (as Object with toString()) * * @param assetName * asset name * @return the parameter of the asset name, or empty map */ public Map<String, Object> getParameters(Object assetName) { return getParameters(assetName.toString()); }
/** * Get the value of the parameter for the asset name * * @param assetName * asset name * @param parameter * parameter * @param <T> * type of the value (aka TypeOfValue value = * context.getParameterValue(...) ) * @return the value of the parameter, or <code>null</code> value */ @SuppressWarnings("unchecked") public <T> T getParameterValue(String assetName, String parameter) { Map<String, Object> values = getParameters(assetName); if (!values.containsKey(parameter)) { return null; } return (T) values.get(parameter); }
/** * Get the value of the parameter for the asset name * * @param assetName * asset name * @param parameter * parameter * @param <T> * type of the value (aka TypeOfValue value = * context.getParameterValue(...) ) * @return the value of the parameter, or <code>null</code> value */ @SuppressWarnings("unchecked") public <T> T getParameterValue(String assetName, String parameter) { Map<String, Object> values = getParameters(assetName); if (!values.containsKey(parameter)) { return null; } return (T) values.get(parameter); }
/** * <p> * Returns the content of the given {@link Asset}, using its * {@link Asset#getFinalLocation()} value. * * <p> * Note that this method can be used to access the asset's content after the * {@link AssetProcessor}'s execution. * * @param asset * The asset from which the content should be extracted. * @param request * The current HTTP request. * @return the raw content (unprocessed) of the passed {@link Asset}. */ public String getContent(Asset asset, HttpServletRequest request) { Map<String, Object> parameters = AssetRequestContext.get(request).getParameters(asset.getName()); String content = doGetContent(asset, parameters, request); // Apply variable replacement if (!parameters.isEmpty()) { for (Map.Entry<String, Object> entry : parameters.entrySet()) { content = content.replace(entry.getKey(), entry.getValue().toString()); } } return content; }
/** * <p> * Returns the content of the given {@link Asset}, using its * {@link Asset#getFinalLocation()} value. * * <p> * Note that this method can be used to access the asset's content after the * {@link AssetProcessor}'s execution. * * @param asset * The asset from which the content should be extracted. * @param request * The current HTTP request. * @return the raw content (unprocessed) of the passed {@link Asset}. */ public String getContent(Asset asset, HttpServletRequest request) { Map<String, Object> parameters = AssetRequestContext.get(request).getParameters(asset.getName()); String content = doGetContent(asset, parameters, request); // Apply variable replacement if (!parameters.isEmpty()) { for (Map.Entry<String, Object> entry : parameters.entrySet()) { content = content.replace(entry.getKey(), entry.getValue().toString()); } } return content; }