Skip to content
Permalink
Browse files
Use String.replace() instead of replaceAll() when we don't need a Regex.
  • Loading branch information
garydgregory committed Feb 28, 2021
1 parent 718f3d2 commit afc1f9beccc1beee119bee3722efdf876bb77d4b
Showing 6 changed files with 17 additions and 17 deletions.
@@ -255,7 +255,7 @@ else if ( ( parent == null || !ASTChain.class.isInstance( parent ) )
if ( context.getCurrentType() != null && context.getCurrentType() == Character.class
&& ASTConst.class.isInstance( children[i] ) )
{
expr = expr.replaceAll( "'", "\"" );
expr = expr.replace( "'", "\"" );
context.setCurrentType( String.class );
}
else
@@ -274,8 +274,8 @@ else if ( ( parent == null || !ASTChain.class.isInstance( parent ) )
if ( lastType != null && String.class.isAssignableFrom( lastType.getGetterClass() ) )
{
// System.out.println("Input expr >>" + expr + "<<");
expr = expr.replaceAll( "&quot;", "\"" );
expr = expr.replaceAll( "\"", "'" );
expr = expr.replace( "&quot;", "\"" );
expr = expr.replace( "\"", "'" );
expr = format( "\"%s\"", expr );
// System.out.println("Expr now >>" + expr + "<<");
}
@@ -154,7 +154,7 @@ public Class<?> getPropertyClass( OgnlContext context, Object target, Object ind
{
if ( index instanceof String )
{
String key = ( (String) index ).replaceAll( "\"", "" );
String key = ( (String) index ).replace( "\"", "" );
if ( "size".equals( key ) )
{
return int.class;
@@ -181,7 +181,7 @@ public Class<?> getPropertyClass( OgnlContext context, Object target, Object ind
@Override
public String getSourceAccessor( OgnlContext context, Object target, Object index )
{
String indexStr = index.toString().replaceAll( "\"", "" );
String indexStr = index.toString().replace( "\"", "" );

if ( String.class.isInstance( index ) )
{
@@ -213,7 +213,7 @@ public String getSourceAccessor( OgnlContext context, Object target, Object inde
@Override
public String getSourceSetter( OgnlContext context, Object target, Object index )
{
String indexStr = index.toString().replaceAll( "\"", "" );
String indexStr = index.toString().replace( "\"", "" );

// 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..
@@ -120,7 +120,7 @@ public String getSourceAccessor( OgnlContext context, Object target, Object inde

if ( String.class.isInstance( index ) && !indexedAccess )
{
String key = indexStr.replaceAll( "\"", "" );
String key = indexStr.replace( "\"", "" );

if ( "size".equals( key ) )
{
@@ -156,7 +156,7 @@ public String getSourceSetter( OgnlContext context, Object target, Object index

if ( String.class.isInstance( index ) )
{
String key = indexStr.replaceAll( "\"", "" );
String key = indexStr.replace( "\"", "" );

if ( "size".equals( key ) || "keys".equals( key ) || "keySet".equals( key ) || "values".equals( key )
|| "isEmpty".equals( key ) )
@@ -187,7 +187,7 @@ public Class<?> getPropertyClass( OgnlContext context, Object target, Object ind

if ( String.class.isAssignableFrom( index.getClass() ) && !target.getClass().isArray() )
{
String key = ( (String) index ).replaceAll( "\"", "" );
String key = ( (String) index ).replace( "\"", "" );
try
{
Field f = target.getClass().getField( key );
@@ -220,7 +220,7 @@ public String getSourceAccessor( OgnlContext context, Object target, Object inde
try
{

String methodName = index.toString().replaceAll( "\"", "" );
String methodName = index.toString().replace( "\"", "" );
Method m = OgnlRuntime.getReadMethod( target.getClass(), methodName );

// try last ditch effort of checking if they were trying to do reflection via a return method value
@@ -229,7 +229,7 @@ public String getSourceAccessor( OgnlContext context, Object target, Object inde
{
m =
OgnlRuntime.getReadMethod( target.getClass(),
context.getCurrentObject().toString().replaceAll( "\"", "" ) );
context.getCurrentObject().toString().replace( "\"", "" ) );
}
// System.out.println("tried to get read method from target: " + target.getClass() + " with methodName:" +
// methodName + " result: " + m);
@@ -278,14 +278,14 @@ public String getSourceSetter( OgnlContext context, Object target, Object index
try
{

String methodName = index.toString().replaceAll( "\"", "" );
String methodName = index.toString().replace( "\"", "" );
Method m = OgnlRuntime.getWriteMethod( target.getClass(), methodName );

if ( m == null && context.getCurrentObject() != null && context.getCurrentObject().toString() != null )
{
m =
OgnlRuntime.getWriteMethod( target.getClass(),
context.getCurrentObject().toString().replaceAll( "\"", "" ) );
context.getCurrentObject().toString().replace( "\"", "" ) );
}

if ( m == null || m.getParameterTypes() == null || m.getParameterTypes().length <= 0 )
@@ -1838,7 +1838,7 @@ public static Method getReadMethod( Class<?> target, String name, int numParms )
{
try
{
name = name.replaceAll( "\"", "" ).toLowerCase();
name = name.replace( "\"", "" ).toLowerCase();

BeanInfo info = Introspector.getBeanInfo( target );
MethodDescriptor[] methodDescriptors = info.getMethodDescriptors();
@@ -1937,7 +1937,7 @@ public static Method getWriteMethod( Class<?> target, String name, int numParms
{
try
{
name = name.replaceAll( "\"", "" );
name = name.replace( "\"", "" );

BeanInfo info = Introspector.getBeanInfo( target );
MethodDescriptor[] methods = info.getMethodDescriptors();
@@ -58,7 +58,7 @@ public boolean hasGetProperty( Map<String, Object> context, Object target, Objec
throws OgnlException
{
BeanProvider provider = (BeanProvider) target;
String beanName = ( (String) oname ).replaceAll( "\"", "" );
String beanName = ( (String) oname ).replace( "\"", "" );

return provider.getBean( beanName ) != null;
}
@@ -67,7 +67,7 @@ public boolean hasGetProperty( Map<String, Object> context, Object target, Objec
public String getSourceAccessor( OgnlContext context, Object target, Object name )
{
BeanProvider provider = (BeanProvider) target;
String beanName = ( (String) name ).replaceAll( "\"", "" );
String beanName = ( (String) name ).replace( "\"", "" );

if ( provider.getBean( beanName ) != null )
{

0 comments on commit afc1f9b

Please sign in to comment.