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 statements.

Author:
Tobias Kuhn

Constructor Summary
protected OntologyElement()
          Initializes the ontology element.
 
Method Summary
 int add(Statement followingStatement, java.util.List<Statement> newStatements)
          Adds one or more new statements to the article.
 int add(Statement followingStatement, Statement newStatement)
          Adds one new statement 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(Statement oldStatement, java.util.List<Statement> newStatements)
          Edits a statement of the article.
 int edit(Statement oldStatement, Statement newStatement)
          Edits a statement of the article.
 java.lang.String getHeadword()
          Returns the headword that is used in the GUI to refer to this ontology element.
 java.lang.String[] getIndexEntries()
          Returns a list of words that should be listed in the index to point 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 ACE sentences of the article text.
 java.util.List<Statement> getStatements()
          Returns the article text as a list of statements.
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(Statement statement)
          Removes the given statement 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.

getIndexEntries

public java.lang.String[] getIndexEntries()
Returns a list of words that should be listed in the index to point to this ontology element.

Returns:
The index words.

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 -

getStatements

public java.util.List<Statement> getStatements()
Returns the article text as a list of statements.

Returns:
The statements.

getSentences

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

Returns:
The ACE sentences.

edit

public int edit(Statement oldStatement,
                Statement newStatement)
Edits a statement of the article. The old statement is replaced by the new statement.

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

edit

public int edit(Statement oldStatement,
                java.util.List<Statement> newStatements)
Edits a statement of the article. The old statement is replaced by the new statements.

Parameters:
oldStatement - The statement that should be edited.
newStatements - The new statements.
Returns:
An integer value denoting the success/failure of the operation.
See Also:
Ontology.commitSentence(Sentence)

add

public int add(Statement followingStatement,
               Statement newStatement)
Adds one new statement to the article. One has to specify in front of which statement the new statement should be added.

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

add

public int add(Statement followingStatement,
               java.util.List<Statement> newStatements)
Adds one or more new statements to the article. It has to be specified in front of which statement the new statement should be added.

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

remove

public void remove(Statement statement)
Removes the given statement from the article.

Parameters:
statement - The statement 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-2009, Attempto Group, University of Zurich (see http://attempto.ifi.uzh.ch)