2ronwalf// The MIT License
2ronwalf//
2ronwalf// Copyright (c) 2004 Evren Sirin
2ronwalf//
2ronwalf// Permission is hereby granted, free of charge, to any person obtaining a copy
2ronwalf// of this software and associated documentation files (the "Software"), to
2ronwalf// deal in the Software without restriction, including without limitation the
2ronwalf// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
2ronwalf// sell copies of the Software, and to permit persons to whom the Software is
2ronwalf// furnished to do so, subject to the following conditions:
2ronwalf//
2ronwalf// The above copyright notice and this permission notice shall be included in
2ronwalf// all copies or substantial portions of the Software.
2ronwalf//
2ronwalf// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2ronwalf// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2ronwalf// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2ronwalf// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2ronwalf// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2ronwalf// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
2ronwalf// IN THE SOFTWARE.
2ronwalf
2ronwalf/*
2ronwalf * Created on Dec 27, 2003
2ronwalf *
2ronwalf */
22daenzeroramapackage impl.owls.process.constructs;
2ronwalf
2ronwalf
2ronwalf
2ronwalfimport impl.owls.generic.list.OWLSObjListImpl;
2ronwalf
2ronwalfimport org.mindswap.owl.OWLIndividual;
2ronwalfimport org.mindswap.owl.OWLValue;
2ronwalfimport org.mindswap.owl.list.RDFList;
2ronwalfimport org.mindswap.owls.process.ControlConstruct;
2ronwalfimport org.mindswap.owls.process.ControlConstructList;
2ronwalfimport org.mindswap.owls.vocabulary.OWLS;
2ronwalf
2ronwalf/**
2ronwalf * @author Evren Sirin
2ronwalf *
2ronwalf */
2ronwalfpublic class ControlConstructListImpl extends OWLSObjListImpl implements ControlConstructList {
2ronwalf public ControlConstructListImpl(OWLIndividual ind) {
2ronwalf super(ind);
2ronwalf
2ronwalf setVocabulary(OWLS.CCList);
2ronwalf }
2ronwalf
2ronwalf public RDFList insert(OWLIndividual item) {
2ronwalf ControlConstructListImpl list = new ControlConstructListImpl( getOntology().createInstance( vocabulary.List() ) );
16daenzerorama list.setVocabulary(vocabulary);
16daenzerorama
2ronwalf list.setFirst( item );
2ronwalf list.setRest( this );
2ronwalf
2ronwalf return list;
2ronwalf }
2ronwalf
2ronwalf public OWLValue getFirstValue() {
17daenzerorama OWLIndividual cc = getProperty(vocabulary.first());
17daenzerorama if (cc != null && !cc.equals(vocabulary.nil()))
17daenzerorama return (ControlConstruct) cc.castTo(ControlConstruct.class);
17daenzerorama else
17daenzerorama return null;
2ronwalf }
2ronwalf
2ronwalf public RDFList getRest() {
2ronwalf return (ControlConstructList) getProperty(vocabulary.rest()).castTo(ControlConstructList.class);
2ronwalf }
2ronwalf
2ronwalf public ControlConstruct constructAt(int index) {
2ronwalf return (ControlConstruct) get(index);
16daenzerorama }
16daenzerorama
16daenzerorama public RDFList remove() {
18daenzerorama ControlConstructList list = (ControlConstructList) getRest();
18daenzerorama
16daenzerorama if (size() > 1) {
16daenzerorama list.setFirst(getRest().getFirstValue());
16daenzerorama list.setRest((ControlConstructList) getRest().getRest());
18daenzerorama } else {
18daenzerorama list = (ControlConstructList) vocabulary.nil().castTo(ControlConstructList.class);
16daenzerorama }
18daenzerorama if (hasProperty(vocabulary.first()))
18daenzerorama removeProperties(vocabulary.first());
18daenzerorama if (hasProperty(vocabulary.rest()))
18daenzerorama removeProperties(vocabulary.rest());
18daenzerorama individual.delete();
18daenzerorama
16daenzerorama return list;
16daenzerorama }
18daenzerorama
18daenzerorama public RDFList removeAll() {
18daenzerorama ControlConstructList list = this;
18daenzerorama while (list.size() > 0)
18daenzerorama list = (ControlConstructList) list.remove();
18daenzerorama return list;
18daenzerorama }
2ronwalf}