|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ComplexDataTypeImpl.java | 0% | 0% | 0% | 0% |
|
1 | /* | |
2 | wsmo4j - a WSMO API and Reference Implementation | |
3 | ||
4 | Copyright (c) 2004-2005, OntoText Lab. / SIRMA | |
5 | University of Innsbruck, Austria | |
6 | ||
7 | This library is free software; you can redistribute it and/or modify it under | |
8 | the terms of the GNU Lesser General Public License as published by the Free | |
9 | Software Foundation; either version 2.1 of the License, or (at your option) | |
10 | any later version. | |
11 | This library is distributed in the hope that it will be useful, but WITHOUT | |
12 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
13 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | |
14 | details. | |
15 | You should have received a copy of the GNU Lesser General Public License along | |
16 | with this library; if not, write to the Free Software Foundation, Inc., | |
17 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 | */ | |
19 | ||
20 | /** | |
21 | * <p>Title: WSMO4J</p> | |
22 | * <p>Description: WSMO API and a Reference Implementation</p> | |
23 | * <p>Copyright: Copyright (c) 2004-2005</p> | |
24 | * <p>Company: OntoText Lab. / SIRMA </p> | |
25 | */ | |
26 | ||
27 | package com.ontotext.wsmo4j.ontology; | |
28 | ||
29 | import org.omwg.ontology.*; | |
30 | import org.omwg.ontology.ComplexDataType; | |
31 | import org.omwg.ontology.SimpleDataType; | |
32 | import org.wsmo.common.IRI; | |
33 | ||
34 | ||
35 | public class ComplexDataTypeImpl implements ComplexDataType{ | |
36 | ||
37 | private IRI iri; | |
38 | private SimpleDataType[] types; | |
39 | ||
40 | 0 | public ComplexDataTypeImpl(IRI typeIRI, SimpleDataType[] types) { |
41 | 0 | assert types != null; |
42 | 0 | assert typeIRI != null; |
43 | ||
44 | 0 | iri = typeIRI; |
45 | 0 | this.types = new SimpleDataType[types.length]; |
46 | 0 | System.arraycopy(types, 0, this.types, 0, types.length); |
47 | } | |
48 | ||
49 | 0 | public byte getArity() { |
50 | 0 | return (byte)this.types.length; |
51 | } | |
52 | ||
53 | 0 | public SimpleDataType getArgumentRange(byte pos) { |
54 | 0 | if (pos < 0 |
55 | || pos >= types.length) { | |
56 | 0 | throw new IllegalArgumentException( |
57 | "Invalid argument position for type '" | |
58 | + getIRI().toString() | |
59 | + "'!"); | |
60 | } | |
61 | 0 | return types[pos]; |
62 | } | |
63 | ||
64 | 0 | public String toString() { |
65 | 0 | return iri.toString(); |
66 | } | |
67 | ||
68 | 0 | public IRI getIRI() { |
69 | 0 | return iri; |
70 | } | |
71 | ||
72 | 0 | public boolean equals(Object object) { |
73 | 0 | if (object == this) { |
74 | 0 | return true; |
75 | } | |
76 | 0 | if (object == null |
77 | || false == object instanceof WsmlDataType) { | |
78 | 0 | return false; |
79 | } | |
80 | 0 | return toString().equals(object.toString()); |
81 | } | |
82 | ||
83 | 0 | public int hashCode() { |
84 | 0 | return iri.hashCode(); |
85 | } | |
86 | ||
87 | } | |
88 | ||
89 | /* | |
90 | * $Log$ | |
91 | * Revision 1.3 2005/09/16 14:02:44 alex_simov | |
92 | * Identifier.asString() removed, use Object.toString() instead | |
93 | * (Implementations MUST override toString()) | |
94 | * | |
95 | * Revision 1.2 2005/09/06 18:33:42 holgerlausen | |
96 | * support for datatypes: updated implementation according to interfaces | |
97 | * renamed WsmlDataTypeImpl to SimpleDataTypeImpl | |
98 | * moved DataValueImpl to ComplexDataValueImpl | |
99 | * added SimpleDataValueImpl for basic strings, decimal, ints | |
100 | * | |
101 | * Revision 1.1 2005/07/04 15:25:16 alex_simov | |
102 | * DataValue/DataType changes | |
103 | * | |
104 | */ | |
105 |
|