View Javadoc

1   /*
2     wsmo4j - a WSMO API and Reference Implementation
3    Copyright (c) 2005, University of Innsbruck, Austria
4    This library is free software; you can redistribute it and/or modify it under
5    the terms of the GNU Lesser General Public License as published by the Free
6    Software Foundation; either version 2.1 of the License, or (at your option)
7    any later version.
8    This library is distributed in the hope that it will be useful, but WITHOUT
9    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10   FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11   details.
12   You should have received a copy of the GNU Lesser General Public License along
13   with this library; if not, write to the Free Software Foundation, Inc.,
14   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15   */
16  package org.deri.wsmo4j.factory;
17  
18  
19  import java.util.*;
20  
21  import org.omwg.logicalexpression.*;
22  import org.omwg.logicalexpression.terms.*;
23  import org.wsmo.factory.*;
24  
25  
26  /**
27   * <pre>
28   *
29   *  Created on Jun 20, 2005
30   *  Committed by $Author$
31   *
32   * </pre>
33   *
34   * @author holger.lausen@deri.org
35   * @version $Revision$ $Date$
36   * @see org.omwg.logexpression.LogicalExpressionFactory
37   */
38  public abstract class AbstractLogicalExpressionFactoryImpl
39          implements LogicalExpressionFactory {
40  
41      /**
42       * @see LogicalExpressionFactory#createAttribusteValues(Term, Term, List)
43       */
44      public CompoundMolecule createAttribusteValues(Term instanceID, Term attributeID, List attributeValues) throws IllegalArgumentException {
45          if (attributeValues == null){
46              throw new IllegalArgumentException("list of attribute values must contain at least 2 terms");
47          }
48          List <Molecule> molecules = new Vector <Molecule>();
49          Iterator i = attributeValues.iterator();
50          while (i.hasNext()){
51              Term term;
52              try{
53                  term=(Term)i.next();
54              }catch (ClassCastException e){
55                  throw new IllegalArgumentException("list of attribute values can only contain terms");
56              }
57              molecules.add(createAttributeValue(instanceID,attributeID, term));
58          }
59          return createCompoundMolecule(molecules);
60      }
61  
62      /**
63       * @see LogicalExpressionFactory#createAttributeConstraints(Term, Term, List)
64       */
65      public CompoundMolecule createAttributeConstraints(Term instanceID, Term attributeID, List attributeTypes) throws IllegalArgumentException {
66          if (attributeTypes == null){
67              throw new IllegalArgumentException("list of attribute types must contain at least 2 term");
68          }
69          List <Molecule> molecules = new Vector <Molecule> ();
70          Iterator i = attributeTypes.iterator();
71          while (i.hasNext()){
72              Term term;
73              try{
74                  term=(Term)i.next();
75              }catch (ClassCastException e){
76                  throw new IllegalArgumentException("list of attribute types can only contain terms");
77              }
78              molecules.add(createAttributeConstraint(instanceID,attributeID, term));
79          }
80          return createCompoundMolecule(molecules);
81      }
82  
83      /**
84       * @see LogicalExpressionFactory#createAttributeInferences(Term, Term, List)
85       */
86      public CompoundMolecule createAttributeInferences(Term instanceID, Term attributeID, List attributeTypes) throws IllegalArgumentException {
87          if (attributeTypes == null){
88              throw new IllegalArgumentException("list of attribute types must contain at least 2 term");
89          }
90          List <Molecule> molecules = new Vector <Molecule> ();
91          Iterator i = attributeTypes.iterator();
92          while (i.hasNext()){
93              Term term;
94              try{
95                  term=(Term)i.next();
96              }catch (ClassCastException e){
97                  throw new IllegalArgumentException("list of attribute types can only contain terms");
98              }
99              molecules.add(createAttributeInference(instanceID,attributeID, term));
100         }
101         return createCompoundMolecule(molecules);
102     }
103 
104     /**
105      * @see LogicalExpressionFactory#createMemberShipMolecules(Term, List)
106      */
107     public CompoundMolecule createMemberShipMolecules(Term identifier, List concepts){
108         if (concepts == null){
109             throw new IllegalArgumentException("list of concepts must contain at least 2 terms");
110         }
111         List <Molecule> molecules = new Vector <Molecule> ();
112         Iterator i = concepts.iterator();
113         while (i.hasNext()){
114             Term concept;
115             try{
116                 concept=(Term)i.next();
117             }catch (ClassCastException e){
118                 throw new IllegalArgumentException("list of concept ids can only contain terms");
119             }
120             molecules.add(createMemberShipMolecule(identifier, concept));
121         }
122         return createCompoundMolecule(molecules);
123     }
124     
125     /**
126      * @see LogicalExpressionFactory#createSubConceptMolecules(Term, List)
127      */
128     public CompoundMolecule createSubConceptMolecules(Term identifier, List concepts){
129         if (concepts == null){
130             throw new IllegalArgumentException("list of concepts must contain at least 2 terms");
131         }
132         List <Molecule> molecules = new Vector <Molecule> ();
133         Iterator i = concepts.iterator();
134         while (i.hasNext()){
135             Term concept;
136             try{
137                 concept=(Term)i.next();
138             }catch (ClassCastException e){
139                 throw new IllegalArgumentException("list of concept ids can only contain terms");
140             }
141             molecules.add(createSubConceptMolecule(identifier, concept));
142         }
143         return createCompoundMolecule(molecules);
144     }
145 
146 
147 }
148 
149 /*
150  * $Log$
151  * Revision 1.2  2007/04/02 12:13:24  morcen
152  * Generics support added to wsmo-api, wsmo4j and wsmo-test
153  *
154  * Revision 1.1  2006/02/16 19:40:27  holgerlausen
155  * added convinience methods to logical expression factory:
156  * RFE 113501
157  *
158  */