Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] String Trimming anyone???

All,
 
I am working with a database [DB2] where the fields are padded with spaces and I want to strip them on when I set the values in my DTO.  So I created the following aspect:
 
privileged aspect CaptureStringSets {
 before(String val): set(* dto..*.*) && args(val) {
        System.out.println("Before[" + val + "]");
        val = val.trim();
        System.out.println("After[" + val + "]");
    }
}
 
Test Program:
 
public class TestDBUtils {
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  ApproveHeaderTO to = new ApproveHeaderTO();
  to.setVendorName("Ron's Aspect Company       ");
  System.out.println("{" + to.getVendorName() + "}");
 }
}
 
It properly captrues the join points, but the output is as follows:
 
Before[Ron's Aspect Company ]
After[Ron's Aspect Company]
{Ron's Aspect Company }

I am wondering why the change to the String is not taking affect, it is like a pass by value/reference thing, but I am not sure why.  Anyone else create such a monster?  

BTW I thnk this would be a good re-usable aspect if we can get it working.

Ron


Back to the top