[Mulgara-dev] why line separator into base64 string?

Roberto Sidoti rsidoti at herzumsoftware.com
Mon Aug 20 03:51:45 CDT 2007


Hi all,
I have this little problem using base64
(<http://www.w3.org/2001/XMLSchema#base64Binary>) data:
When I have to convert an Answer field into string it is not a valid base64
string:

public String asBase64String(Answer a) {
   String prop=null;
   String obj=null;
   boolean empty=true;
   if(a.next()){
 	empty=false;
	prop=a.getObject(0).toString();
	if(prop.equals(BASEURL+"blobContent")){
 		obj=a.getObject(1).toString();
		obj=obj.replaceAll(System.getProperty("line.separator"),
"");
		int ind=obj.lastIndexOf("^^");
		obj=obj.substring(0,ind);
		obj=obj.substring(1,obj.length()-1);//escape \" at start and
end of string
	}
}	
		if(empty)
			return null;
		else
			return obj;
	}

In order to get a valid base64 string I used 

obj=obj.replaceAll(System.getProperty("line.separator"), "");

because every 77 characters there is a System.getProperty("line.separator")
String. I discovered this thing looking into
org.mulgara.store.stringpool.xa.SPBase64BinaryImpl
getLexicalForm method (I thing this is the matter...).

Why did you put a "line.separator" every 77 chars?
There is another way to get a valid base64 string from an Answer object?

Regards
roby 



More information about the Mulgara-dev mailing list