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.io.parser.rdf;
17  
18  import java.util.HashSet;
19  import java.util.Set;
20  
21  import org.openrdf.model.Statement;
22  
23  /**
24   * This class represents a RDF Parse Warning.
25   *
26   * <pre>
27   *  Created on May 02, 2006
28   *  Committed by $Author: morcen $
29   *  $Source$
30   * </pre>
31   *
32   * @author nathalie.steinmetz@deri.org
33   * @version $Revision: 1946 $ $Date: 2007-04-02 15:13:28 +0300 (Mon, 02 Apr 2007) $
34   */
35  public class RDFParserWarning extends RDFParserMessage{
36      
37      private Set <Statement> triples = null;
38      
39      public RDFParserWarning(String warningMessage, int lineNo, int colNo) {
40          super(warningMessage, lineNo, colNo);
41          if (triples == null) {
42              triples = new HashSet <Statement>();
43          }
44      }
45      
46      /**
47       * All triples that were not recognized, and thus not transformed 
48       * and added to the WSMO object model, are put into a Set. 
49       * 
50       * @param statement statement to be added to the triples set
51       */
52      public void addToTriples(Statement statement) {
53          triples.add(statement);
54      }
55      
56      /**
57       * This method returns a Set containing all triples 
58       * that were not recognized, and thus not transformed 
59       * and added to the WSMO object model. 
60       * 
61       * @return Set of RDF statements concerned by this warning
62       */
63      public Set getTriples() {
64          return triples;
65      }
66  
67      /**
68       * <p>
69       * The <code>equals</code> method implements an equivalence relation
70       * on non-null object references. RDFParserWarnings are equal if their 
71       * warning message and their line and column numbers are equal.
72       * </p>
73       * <p>
74       * It is generally necessary to override the <code>hashCode</code> method whenever this method
75       * is overridden.
76       * </p>
77       * @param o the reference object with which to compare.
78       * @return <code>true</code> if this object is the same as the obj
79       *          argument; <code>false</code> otherwise.
80       * @see java.lang.Object#equals(java.lang.Object)
81       * @see java.lang.Object#hashCode()
82       */
83      public boolean equals(Object obj) {
84          if (obj instanceof RDFParserWarning) {
85              RDFParserWarning w = (RDFParserWarning) obj;
86              return ((w.getMessage().equals(this.getMessage())
87                       && (w.getLine() == this.getLine()) && 
88                       (w.getColumn() == this.getColumn())));
89          }
90          return false;
91      }
92      
93      /**
94       * <p>
95       * If two objects are equal according to the <code>equals(Object)</code> method, then calling
96       * the <code>hashCode</code> method on each of the two objects must produce the same integer
97       * result. However, it is not required that if two objects are unequal according to
98       * the <code>equals(Object)</code> method, then calling the <code>hashCode</code> method on each of the two
99       * objects must produce distinct integer results.
100      * </p>
101      * <p>
102      * This method should be overriden, when the <code>equals(Object)</code> method is overriden.
103      * </p>
104      * @return A hash code value for this Object.
105      * @see java.lang.Object#hashCode()
106      * @see java.lang.Object#equals(Object)
107      */
108     public int hashCode() {
109         return super.hashCode();
110     }
111    
112 }
113 /*
114  * $Log$
115  * Revision 1.3  2007/04/02 12:13:23  morcen
116  * Generics support added to wsmo-api, wsmo4j and wsmo-test
117  *
118  * Revision 1.2  2006/11/16 09:53:28  nathaliest
119  * added RDFParserError
120  *
121  * Revision 1.1  2006/05/03 13:32:49  nathaliest
122  * adding RDF parser
123  *
124  * 
125  */