OWLSObjListImpl.java revision 17
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen// The MIT License
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen//
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen// Copyright (c) 2004 Evren Sirin
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen//
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen// Permission is hereby granted, free of charge, to any person obtaining a copy
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen// of this software and associated documentation files (the "Software"), to
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen// deal in the Software without restriction, including without limitation the
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen// sell copies of the Software, and to permit persons to whom the Software is
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen// furnished to do so, subject to the following conditions:
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen//
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen// The above copyright notice and this permission notice shall be included in
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen// all copies or substantial portions of the Software.
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen//
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen// IN THE SOFTWARE.
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen/*
eb0816090cf5a549280ad783b9aa6fec199d36baTimo Sirainen * Created on Dec 23, 2004
eb0816090cf5a549280ad783b9aa6fec199d36baTimo Sirainen */
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainenpackage impl.owls.generic.list;
eb0816090cf5a549280ad783b9aa6fec199d36baTimo Sirainen
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainenimport impl.owl.list.RDFListImpl;
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainenimport org.mindswap.owl.OWLIndividual;
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainenimport org.mindswap.owl.OWLValue;
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainenimport org.mindswap.owl.list.RDFList;
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainenimport org.mindswap.owls.generic.list.OWLSObjList;
eb0816090cf5a549280ad783b9aa6fec199d36baTimo Sirainenimport org.mindswap.owls.vocabulary.OWLS;
eb0816090cf5a549280ad783b9aa6fec199d36baTimo Sirainen
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen/**
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen * @author Evren Sirin
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen * @author Michael D�nzer, University of Zurich
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen */
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainenpublic class OWLSObjListImpl extends RDFListImpl implements OWLSObjList {
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen public OWLSObjListImpl(OWLIndividual ind) {
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen super(ind);
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen setVocabulary(OWLS.ObjList);
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen }
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen public RDFList getRest() {
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen return (OWLSObjList) getProperty(vocabulary.rest()).castTo(OWLSObjList.class);
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen }
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen // TODO returning an instance of the superclass as replacement for the instance this operation was called is really bad.
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen public RDFList insert(OWLValue item) {
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen OWLSObjListImpl list = new OWLSObjListImpl(getOntology().createInstance( vocabulary.List()));
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen list.setVocabulary(vocabulary);
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen list.setFirst( item );
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen list.setRest( this );
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen return list;
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen }
363929157786b549c80630bda3c3575f5115c6c5Timo Sirainen
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen public RDFList remove() {
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen OWLSObjListImpl list = new OWLSObjListImpl(getOntology().createInstance(vocabulary.List()));
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen list.setVocabulary(vocabulary);
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen if (size() > 1) {
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen list.setFirst(getRest().getFirstValue());
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen list.setRest((OWLSObjList) getRest().getRest());
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen } else {
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen return new OWLSObjListImpl(vocabulary.nil());
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen }
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen return list;
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen }
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen}
c115c742f730e312d6b6ab5064595cd0d8b4e26eTimo Sirainen