Author: mcucchiara
Date: Tue Oct 25 14:58:13 2011
New Revision: 1188685
URL: http://svn.apache.org/viewvc?rev=1188685&view=rev
Log:
Fixed checkstyle warning (added missing spaces, missing default case, etc.)
Modified:
commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ListPropertyAccessor.java
Modified:
commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ListPropertyAccessor.java
URL:
http://svn.apache.org/viewvc/commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ListPropertyAccessor.java?rev=1188685&r1=1188684&r2=1188685&view=diff
==============================================================================
---
commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ListPropertyAccessor.java
(original)
+++
commons/proper/ognl/trunk/src/main/java/org/apache/commons/ognl/ListPropertyAccessor.java
Tue Oct 25 14:58:13 2011
@@ -28,7 +28,7 @@ import java.util.Map;
/**
* Implementation of PropertyAccessor that uses numbers and dynamic subscripts
as properties to index into Lists.
- *
+ *
* @author Luke Blanshard ([email protected])
* @author Drew Davidson ([email protected])
*/
@@ -45,23 +45,23 @@ public class ListPropertyAccessor
if ( name instanceof String )
{
- Object result = null;
+ Object result;
if ( name.equals( "size" ) )
{
- result = Integer.valueOf( list.size() );
+ result = list.size( );
}
else
{
if ( name.equals( "iterator" ) )
{
- result = list.iterator();
+ result = list.iterator( );
}
else
{
if ( name.equals( "isEmpty" ) || name.equals( "empty" ) )
{
- result = list.isEmpty() ? Boolean.TRUE : Boolean.FALSE;
+ result = list.isEmpty( ) ? Boolean.TRUE :
Boolean.FALSE;
}
else
{
@@ -75,30 +75,24 @@ public class ListPropertyAccessor
if ( name instanceof Number )
{
- return list.get( ( (Number) name ).intValue() );
+ return list.get( ( (Number) name ).intValue( ) );
}
if ( name instanceof DynamicSubscript )
{
- int len = list.size();
- switch ( ( (DynamicSubscript) name ).getFlag() )
+ int len = list.size( );
+ switch ( ( (DynamicSubscript) name ).getFlag( ) )
{
case DynamicSubscript.FIRST:
- {
return len > 0 ? list.get( 0 ) : null;
- }
case DynamicSubscript.MID:
- {
return len > 0 ? list.get( len / 2 ) : null;
- }
case DynamicSubscript.LAST:
- {
return len > 0 ? list.get( len - 1 ) : null;
- }
case DynamicSubscript.ALL:
- {
return new ArrayList<Object>( list );
- }
+ default:
+ break;
}
}
@@ -109,25 +103,25 @@ public class ListPropertyAccessor
public void setProperty( Map<String, Object> context, Object target,
Object name, Object value )
throws OgnlException
{
- if ( name instanceof String && ( (String) name ).indexOf( "$" ) < 0 )
+ if ( name instanceof String && !( (String) name ).contains( "$" ) )
{
super.setProperty( context, target, name, value );
return;
}
@SuppressWarnings( "unchecked" ) // check performed by the invoker
- List<Object> list = (List<Object>) target;
+ List<Object> list = (List<Object>) target;
if ( name instanceof Number )
{
- list.set( ( (Number) name ).intValue(), value );
+ list.set( ( (Number) name ).intValue( ), value );
return;
}
if ( name instanceof DynamicSubscript )
{
- int len = list.size();
- switch ( ( (DynamicSubscript) name ).getFlag() )
+ int len = list.size( );
+ switch ( ( (DynamicSubscript) name ).getFlag( ) )
{
case DynamicSubscript.FIRST:
if ( len > 0 )
@@ -153,7 +147,7 @@ public class ListPropertyAccessor
{
throw new OgnlException( "Value must be a collection"
);
}
- list.clear();
+ list.clear( );
list.addAll( (Collection<?>) value );
return;
}
@@ -185,7 +179,9 @@ public class ListPropertyAccessor
}
if ( index instanceof Number )
+ {
return Object.class;
+ }
return null;
}
@@ -193,7 +189,7 @@ public class ListPropertyAccessor
@Override
public String getSourceAccessor( OgnlContext context, Object target,
Object index )
{
- String indexStr = index.toString().replaceAll( "\"", "" );
+ String indexStr = index.toString( ).replaceAll( "\"", "" );
if ( String.class.isInstance( index ) )
{
@@ -220,11 +216,11 @@ public class ListPropertyAccessor
// TODO: This feels really inefficient, must be some better way
// check if the index string represents a method on a custom class
implementing java.util.List instead..
- if ( context.getCurrentObject() != null && !Number.class.isInstance(
context.getCurrentObject() ) )
+ if ( context.getCurrentObject( ) != null && !Number.class.isInstance(
context.getCurrentObject( ) ) )
{
try
{
- Method m = OgnlRuntime.getReadMethod( target.getClass(),
indexStr );
+ Method m = OgnlRuntime.getReadMethod( target.getClass( ),
indexStr );
if ( m != null )
{
@@ -244,18 +240,17 @@ public class ListPropertyAccessor
// System.out.println("Curent type: " + context.getCurrentType() + "
current object type " +
// context.getCurrentObject().getClass());
- if ( !context.getCurrentType().isPrimitive() &&
Number.class.isAssignableFrom( context.getCurrentType() ) )
+ if ( !context.getCurrentType( ).isPrimitive( ) &&
Number.class.isAssignableFrom( context.getCurrentType( ) ) )
{
- indexStr += "." + OgnlRuntime.getNumericValueGetter(
context.getCurrentType() );
+ indexStr += "." + OgnlRuntime.getNumericValueGetter(
context.getCurrentType( ) );
}
- else if ( context.getCurrentObject() != null
- && Number.class.isAssignableFrom(
context.getCurrentObject().getClass() )
- && !context.getCurrentType().isPrimitive() )
+ else if ( context.getCurrentObject( ) != null &&
Number.class.isAssignableFrom(
+ context.getCurrentObject( ).getClass( ) ) &&
!context.getCurrentType( ).isPrimitive( ) )
{
// means it needs to be cast first as well
String toString =
- String.class.isInstance( index ) && context.getCurrentType()
!= Object.class ? "" : ".toString()";
+ String.class.isInstance( index ) && context.getCurrentType( )
!= Object.class ? "" : ".toString()";
indexStr = "org.apache.commons.ognl.OgnlOps#getIntValue(" +
indexStr + toString + ")";
}
@@ -268,7 +263,7 @@ public class ListPropertyAccessor
@Override
public String getSourceSetter( OgnlContext context, Object target, Object
index )
{
- String indexStr = index.toString().replaceAll( "\"", "" );
+ String indexStr = index.toString( ).replaceAll( "\"", "" );
// TODO: This feels really inefficient, must be some better way
// check if the index string represents a method on a custom class
implementing java.util.List instead..
@@ -278,16 +273,16 @@ public class ListPropertyAccessor
* Number.class.isInstance(context.getCurrentObject()));
*/
- if ( context.getCurrentObject() != null && !Number.class.isInstance(
context.getCurrentObject() ) )
+ if ( context.getCurrentObject( ) != null && !Number.class.isInstance(
context.getCurrentObject( ) ) )
{
try
{
- Method m = OgnlRuntime.getWriteMethod( target.getClass(),
indexStr );
+ Method m = OgnlRuntime.getWriteMethod( target.getClass( ),
indexStr );
- if ( m != null || !context.getCurrentType().isPrimitive() )
+ if ( m != null || !context.getCurrentType( ).isPrimitive( ) )
{
- System.out.println( "super source setter returned: "
- + super.getSourceSetter( context, target, index ) );
+ System.out.println(
+ "super source setter returned: " +
super.getSourceSetter( context, target, index ) );
return super.getSourceSetter( context, target, index );
}
@@ -306,18 +301,17 @@ public class ListPropertyAccessor
// need to convert to primitive for list index access
- if ( !context.getCurrentType().isPrimitive() &&
Number.class.isAssignableFrom( context.getCurrentType() ) )
+ if ( !context.getCurrentType( ).isPrimitive( ) &&
Number.class.isAssignableFrom( context.getCurrentType( ) ) )
{
- indexStr += "." + OgnlRuntime.getNumericValueGetter(
context.getCurrentType() );
+ indexStr += "." + OgnlRuntime.getNumericValueGetter(
context.getCurrentType( ) );
}
- else if ( context.getCurrentObject() != null
- && Number.class.isAssignableFrom(
context.getCurrentObject().getClass() )
- && !context.getCurrentType().isPrimitive() )
+ else if ( context.getCurrentObject( ) != null &&
Number.class.isAssignableFrom(
+ context.getCurrentObject( ).getClass( ) ) &&
!context.getCurrentType( ).isPrimitive( ) )
{
// means it needs to be cast first as well
String toString =
- String.class.isInstance( index ) && context.getCurrentType()
!= Object.class ? "" : ".toString()";
+ String.class.isInstance( index ) && context.getCurrentType( )
!= Object.class ? "" : ".toString()";
indexStr = "org.apache.commons.ognl.OgnlOps#getIntValue(" +
indexStr + toString + ")";
}