View Javadoc

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.OntologyException;
29  
30  /***
31   * @author Federico Bergenti - Universita` di Parma
32   */
33  public class ContentElementSchema extends ObjectSchema {
34      public static final String         BASE_NAME = "ContentElement";
35      private static ContentElementSchema baseSchema = new ContentElementSchema();
36  
37      /***
38       * Construct a schema that vinculates an entity to be a generic
39       * content element
40       */
41      private ContentElementSchema() {
42          super(BASE_NAME);
43      }
44  
45      /***
46       * Creates a <code>ContentElementSchema</code> with a given type-name.
47       * @param typeName The name of this <code>ContentElementSchema</code>.
48       */
49      protected ContentElementSchema(String typeName) {
50          super(typeName);
51      }
52  
53      /***
54       * Retrieve the generic base schema for all content elements.
55       * @return the generic base schema for all content elements.
56       */
57      public static ObjectSchema getBaseSchema() {
58          return baseSchema;
59      } 
60  
61      /***
62       * Creates an Abstract descriptor to hold a content element of
63       * the proper type.
64       */
65      public AbsObject newInstance() throws OntologyException {
66  			throw new OntologyException("AbsContentElement cannot be instantieted"); 
67      } 
68      
69    	/***
70    	   Return true if 
71    	   - s is the base schema for the XXXSchema class this schema is
72    	     an instance of (e.g. s is ConceptSchema.getBaseSchema() and this 
73    	     schema is an instance of ConceptSchema)
74    	   - s is the base schema for a super-class of the XXXSchema class
75    	     this schema is an instance of (e.g. s is TermSchema.getBaseSchema()
76    	     and this schema is an instance of ConceptSchema)
77    	 */
78    	protected boolean descendsFrom(ObjectSchema s) {
79    		if (s != null) {
80    			if (s.equals(getBaseSchema())) {
81  	  			return true;
82    			}
83    			return super.descendsFrom(s);
84    		}
85    		else {
86    			return false;
87    		}
88    	}
89  }