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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 
<https://emu.freenetproject.org/pipermail/devl/attachments/20080812/dab1e97c/attachment.pgp>

Reply via email to