-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Matthew Toseland a ?crit :
> On Sunday 10 August 2008 15:09, batosai at freenetproject.org wrote:
>> Author: batosai
>> Date: 2008-08-10 14:09:53 +0000 (Sun, 10 Aug 2008)
>> New Revision: 21711
>>
>> Modified:
>>    trunk/apps/WoT/src/plugins/WoT/IdentityParser.java
>> Log:
>> Get the identity's properties from the XML file.
>>
>> Modified: trunk/apps/WoT/src/plugins/WoT/IdentityParser.java
>> ===================================================================
>> --- trunk/apps/WoT/src/plugins/WoT/IdentityParser.java       2008-08-10 
>> 13:51:47 
> UTC (rev 21710)
>> +++ trunk/apps/WoT/src/plugins/WoT/IdentityParser.java       2008-08-10 
>> 14:09:53 
> UTC (rev 21711)
>> @@ -7,6 +7,7 @@
>>  package plugins.WoT;
>>  
>>  import java.io.InputStream;
>> +import java.util.Date;
>>  
>>  import javax.xml.parsers.ParserConfigurationException;
>>  import javax.xml.parsers.SAXParser;
>> @@ -17,7 +18,10 @@
>>  import org.xml.sax.helpers.DefaultHandler;
>>  
>>  import com.db4o.ObjectContainer;
>> +import com.db4o.ObjectSet;
>>  
>> +import freenet.keys.FreenetURI;
>> +
>>  /**
>>   * @author Julien Cornuwel (batosai at freenetproject.org)
>>   *
>> @@ -27,6 +31,7 @@
>>      ObjectContainer db;
>>      WoT wot;
>>      SAXParser saxParser;
>> +    Identity identity;
>>  
>>      public IdentityParser(ObjectContainer db, WoT wot) throws 
> ParserConfigurationException, SAXException {
>>  
>> @@ -36,8 +41,23 @@
>>              saxParser = factory.newSAXParser();
>>      }
>>      
>> -    public void parse (InputStream is) throws Exception {
>> +    public void parse (InputStream is, FreenetURI fetchedURI) throws 
>> Exception 
> {
>>              
>> +            // Find the identity we just fetched
>> +            // This is ugly, I could not find a request able to find the 
>> good 
> identity 
>> +            ObjectSet<Identity> result = db.queryByExample(Identity.class);
>> +            while (result.hasNext()) {
>> +                    Identity id = result.next();
>> +                    
> if(id.getRequestURI().getRoutingKey().equals(fetchedURI.getRoutingKey()))
>> +                            identity = id;
>> +            }
> 
> Yeah, fetching by Key's (and other objects based on byte[]'s) in db4o can be 
> extremely ugly. The obvious ways to do it (with native queries or SODA) 
> result in it instantiating every object to compare it.
> 
> What I do is simply store a string, and query on that.

Damn ! I was wondering if I shouldn't get back to strings and you just
confirmed it. Let's go for refactor...
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIobi7mY5qNqKdYw0RAgq6AJ9tJ+ac0wznp2mfO70RiH4AdorhEwCgrBlV
aG9wmqXKS+wkwkMYnkUMUi4=
=KY0l
-----END PGP SIGNATURE-----

Reply via email to