Hi all,
I'm working with Java classad.jar package and I found some problem while using the windows backslash separator,can you please help me?
Here follows a simple test program:
String attr1 = "First" ;
String attr2 = "Second" ;
String attrValue = "C:\\Dir\\file.exe" ;
// Creating a RecordExpr from parser
String classAd = "[ " + attr1 + "= \"" + attrValue +"\"]" ;
ClassAdParser cp = new ClassAdParser( classAd ) ;
System.out.println( "*** Parse:\n" + classAd ) ;
RecordExpr re = (RecordExpr) cp.parse() ;
// insertAttribute
System.out.println( "*** Insert:\n" + attrValue ) ;
re.insertAttribute ( attr2 , Constant.getInstance(attrValue) ) ;
// Print ClassAd
System.out.println( "*** ClassAd:\n" + re ) ;
// retrieve info
Constant co1 = (Constant) re.lookup( attr1 ) ;
System.out.println( "*** Retrieve 1:\n" + co1.stringValue() ) ;
Constant co2 = (Constant) re.lookup( attr2 ) ;
System.out.println( "*** Retrieve 2:\n" + co2.stringValue() ) ;
and here's the standard output:
*** Parse:
[ First= "C:\Dir\file.exe"]
*** Insert:
C:\Dir\file.exe
*** ClassAd:
[ First = "C:Dir\file.exe"; Second = "C:\\Dir\\file.exe" ]
*** Retrieve 1:
C:Dir
ile.exe
*** Retrieve 2:
C:\Dir\file.exe
There are two different problems:
1) If I use the ClassAdParser to parse a String and create a RecordExpr then I lose my information on some backslash, and
moreover when I retrieve this value it interpretates "survival" backslashes as Java special caracther '\n' '\f' '\t' and so on
3) If I use the insertAttribute it works well when I get back the value but when I print the created RecordExpr with the toString() method it prints two backslashes
I guess maybe the two problems are connected someway...
thanks,
Alessandro
--
=============================================================
Alessandro Maraschini
GRID R&D Group
Defence, Space & Environment Division
DATAMAT S.p.A.
Via Laurentina, 760 -I- 00143 Rome - Italy
http://www.datamat.it
mailto:alessandro.maraschini@xxxxxxxxxx
Phone: +39 06 5027 4501 (direct) +39 06 5027 4570 (secretary)
Fax: +39 06 5027 4500
=============================================================
|