Skip to main content

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

It seems to manipulate the hashCode:
 
Before[Ron's Aspect Company ]

Before[292824200]

After[Ron's Aspect Company]

After[-2000128872]

{Ron's Aspect Company }

 

Any other thoughts....

	-----Original Message----- 
	From: Alexandru Popescu [mailto:the.mindstorm.mailinglist@xxxxxxxxx] 
	Sent: Thu 9/15/2005 5:34 PM 
	To: aspectj-users@xxxxxxxxxxx 
	Cc: 
	Subject: Re: [aspectj-users] String Trimming anyone???
	
	

	#: Ron DiFrango changed the world a bit at a time by saying on  9/15/2005 10:27 PM :#
	> 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
	>
	
	Not sure why this is may happen, but try watching if the same string instance is manipulated (print
	some hashCode()).
	
	:alex |.::the_mindstorm::.|
	
	>
	>
	> ------------------------------------------------------------------------
	>
	> _______________________________________________
	> aspectj-users mailing list
	> aspectj-users@xxxxxxxxxxx
	> https://dev.eclipse.org/mailman/listinfo/aspectj-users
	_______________________________________________
	aspectj-users mailing list
	aspectj-users@xxxxxxxxxxx
	https://dev.eclipse.org/mailman/listinfo/aspectj-users
	


Back to the top