Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
DocumentTOC |
|
| 1.8181818181818181;1,818 |
1 | /* | |
2 | * $Id$ | |
3 | */ | |
4 | ||
5 | package org.apache.maven.doxia.docrenderer.document; | |
6 | ||
7 | //---------------------------------/ | |
8 | //- Imported classes and packages -/ | |
9 | //---------------------------------/ | |
10 | ||
11 | import java.util.Date; | |
12 | ||
13 | /** | |
14 | * A Table Of Content for the document. | |
15 | * | |
16 | * @version $Revision$ $Date$ | |
17 | */ | |
18 | 0 | public class DocumentTOC implements java.io.Serializable { |
19 | ||
20 | ||
21 | //--------------------------/ | |
22 | //- Class/Member Variables -/ | |
23 | //--------------------------/ | |
24 | ||
25 | /** | |
26 | * Field name | |
27 | */ | |
28 | private String name; | |
29 | ||
30 | /** | |
31 | * Field items | |
32 | */ | |
33 | private java.util.List items; | |
34 | ||
35 | ||
36 | //-----------/ | |
37 | //- Methods -/ | |
38 | //-----------/ | |
39 | ||
40 | /** | |
41 | * Method addItem | |
42 | * | |
43 | * @param documentTOCItem | |
44 | */ | |
45 | public void addItem(DocumentTOCItem documentTOCItem) | |
46 | { | |
47 | 0 | if ( !(documentTOCItem instanceof DocumentTOCItem) ) |
48 | { | |
49 | 0 | throw new ClassCastException( "DocumentTOC.addItems(documentTOCItem) parameter must be instanceof " + DocumentTOCItem.class.getName() ); |
50 | } | |
51 | 0 | getItems().add( documentTOCItem ); |
52 | 0 | } //-- void addItem(DocumentTOCItem) |
53 | ||
54 | /** | |
55 | * Method equals | |
56 | * | |
57 | * @param other | |
58 | */ | |
59 | public boolean equals(Object other) | |
60 | { | |
61 | 0 | if ( this == other) |
62 | { | |
63 | 0 | return true; |
64 | } | |
65 | ||
66 | 0 | if ( !(other instanceof DocumentTOC) ) |
67 | { | |
68 | 0 | return false; |
69 | } | |
70 | ||
71 | 0 | DocumentTOC that = (DocumentTOC) other; |
72 | 0 | boolean result = true; |
73 | 0 | result = result && ( getName() == null ? that.getName() == null : getName().equals( that.getName() ) ); |
74 | 0 | result = result && ( getItems() == null ? that.getItems() == null : getItems().equals( that.getItems() ) ); |
75 | 0 | return result; |
76 | } //-- boolean equals(Object) | |
77 | ||
78 | /** | |
79 | * Method getItems | |
80 | */ | |
81 | public java.util.List getItems() | |
82 | { | |
83 | 0 | if ( this.items == null ) |
84 | { | |
85 | 0 | this.items = new java.util.ArrayList(); |
86 | } | |
87 | ||
88 | 0 | return this.items; |
89 | } //-- java.util.List getItems() | |
90 | ||
91 | /** | |
92 | * Get The name to use for the menu. | |
93 | */ | |
94 | public String getName() | |
95 | { | |
96 | 0 | return this.name; |
97 | } //-- String getName() | |
98 | ||
99 | /** | |
100 | * Method hashCode | |
101 | */ | |
102 | public int hashCode() | |
103 | { | |
104 | 0 | int result = 17; |
105 | long tmp; | |
106 | 0 | result = 37 * result + ( name != null ? name.hashCode() : 0 ); |
107 | 0 | result = 37 * result + ( items != null ? items.hashCode() : 0 ); |
108 | 0 | return result; |
109 | } //-- int hashCode() | |
110 | ||
111 | /** | |
112 | * Method removeItem | |
113 | * | |
114 | * @param documentTOCItem | |
115 | */ | |
116 | public void removeItem(DocumentTOCItem documentTOCItem) | |
117 | { | |
118 | 0 | if ( !(documentTOCItem instanceof DocumentTOCItem) ) |
119 | { | |
120 | 0 | throw new ClassCastException( "DocumentTOC.removeItems(documentTOCItem) parameter must be instanceof " + DocumentTOCItem.class.getName() ); |
121 | } | |
122 | 0 | getItems().remove( documentTOCItem ); |
123 | 0 | } //-- void removeItem(DocumentTOCItem) |
124 | ||
125 | /** | |
126 | * Set TOC item. | |
127 | * | |
128 | * @param items | |
129 | */ | |
130 | public void setItems(java.util.List items) | |
131 | { | |
132 | 0 | this.items = items; |
133 | 0 | } //-- void setItems(java.util.List) |
134 | ||
135 | /** | |
136 | * Set The name to use for the menu. | |
137 | * | |
138 | * @param name | |
139 | */ | |
140 | public void setName(String name) | |
141 | { | |
142 | 0 | this.name = name; |
143 | 0 | } //-- void setName(String) |
144 | ||
145 | /** | |
146 | * Method toString | |
147 | */ | |
148 | public java.lang.String toString() | |
149 | { | |
150 | 0 | StringBuffer buf = new StringBuffer(); |
151 | 0 | buf.append( "name = '" ); |
152 | 0 | buf.append( getName() + "'" ); |
153 | 0 | buf.append( "\n" ); |
154 | 0 | buf.append( "items = '" ); |
155 | 0 | buf.append( getItems() + "'" ); |
156 | 0 | return buf.toString(); |
157 | } //-- java.lang.String toString() | |
158 | ||
159 | ||
160 | 0 | private String modelEncoding = "UTF-8"; |
161 | ||
162 | public void setModelEncoding( String modelEncoding ) | |
163 | { | |
164 | 0 | this.modelEncoding = modelEncoding; |
165 | 0 | } |
166 | ||
167 | public String getModelEncoding() | |
168 | { | |
169 | 0 | return modelEncoding; |
170 | } | |
171 | } |