You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2009/11/17 15:03:11 UTC
svn commit: r881294 - in /myfaces/tobago/trunk:
core/src/main/java/org/apache/myfaces/tobago/model/
core/src/main/java/org/apache/myfaces/tobago/renderkit/
core/src/main/java/org/apache/myfaces/tobago/util/
extension/deprecation/src/main/java/org/apach...
Author: lofwyr
Date: Tue Nov 17 14:03:10 2009
New Revision: 881294
URL: http://svn.apache.org/viewvc?rev=881294&view=rev
Log:
optimize code: replace new String[0] with ArrayUtils.EMPTY_STRING_ARRAY
Modified:
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/model/SelectItem.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/SelectManyRendererBase.java
myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
myfaces/tobago/trunk/extension/deprecation/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java
myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java
myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockHttpSession.java
myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.1.stg
myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.2.stg
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/model/SelectItem.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/model/SelectItem.java?rev=881294&r1=881293&r2=881294&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/model/SelectItem.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/model/SelectItem.java Tue Nov 17 14:03:10 2009
@@ -17,18 +17,15 @@
* limitations under the License.
*/
+import org.apache.commons.lang.ArrayUtils;
import org.apache.myfaces.tobago.component.SupportsMarkup;
-/*
- * Date: Apr 5, 2005
- * Time: 6:11:16 PM
- */
public class SelectItem extends javax.faces.model.SelectItem implements SupportsMarkup {
private static final long serialVersionUID = 2582455665060354639L;
private String image;
- private String[] markup = new String[0];
+ private String[] markup = ArrayUtils.EMPTY_STRING_ARRAY;
public SelectItem() {
super();
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/SelectManyRendererBase.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/SelectManyRendererBase.java?rev=881294&r1=881293&r2=881294&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/SelectManyRendererBase.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/renderkit/SelectManyRendererBase.java Tue Nov 17 14:03:10 2009
@@ -17,6 +17,7 @@
* limitations under the License.
*/
+import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.myfaces.tobago.util.ComponentUtils;
@@ -58,7 +59,7 @@
}
if (newValues == null) {
- newValues = new String[0]; // because no selection will not submitted by browsers
+ newValues = ArrayUtils.EMPTY_STRING_ARRAY; // because no selection will not submitted by browsers
}
uiSelectMany.setSubmittedValue(newValues);
}
Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java?rev=881294&r1=881293&r2=881294&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java Tue Nov 17 14:03:10 2009
@@ -22,6 +22,7 @@
* $Id$
*/
+import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -777,6 +778,7 @@
}
+ @Deprecated
public static String[] getMarkupBinding(FacesContext facesContext, SupportsMarkup component) {
ValueBinding vb = ((UIComponent) component).getValueBinding(Attributes.MARKUP);
if (vb != null) {
@@ -793,13 +795,13 @@
}
return result.toArray(new String[result.size()]);
} else if (markups == null) {
- return new String[0];
+ return ArrayUtils.EMPTY_STRING_ARRAY;
} else {
return new String[]{markups.toString()};
}
}
- return new String[0];
+ return ArrayUtils.EMPTY_STRING_ARRAY;
}
/**
Modified: myfaces/tobago/trunk/extension/deprecation/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/extension/deprecation/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java?rev=881294&r1=881293&r2=881294&view=diff
==============================================================================
--- myfaces/tobago/trunk/extension/deprecation/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java (original)
+++ myfaces/tobago/trunk/extension/deprecation/src/main/java/org/apache/myfaces/tobago/component/ComponentUtil.java Tue Nov 17 14:03:10 2009
@@ -399,6 +399,7 @@
}
}
+ @Deprecated
public static String[] getMarkupBinding(FacesContext facesContext, SupportsMarkup component) {
return ComponentUtils.getMarkupBinding(facesContext, component);
}
Modified: myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java?rev=881294&r1=881293&r2=881294&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java (original)
+++ myfaces/tobago/trunk/theme/scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/TabGroupRenderer.java Tue Nov 17 14:03:10 2009
@@ -22,6 +22,7 @@
* $Id$
*/
+import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.myfaces.tobago.ajax.api.AjaxRenderer;
@@ -116,7 +117,7 @@
final String switchType = tabGroup.getSwitchType();
if (TobagoConfig.getInstance(facesContext).isAjaxEnabled()) {
- HtmlRendererUtils.writeScriptLoader(facesContext, SCRIPTS, new String[0]);
+ HtmlRendererUtils.writeScriptLoader(facesContext, SCRIPTS, ArrayUtils.EMPTY_STRING_ARRAY);
}
TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
@@ -171,7 +172,7 @@
" '" + activeIndex + "', ",
" '" + tabGroup.getChildCount() + "');"
};
- HtmlRendererUtils.writeScriptLoader(facesContext, new String[0], cmds);
+ HtmlRendererUtils.writeScriptLoader(facesContext, ArrayUtils.EMPTY_STRING_ARRAY, cmds);
}
}
}
Modified: myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockHttpSession.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockHttpSession.java?rev=881294&r1=881293&r2=881294&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockHttpSession.java (original)
+++ myfaces/tobago/trunk/tobago-jsf-compat/src/test/java/org/apache/myfaces/tobago/mock/servlet/MockHttpSession.java Tue Nov 17 14:03:10 2009
@@ -18,6 +18,7 @@
*/
import org.apache.commons.collections.iterators.IteratorEnumeration;
+import org.apache.commons.lang.ArrayUtils;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
@@ -64,7 +65,7 @@
}
public String[] getValueNames() {
- return new String[0];
+ return ArrayUtils.EMPTY_STRING_ARRAY;
}
public void invalidate() {
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.1.stg
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.1.stg?rev=881294&r1=881293&r2=881294&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.1.stg (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.1.stg Tue Nov 17 14:03:10 2009
@@ -40,6 +40,13 @@
package <componentInfo.packageName>;
<componentInfo.imports:import(); separator="\n">
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.myfaces.tobago.layout.PixelMeasure;
+import java.util.ArrayList;
+import java.util.List;
+import javax.faces.FacesMessage;
+import javax.faces.validator.Validator;
+import javax.faces.validator.ValidatorException;
/**
* UIComponent class, generated from template {@code component1.1.stg} with class
@@ -110,7 +117,7 @@
if (isRequired() && empty && getRequiredMessage() != null) {
String requiredMessage = getRequiredMessage();
context.addMessage(this.getClientId(context),
- new javax.faces.application.FacesMessage(javax.faces.application.FacesMessage.SEVERITY_ERROR, requiredMessage, requiredMessage));
+ new FacesMessage(FacesMessage.SEVERITY_ERROR, requiredMessage, requiredMessage));
setValid(false);
return;
}
@@ -118,13 +125,13 @@
if (validatorMessage == null) {
super.validateValue(context, convertedValue);
} else {
- for (javax.faces.validator.Validator validator : getValidators()) {
+ for (Validator validator : getValidators()) {
try {
validator.validate(context, this, convertedValue);
- } catch (javax.faces.validator.ValidatorException e) {
+ } catch (ValidatorException e) {
setValid(false);
context.addMessage(getClientId(context),
- new javax.faces.application.FacesMessage(javax.faces.application.FacesMessage.SEVERITY_ERROR, validatorMessage, validatorMessage));
+ new FacesMessage(FacesMessage.SEVERITY_ERROR, validatorMessage, validatorMessage));
}
}
@@ -135,9 +142,9 @@
} catch (javax.faces.el.EvaluationException e) {
setValid(false);
Throwable cause = e.getCause();
- if (cause instanceof javax.faces.validator.ValidatorException) {
+ if (cause instanceof ValidatorException) {
context.addMessage(getClientId(context),
- new javax.faces.application.FacesMessage(javax.faces.application.FacesMessage.SEVERITY_ERROR, validatorMessage, validatorMessage));
+ new FacesMessage(FacesMessage.SEVERITY_ERROR, validatorMessage, validatorMessage));
} else {
throw e;
}
@@ -163,7 +170,7 @@
}
} catch (javax.faces.convert.ConverterException e) {
context.addMessage(getClientId(context),
- new javax.faces.application.FacesMessage(javax.faces.application.FacesMessage.SEVERITY_ERROR, converterMessage, converterMessage));
+ new FacesMessage(FacesMessage.SEVERITY_ERROR, converterMessage, converterMessage));
setValid(false);
}
return submittedValue;
@@ -263,7 +270,7 @@
return (String[]) strArray;
} else if (strArray instanceof String) {
String[] strings = ((String) strArray).split("[, ]");
- java.util.List\<String\> result = new java.util.ArrayList\<String\>(strings.length);
+ List\<String\> result = new ArrayList\<String\>(strings.length);
for (String string : strings) {
if (string.trim().length() != 0) {
result.add(string.trim());
@@ -271,12 +278,12 @@
}
return result.toArray(new String[result.size()]);
} else if (strArray == null) {
- return new String[0];
+ return ArrayUtils.EMPTY_STRING_ARRAY;
} else {
return new String[]{strArray.toString()};
}
}
- return new String[0];
+ return ArrayUtils.EMPTY_STRING_ARRAY;
}
public void set<property.upperCamelCaseName>(String[] <property.propertyName>) {
@@ -311,7 +318,7 @@
BooleanProperty(property) ::= <<
-public java.lang.Boolean get<property.upperCamelCaseName>() {
+public Boolean get<property.upperCamelCaseName>() {
if (<property.propertyName> != null) {
return <property.propertyName>;
}
@@ -329,7 +336,7 @@
<endif>
}
-public void set<property.upperCamelCaseName>(java.lang.Boolean <property.propertyName>) {
+public void set<property.upperCamelCaseName>(Boolean <property.propertyName>) {
this.<property.propertyName> = <property.propertyName>;
}
>>
@@ -411,7 +418,7 @@
Measure <property.propertyName> = (Measure) object;
return <property.propertyName>;
} else if (object instanceof Number) {
- return new org.apache.myfaces.tobago.layout.PixelMeasure(((Number)object).intValue());
+ return new PixelMeasure(((Number)object).intValue());
} else if (object instanceof String) {
return Measure.parse((String)object);
} else if (object != null) {
Modified: myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.2.stg
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.2.stg?rev=881294&r1=881293&r2=881294&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.2.stg (original)
+++ myfaces/tobago/trunk/tobago-tool/tobago-tool-apt/src/main/resources/org/apache/myfaces/tobago/apt/component1.2.stg Tue Nov 17 14:03:10 2009
@@ -40,6 +40,16 @@
package <componentInfo.packageName>;
<componentInfo.imports:import(); separator="\n">
+import org.apache.commons.lang.ArrayUtils;
+import org.apache.myfaces.tobago.component.MethodBindingToMethodExpression;
+import org.apache.myfaces.tobago.component.MethodExpressionToMethodBinding;
+import org.apache.myfaces.tobago.layout.PixelMeasure;
+import javax.el.ELException;
+import javax.faces.FacesException;
+import java.util.ArrayList;
+import java.util.List;
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
/**
* UIComponent class, generated from template {@code component1.2.stg} with class
@@ -111,8 +121,8 @@
if (number != null) {
return number.intValue();
}
- } catch (javax.el.ELException e) {
- throw new javax.faces.FacesException(e);
+ } catch (ELException e) {
+ throw new FacesException(e);
}
}
<if(property.defaultCode)>
@@ -137,8 +147,8 @@
if (ve != null) {
try {
return (<property.type>) <getValue(property)>
- } catch (javax.el.ELException e) {
- throw new javax.faces.FacesException(e);
+ } catch (ELException e) {
+ throw new FacesException(e);
}
}
return null;
@@ -163,7 +173,7 @@
return (String[]) strArray;
} else if (strArray instanceof String) {
String[] strings = ((String) strArray).split("[, ]");
- java.util.List\<String\> result = new java.util.ArrayList\<String\>(strings.length);
+ List\<String\> result = new ArrayList\<String\>(strings.length);
for (String string : strings) {
if (string.trim().length() != 0) {
result.add(string.trim());
@@ -171,15 +181,15 @@
}
return result.toArray(new String[result.size()]);
} else if (strArray == null) {
- return new String[0];
+ return ArrayUtils.EMPTY_STRING_ARRAY;
} else {
return new String[]{strArray.toString()};
}
- } catch (javax.el.ELException e) {
- throw new javax.faces.FacesException(e);
+ } catch (ELException e) {
+ throw new FacesException(e);
}
}
- return new String[0];
+ return ArrayUtils.EMPTY_STRING_ARRAY;
}
public void set<property.upperCamelCaseName>(String[] <property.propertyName>) {
@@ -200,8 +210,8 @@
if (bool != null) {
return bool;
}
- } catch (javax.el.ELException e) {
- throw new javax.faces.FacesException(e);
+ } catch (ELException e) {
+ throw new FacesException(e);
}
}
<if(property.defaultCode)>
@@ -218,7 +228,7 @@
BooleanProperty(property) ::= <<
-public java.lang.Boolean get<property.upperCamelCaseName>() {
+public Boolean get<property.upperCamelCaseName>() {
if (<property.propertyName> != null) {
return <property.propertyName>;
}
@@ -229,8 +239,8 @@
if (bool != null) {
return bool;
}
- } catch (javax.el.ELException e) {
- throw new javax.faces.FacesException(e);
+ } catch (ELException e) {
+ throw new FacesException(e);
}
}
<if(property.defaultCode)>
@@ -240,7 +250,7 @@
<endif>
}
-public void set<property.upperCamelCaseName>(java.lang.Boolean <property.propertyName>) {
+public void set<property.upperCamelCaseName>(Boolean <property.propertyName>) {
this.<property.propertyName> = <property.propertyName>;
}
>>
@@ -273,12 +283,12 @@
public <property.type> get<property.upperCamelCaseName>() {
<if(property.elAlternativeAvailable)>
- javax.el.MethodExpression expression = get<property.upperCamelCaseName>Expression();
- if (expression instanceof org.apache.myfaces.tobago.component.MethodBindingToMethodExpression) {
- return ((org.apache.myfaces.tobago.component.MethodBindingToMethodExpression)expression).getMethodBinding();
+ MethodExpression expression = get<property.upperCamelCaseName>Expression();
+ if (expression instanceof MethodBindingToMethodExpression) {
+ return ((MethodBindingToMethodExpression)expression).getMethodBinding();
}
if (expression != null) {
- return new org.apache.myfaces.tobago.component.MethodExpressionToMethodBinding(expression);
+ return new MethodExpressionToMethodBinding(expression);
}
return null;
<else>
@@ -290,7 +300,7 @@
public void set<property.upperCamelCaseName>(<property.type> <property.propertyName>) {
<if(property.elAlternativeAvailable)>
if (<property.propertyName> != null) {
- set<property.upperCamelCaseName>Expression(new org.apache.myfaces.tobago.component.MethodBindingToMethodExpression(<property.propertyName>));
+ set<property.upperCamelCaseName>Expression(new MethodBindingToMethodExpression(<property.propertyName>));
} else {
set<property.upperCamelCaseName>Expression(null);
}
@@ -329,8 +339,8 @@
<else>
return (<property.type>) <getValue(property)>
<endif>
- } catch (javax.el.ELException e) {
- throw new javax.faces.FacesException(e);
+ } catch (ELException e) {
+ throw new FacesException(e);
}
}
<if(property.defaultCode)>
@@ -359,14 +369,14 @@
Measure <property.propertyName> = (Measure) object;
return <property.propertyName>;
} else if (object instanceof Number) {
- return new org.apache.myfaces.tobago.layout.PixelMeasure(((Number)object).intValue());
+ return new PixelMeasure(((Number)object).intValue());
} else if (object instanceof String) {
return Measure.parse((String)object);
} else if (object != null) {
return Measure.parse(object.toString());
}
- } catch (javax.el.ELException e) {
- throw new javax.faces.FacesException(e);
+ } catch (ELException e) {
+ throw new FacesException(e);
}
}
<if(property.defaultCode)>
@@ -517,7 +527,7 @@
>>
getValueExpression(property) ::= <<
-javax.el.ValueExpression ve = getValueExpression("<property.name>");
+ValueExpression ve = getValueExpression("<property.name>");
>>
getValue(property) ::= <<