Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/WebXmlUtilsForJ2EE.java')
-rw-r--r--jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/WebXmlUtilsForJ2EE.java72
1 files changed, 72 insertions, 0 deletions
diff --git a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/WebXmlUtilsForJ2EE.java b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/WebXmlUtilsForJ2EE.java
index 27676281c..6354dc8e3 100644
--- a/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/WebXmlUtilsForJ2EE.java
+++ b/jsf/plugins/org.eclipse.jst.jsf.common/src/org/eclipse/jst/jsf/common/webxml/WebXmlUtilsForJ2EE.java
@@ -11,6 +11,7 @@
package org.eclipse.jst.jsf.common.webxml;
+import java.util.Arrays;
import java.util.List;
import org.eclipse.jst.j2ee.common.CommonFactory;
@@ -497,6 +498,77 @@ public class WebXmlUtilsForJ2EE
/**
+ * @param webApp
+ * @param paramName
+ * @return the param value or null if not found
+ */
+ public static String getContextParamValue (final WebApp webApp,
+ final String paramName)
+ {
+ for (final Object param : webApp.getContextParams())
+ {
+ final ParamValue contextParam = (ParamValue) param;
+ if (contextParam.getName().equals(paramName))
+ {
+ return contextParam.getValue();
+ }
+ }
+
+ return null;
+ }
+
+
+ /**
+ * @param webApp
+ * @param paramName Name of context param
+ * @param valuesDelimiterRegex
+ * @return Values of the given context param as a list
+ */
+ public static List<String> getContextParamValuesAsList (final WebApp webApp,
+ final String paramName,
+ final String valuesDelimiterRegex)
+ {
+ final String valuesString = getContextParamValue(webApp, paramName);
+ return Arrays.asList(valuesString.split(valuesDelimiterRegex));
+ }
+
+
+ /**
+ * Updates the value of a context param if it exists. Otherwise, adds this
+ * as a new context param.
+ *
+ * @param webApp
+ * @param paramName
+ * @param paramValue
+ */
+ public static void setContextParamValue (final WebApp webApp,
+ final String paramName,
+ final String paramValue)
+ {
+ ParamValue contextParam = null;
+
+ for (final Object p : webApp.getContextParams())
+ {
+ final ParamValue param = (ParamValue) p;
+ if (param.getName().equals(paramName))
+ {
+ contextParam = param;
+ break;
+ }
+ }
+
+ if (contextParam == null)
+ {
+ webApp.getContextParams().add(createContextParam(paramName, paramValue, null));
+ }
+ else
+ {
+ contextParam.setValue(paramValue);
+ }
+ }
+
+
+ /**
* @param webapp
* @param listenerClass
*/

Back to the top