You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2011/11/10 00:44:04 UTC
svn commit: r1200044 [6/7] - in
/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared:
application/ component/ config/ context/flash/ renderkit/ renderkit/html/
renderkit/html/util/ resource/ taglib/ test/ util/ util/el/ util/servlet/
view...
Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/taglib/UIComponentELTagUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/taglib/UIComponentELTagUtils.java?rev=1200044&r1=1200043&r2=1200044&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/taglib/UIComponentELTagUtils.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/taglib/UIComponentELTagUtils.java Wed Nov 9 23:44:02 2011
@@ -47,16 +47,18 @@ import javax.faces.validator.MethodExpre
public class UIComponentELTagUtils
{
//private static final Log log = LogFactory.getLog(UIComponentELTagUtils.class);
- private static final Logger log = Logger.getLogger(UIComponentELTagUtils.class.getName());
+ private static final Logger log = Logger
+ .getLogger(UIComponentELTagUtils.class.getName());
- private UIComponentELTagUtils() {} //util class, no instantiation allowed
+ private UIComponentELTagUtils()
+ {
+ } //util class, no instantiation allowed
/**
* @since 1.2
*/
public static void setIntegerProperty(UIComponent component,
- String propName,
- ValueExpression value)
+ String propName, ValueExpression value)
{
setIntegerProperty(component, propName, value, null);
}
@@ -65,15 +67,14 @@ public class UIComponentELTagUtils
* @since 1.2
*/
public static void setIntegerProperty(UIComponent component,
- String propName,
- ValueExpression value,
- Integer defaultValue)
+ String propName, ValueExpression value, Integer defaultValue)
{
if (value != null)
{
if (value.isLiteralText())
{
- component.getAttributes().put(propName, Integer.valueOf(value.getExpressionString()));
+ component.getAttributes().put(propName,
+ Integer.valueOf(value.getExpressionString()));
}
else
{
@@ -89,13 +90,11 @@ public class UIComponentELTagUtils
}
}
-
/**
* @since 1.2
*/
- public static void setLongProperty(UIComponent component,
- String propName,
- ValueExpression value)
+ public static void setLongProperty(UIComponent component, String propName,
+ ValueExpression value)
{
setLongProperty(component, propName, value, null);
}
@@ -103,16 +102,15 @@ public class UIComponentELTagUtils
/**
* @since 1.2
*/
- public static void setLongProperty(UIComponent component,
- String propName,
- ValueExpression value,
- Long defaultValue)
+ public static void setLongProperty(UIComponent component, String propName,
+ ValueExpression value, Long defaultValue)
{
if (value != null)
{
if (value.isLiteralText())
{
- component.getAttributes().put(propName, Long.valueOf(value.getExpressionString()));
+ component.getAttributes().put(propName,
+ Long.valueOf(value.getExpressionString()));
}
else
{
@@ -132,8 +130,7 @@ public class UIComponentELTagUtils
* @since 1.2
*/
public static void setStringProperty(UIComponent component,
- String propName,
- ValueExpression value)
+ String propName, ValueExpression value)
{
setStringProperty(component, propName, value, null);
}
@@ -142,15 +139,14 @@ public class UIComponentELTagUtils
* @since 1.2
*/
public static void setStringProperty(UIComponent component,
- String propName,
- ValueExpression value,
- String defaultValue)
+ String propName, ValueExpression value, String defaultValue)
{
if (value != null)
{
if (value.isLiteralText())
{
- component.getAttributes().put(propName, value.getExpressionString());
+ component.getAttributes().put(propName,
+ value.getExpressionString());
}
else
{
@@ -166,13 +162,11 @@ public class UIComponentELTagUtils
}
}
-
/**
* @since 1.2
*/
public static void setBooleanProperty(UIComponent component,
- String propName,
- ValueExpression value)
+ String propName, ValueExpression value)
{
setBooleanProperty(component, propName, value, null);
}
@@ -181,15 +175,14 @@ public class UIComponentELTagUtils
* @since 1.2
*/
public static void setBooleanProperty(UIComponent component,
- String propName,
- ValueExpression value,
- Boolean defaultValue)
+ String propName, ValueExpression value, Boolean defaultValue)
{
if (value != null)
{
if (value.isLiteralText())
{
- component.getAttributes().put(propName, Boolean.valueOf(value.getExpressionString()));
+ component.getAttributes().put(propName,
+ Boolean.valueOf(value.getExpressionString()));
}
else
{
@@ -209,40 +202,43 @@ public class UIComponentELTagUtils
* @since 1.2
*/
public static void setValueProperty(FacesContext context,
- UIComponent component,
- ValueExpression value)
+ UIComponent component, ValueExpression value)
{
if (value != null)
{
if (!value.isLiteralText())
{
- component.setValueExpression(org.apache.myfaces.shared.renderkit.JSFAttr.VALUE_ATTR, value);
+ component.setValueExpression(
+ org.apache.myfaces.shared.renderkit.JSFAttr.VALUE_ATTR,
+ value);
}
else if (component instanceof UICommand)
{
- ((UICommand)component).setValue(value.getExpressionString());
+ ((UICommand) component).setValue(value.getExpressionString());
}
else if (component instanceof UIParameter)
{
- ((UIParameter)component).setValue(value.getExpressionString());
+ ((UIParameter) component).setValue(value.getExpressionString());
}
else if (component instanceof UISelectBoolean)
{
- ((UISelectBoolean)component).setValue(Boolean.valueOf(value.getExpressionString()));
+ ((UISelectBoolean) component).setValue(Boolean.valueOf(value
+ .getExpressionString()));
}
else if (component instanceof UIGraphic)
{
- ((UIGraphic)component).setValue(value.getExpressionString());
+ ((UIGraphic) component).setValue(value.getExpressionString());
}
//Since many input components are ValueHolders the special components
//must come first, ValueHolder is the last resort.
else if (component instanceof ValueHolder)
{
- ((ValueHolder)component).setValue(value.getExpressionString());
+ ((ValueHolder) component).setValue(value.getExpressionString());
}
else
{
- log.severe("Component " + component.getClass().getName() + " is no ValueHolder, cannot set value.");
+ log.severe("Component " + component.getClass().getName()
+ + " is no ValueHolder, cannot set value.");
}
}
}
@@ -251,8 +247,7 @@ public class UIComponentELTagUtils
* @since 1.2
*/
public static void setConverterProperty(FacesContext context,
- UIComponent component,
- ValueExpression value)
+ UIComponent component, ValueExpression value)
{
if (value != null)
{
@@ -260,18 +255,24 @@ public class UIComponentELTagUtils
{
if (value.isLiteralText())
{
- FacesContext facesContext = FacesContext.getCurrentInstance();
- Converter converter = facesContext.getApplication().createConverter(value.getExpressionString());
- ((ValueHolder)component).setConverter(converter);
+ FacesContext facesContext = FacesContext
+ .getCurrentInstance();
+ Converter converter = facesContext.getApplication()
+ .createConverter(value.getExpressionString());
+ ((ValueHolder) component).setConverter(converter);
}
else
{
- component.setValueExpression(org.apache.myfaces.shared.renderkit.JSFAttr.CONVERTER_ATTR, value);
+ component
+ .setValueExpression(
+ org.apache.myfaces.shared.renderkit.JSFAttr.CONVERTER_ATTR,
+ value);
}
}
else
{
- log.severe("Component " + component.getClass().getName() + " is no ValueHolder, cannot set value.");
+ log.severe("Component " + component.getClass().getName()
+ + " is no ValueHolder, cannot set value.");
}
}
}
@@ -280,17 +281,19 @@ public class UIComponentELTagUtils
* @since 1.2
*/
public static void addValidatorProperty(FacesContext context,
- UIComponent component,
- MethodExpression validator)
+ UIComponent component, MethodExpression validator)
{
if (validator != null)
{
if (!(component instanceof EditableValueHolder))
{
- throw new IllegalArgumentException("Component " + component.getClientId(context) + " is no EditableValueHolder");
+ throw new IllegalArgumentException("Component "
+ + component.getClientId(context)
+ + " is no EditableValueHolder");
}
- ((EditableValueHolder)component).addValidator(new MethodExpressionValidator(validator));
+ ((EditableValueHolder) component)
+ .addValidator(new MethodExpressionValidator(validator));
}
}
@@ -298,9 +301,7 @@ public class UIComponentELTagUtils
* @since 1.2
*/
public static void setValueBinding(FacesContext context,
- UIComponent component,
- String propName,
- ValueExpression value)
+ UIComponent component, String propName, ValueExpression value)
{
if (value != null)
{
@@ -310,7 +311,9 @@ public class UIComponentELTagUtils
}
else
{
- throw new IllegalArgumentException("Component " + component.getClientId(context) + " attribute " + propName + " must be a value reference, was " + value);
+ throw new IllegalArgumentException("Component "
+ + component.getClientId(context) + " attribute "
+ + propName + " must be a value reference, was " + value);
}
}
}
@@ -319,17 +322,18 @@ public class UIComponentELTagUtils
* @since 1.2
*/
public static void setActionProperty(FacesContext context,
- UIComponent component,
- MethodExpression action)
+ UIComponent component, MethodExpression action)
{
if (action != null)
{
if (!(component instanceof ActionSource2))
{
- throw new IllegalArgumentException("Component " + component.getClientId(context) + " is no ActionSource2");
+ throw new IllegalArgumentException("Component "
+ + component.getClientId(context)
+ + " is no ActionSource2");
}
- ((ActionSource2)component).setActionExpression(action);
+ ((ActionSource2) component).setActionExpression(action);
}
}
@@ -337,17 +341,20 @@ public class UIComponentELTagUtils
* @since 1.2
*/
public static void addActionListenerProperty(FacesContext context,
- UIComponent component,
- MethodExpression actionListener)
+ UIComponent component, MethodExpression actionListener)
{
if (actionListener != null)
{
if (!(component instanceof ActionSource2))
{
- throw new IllegalArgumentException("Component " + component.getClientId(context) + " is no ActionSource");
+ throw new IllegalArgumentException("Component "
+ + component.getClientId(context)
+ + " is no ActionSource");
}
- ((ActionSource2)component).addActionListener(new MethodExpressionActionListener(actionListener));
+ ((ActionSource2) component)
+ .addActionListener(new MethodExpressionActionListener(
+ actionListener));
}
}
@@ -355,48 +362,56 @@ public class UIComponentELTagUtils
* @since 1.2
*/
public static void addValueChangedListenerProperty(FacesContext context,
- UIComponent component,
- MethodExpression valueChangedListener)
+ UIComponent component, MethodExpression valueChangedListener)
{
if (valueChangedListener != null)
{
if (!(component instanceof EditableValueHolder))
{
- throw new IllegalArgumentException("Component " + component.getClientId(context) + " is no EditableValueHolder");
+ throw new IllegalArgumentException("Component "
+ + component.getClientId(context)
+ + " is no EditableValueHolder");
}
- ((EditableValueHolder)component).addValueChangeListener(
- new MethodExpressionValueChangeListener(valueChangedListener));
+ ((EditableValueHolder) component)
+ .addValueChangeListener(new MethodExpressionValueChangeListener(
+ valueChangedListener));
}
}
/**
* @since 1.2
*/
- public static Object evaluateValueExpression(ELContext elContext, ValueExpression valueExpression )
+ public static Object evaluateValueExpression(ELContext elContext,
+ ValueExpression valueExpression)
{
- return valueExpression.isLiteralText() ? valueExpression.getExpressionString() : valueExpression.getValue(elContext);
+ return valueExpression.isLiteralText() ? valueExpression
+ .getExpressionString() : valueExpression.getValue(elContext);
}
/**
* @since 1.2
*/
- public static Boolean getBooleanValue(ELContext elContext, ValueExpression valueExpression)
+ public static Boolean getBooleanValue(ELContext elContext,
+ ValueExpression valueExpression)
{
- if (valueExpression.isLiteralText()){
+ if (valueExpression.isLiteralText())
+ {
return Boolean.valueOf(valueExpression.getExpressionString());
}
-
+
return (Boolean) valueExpression.getValue(elContext);
}
- public static Integer getIntegerValue(ELContext elContext, ValueExpression valueExpression)
+ public static Integer getIntegerValue(ELContext elContext,
+ ValueExpression valueExpression)
{
- if (valueExpression.isLiteralText()){
+ if (valueExpression.isLiteralText())
+ {
return Integer.valueOf(valueExpression.getExpressionString());
}
-
- return (Integer) valueExpression.getValue(elContext);
+
+ return (Integer) valueExpression.getValue(elContext);
}
}
Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/taglib/UIComponentTagUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/taglib/UIComponentTagUtils.java?rev=1200044&r1=1200043&r2=1200044&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/taglib/UIComponentTagUtils.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/taglib/UIComponentTagUtils.java Wed Nov 9 23:44:02 2011
@@ -47,33 +47,32 @@ import org.apache.myfaces.shared.el.Simp
public class UIComponentTagUtils
{
//private static final Log log = LogFactory.getLog(UIComponentTagUtils.class);
- private static final Logger log = Logger.getLogger(UIComponentTagUtils.class.getName());
+ private static final Logger log = Logger
+ .getLogger(UIComponentTagUtils.class.getName());
- private static final Class[] VALIDATOR_ARGS = {FacesContext.class,
- UIComponent.class,
- Object.class};
- private static final Class[] ACTION_LISTENER_ARGS = {ActionEvent.class};
- private static final Class[] VALUE_LISTENER_ARGS = {ValueChangeEvent.class};
-
- private UIComponentTagUtils() {} //util class, no instantiation allowed
+ private static final Class[] VALIDATOR_ARGS = { FacesContext.class,
+ UIComponent.class, Object.class };
+ private static final Class[] ACTION_LISTENER_ARGS = { ActionEvent.class };
+ private static final Class[] VALUE_LISTENER_ARGS = { ValueChangeEvent.class };
+ private UIComponentTagUtils()
+ {
+ } //util class, no instantiation allowed
public static boolean isValueReference(String v)
{
return UIComponentTag.isValueReference(v);
}
-
public static void setIntegerProperty(FacesContext context,
- UIComponent component,
- String propName,
- String value)
+ UIComponent component, String propName, String value)
{
if (value != null)
{
if (isValueReference(value))
{
- ValueBinding vb = context.getApplication().createValueBinding(value);
+ ValueBinding vb = context.getApplication().createValueBinding(
+ value);
component.setValueBinding(propName, vb);
}
else
@@ -85,15 +84,14 @@ public class UIComponentTagUtils
}
public static void setLongProperty(FacesContext context,
- UIComponent component,
- String propName,
- String value)
+ UIComponent component, String propName, String value)
{
if (value != null)
{
if (isValueReference(value))
{
- ValueBinding vb = context.getApplication().createValueBinding(value);
+ ValueBinding vb = context.getApplication().createValueBinding(
+ value);
component.setValueBinding(propName, vb);
}
else
@@ -105,15 +103,14 @@ public class UIComponentTagUtils
}
public static void setStringProperty(FacesContext context,
- UIComponent component,
- String propName,
- String value)
+ UIComponent component, String propName, String value)
{
if (value != null)
{
if (isValueReference(value))
{
- ValueBinding vb = context.getApplication().createValueBinding(value);
+ ValueBinding vb = context.getApplication().createValueBinding(
+ value);
component.setValueBinding(propName, vb);
}
else
@@ -124,17 +121,15 @@ public class UIComponentTagUtils
}
}
-
public static void setBooleanProperty(FacesContext context,
- UIComponent component,
- String propName,
- String value)
+ UIComponent component, String propName, String value)
{
if (value != null)
{
if (isValueReference(value))
{
- ValueBinding vb = context.getApplication().createValueBinding(value);
+ ValueBinding vb = context.getApplication().createValueBinding(
+ value);
component.setValueBinding(propName, vb);
}
else
@@ -145,51 +140,51 @@ public class UIComponentTagUtils
}
}
-
public static void setValueProperty(FacesContext context,
- UIComponent component,
- String value)
+ UIComponent component, String value)
{
if (value != null)
{
if (isValueReference(value))
{
- ValueBinding vb = context.getApplication().createValueBinding(value);
- component.setValueBinding(org.apache.myfaces.shared.renderkit.JSFAttr.VALUE_ATTR, vb);
+ ValueBinding vb = context.getApplication().createValueBinding(
+ value);
+ component.setValueBinding(
+ org.apache.myfaces.shared.renderkit.JSFAttr.VALUE_ATTR,
+ vb);
}
else if (component instanceof UICommand)
{
- ((UICommand)component).setValue(value);
+ ((UICommand) component).setValue(value);
}
else if (component instanceof UIParameter)
{
- ((UIParameter)component).setValue(value);
+ ((UIParameter) component).setValue(value);
}
else if (component instanceof UISelectBoolean)
{
- ((UISelectBoolean)component).setValue(Boolean.valueOf(value));
+ ((UISelectBoolean) component).setValue(Boolean.valueOf(value));
}
else if (component instanceof UIGraphic)
{
- ((UIGraphic)component).setValue(value);
+ ((UIGraphic) component).setValue(value);
}
//Since many input components are ValueHolders the special components
//must come first, ValueHolder is the last resort.
else if (component instanceof ValueHolder)
{
- ((ValueHolder)component).setValue(value);
+ ((ValueHolder) component).setValue(value);
}
else
{
- log.severe("Component " + component.getClass().getName() + " is no ValueHolder, cannot set value.");
+ log.severe("Component " + component.getClass().getName()
+ + " is no ValueHolder, cannot set value.");
}
}
}
-
public static void setConverterProperty(FacesContext context,
- UIComponent component,
- String value)
+ UIComponent component, String value)
{
if (value != null)
{
@@ -197,75 +192,85 @@ public class UIComponentTagUtils
{
if (isValueReference(value))
{
- ValueBinding vb = context.getApplication().createValueBinding(value);
- component.setValueBinding(org.apache.myfaces.shared.renderkit.JSFAttr.CONVERTER_ATTR, vb);
+ ValueBinding vb = context.getApplication()
+ .createValueBinding(value);
+ component
+ .setValueBinding(
+ org.apache.myfaces.shared.renderkit.JSFAttr.CONVERTER_ATTR,
+ vb);
}
else
{
- FacesContext facesContext = FacesContext.getCurrentInstance();
- Converter converter = facesContext.getApplication().createConverter(value);
- ((ValueHolder)component).setConverter(converter);
+ FacesContext facesContext = FacesContext
+ .getCurrentInstance();
+ Converter converter = facesContext.getApplication()
+ .createConverter(value);
+ ((ValueHolder) component).setConverter(converter);
}
}
else
{
- log.severe("Component " + component.getClass().getName() + " is no ValueHolder, cannot set value.");
+ log.severe("Component " + component.getClass().getName()
+ + " is no ValueHolder, cannot set value.");
}
}
}
-
public static void setValidatorProperty(FacesContext context,
- UIComponent component,
- String validator)
+ UIComponent component, String validator)
{
if (validator != null)
{
if (!(component instanceof EditableValueHolder))
{
- throw new IllegalArgumentException("Component " + component.getClientId(context) + " is no EditableValueHolder");
+ throw new IllegalArgumentException("Component "
+ + component.getClientId(context)
+ + " is no EditableValueHolder");
}
if (isValueReference(validator))
{
- MethodBinding mb = context.getApplication().createMethodBinding(validator,
- VALIDATOR_ARGS);
- ((EditableValueHolder)component).setValidator(mb);
+ MethodBinding mb = context.getApplication()
+ .createMethodBinding(validator, VALIDATOR_ARGS);
+ ((EditableValueHolder) component).setValidator(mb);
}
else
{
- log.severe("Component " + component.getClientId(context) + " has invalid validation expression " + validator);
+ log.severe("Component " + component.getClientId(context)
+ + " has invalid validation expression " + validator);
}
}
}
public static void setValueBinding(FacesContext context,
- UIComponent component,
- String propName,
- String value)
+ UIComponent component, String propName, String value)
{
if (value != null)
{
if (isValueReference(value))
{
- ValueBinding vb = context.getApplication().createValueBinding(value);
+ ValueBinding vb = context.getApplication().createValueBinding(
+ value);
component.setValueBinding(propName, vb);
}
else
{
- throw new IllegalArgumentException("Component " + component.getClientId(context) + " attribute " + propName + " must be a value reference, was " + value);
+ throw new IllegalArgumentException("Component "
+ + component.getClientId(context) + " attribute "
+ + propName + " must be a value reference, was " + value);
}
}
}
public static void setActionProperty(FacesContext context,
- UIComponent component,
- String action)
+ UIComponent component, String action)
{
if (action != null)
{
if (!(component instanceof ActionSource))
{
- throw new IllegalArgumentException("Component " + component.getClientId(context) + " is no ActionSource");
+ throw new IllegalArgumentException("Component "
+ + component.getClientId(context)
+ + " is no ActionSource");
}
MethodBinding mb;
if (isValueReference(action))
@@ -276,24 +281,26 @@ public class UIComponentTagUtils
{
mb = new SimpleActionMethodBinding(action);
}
- ((ActionSource)component).setAction(mb);
+ ((ActionSource) component).setAction(mb);
}
}
public static void setActionListenerProperty(FacesContext context,
- UIComponent component,
- String actionListener)
+ UIComponent component, String actionListener)
{
if (actionListener != null)
{
if (!(component instanceof ActionSource))
{
- throw new IllegalArgumentException("Component " + component.getClientId(context) + " is no ActionSource");
+ throw new IllegalArgumentException("Component "
+ + component.getClientId(context)
+ + " is no ActionSource");
}
if (isValueReference(actionListener))
{
- MethodBinding mb = context.getApplication().createMethodBinding(actionListener,
- ACTION_LISTENER_ARGS);
+ MethodBinding mb = context.getApplication()
+ .createMethodBinding(actionListener,
+ ACTION_LISTENER_ARGS);
/**
if(! Void.class.equals(mb.getType(context)))
@@ -304,29 +311,33 @@ public class UIComponentTagUtils
}
*/
- ((ActionSource)component).setActionListener(mb);
+ ((ActionSource) component).setActionListener(mb);
}
else
{
- log.severe("Component " + component.getClientId(context) + " has invalid actionListener value: " + actionListener);
+ log.severe("Component " + component.getClientId(context)
+ + " has invalid actionListener value: "
+ + actionListener);
}
}
}
public static void setValueChangedListenerProperty(FacesContext context,
- UIComponent component,
- String valueChangedListener)
+ UIComponent component, String valueChangedListener)
{
if (valueChangedListener != null)
{
if (!(component instanceof EditableValueHolder))
{
- throw new IllegalArgumentException("Component " + component.getClientId(context) + " is no EditableValueHolder");
+ throw new IllegalArgumentException("Component "
+ + component.getClientId(context)
+ + " is no EditableValueHolder");
}
if (isValueReference(valueChangedListener))
{
- MethodBinding mb = context.getApplication().createMethodBinding(valueChangedListener,
- VALUE_LISTENER_ARGS);
+ MethodBinding mb = context.getApplication()
+ .createMethodBinding(valueChangedListener,
+ VALUE_LISTENER_ARGS);
/**
if(! Void.class.equals(mb.getType(context)))
{
@@ -336,11 +347,13 @@ public class UIComponentTagUtils
}
*/
- ((EditableValueHolder)component).setValueChangeListener(mb);
+ ((EditableValueHolder) component).setValueChangeListener(mb);
}
else
{
- log.severe("Component " + component.getClientId(context) + " has invalid valueChangedListener expression " + valueChangedListener);
+ log.severe("Component " + component.getClientId(context)
+ + " has invalid valueChangedListener expression "
+ + valueChangedListener);
}
}
}
Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/test/ClassElementHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/test/ClassElementHandler.java?rev=1200044&r1=1200043&r2=1200044&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/test/ClassElementHandler.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/test/ClassElementHandler.java Wed Nov 9 23:44:02 2011
@@ -38,7 +38,8 @@ public class ClassElementHandler extends
private List className = new ArrayList();
private StringBuffer buffer ;
- public ClassElementHandler(){
+ public ClassElementHandler()
+ {
elementName.add("component-class");
elementName.add("tag-class");
@@ -84,7 +85,8 @@ public class ClassElementHandler extends
throws SAXException
{
- if(clazz){
+ if(clazz)
+ {
className.add(buffer.toString());
clazz = false;
}
Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/BiLevelCacheMap.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/BiLevelCacheMap.java?rev=1200044&r1=1200043&r2=1200044&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/BiLevelCacheMap.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/BiLevelCacheMap.java Wed Nov 9 23:44:02 2011
@@ -67,14 +67,16 @@ public abstract class BiLevelCacheMap im
public boolean isEmpty()
{
- synchronized (_cacheL2) {
+ synchronized (_cacheL2)
+ {
return _cacheL1.isEmpty() && _cacheL2.isEmpty();
}
}
public void clear()
{
- synchronized (_cacheL2) {
+ synchronized (_cacheL2)
+ {
_cacheL1 = new HashMap(); // dafault size
_cacheL2.clear();
}
@@ -82,14 +84,16 @@ public abstract class BiLevelCacheMap im
public boolean containsKey(Object key)
{
- synchronized (_cacheL2) {
+ synchronized (_cacheL2)
+ {
return _cacheL1.containsKey(key) || _cacheL2.containsKey(key);
}
}
public boolean containsValue(Object value)
{
- synchronized (_cacheL2) {
+ synchronized (_cacheL2)
+ {
return _cacheL1.containsValue(value) || _cacheL2.containsValue(value);
}
}
@@ -117,14 +121,16 @@ public abstract class BiLevelCacheMap im
// Has another thread merged caches while we were waiting on the mutex? Then check L1 again
if (cacheL1 != _cacheL1)
{
- if ((retval = _cacheL1.get(key)) != null)
+ retval = _cacheL1.get(key);
+ if (retval != null)
{
// do not update miss count (it is not a miss anymore)
return retval;
}
}
- if ((retval = _cacheL2.get(key)) == null)
+ retval = _cacheL2.get(key);
+ if (retval == null)
{
retval = newInstance(key);
if (retval != null)
Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/ClassLoaderExtension.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/ClassLoaderExtension.java?rev=1200044&r1=1200043&r2=1200044&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/ClassLoaderExtension.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/ClassLoaderExtension.java Wed Nov 9 23:44:02 2011
@@ -23,14 +23,16 @@ package org.apache.myfaces.shared.util;
*
* @author Werner Punz
*/
-public class ClassLoaderExtension {
+public class ClassLoaderExtension
+{
/**
* standard forName for the loader
*
* @param name
* @return
*/
- public Class forName(String name) {
+ public Class forName(String name)
+ {
return null;
}
}
Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/ClassLoaderUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/ClassLoaderUtils.java?rev=1200044&r1=1200043&r2=1200044&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/ClassLoaderUtils.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/ClassLoaderUtils.java Wed Nov 9 23:44:02 2011
@@ -130,7 +130,6 @@ public final class ClassLoaderUtils
catch (ClassNotFoundException e)
{
// treat as though loader not set
- ;
}
if (clazz == null)
@@ -240,7 +239,8 @@ public final class ClassLoaderUtils
{
if (System.getSecurityManager() != null)
{
- try {
+ try
+ {
ClassLoader cl = AccessController.doPrivileged(new PrivilegedExceptionAction<ClassLoader>()
{
public ClassLoader run() throws PrivilegedActionException
Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/ClassUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/ClassUtils.java?rev=1200044&r1=1200043&r2=1200044&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/ClassUtils.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/ClassUtils.java Wed Nov 9 23:44:02 2011
@@ -126,7 +126,8 @@ public final class ClassUtils
//~ Methods ------------------------------------------------------------------------------------
- public synchronized static void addClassLoadingExtension(ClassLoaderExtension extension, boolean top) {
+ public synchronized static void addClassLoadingExtension(ClassLoaderExtension extension, boolean top)
+ {
/**
* now at the first look this looks somewhat strange
* but to get the best performance access we assign new native
@@ -138,11 +139,13 @@ public final class ClassUtils
ClassLoaderExtension [] retVal = new ClassLoaderExtension[classLoadingExtensions.length+1];
ArrayList extensions = new ArrayList(classLoadingExtensions.length+1);
- if(!top) {
+ if(!top)
+ {
extensions.addAll(Arrays.asList(classLoadingExtensions));
}
extensions.add(extension);
- if(top) {
+ if(top)
+ {
extensions.addAll(Arrays.asList(classLoadingExtensions));
}
@@ -168,10 +171,12 @@ public final class ClassUtils
ClassLoaderExtension [] loaderPlugins = classLoadingExtensions;
int plugins = loaderPlugins.length;
- for(int cnt = 0; cnt < loaderPlugins.length; cnt ++) {
+ for(int cnt = 0; cnt < loaderPlugins.length; cnt ++)
+ {
ClassLoaderExtension extension = loaderPlugins[cnt];
Class retVal = extension.forName(type);
- if(retVal != null) {
+ if(retVal != null)
+ {
return retVal;
}
}
@@ -303,7 +308,8 @@ public final class ClassUtils
/**
* @param resource Name of resource(s) to find in classpath
- * @param defaultObject The default object to use to determine the class loader (if none associated with current thread.)
+ * @param defaultObject The default object to use to determine the class loader
+ * (if none associated with current thread.)
* @return Iterator over URL Objects
*/
public static Iterator getResources(String resource, Object defaultObject)
@@ -438,7 +444,8 @@ public final class ClassUtils
* Gets the ClassLoader associated with the current thread. Returns the class loader associated with
* the specified default object if no context loader is associated with the current thread.
*
- * @param defaultObject The default object to use to determine the class loader (if none associated with current thread.)
+ * @param defaultObject The default object to use to determine the class loader
+ * (if none associated with current thread.)
* @return ClassLoader
*/
protected static ClassLoader getCurrentLoader(Object defaultObject)
@@ -474,7 +481,8 @@ public final class ClassUtils
* @param defaultObject The default implementation for the given ApplicationObject.
* @return
*/
- public static <T> T buildApplicationObject(Class<T> interfaceClass, Collection<String> classNamesIterator, T defaultObject)
+ public static <T> T buildApplicationObject(Class<T> interfaceClass,
+ Collection<String> classNamesIterator, T defaultObject)
{
return buildApplicationObject(interfaceClass, null, null, classNamesIterator, defaultObject);
}
Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/ExceptionUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/ExceptionUtils.java?rev=1200044&r1=1200043&r2=1200044&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/ExceptionUtils.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/ExceptionUtils.java Wed Nov 9 23:44:02 2011
@@ -36,8 +36,9 @@ public final class ExceptionUtils
/**
* <p>
* returns a list of all throwables (including the one you passed in) wrapped by the given throwable.
- * In contrast to a simple call to <code>getClause()</code> on each throwable it will also check if the throwable class
- * contain a method <code>getRootCause()</code> (e.g. ServletException or JspException) and call it instead.
+ * In contrast to a simple call to <code>getClause()</code> on each throwable it will also check if
+ * the throwable class contain a method <code>getRootCause()</code> (e.g. ServletException or JspException)
+ * and call it instead.
* </p>
* <p>
* The first list element will your passed in exception, the last list element is the cause.
Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/HashMapUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/HashMapUtils.java?rev=1200044&r1=1200043&r2=1200044&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/HashMapUtils.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/HashMapUtils.java Wed Nov 9 23:44:02 2011
@@ -76,7 +76,8 @@ public class HashMapUtils
/**
* spit out each name/value pair
*/
- public static String mapToString(Map map){
+ public static String mapToString(Map map)
+ {
Set entries = map.entrySet();
Iterator iter = entries.iterator();
StringBuffer buff = new StringBuffer();
Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/LocaleUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/LocaleUtils.java?rev=1200044&r1=1200043&r2=1200044&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/LocaleUtils.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/LocaleUtils.java Wed Nov 9 23:44:02 2011
@@ -53,14 +53,16 @@ public final class LocaleUtils
Locale locale = Locale.getDefault();
if(log.isLoggable(Level.WARNING))
{
- log.warning("Locale name in faces-config.xml null or empty, setting locale to default locale : " + locale.toString());
+ log.warning("Locale name in faces-config.xml null or empty, setting locale to default locale : "
+ + locale.toString());
}
return locale;
}
int separatorCountry = localeString.indexOf('_');
char separator;
- if (separatorCountry >= 0) {
+ if (separatorCountry >= 0)
+ {
separator = '_';
}
else
@@ -69,11 +71,14 @@ public final class LocaleUtils
separator = '-';
}
- String language, country, variant;
+ String language;
+ String country;
+ String variant;
if (separatorCountry < 0)
{
language = localeString;
- country = variant = "";
+ country = "";
+ variant = "";
}
else
{
Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/MessageUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/MessageUtils.java?rev=1200044&r1=1200043&r2=1200044&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/MessageUtils.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/MessageUtils.java Wed Nov 9 23:44:02 2011
@@ -200,7 +200,8 @@ public final class MessageUtils
String forClientId,
FacesContext facesContext)
{
- if(log.isLoggable(Level.FINEST)) {
+ if(log.isLoggable(Level.FINEST))
+ {
log.finest("adding message " + messageId + " for clientId " + forClientId);
}
facesContext.addMessage(forClientId,
@@ -214,7 +215,8 @@ public final class MessageUtils
String forClientId,
FacesContext facesContext)
{
- if(log.isLoggable(Level.FINEST)) {
+ if(log.isLoggable(Level.FINEST))
+ {
log.finest("adding message " + messageId + " for clientId " + forClientId);
}
facesContext.addMessage(forClientId,
@@ -262,7 +264,8 @@ public final class MessageUtils
{
locale = Locale.getDefault();
}
- } else
+ }
+ else
{
locale = Locale.getDefault();
}
@@ -280,10 +283,12 @@ public final class MessageUtils
{
try
{
- bundle = ResourceBundle.getBundle(bundleName, locale, org.apache.myfaces.shared.util.ClassUtils.getCurrentLoader(bundleName));
+ bundle = ResourceBundle.getBundle(bundleName, locale,
+ org.apache.myfaces.shared.util.ClassUtils.getCurrentLoader(bundleName));
summary = bundle.getString(messageId);
}
- catch (MissingResourceException e) {
+ catch (MissingResourceException e)
+ {
// NoOp
}
}
@@ -292,14 +297,16 @@ public final class MessageUtils
{
try
{
- bundle = ResourceBundle.getBundle(DEFAULT_BUNDLE, locale, org.apache.myfaces.shared.util.ClassUtils.getCurrentLoader(DEFAULT_BUNDLE));
+ bundle = ResourceBundle.getBundle(DEFAULT_BUNDLE, locale,
+ org.apache.myfaces.shared.util.ClassUtils.getCurrentLoader(DEFAULT_BUNDLE));
if(bundle == null)
{
throw new NullPointerException();
}
summary = bundle.getString(messageId);
}
- catch(MissingResourceException e) {
+ catch(MissingResourceException e)
+ {
// NoOp
}
}
@@ -320,7 +327,8 @@ public final class MessageUtils
{
detail = bundle.getString(messageId + DETAIL_SUFFIX);
}
- catch(MissingResourceException e) {
+ catch(MissingResourceException e)
+ {
// NoOp
}
return new ParametrizableFacesMessage(summary, detail, params, locale);
@@ -333,14 +341,16 @@ public final class MessageUtils
detail = substituteParams(locale,
bundle.getString(messageId + DETAIL_SUFFIX), params);
}
- catch(MissingResourceException e) {
+ catch(MissingResourceException e)
+ {
// NoOp
}
return new FacesMessage(summary, detail);
}
}
- public static FacesMessage getMessageFromBundle(String bundleBaseName, FacesContext context, Locale locale, String messageId, Object params[])
+ public static FacesMessage getMessageFromBundle(String bundleBaseName,
+ FacesContext context, Locale locale, String messageId, Object params[])
{
String summary = null;
String detail = null;
@@ -351,10 +361,12 @@ public final class MessageUtils
{
try
{
- bundle = ResourceBundle.getBundle(bundleName, locale, org.apache.myfaces.shared.util.ClassUtils.getCurrentLoader(bundleName));
+ bundle = ResourceBundle.getBundle(bundleName, locale,
+ org.apache.myfaces.shared.util.ClassUtils.getCurrentLoader(bundleName));
summary = bundle.getString(messageId);
}
- catch (MissingResourceException e) {
+ catch (MissingResourceException e)
+ {
// NoOp
}
}
@@ -363,14 +375,16 @@ public final class MessageUtils
{
try
{
- bundle = ResourceBundle.getBundle(bundleBaseName, locale, org.apache.myfaces.shared.util.ClassUtils.getCurrentLoader(bundleBaseName));
+ bundle = ResourceBundle.getBundle(bundleBaseName, locale,
+ org.apache.myfaces.shared.util.ClassUtils.getCurrentLoader(bundleBaseName));
if(bundle == null)
{
throw new NullPointerException();
}
summary = bundle.getString(messageId);
}
- catch(MissingResourceException e) {
+ catch(MissingResourceException e)
+ {
// NoOp
}
}
@@ -379,14 +393,16 @@ public final class MessageUtils
{
try
{
- bundle = ResourceBundle.getBundle(DEFAULT_BUNDLE, locale, org.apache.myfaces.shared.util.ClassUtils.getCurrentLoader(DEFAULT_BUNDLE));
+ bundle = ResourceBundle.getBundle(DEFAULT_BUNDLE, locale,
+ org.apache.myfaces.shared.util.ClassUtils.getCurrentLoader(DEFAULT_BUNDLE));
if(bundle == null)
{
throw new NullPointerException();
}
summary = bundle.getString(messageId);
}
- catch(MissingResourceException e) {
+ catch(MissingResourceException e)
+ {
// NoOp
}
}
@@ -408,7 +424,8 @@ public final class MessageUtils
{
detail = bundle.getString(messageId + DETAIL_SUFFIX);
}
- catch(MissingResourceException e) {
+ catch(MissingResourceException e)
+ {
// NoOp
}
return new ParametrizableFacesMessage(summary, detail, params, locale);
@@ -421,7 +438,8 @@ public final class MessageUtils
detail = substituteParams(locale,
bundle.getString(messageId + DETAIL_SUFFIX), params);
}
- catch(MissingResourceException e) {
+ catch(MissingResourceException e)
+ {
// NoOp
}
return new FacesMessage(summary, detail);
@@ -446,11 +464,13 @@ public final class MessageUtils
*
* @return currently applicable Locale for this request.
*/
- public static Locale getCurrentLocale() {
+ public static Locale getCurrentLocale()
+ {
return getCurrentLocale(FacesContext.getCurrentInstance());
}
- public static Locale getCurrentLocale(FacesContext context) {
+ public static Locale getCurrentLocale(FacesContext context)
+ {
Locale locale;
if(context != null && context.getViewRoot() != null)
{
@@ -475,7 +495,8 @@ public final class MessageUtils
* @param params parameters to set at localized message
* @return generated FacesMessage
*/
- public static FacesMessage getMessage(FacesMessage.Severity severity, String bundleBaseName, String messageId, Object params[])
+ public static FacesMessage getMessage(FacesMessage.Severity severity, String bundleBaseName,
+ String messageId, Object params[])
{
FacesMessage msg = getMessage(bundleBaseName, messageId, params);
msg.setSeverity(severity);
@@ -521,7 +542,8 @@ public final class MessageUtils
{
summary = bundle.getString(messageId);
}
- catch (MissingResourceException e) {
+ catch (MissingResourceException e)
+ {
// NoOp
}
@@ -538,7 +560,8 @@ public final class MessageUtils
detail = substituteParams(bundle.getLocale(),
bundle.getString(messageId + DETAIL_SUFFIX), params);
}
- catch(MissingResourceException e) {
+ catch(MissingResourceException e)
+ {
// NoOp
}
@@ -583,7 +606,8 @@ public final class MessageUtils
if(message != null)
{
return message;
- } else
+ }
+ else
{
// TODO /FIX: Note that this has fallback behavior to default Locale for message,
// but similar behavior above does not. The methods should probably behave
@@ -592,7 +616,8 @@ public final class MessageUtils
}
}
- public static FacesMessage getMessage(String bundleBaseName, FacesContext context, String messageId, Object params[])
+ public static FacesMessage getMessage(String bundleBaseName, FacesContext context,
+ String messageId, Object params[])
{
if(context == null || messageId == null)
{
@@ -607,7 +632,8 @@ public final class MessageUtils
if(message != null)
{
return message;
- } else
+ }
+ else
{
// TODO /FIX: Note that this has fallback behavior to default Locale for message,
// but similar behavior above does not. The methods should probably behave
@@ -616,7 +642,8 @@ public final class MessageUtils
}
}
- public static Object getLabel(FacesContext facesContext, UIComponent component) {
+ public static Object getLabel(FacesContext facesContext, UIComponent component)
+ {
Object label = component.getAttributes().get("label");
if(label != null)
{
@@ -639,9 +666,11 @@ public final class MessageUtils
if(context != null)
{
return context.getApplication();
- } else
+ }
+ else
{
- ApplicationFactory afactory = (ApplicationFactory)FactoryFinder.getFactory("javax.faces.application.ApplicationFactory");
+ ApplicationFactory afactory = (ApplicationFactory)FactoryFinder.getFactory(
+ "javax.faces.application.ApplicationFactory");
return afactory.getApplication();
}
}
Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/NullEnumeration.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/NullEnumeration.java?rev=1200044&r1=1200043&r2=1200044&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/NullEnumeration.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/NullEnumeration.java Wed Nov 9 23:44:02 2011
@@ -29,11 +29,11 @@ import java.util.NoSuchElementException;
*/
public final class NullEnumeration implements Enumeration
{
- private static final NullEnumeration s_nullEnumeration = new NullEnumeration();
+ private static final NullEnumeration NULL_ENUMERATION = new NullEnumeration();
public static final NullEnumeration instance()
{
- return s_nullEnumeration;
+ return NULL_ENUMERATION;
}
public boolean hasMoreElements()
Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/SelectItemsIterator.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/SelectItemsIterator.java?rev=1200044&r1=1200043&r2=1200044&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/SelectItemsIterator.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/SelectItemsIterator.java Wed Nov 9 23:44:02 2011
@@ -69,7 +69,8 @@ public class SelectItemsIterator impleme
public SelectItemsIterator(UIComponent selectItemsParent, FacesContext facesContext)
{
- _children = selectItemsParent.getChildCount() > 0 ? selectItemsParent.getChildren().iterator() : _EMPTY_UICOMPONENT_ITERATOR;
+ _children = selectItemsParent.getChildCount() > 0 ?
+ selectItemsParent.getChildren().iterator() : _EMPTY_UICOMPONENT_ITERATOR;
_facesContext = facesContext;
}
@@ -136,7 +137,8 @@ public class SelectItemsIterator impleme
ValueExpression expression = uiSelectItem.getValueExpression("value");
throw new IllegalArgumentException("ValueExpression '"
+ (expression == null ? null : expression.getExpressionString()) + "' of UISelectItem : "
- + RendererUtils.getPathToComponent(child) + " does not reference an Object of type SelectItem");
+ + RendererUtils.getPathToComponent(child) +
+ " does not reference an Object of type SelectItem");
}
_nextItem = (SelectItem) item;
return true;
Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/StateUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/StateUtils.java?rev=1200044&r1=1200043&r2=1200044&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/StateUtils.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/StateUtils.java Wed Nov 9 23:44:02 2011
@@ -28,7 +28,6 @@ import java.security.AccessController;
import java.security.NoSuchAlgorithmException;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
-import java.util.Arrays;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -89,7 +88,8 @@ import org.apache.myfaces.shared.util.se
* @author Dennis C. Byrne
* @see org.apache.myfaces.webapp.StartupServletContextListener
*/
-public final class StateUtils {
+public final class StateUtils
+{
//private static final Log log = LogFactory.getLog(StateUtils.class);
private static final Logger log = Logger.getLogger(StateUtils.class.getName());
@@ -104,7 +104,8 @@ public final class StateUtils {
/**
* Indicate if the view state is encrypted or not. By default, encryption is enabled.
*/
- @JSFWebConfigParam(name="org.apache.myfaces.USE_ENCRYPTION",since="1.1",defaultValue="true",expectedValues="true,false",group="state")
+ @JSFWebConfigParam(name="org.apache.myfaces.USE_ENCRYPTION",since="1.1",
+ defaultValue="true",expectedValues="true,false",group="state")
public static final String USE_ENCRYPTION = INIT_PREFIX + "USE_ENCRYPTION";
/**
@@ -119,7 +120,8 @@ public final class StateUtils {
/**
* Indicate the encryption algorithm used for encrypt the view state.
*/
- @JSFWebConfigParam(name="org.apache.myfaces.ALGORITHM",since="1.1",defaultValue="DES",group="state",tags="performance")
+ @JSFWebConfigParam(name="org.apache.myfaces.ALGORITHM",since="1.1",
+ defaultValue="DES",group="state",tags="performance")
public static final String INIT_ALGORITHM = INIT_PREFIX + "ALGORITHM";
/**
@@ -138,7 +140,8 @@ public final class StateUtils {
/**
* Defines the default mode and padding used for the encryption algorithm
*/
- @JSFWebConfigParam(name="org.apache.myfaces.ALGORITHM.PARAMETERS",since="1.1",defaultValue="ECB/PKCS5Padding",group="state")
+ @JSFWebConfigParam(name="org.apache.myfaces.ALGORITHM.PARAMETERS",since="1.1",
+ defaultValue="ECB/PKCS5Padding",group="state")
public static final String INIT_ALGORITHM_PARAM = INIT_ALGORITHM + ".PARAMETERS";
/**
@@ -152,7 +155,8 @@ public final class StateUtils {
/**
* Indicate if the view state should be compressed before encrypted(optional) and encoded
*/
- @JSFWebConfigParam(name="org.apache.myfaces.COMPRESS_STATE_IN_CLIENT",since="1.1",defaultValue="false",expectedValues="true,false",group="state",tags="performance")
+ @JSFWebConfigParam(name="org.apache.myfaces.COMPRESS_STATE_IN_CLIENT",since="1.1",defaultValue="false",
+ expectedValues="true,false",group="state",tags="performance")
public static final String COMPRESS_STATE_IN_CLIENT = INIT_PREFIX + "COMPRESS_STATE_IN_CLIENT";
public static final String DEFAULT_MAC_ALGORITHM = "HmacSHA1";
@@ -161,7 +165,8 @@ public final class StateUtils {
* Indicate the algorithm used to calculate the Message Authentication Code that is
* added to the view state.
*/
- @JSFWebConfigParam(name="org.apache.myfaces.MAC_ALGORITHM",defaultValue="HmacSHA1",group="state",tags="performance")
+ @JSFWebConfigParam(name="org.apache.myfaces.MAC_ALGORITHM",defaultValue="HmacSHA1",
+ group="state",tags="performance")
public static final String INIT_MAC_ALGORITHM = "org.apache.myfaces.MAC_ALGORITHM";
/**
@@ -184,7 +189,8 @@ public final class StateUtils {
//nope
}
- private static void testConfiguration(ExternalContext ctx){
+ private static void testConfiguration(ExternalContext ctx)
+ {
String algorithmParams = ctx.getInitParameter(INIT_ALGORITHM_PARAM);
@@ -237,7 +243,8 @@ public final class StateUtils {
* This fires during the Render Response phase, saving state.
*/
- public static final String construct(Object object, ExternalContext ctx){
+ public static final String construct(Object object, ExternalContext ctx)
+ {
byte[] bytes = getAsByteArray(object, ctx);
if( enableCompression(ctx) )
{
@@ -559,7 +566,8 @@ public final class StateUtils {
{
//Put IOException and ClassNotFoundException as "checked" exceptions,
//so AccessController wrap them in a PrivilegedActionException
- public Object run() throws PrivilegedActionException, IOException, ClassNotFoundException
+ public Object run() throws PrivilegedActionException,
+ IOException, ClassNotFoundException
{
return ois.readObject();
}
@@ -650,25 +658,27 @@ public final class StateUtils {
System.out.println(new String(bytes, ZIP_CHARSET));
}
- private static byte[] findInitializationVector(ExternalContext ctx) {
+ private static byte[] findInitializationVector(ExternalContext ctx)
+ {
byte[] iv = null;
- String _iv = ctx.getInitParameter(INIT_ALGORITHM_IV);
+ String ivString = ctx.getInitParameter(INIT_ALGORITHM_IV);
- if(_iv == null)
+ if(ivString == null)
{
- _iv = ctx.getInitParameter(INIT_ALGORITHM_IV.toLowerCase());
+ ivString = ctx.getInitParameter(INIT_ALGORITHM_IV.toLowerCase());
}
- if (_iv != null)
+ if (ivString != null)
{
- iv = new Base64().decode(_iv.getBytes());
+ iv = new Base64().decode(ivString.getBytes());
}
return iv;
}
- private static String findAlgorithmParams(ExternalContext ctx) {
+ private static String findAlgorithmParams(ExternalContext ctx)
+ {
String algorithmParams = ctx.getInitParameter(INIT_ALGORITHM_PARAM);
@@ -690,7 +700,8 @@ public final class StateUtils {
return algorithmParams;
}
- private static String findAlgorithm(ExternalContext ctx) {
+ private static String findAlgorithm(ExternalContext ctx)
+ {
String algorithm = ctx.getInitParameter(INIT_ALGORITHM);
@@ -702,7 +713,8 @@ public final class StateUtils {
return findAlgorithm( algorithm );
}
- private static String findAlgorithm(ServletContext ctx) {
+ private static String findAlgorithm(ServletContext ctx)
+ {
String algorithm = ctx.getInitParameter(INIT_ALGORITHM);
@@ -714,7 +726,8 @@ public final class StateUtils {
return findAlgorithm( algorithm );
}
- private static String findAlgorithm(String initParam) {
+ private static String findAlgorithm(String initParam)
+ {
if (initParam == null)
{
@@ -740,7 +753,8 @@ public final class StateUtils {
* stored in application scope where it can be used for all requests.
*/
- public static void initSecret(ServletContext ctx){
+ public static void initSecret(ServletContext ctx)
+ {
if(ctx == null)
{
@@ -764,7 +778,8 @@ public final class StateUtils {
{
String algorithm = findAlgorithm(ctx);
// you want to create this as few times as possible
- ctx.setAttribute(INIT_SECRET_KEY_CACHE, new SecretKeySpec(findSecret(ctx, algorithm), algorithm));
+ ctx.setAttribute(INIT_SECRET_KEY_CACHE, new SecretKeySpec(
+ findSecret(ctx, algorithm), algorithm));
}
if (log.isLoggable(Level.FINE))
@@ -783,7 +798,8 @@ public final class StateUtils {
{
String macAlgorithm = findMacAlgorithm(ctx);
// init mac secret and algorithm
- ctx.setAttribute(INIT_MAC_SECRET_KEY_CACHE, new SecretKeySpec(findMacSecret(ctx, macAlgorithm), macAlgorithm));
+ ctx.setAttribute(INIT_MAC_SECRET_KEY_CACHE, new SecretKeySpec(
+ findMacSecret(ctx, macAlgorithm), macAlgorithm));
}
}
@@ -860,7 +876,8 @@ public final class StateUtils {
return findSecret(secret, algorithm);
}
- private static byte[] findSecret(String secret, String algorithm) {
+ private static byte[] findSecret(String secret, String algorithm)
+ {
byte[] bytes = null;
if(secret == null)
@@ -896,7 +913,8 @@ public final class StateUtils {
return bytes;
}
- private static String findMacAlgorithm(ExternalContext ctx) {
+ private static String findMacAlgorithm(ExternalContext ctx)
+ {
String algorithm = ctx.getInitParameter(INIT_MAC_ALGORITHM);
@@ -909,7 +927,8 @@ public final class StateUtils {
}
- private static String findMacAlgorithm(ServletContext ctx) {
+ private static String findMacAlgorithm(ServletContext ctx)
+ {
String algorithm = ctx.getInitParameter(INIT_MAC_ALGORITHM);
@@ -922,7 +941,8 @@ public final class StateUtils {
}
- private static String findMacAlgorithm(String initParam) {
+ private static String findMacAlgorithm(String initParam)
+ {
if (initParam == null)
{
@@ -1011,7 +1031,8 @@ public final class StateUtils {
return findMacSecret(secret, algorithm);
}
- private static byte[] findMacSecret(String secret, String algorithm) {
+ private static byte[] findMacSecret(String secret, String algorithm)
+ {
byte[] bytes = null;
if(secret == null)
Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/StringUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/StringUtils.java?rev=1200044&r1=1200043&r2=1200044&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/StringUtils.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/StringUtils.java Wed Nov 9 23:44:02 2011
@@ -18,8 +18,6 @@
*/
package org.apache.myfaces.shared.util;
-import org.apache.myfaces.shared.util.ArrayUtils;
-
import java.util.ArrayList;
@@ -267,31 +265,33 @@ public final class StringUtils
return "";
}
- int end_ = str.indexOf(quote, begin);
+ int endInt = str.indexOf(quote, begin);
// If no quotes, return the original string
// and save StringBuffer allocation/char copying
- if (end_ < 0)
+ if (endInt < 0)
{
return str.substring(begin, end);
}
StringBuffer sb = new StringBuffer(end - begin);
- int begin_ = begin; // need begin later
- for (; (end_ >= 0) && (end_ < end);
- end_ = str.indexOf(quote, begin_ = end_ + 2))
+ int beginInt = begin; // need begin later
+ do
{
- if (((end_ + 1) >= end) || (str.charAt(end_ + 1) != quote))
+ if (((endInt + 1) >= end) || (str.charAt(endInt + 1) != quote))
{
throw new IllegalArgumentException(
"Internal quote not doubled in string '"
+ str.substring(begin, end) + "'");
}
- sb.append(substring(str, begin_, end_)).append(quote);
+ sb.append(substring(str, beginInt, endInt)).append(quote);
+ beginInt = endInt + 2;
+ endInt = str.indexOf(quote, beginInt);
}
+ while ((endInt >= 0) && (endInt < end));
- return sb.append(substring(str, begin_, end)).toString();
+ return sb.append(substring(str, beginInt, end)).toString();
}
/**
@@ -330,15 +330,15 @@ public final class StringUtils
return str.substring(begin, end);
}
- int _end = end - 1;
- if ((str.length() < 2) || (str.charAt(_end) != quote))
+ int endInt = end - 1;
+ if ((str.length() < 2) || (str.charAt(endInt) != quote))
{
throw new IllegalArgumentException(
"Closing quote missing in string '"
+ substring(str, begin, end) + "'");
}
- return dequote(str, begin + 1, _end, quote);
+ return dequote(str, begin + 1, endInt, quote);
}
public static String replace(String str, String repl, String with)
@@ -358,9 +358,11 @@ public final class StringUtils
StringBuffer out =
new StringBuffer((lendiff <= 0) ? str.length()
: (str.length() + (10 * lendiff)));
- for (; pos >= 0; pos = str.indexOf(repl, lastindex = pos + len))
+ while(pos >= 0)
{
out.append(substring(str, lastindex, pos)).append(with);
+ lastindex = pos + len;
+ pos = str.indexOf(repl, lastindex);
}
return out.append(substring(str, lastindex, str.length())).toString();
@@ -383,9 +385,11 @@ public final class StringUtils
new StringBuffer((lendiff <= 0) ? str.length()
: (str.length() + (10 * lendiff)));
int lastindex = 0;
- for (; pos >= 0; pos = str.indexOf(repl, lastindex = pos + 1))
+ while( pos >= 0)
{
out.append(substring(str, lastindex, pos)).append(with);
+ lastindex = pos + 1;
+ pos = str.indexOf(repl, lastindex);
}
return out.append(substring(str, lastindex, len)).toString();
@@ -396,11 +400,13 @@ public final class StringUtils
{
int lastindex = 0;
int len = repl.length();
- for (int index = s.indexOf(repl); index >= 0;
- index = s.indexOf(repl, lastindex = index + len))
+ int index = s.indexOf(repl);
+ while (index >= 0)
{
// we have search string at position index
out.append(substring(s, lastindex, index)).append(with);
+ lastindex = index + len;
+ index = s.indexOf(repl, lastindex);
}
return out.append(substring(s, lastindex, len));
@@ -417,21 +423,23 @@ public final class StringUtils
*/
public static String[] splitLongString(String str, char separator)
{
- int len;
- if (str == null || (len = str.length()) == 0)
+ int len = (str == null) ? 0 : str.length();
+ if (str == null || len == 0)
{
return ArrayUtils.EMPTY_STRING_ARRAY;
}
int oldPos = 0;
ArrayList list = new ArrayList();
- for (
- int pos = str.indexOf(separator); pos >= 0;
- pos = str.indexOf(separator, (oldPos = (pos + 1))))
+ int pos = str.indexOf(separator);
+ while(pos >= 0)
{
list.add(substring(str, oldPos, pos));
+ oldPos = (pos + 1);
+ pos = str.indexOf(separator, oldPos);
}
+
list.add(substring(str, oldPos, len));
return (String[]) list.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
@@ -453,8 +461,8 @@ public final class StringUtils
public static String[] splitLongString(
String str, char separator, char quote)
{
- int len;
- if (str == null || (len = str.length()) == 0)
+ int len = (str == null) ? 0 : str.length();
+ if (str == null || len == 0)
{
return ArrayUtils.EMPTY_STRING_ARRAY;
}
@@ -518,8 +526,8 @@ public final class StringUtils
*/
public static String[] splitShortString(String str, char separator)
{
- int len;
- if (str == null || (len = str.length()) == 0)
+ int len = (str == null) ? 0 : str.length();
+ if (str == null || len == 0)
{
return org.apache.myfaces.shared.util.ArrayUtils.EMPTY_STRING_ARRAY;
}
@@ -540,11 +548,14 @@ public final class StringUtils
int oldPos = 0;
// Step 3: retrieve substrings
- for (
- int pos = str.indexOf(separator), i = 0; pos >= 0;
- pos = str.indexOf(separator, (oldPos = (pos + 1))))
+ int pos = str.indexOf(separator);
+ int i = 0;
+
+ while (pos >= 0)
{
list[i++] = substring(str, oldPos, pos);
+ oldPos = (pos + 1);
+ pos = str.indexOf(separator, oldPos);
}
list[lastTokenIndex] = substring(str, oldPos, len);
@@ -569,8 +580,8 @@ public final class StringUtils
public static String[] splitShortString(
String str, char separator, char quote)
{
- int len;
- if (str == null || (len = str.length()) == 0)
+ int len = (str == null) ? 0 : str.length();
+ if (str == null || len == 0)
{
return ArrayUtils.EMPTY_STRING_ARRAY;
}
Modified: myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/WebConfigParamUtils.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/WebConfigParamUtils.java?rev=1200044&r1=1200043&r2=1200044&view=diff
==============================================================================
--- myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/WebConfigParamUtils.java (original)
+++ myfaces/core/trunk/shared/src/main/java/org/apache/myfaces/shared/util/WebConfigParamUtils.java Wed Nov 9 23:44:02 2011
@@ -91,13 +91,15 @@ public final class WebConfigParamUtils
}
/**
- * Gets the String init parameter value from the specified context. If the parameter is an empty String or a String
+ * Gets the String init parameter value from the specified context. If the parameter is an
+ * empty String or a String
* containing only white space, this method returns <code>null</code>
*
* @param context
* the application's external context
* @param names
- * the init parameter's names, the first one is scanned first. Usually used when a param has multiple aliases
+ * the init parameter's names, the first one is scanned first. Usually used when a
+ * param has multiple aliases
*
* @return the parameter if it was specified and was not empty, <code>null</code> otherwise
*
@@ -110,13 +112,14 @@ public final class WebConfigParamUtils
}
/**
- * Gets the String init parameter value from the specified context. If the parameter is an empty String or a String
- * containing only white space, this method returns <code>null</code>
+ * Gets the String init parameter value from the specified context. If the parameter is an empty
+ * String or a String containing only white space, this method returns <code>null</code>
*
* @param context
* the application's external context
* @param names
- * the init parameter's names, the first one is scanned first. Usually used when a param has multiple aliases
+ * the init parameter's names, the first one is scanned first. Usually used when a param has
+ * multiple aliases
* @param defaultValue
* the value by default if null or empty
*
@@ -222,7 +225,8 @@ public final class WebConfigParamUtils
}
/**
- * Gets the boolean init parameter value from the specified context. If the parameter was not specified, the default
+ * Gets the boolean init parameter value from the specified context. If the parameter
+ * was not specified, the default
* value is used instead.
*
* @param context
@@ -243,7 +247,8 @@ public final class WebConfigParamUtils
* @throws NullPointerException
* if context or name is <code>null</code>
*/
- public static boolean getBooleanInitParameter(ExternalContext context, String name, boolean defaultValue, String [] valuesIgnoreCase, boolean returnOnValueEqualsIgnoreCase)
+ public static boolean getBooleanInitParameter(ExternalContext context, String name,
+ boolean defaultValue, String [] valuesIgnoreCase, boolean returnOnValueEqualsIgnoreCase)
{
if (name == null)
{
@@ -276,8 +281,8 @@ public final class WebConfigParamUtils
}
/**
- * Gets the boolean init parameter value from the specified context. If the parameter was not specified, the default
- * value is used instead.
+ * Gets the boolean init parameter value from the specified context. If the parameter was not specified,
+ * the default value is used instead.
*
* @param context
* the application's external context
@@ -296,8 +301,8 @@ public final class WebConfigParamUtils
}
/**
- * Gets the boolean init parameter value from the specified context. If the parameter was not specified, the default
- * value is used instead.
+ * Gets the boolean init parameter value from the specified context. If the parameter was not specified,
+ * the default value is used instead.
*
* @param context
* the application's external context
@@ -343,8 +348,8 @@ public final class WebConfigParamUtils
}
/**
- * Gets the boolean init parameter value from the specified context. If the parameter was not specified, the default
- * value is used instead.
+ * Gets the boolean init parameter value from the specified context. If the parameter was not specified,
+ * the default value is used instead.
*
* @param context
* the application's external context
@@ -363,7 +368,8 @@ public final class WebConfigParamUtils
* if context or name is <code>null</code>
*/
- public static boolean getBooleanInitParameter(ExternalContext context, String[] names, boolean defaultValue, String [] valuesIgnoreCase, boolean returnOnValueEqualsIgnoreCase)
+ public static boolean getBooleanInitParameter(ExternalContext context, String[] names, boolean defaultValue,
+ String [] valuesIgnoreCase, boolean returnOnValueEqualsIgnoreCase)
{
if (names == null)
{
@@ -409,8 +415,8 @@ public final class WebConfigParamUtils
}
/**
- * Gets the int init parameter value from the specified context. If the parameter was not specified, the default
- * value is used instead.
+ * Gets the int init parameter value from the specified context. If the parameter was not
+ * specified, the default value is used instead.
*
* @param context
* the application's external context
@@ -432,8 +438,8 @@ public final class WebConfigParamUtils
}
/**
- * Gets the int init parameter value from the specified context. If the parameter was not specified, the default
- * value is used instead.
+ * Gets the int init parameter value from the specified context. If the parameter was not specified,
+ * the default value is used instead.
*
* @param context
* the application's external context
@@ -468,8 +474,8 @@ public final class WebConfigParamUtils
}
/**
- * Gets the int init parameter value from the specified context. If the parameter was not specified, the default
- * value is used instead.
+ * Gets the int init parameter value from the specified context. If the parameter was not specified,
+ * the default value is used instead.
*
* @param context
* the application's external context
@@ -662,8 +668,8 @@ public final class WebConfigParamUtils
}
/**
- * Gets the init parameter value from the specified context and instanciate it. If the parameter was not specified,
- * the default value is used instead.
+ * Gets the init parameter value from the specified context and instanciate it.
+ * If the parameter was not specified, the default value is used instead.
*
* @param context
* the application's external context
@@ -680,7 +686,8 @@ public final class WebConfigParamUtils
* if context or name is <code>null</code>
*/
@SuppressWarnings("unchecked")
- public static <T> T getInstanceInitParameter(ExternalContext context, String name, String deprecatedName, T defaultValue)
+ public static <T> T getInstanceInitParameter(ExternalContext context, String name,
+ String deprecatedName, T defaultValue)
{
String param = getStringInitParameter(context, name, deprecatedName);
if (param == null)