ElementList.java
01 /* This file is part of the project "Hilbert II" - http://www.qedeq.org
02  *
03  * Copyright 2000-2011,  Michael Meyling <mime@qedeq.org>.
04  *
05  * "Hilbert II" is free software; you can redistribute
06  * it and/or modify it under the terms of the GNU General Public
07  * License as published by the Free Software Foundation; either
08  * version 2 of the License, or (at your option) any later version.
09  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  */
15 
16 package org.qedeq.kernel.se.base.list;
17 
18 import java.util.List;
19 
20 /**
21  * Every Operator must implement this interface. Each operator deals with arguments. These arguments
22  * form an ordered list. So there is the number of arguments, which is told by {@link #size} and the
23  <code>i</code>-th argument, accessible by {@link #getElement(int)}.
24  *
25  @author Michael Meyling
26  */
27 public interface ElementList extends Element {
28 
29     /**
30      * Get the number of arguments.
31      *
32      @return Number of arguments.
33      */
34     public int size();
35 
36     /**
37      * Get the operator.
38      *
39      @return Operator.
40      */
41     public String getOperator();
42 
43     /**
44      * Get the requested argument.
45      *
46      @param i Number of argument (starting with <code>0</code>).
47      @return <code>i</code>-th part formula.
48      @throws IllegalArgumentException <code>i</code> is not between <code>0</code> and
49      *             <code>{@link #size()} - 1</code>
50      */
51     public Element getElement(int i);
52 
53     /**
54      * Get all arguments as an list.
55      *
56      @return All elements.
57      */
58     public List getElements();
59 
60     /**
61      * FIXME 20110327 m31: do we have to use modifying methods like this or {@link ElementList#remove(int)}
62      * and so on? If we need them we have to make a deep copy. Otherwise we can save lots of space!
63      * Adds an element to end of list.
64      *
65      @param element Element to add.
66      @throws IllegalArgumentException The given element was a NullPointer.
67      */
68     public void add(final Element element);
69 
70     /**
71      * Inserts an element to specified position.
72      *
73      @param position Position of element to add.
74      @param element Element to add.
75      @throws IllegalArgumentException The given element was a NullPointer or the position was not
76      *             valid.
77      */
78     public void insert(int position, final Element element);
79 
80     /**
81      * Replaces an element at specified position.
82      *
83      @param position Position of element to replace.
84      @param element Replacement element.
85      @throws IllegalArgumentException The given element was a NullPointer or the position was not
86      *             valid.
87      */
88     public void replace(int position, final Element element);
89 
90     /**
91      * Deletes an element of element list.
92      *
93      @param i Position of element to remove.
94      @throws IllegalArgumentException The given position was not valid.
95      */
96     public void remove(final int i);
97 
98 }