ch.uzh.ifi.attempto.acewiki.core.ontology
Class OntologyElement

java.lang.Object
  extended by ch.uzh.ifi.attempto.acewiki.core.ontology.OntologyElement
All Implemented Interfaces:
java.lang.Comparable<OntologyElement>
Direct Known Subclasses:
Concept, Individual, Role

public abstract class OntologyElement
extends java.lang.Object
implements java.lang.Comparable<OntologyElement>

This class represents an ontology element which can be an individual ("constant"), a concept ("unary relation", "class", "type"), or a role ("binary relation", "property"). See the respective sub-classes.

In AceWiki, each ontology element corresponds to a word which has one or more word forms. Word forms are identified by a number (the word form id).

Every ontology element has an article which consists of a list of sentences.

Author:
Tobias Kuhn

Constructor Summary
protected OntologyElement()
          Initializes the ontology element.
 
Method Summary
 int add(Sentence followingSentence, java.util.List<Sentence> newSentences)
          Adds one or more new sentences to the article.
protected abstract  void changeWords(java.lang.String... words)
          Changes the word forms without updating the ontology indexes.
 int compareTo(OntologyElement e)
           
 int edit(Sentence oldSentence, java.util.List<Sentence> newSentences)
          Edits a sentence of the article.
 java.lang.String getHeadword()
          Returns the headword that is used in the GUI to refer to this ontology element.
abstract  java.lang.String getInternalType()
          Returns the word type as it is used internally.
 Ontology getOntology()
          Returns the ontology this ontology element is registered at.
 java.lang.String getPrettyWord(int n)
          Returns the pretty-printed word form for the given word form id.
 java.util.List<Sentence> getSentences()
          Returns the article text as a list of sentences.
abstract  java.lang.String getType()
          Returns the word type as it is shown to the user.
 java.net.URI getURI()
          Returns the URI of the ontology element.
 java.lang.String getURISuffix()
          Returns the URI suffix of this ontology element.
 java.lang.String getWord()
          Returns the word form with the id 0 (the default word form).
 java.lang.String getWord(int n)
          Returns the word form for the given word form id.
abstract  java.lang.String[] getWords()
          Returns the word forms.
protected  void log(java.lang.String text)
          Writes the text to the log file.
 void registerAt(Ontology ontology)
          Registers this ontology element at the given ontology.
 void remove(Sentence sentence)
          Removes the given sentence from the article.
 void setWords(java.lang.String... words)
          Sets the word forms.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OntologyElement

protected OntologyElement()
Initializes the ontology element.

Method Detail

getWords

public abstract java.lang.String[] getWords()
Returns the word forms. The position in the array corresponds to the word form id.

Returns:
An array containing the word forms.

getWord

public java.lang.String getWord(int n)
Returns the word form for the given word form id.

Parameters:
n - The word form id.
Returns:
The word form.

getWord

public java.lang.String getWord()
Returns the word form with the id 0 (the default word form).

Returns:
The word form.

getPrettyWord

public java.lang.String getPrettyWord(int n)
Returns the pretty-printed word form for the given word form id. The pretty-printing transforms underscores into blanks.

Parameters:
n - The word form id.
Returns:
The word form.

setWords

public final void setWords(java.lang.String... words)
Sets the word forms. The order reflects the word form ids. The indexes of the ontology are automatically updated.

Parameters:
words - The word forms.

changeWords

protected abstract void changeWords(java.lang.String... words)
Changes the word forms without updating the ontology indexes. The order reflects the word form ids.

Parameters:
words - The word forms.

getHeadword

public java.lang.String getHeadword()
Returns the headword that is used in the GUI to refer to this ontology element. For example, it is used for the title of the article. Unless overridden, it is the same as the pretty-printed word form with the id 0.

Returns:
The headword.

getType

public abstract java.lang.String getType()
Returns the word type as it is shown to the user. Newer versions of AceWiki can savely change this value.

Returns:
The word type.

getInternalType

public abstract java.lang.String getInternalType()
Returns the word type as it is used internally. Changing this value in newer versions of AceWiki breaks backwards compatibility for loading ontologies.

Returns:
The internal word type.

getOntology

public Ontology getOntology()
Returns the ontology this ontology element is registered at.

Returns:
The ontology.

registerAt

public void registerAt(Ontology ontology)
Registers this ontology element at the given ontology. An ontology element can be registered only once.

Parameters:
ontology -

getSentences

public java.util.List<Sentence> getSentences()
Returns the article text as a list of sentences.

Returns:
The sentences.

edit

public int edit(Sentence oldSentence,
                java.util.List<Sentence> newSentences)
Edits a sentence of the article. The old sentence is replaces by the new sentences.

Parameters:
oldSentence - The sentence that should be edited.
newSentences - The new sentences.
Returns:
An integer value denoting the success/failure of the operation.
See Also:
Ontology.commitSentence(Sentence)

add

public int add(Sentence followingSentence,
               java.util.List<Sentence> newSentences)
Adds one or more new sentences to the article. It has to be specified in front of which sentence the new sentences should be added.

Parameters:
followingSentence - The sentence in front of which the new sentences should be added, or null if the sentences should be added to the end of the article.
newSentences - The new sentences to be added.
Returns:
An integer value denoting the success/failure of the operation.
See Also:
Ontology.commitSentence(Sentence)

remove

public void remove(Sentence sentence)
Removes the given sentence from the article.

Parameters:
sentence - The sentence to be removed.

getURI

public final java.net.URI getURI()
Returns the URI of the ontology element. This URI is a concatenation of the ontology URI and the URI suffix of the ontology element.

Returns:
The URI.
See Also:
getURISuffix()

getURISuffix

public java.lang.String getURISuffix()
Returns the URI suffix of this ontology element. For example "#country".

Returns:
The URI suffix.
See Also:
getURI()

log

protected void log(java.lang.String text)
Writes the text to the log file.

Parameters:
text - The text to be written to the log file.

compareTo

public int compareTo(OntologyElement e)
Specified by:
compareTo in interface java.lang.Comparable<OntologyElement>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright 2008, Attempto Group, University of Zurich (see http://attempto.ifi.uzh.ch)