1 | package org.greenstone.gsdl3.gs3build.metadata;
|
---|
2 |
|
---|
3 | import java.io.PrintWriter;
|
---|
4 |
|
---|
5 | import java.util.List;
|
---|
6 | import java.util.ArrayList;
|
---|
7 | import java.util.Map;
|
---|
8 | import java.util.LinkedHashMap;
|
---|
9 | import java.util.Iterator;
|
---|
10 |
|
---|
11 | /**
|
---|
12 | * A helpful 'superclass' of METSStructure and METSDivision which allows for some
|
---|
13 | * simple generalisation of the two classes.
|
---|
14 | */
|
---|
15 |
|
---|
16 | public abstract class AbstractStructure
|
---|
17 | { Map children;
|
---|
18 | AbstractStructure parent;
|
---|
19 | String ID; // the unique identifier for this division (unique within the
|
---|
20 | // document, not necessarily unique within the collection).
|
---|
21 |
|
---|
22 | public AbstractStructure(String ID)
|
---|
23 | { this.children = new LinkedHashMap();
|
---|
24 | this.parent = null;
|
---|
25 | this.ID = ID;
|
---|
26 | }
|
---|
27 |
|
---|
28 | public AbstractStructure getParent()
|
---|
29 | { return this.parent;
|
---|
30 | }
|
---|
31 |
|
---|
32 | public void setParent(AbstractStructure parent)
|
---|
33 | { this.parent = parent;
|
---|
34 | }
|
---|
35 |
|
---|
36 | /**
|
---|
37 | * Get the identifer of this structure
|
---|
38 | *
|
---|
39 | * @param <code>String</code> the identifier.
|
---|
40 | */
|
---|
41 | public String getID()
|
---|
42 | { return this.ID;
|
---|
43 | }
|
---|
44 |
|
---|
45 | public abstract String getStructureType();
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * Add a child division, or sub-division to the document. For example,
|
---|
49 | * sections within a chapter.
|
---|
50 | *
|
---|
51 | * @param <code>METSDivision</code> the child division.
|
---|
52 | */
|
---|
53 | public void addDivision(METSDivision child)
|
---|
54 | { this.children.put(child.getLabel(), child);
|
---|
55 | child.setParent(this);
|
---|
56 | }
|
---|
57 |
|
---|
58 | public Iterator getChildIterator()
|
---|
59 | { return this.children.values().iterator();
|
---|
60 | }
|
---|
61 |
|
---|
62 | public int size()
|
---|
63 | { return this.children.size();
|
---|
64 | }
|
---|
65 | }
|
---|
66 |
|
---|