/*********************************************************************/ /* */ /* AgentService Framework */ /* www.agentservice.it */ /* */ /* Copyright (C) 2007 l.i.d.o. - DIST, University of Genoa, Italy */ /* GNU Lesser General Public License */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation, */ /* version 2.1 of the License. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public */ /* License along with this library; if not, write to the */ /* Free Software Foundation, Inc., 59 Temple Place - Suite 330, */ /* Boston, MA 02111-1307, USA. */ /* */ /*********************************************************************/ using System.Collections; using System; using AgentService.Ontology; namespace AgentService.Ontology.Interfaces { /// /// A class that provides to manage a list of content elements. /// public class ContentElementList : ContentElement { private ArrayList elements = new ArrayList(); /// /// Construct a content element list. /// public ContentElementList() { } public ArrayList Elements { get { return elements; } } /// /// Adds a content element to the content element list. /// /// The content element to Add. public void Add(ContentElement element) { try { elements.Add(element); } catch(Exception ex) { throw new OntologyException(ex.ToString()); } } /// /// Returns the Size of the content element list. /// /// public int Size() { try { return elements.Count; } catch(Exception ex) { throw new OntologyException(ex.ToString()); } } /// /// Returns the element in the position i. /// /// The index of the element /// public ContentElement GetElement(int i) { try { return (ContentElement) elements[i]; } catch(Exception ex) { throw new OntologyException(ex.ToString()); } } /// /// Resets the content element list. /// public void Clear() { try { elements.Clear(); } catch(Exception ex) { throw new OntologyException(ex.ToString()); } } /// /// Returns true if the content element list Contains a given content element. /// /// The content element. /// public bool Contains (ContentElement element) { try { return elements.Contains(element); } catch(Exception ex) { throw new OntologyException(ex.ToString()); } } /// /// Returns the index of a given content element. /// /// The content element. /// public int IndexOf (ContentElement element) { try { return elements.IndexOf(element); } catch(Exception ex) { throw new OntologyException(ex.ToString()); } } /// /// Removes a given content element. /// /// The index of the content element to Remove. public void Remove (int index) { try { elements.Remove(index); } catch(Exception ex) { throw new OntologyException(ex.ToString()); } } /// /// Checks if the content element list is empty. /// /// public bool IsEmpty () { try { if(elements.Count==0) return true; else return false; } catch(Exception ex) { throw new OntologyException(ex.ToString()); } } /// /// Returns an array that Contains the content elements of the content element list. /// /// public ContentElement[] ToArray () { try { int size = elements.Count; ContentElement[] tmp = new ContentElement[size]; for (int i = 0; i < size; i++) tmp[i] = (ContentElement)elements[i]; return tmp; } catch(Exception ex) { throw new OntologyException(ex.ToString()); } } } }