View Javadoc

1   /*
2    wsmo4j - a WSMO API and Reference Implementation
3   
4    Copyright (c) 2006, University of Innsbruck, Austria
5   
6    This library is free software; you can redistribute it and/or modify it under
7    the terms of the GNU Lesser General Public License as published by the Free
8    Software Foundation; either version 2.1 of the License, or (at your option)
9    any later version.
10   This library is distributed in the hope that it will be useful, but WITHOUT
11   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12   FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13   details.
14   You should have received a copy of the GNU Lesser General Public License along
15   with this library; if not, write to the Free Software Foundation, Inc.,
16   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17   */
18  package org.deri.wsmo4j.io.serializer.rdf;
19  
20  import java.io.*;
21  
22  import org.omwg.ontology.*;
23  import org.openrdf.model.*;
24  import org.openrdf.model.Value;
25  
26  /**
27   * Helper type to serialize/deserialize xml element relation instance
28   * 
29   * @author not attributable
30   */
31  class NodeRelationInstance {
32      
33      static void serialize(RelationInstance relInstance, WsmlRdfSerializer serializer) {
34          if (relInstance.getRelation() != null) {
35              URI pred = serializer.getFactory().createURI(
36                      relInstance.getRelation().getIdentifier().toString());
37              
38              if (!relInstance.listParameterValues().isEmpty() && relInstance.listParameterValues().size()==2) {
39                  Value rv = NodeValue.serialize(
40                          relInstance.listParameterValues().get(0), serializer);
41                  if(rv instanceof URI) {
42                      Resource r = (URI)rv;
43                      Value v = NodeValue.serialize(
44                              relInstance.listParameterValues().get(1), serializer);
45                      try {
46                          serializer.getWriter().writeStatement(r,pred,v);
47                          
48                          if (!relInstance.listNFPValues().isEmpty()) {
49                              NodeNFP.serialize(r, relInstance, serializer);
50                          }
51                          
52                      } catch(IOException e) {
53                          throw new RuntimeException(e);
54                      }
55                  } else {
56                      return;
57                  }
58              }
59          } else {
60              return;
61          }
62      }
63  }
64  
65  /*
66   * $Log$
67   * Revision 1.1  2006/11/10 15:02:59  ohamano
68   * *** empty log message ***
69   *
70   * Revision 1.1  2006/11/10 10:08:42  ohamano
71   * *** empty log message ***
72   *
73   *
74  */