1 /***
2 * ***************************************************************
3 * JADE - Java Agent DEvelopment Framework is a framework to develop
4 * multi-agent systems in compliance with the FIPA specifications.
5 * Copyright (C) 2000 CSELT S.p.A.
6 *
7 * GNU Lesser General Public License
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation,
12 * version 2.1 of the License.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
23 * **************************************************************
24 */
25 package JADE_SL.schema;
26
27 import JADE_SL.abs.*;
28 import JADE_SL.onto.*;
29 import java.util.*;
30
31 /***
32 * @author Federico Bergenti - Universita` di Parma
33 */
34 public class ContentElementListSchema extends ContentElementSchema {
35 public static final String BASE_NAME = "ContentElementList";
36 private static ContentElementListSchema baseSchema = new ContentElementListSchema();
37
38 /***
39 * Construct a schema that vinculates an entity to be a content element
40 * list. Note that there are no different types of content element
41 * list as it
42 * happens for concepts (e.g. Person, Address...), IREs (e.g. IOTA,
43 * ANY, ALL...) and the like. Therefore there is no ContentElementListSchema
44 * constructor that takes a String parameter.
45 */
46 private ContentElementListSchema() {
47 super(BASE_NAME);
48 }
49
50 /***
51 * Retrieve the generic base schema for all content element lists.
52 * @return the generic base schema for all content element lists.
53 */
54 public static ObjectSchema getBaseSchema() {
55 return baseSchema;
56 }
57
58 /***
59 * Creates an Abstract descriptor to hold a content element list
60 */
61 public AbsObject newInstance() throws OntologyException {
62 return new AbsContentElementList();
63 }
64
65 /***
66 Check whether a given abstract descriptor complies with this
67 schema.
68 @param abs The abstract descriptor to be checked
69 @throws OntologyException If the abstract descriptor does not
70 complies with this schema
71 */
72 public void validate(AbsObject abs, Ontology onto) throws OntologyException {
73
74 if (!(abs instanceof AbsContentElementList)) {
75 throw new OntologyException(abs+" is not an AbsContentElementList");
76 }
77
78
79
80
81
82
83 AbsContentElementList list = (AbsContentElementList) abs;
84 Iterator it = list.iterator();
85 while (it.hasNext()) {
86 AbsContentElement el = (AbsContentElement) it.next();
87 ObjectSchema s = onto.getSchema(el.getTypeName());
88 s.validate(el, onto);
89 }
90 }
91
92 /***
93 Return true if
94 - s is the base schema for the XXXSchema class this schema is
95 an instance of (e.g. s is ConceptSchema.getBaseSchema() and this
96 schema is an instance of ConceptSchema)
97 - s is the base schema for a super-class of the XXXSchema class
98 this schema is an instance of (e.g. s is TermSchema.getBaseSchema()
99 and this schema is an instance of ConceptSchema)
100 */
101 protected boolean descendsFrom(ObjectSchema s) {
102 if (s != null) {
103 if (s.equals(getBaseSchema())) {
104 return true;
105 }
106 return super.descendsFrom(s);
107 }
108 else {
109 return false;
110 }
111 }
112 }