KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > books > publisher > impl > bookmodel > SectionContainerHelper


1 /*
2  * Copyright 2004 Outerthought bvba and Schaubroeck nv
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.outerj.daisy.books.publisher.impl.bookmodel;
17
18 import org.outerx.daisy.x10Bookdef.SectionContainerXml;
19 import org.outerx.daisy.x10Bookdef.SectionDocument;
20
21 import java.util.List JavaDoc;
22 import java.util.ArrayList JavaDoc;
23
24 public class SectionContainerHelper implements SectionContainer {
25     private List JavaDoc sections;
26
27     public Section[] getSections() {
28         if (sections == null)
29             return new Section[0];
30         else
31             return (Section[])sections.toArray(new Section[sections.size()]);
32     }
33
34     public void addSection(Section section) {
35         if (sections == null)
36             sections = new ArrayList JavaDoc();
37         sections.add(section);
38     }
39
40     public void addXml(SectionContainerXml sectionContainerXml) {
41         if (sections == null)
42             return;
43
44         Section[] sections = getSections();
45         SectionDocument.Section[] sectionsXml = new SectionDocument.Section[sections.length];
46         for (int i = 0; i < sections.length; i++) {
47             sectionsXml[i] = sections[i].getXml();
48         }
49         sectionContainerXml.setSectionArray(sectionsXml);
50     }
51
52 }
53
Popular Tags