3
* <p>Class OWLContainer - A Container item that holds different OWLItems</p>
8
* <p>flag for type equivalence</p>
10
public constant is_container=1;
13
* <p>The iterator for this container</p>
15
private int iterator = -1;
18
* <p>the array holding the OWLItems</p>
20
public array container = ({});
24
* <p>Add a OWLItem to this container</p>
27
* @param item - OWLItem to add
29
public void add(Visconte.Onto.Item.OWLItem owlitem) {
30
container+=({owlitem});
35
* <p>Returns the next OWLItem in the container and pushes the iterator</p>
38
* @return OWLItem - which comes next
40
public Visconte.Onto.Item.OWLItem next()
42
Visconte.Onto.Item.OWLItem current_item;
43
if(iterator>=0 && iterator <sizeof(container))
45
current_item = container[iterator];
51
current_item = container[iterator];
60
* <p>Checks if the container has more items</p>
65
public int has_items()
67
if(iterator>=0 && iterator <sizeof(container))
79
* <p>Find a OWLItem in the container</p>
80
* @param id - the id of the owlitem to find
84
public Visconte.Onto.Item.OWLItem find_by_id(string id)
86
Visconte.Onto.Item.OWLItem item;
87
foreach (container,Visconte.Onto.Item.OWLItem tmp_item)
89
if(tmp_item->get_Id()==id)
100
* <p>Prints a String with the content of the container</p>
103
* @return the string dump
105
public string to_string()
107
string content ="\nContent of OWLContainer:\n";
108
foreach(container,Visconte.Onto.Item.OWLItem i)
109
content+="\nItem id:"+i->get_Id()+", label:"+i->get_Label();
116
* <p>Return the size of the container</p>
119
* @return size as int
123
return sizeof(container);
127
* <p>Resets the iterator manuall</p>
132
public void reset_iterator()
134
if(sizeof(container)>0)
141
* <p>merges another OWLContainer with this one. Duplicates will be ommited </p>
142
* @param merge_container - the OWLContainer to merge
146
public int merge(object merge_container)
149
if(merge_container && merge_container->is_container)
151
foreach(merge_container->container,Visconte.Onto.Item.OWLItem tmp_item)
153
if(!find_by_id(tmp_item->get_Id()))
154
container+=({tmp_item});