View Javadoc
1   // =================== DO NOT EDIT THIS FILE ====================
2   // Generated by Modello 1.9.1,
3   // any modifications will be overwritten.
4   // ==============================================================
5   
6   package org.apache.maven.doxia.document.io.xpp3;
7   
8     //---------------------------------/
9    //- Imported classes and packages -/
10  //---------------------------------/
11  
12  import java.io.OutputStream;
13  import java.io.Writer;
14  import java.util.Iterator;
15  import org.apache.maven.doxia.document.DocumentAuthor;
16  import org.apache.maven.doxia.document.DocumentCover;
17  import org.apache.maven.doxia.document.DocumentHyperlinkBehaviour;
18  import org.apache.maven.doxia.document.DocumentMeta;
19  import org.apache.maven.doxia.document.DocumentModel;
20  import org.apache.maven.doxia.document.DocumentStatistic;
21  import org.apache.maven.doxia.document.DocumentTOC;
22  import org.apache.maven.doxia.document.DocumentTOCItem;
23  import org.apache.maven.doxia.document.DocumentTemplate;
24  import org.codehaus.plexus.util.xml.pull.MXSerializer;
25  import org.codehaus.plexus.util.xml.pull.XmlSerializer;
26  
27  /**
28   * Class DocumentXpp3Writer.
29   * 
30   * @version $Revision$ $Date$
31   */
32  @SuppressWarnings( "all" )
33  public class DocumentXpp3Writer
34  {
35  
36        //--------------------------/
37       //- Class/Member Variables -/
38      //--------------------------/
39  
40      /**
41       * Field NAMESPACE.
42       */
43      private static final String NAMESPACE = null;
44  
45      /**
46       * Field fileComment.
47       */
48      private String fileComment = null;
49  
50  
51        //-----------/
52       //- Methods -/
53      //-----------/
54  
55      /**
56       * Method setFileComment.
57       * 
58       * @param fileComment
59       */
60      public void setFileComment( String fileComment )
61      {
62          this.fileComment = fileComment;
63      } //-- void setFileComment( String )
64  
65      /**
66       * Method write.
67       * 
68       * @param writer
69       * @param documentModel
70       * @throws java.io.IOException
71       */
72      public void write( Writer writer, DocumentModel documentModel )
73          throws java.io.IOException
74      {
75          XmlSerializer serializer = new MXSerializer();
76          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
77          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
78          serializer.setOutput( writer );
79          serializer.startDocument( documentModel.getModelEncoding(), null );
80          writeDocumentModel( documentModel, "document", serializer );
81          serializer.endDocument();
82      } //-- void write( Writer, DocumentModel )
83  
84      /**
85       * Method write.
86       * 
87       * @param stream
88       * @param documentModel
89       * @throws java.io.IOException
90       */
91      public void write( OutputStream stream, DocumentModel documentModel )
92          throws java.io.IOException
93      {
94          XmlSerializer serializer = new MXSerializer();
95          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
96          serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
97          serializer.setOutput( stream, documentModel.getModelEncoding() );
98          serializer.startDocument( documentModel.getModelEncoding(), null );
99          writeDocumentModel( documentModel, "document", serializer );
100         serializer.endDocument();
101     } //-- void write( OutputStream, DocumentModel )
102 
103     /**
104      * Method writeDocumentAuthor.
105      * 
106      * @param documentAuthor
107      * @param serializer
108      * @param tagName
109      * @throws java.io.IOException
110      */
111     private void writeDocumentAuthor( DocumentAuthor documentAuthor, String tagName, XmlSerializer serializer )
112         throws java.io.IOException
113     {
114         serializer.startTag( NAMESPACE, tagName );
115         if ( documentAuthor.getFirstName() != null )
116         {
117             serializer.startTag( NAMESPACE, "firstName" ).text( documentAuthor.getFirstName() ).endTag( NAMESPACE, "firstName" );
118         }
119         if ( documentAuthor.getLastName() != null )
120         {
121             serializer.startTag( NAMESPACE, "lastName" ).text( documentAuthor.getLastName() ).endTag( NAMESPACE, "lastName" );
122         }
123         if ( documentAuthor.getName() != null )
124         {
125             serializer.startTag( NAMESPACE, "name" ).text( documentAuthor.getName() ).endTag( NAMESPACE, "name" );
126         }
127         if ( documentAuthor.getInitials() != null )
128         {
129             serializer.startTag( NAMESPACE, "initials" ).text( documentAuthor.getInitials() ).endTag( NAMESPACE, "initials" );
130         }
131         if ( documentAuthor.getTitle() != null )
132         {
133             serializer.startTag( NAMESPACE, "title" ).text( documentAuthor.getTitle() ).endTag( NAMESPACE, "title" );
134         }
135         if ( documentAuthor.getPosition() != null )
136         {
137             serializer.startTag( NAMESPACE, "position" ).text( documentAuthor.getPosition() ).endTag( NAMESPACE, "position" );
138         }
139         if ( documentAuthor.getEmail() != null )
140         {
141             serializer.startTag( NAMESPACE, "email" ).text( documentAuthor.getEmail() ).endTag( NAMESPACE, "email" );
142         }
143         if ( documentAuthor.getPhoneNumber() != null )
144         {
145             serializer.startTag( NAMESPACE, "phoneNumber" ).text( documentAuthor.getPhoneNumber() ).endTag( NAMESPACE, "phoneNumber" );
146         }
147         if ( documentAuthor.getFaxNumber() != null )
148         {
149             serializer.startTag( NAMESPACE, "faxNumber" ).text( documentAuthor.getFaxNumber() ).endTag( NAMESPACE, "faxNumber" );
150         }
151         if ( documentAuthor.getCompanyName() != null )
152         {
153             serializer.startTag( NAMESPACE, "companyName" ).text( documentAuthor.getCompanyName() ).endTag( NAMESPACE, "companyName" );
154         }
155         if ( documentAuthor.getStreet() != null )
156         {
157             serializer.startTag( NAMESPACE, "street" ).text( documentAuthor.getStreet() ).endTag( NAMESPACE, "street" );
158         }
159         if ( documentAuthor.getCity() != null )
160         {
161             serializer.startTag( NAMESPACE, "city" ).text( documentAuthor.getCity() ).endTag( NAMESPACE, "city" );
162         }
163         if ( documentAuthor.getPostalCode() != null )
164         {
165             serializer.startTag( NAMESPACE, "postalCode" ).text( documentAuthor.getPostalCode() ).endTag( NAMESPACE, "postalCode" );
166         }
167         if ( documentAuthor.getCountry() != null )
168         {
169             serializer.startTag( NAMESPACE, "country" ).text( documentAuthor.getCountry() ).endTag( NAMESPACE, "country" );
170         }
171         if ( documentAuthor.getState() != null )
172         {
173             serializer.startTag( NAMESPACE, "state" ).text( documentAuthor.getState() ).endTag( NAMESPACE, "state" );
174         }
175         serializer.endTag( NAMESPACE, tagName );
176     } //-- void writeDocumentAuthor( DocumentAuthor, String, XmlSerializer )
177 
178     /**
179      * Method writeDocumentCover.
180      * 
181      * @param documentCover
182      * @param serializer
183      * @param tagName
184      * @throws java.io.IOException
185      */
186     private void writeDocumentCover( DocumentCover documentCover, String tagName, XmlSerializer serializer )
187         throws java.io.IOException
188     {
189         serializer.startTag( NAMESPACE, tagName );
190         if ( documentCover.getCoverTitle() != null )
191         {
192             serializer.startTag( NAMESPACE, "coverTitle" ).text( documentCover.getCoverTitle() ).endTag( NAMESPACE, "coverTitle" );
193         }
194         if ( documentCover.getCoverSubTitle() != null )
195         {
196             serializer.startTag( NAMESPACE, "coverSubTitle" ).text( documentCover.getCoverSubTitle() ).endTag( NAMESPACE, "coverSubTitle" );
197         }
198         if ( documentCover.getCoverVersion() != null )
199         {
200             serializer.startTag( NAMESPACE, "coverVersion" ).text( documentCover.getCoverVersion() ).endTag( NAMESPACE, "coverVersion" );
201         }
202         if ( documentCover.getCoverType() != null )
203         {
204             serializer.startTag( NAMESPACE, "coverType" ).text( documentCover.getCoverType() ).endTag( NAMESPACE, "coverType" );
205         }
206         if ( documentCover.getCoverDate() != null )
207         {
208             serializer.startTag( NAMESPACE, "coverDate" ).text( new java.text.SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS", java.util.Locale.US ).format( documentCover.getCoverDate() ) ).endTag( NAMESPACE, "coverDate" );
209         }
210         if ( documentCover.getCoverdate() != null )
211         {
212             serializer.startTag( NAMESPACE, "coverdate" ).text( documentCover.getCoverdate() ).endTag( NAMESPACE, "coverdate" );
213         }
214         if ( ( documentCover.getAuthors() != null ) && ( documentCover.getAuthors().size() > 0 ) )
215         {
216             serializer.startTag( NAMESPACE, "authors" );
217             for ( Iterator iter = documentCover.getAuthors().iterator(); iter.hasNext(); )
218             {
219                 DocumentAuthor o = (DocumentAuthor) iter.next();
220                 writeDocumentAuthor( o, "author", serializer );
221             }
222             serializer.endTag( NAMESPACE, "authors" );
223         }
224         if ( documentCover.getAuthor() != null )
225         {
226             serializer.startTag( NAMESPACE, "author" ).text( documentCover.getAuthor() ).endTag( NAMESPACE, "author" );
227         }
228         if ( documentCover.getProjectName() != null )
229         {
230             serializer.startTag( NAMESPACE, "projectName" ).text( documentCover.getProjectName() ).endTag( NAMESPACE, "projectName" );
231         }
232         if ( documentCover.getProjectLogo() != null )
233         {
234             serializer.startTag( NAMESPACE, "projectLogo" ).text( documentCover.getProjectLogo() ).endTag( NAMESPACE, "projectLogo" );
235         }
236         if ( documentCover.getCompanyName() != null )
237         {
238             serializer.startTag( NAMESPACE, "companyName" ).text( documentCover.getCompanyName() ).endTag( NAMESPACE, "companyName" );
239         }
240         if ( documentCover.getCompanyLogo() != null )
241         {
242             serializer.startTag( NAMESPACE, "companyLogo" ).text( documentCover.getCompanyLogo() ).endTag( NAMESPACE, "companyLogo" );
243         }
244         serializer.endTag( NAMESPACE, tagName );
245     } //-- void writeDocumentCover( DocumentCover, String, XmlSerializer )
246 
247     /**
248      * Method writeDocumentHyperlinkBehaviour.
249      * 
250      * @param documentHyperlinkBehaviour
251      * @param serializer
252      * @param tagName
253      * @throws java.io.IOException
254      */
255     private void writeDocumentHyperlinkBehaviour( DocumentHyperlinkBehaviour documentHyperlinkBehaviour, String tagName, XmlSerializer serializer )
256         throws java.io.IOException
257     {
258         serializer.startTag( NAMESPACE, tagName );
259         if ( ( documentHyperlinkBehaviour.getTargetFrame() != null ) && !documentHyperlinkBehaviour.getTargetFrame().equals( "_self" ) )
260         {
261             serializer.attribute( NAMESPACE, "targetFrame", documentHyperlinkBehaviour.getTargetFrame() );
262         }
263         serializer.endTag( NAMESPACE, tagName );
264     } //-- void writeDocumentHyperlinkBehaviour( DocumentHyperlinkBehaviour, String, XmlSerializer )
265 
266     /**
267      * Method writeDocumentMeta.
268      * 
269      * @param documentMeta
270      * @param serializer
271      * @param tagName
272      * @throws java.io.IOException
273      */
274     private void writeDocumentMeta( DocumentMeta documentMeta, String tagName, XmlSerializer serializer )
275         throws java.io.IOException
276     {
277         serializer.startTag( NAMESPACE, tagName );
278         if ( documentMeta.getTitle() != null )
279         {
280             serializer.startTag( NAMESPACE, "title" ).text( documentMeta.getTitle() ).endTag( NAMESPACE, "title" );
281         }
282         if ( documentMeta.getAuthor() != null )
283         {
284             serializer.startTag( NAMESPACE, "author" ).text( documentMeta.getAuthor() ).endTag( NAMESPACE, "author" );
285         }
286         if ( ( documentMeta.getAuthors() != null ) && ( documentMeta.getAuthors().size() > 0 ) )
287         {
288             serializer.startTag( NAMESPACE, "authors" );
289             for ( Iterator iter = documentMeta.getAuthors().iterator(); iter.hasNext(); )
290             {
291                 DocumentAuthor o = (DocumentAuthor) iter.next();
292                 writeDocumentAuthor( o, "author", serializer );
293             }
294             serializer.endTag( NAMESPACE, "authors" );
295         }
296         if ( documentMeta.getSubject() != null )
297         {
298             serializer.startTag( NAMESPACE, "subject" ).text( documentMeta.getSubject() ).endTag( NAMESPACE, "subject" );
299         }
300         if ( documentMeta.getKeywords() != null )
301         {
302             serializer.startTag( NAMESPACE, "keywords" ).text( documentMeta.getKeywords() ).endTag( NAMESPACE, "keywords" );
303         }
304         if ( ( documentMeta.getKeyWords() != null ) && ( documentMeta.getKeyWords().size() > 0 ) )
305         {
306             serializer.startTag( NAMESPACE, "keyWords" );
307             for ( Iterator iter = documentMeta.getKeyWords().iterator(); iter.hasNext(); )
308             {
309                 String keyWord = (String) iter.next();
310                 serializer.startTag( NAMESPACE, "keyWord" ).text( keyWord ).endTag( NAMESPACE, "keyWord" );
311             }
312             serializer.endTag( NAMESPACE, "keyWords" );
313         }
314         if ( documentMeta.getPageSize() != null )
315         {
316             serializer.startTag( NAMESPACE, "pageSize" ).text( documentMeta.getPageSize() ).endTag( NAMESPACE, "pageSize" );
317         }
318         if ( documentMeta.getGenerator() != null )
319         {
320             serializer.startTag( NAMESPACE, "generator" ).text( documentMeta.getGenerator() ).endTag( NAMESPACE, "generator" );
321         }
322         if ( documentMeta.getDescription() != null )
323         {
324             serializer.startTag( NAMESPACE, "description" ).text( documentMeta.getDescription() ).endTag( NAMESPACE, "description" );
325         }
326         if ( documentMeta.getInitialCreator() != null )
327         {
328             serializer.startTag( NAMESPACE, "initialCreator" ).text( documentMeta.getInitialCreator() ).endTag( NAMESPACE, "initialCreator" );
329         }
330         if ( documentMeta.getCreator() != null )
331         {
332             serializer.startTag( NAMESPACE, "creator" ).text( documentMeta.getCreator() ).endTag( NAMESPACE, "creator" );
333         }
334         if ( documentMeta.getPrintedBy() != null )
335         {
336             serializer.startTag( NAMESPACE, "printedBy" ).text( documentMeta.getPrintedBy() ).endTag( NAMESPACE, "printedBy" );
337         }
338         if ( documentMeta.getCreationDate() != null )
339         {
340             serializer.startTag( NAMESPACE, "creationDate" ).text( new java.text.SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS", java.util.Locale.US ).format( documentMeta.getCreationDate() ) ).endTag( NAMESPACE, "creationDate" );
341         }
342         if ( documentMeta.getCreationdate() != null )
343         {
344             serializer.startTag( NAMESPACE, "creationdate" ).text( documentMeta.getCreationdate() ).endTag( NAMESPACE, "creationdate" );
345         }
346         if ( documentMeta.getDate() != null )
347         {
348             serializer.startTag( NAMESPACE, "date" ).text( new java.text.SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS", java.util.Locale.US ).format( documentMeta.getDate() ) ).endTag( NAMESPACE, "date" );
349         }
350         if ( documentMeta.getModifydate() != null )
351         {
352             serializer.startTag( NAMESPACE, "modifydate" ).text( documentMeta.getModifydate() ).endTag( NAMESPACE, "modifydate" );
353         }
354         if ( documentMeta.getPrintDate() != null )
355         {
356             serializer.startTag( NAMESPACE, "printDate" ).text( new java.text.SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS", java.util.Locale.US ).format( documentMeta.getPrintDate() ) ).endTag( NAMESPACE, "printDate" );
357         }
358         if ( documentMeta.getPrintdate() != null )
359         {
360             serializer.startTag( NAMESPACE, "printdate" ).text( documentMeta.getPrintdate() ).endTag( NAMESPACE, "printdate" );
361         }
362         if ( documentMeta.getTemplate() != null )
363         {
364             writeDocumentTemplate( (DocumentTemplate) documentMeta.getTemplate(), "template", serializer );
365         }
366         if ( documentMeta.getHyperlinkBehaviour() != null )
367         {
368             writeDocumentHyperlinkBehaviour( (DocumentHyperlinkBehaviour) documentMeta.getHyperlinkBehaviour(), "hyperlinkBehaviour", serializer );
369         }
370         if ( ( documentMeta.getLanguage() != null ) && !documentMeta.getLanguage().equals( "en-US" ) )
371         {
372             serializer.startTag( NAMESPACE, "language" ).text( documentMeta.getLanguage() ).endTag( NAMESPACE, "language" );
373         }
374         if ( documentMeta.getEditingCycles() != 0L )
375         {
376             serializer.startTag( NAMESPACE, "editingCycles" ).text( String.valueOf( documentMeta.getEditingCycles() ) ).endTag( NAMESPACE, "editingCycles" );
377         }
378         if ( documentMeta.getEditingDuration() != 0L )
379         {
380             serializer.startTag( NAMESPACE, "editingDuration" ).text( String.valueOf( documentMeta.getEditingDuration() ) ).endTag( NAMESPACE, "editingDuration" );
381         }
382         if ( documentMeta.getDocumentStatistic() != null )
383         {
384             writeDocumentStatistic( (DocumentStatistic) documentMeta.getDocumentStatistic(), "documentStatistic", serializer );
385         }
386         if ( documentMeta.isConfidential() != false )
387         {
388             serializer.startTag( NAMESPACE, "confidential" ).text( String.valueOf( documentMeta.isConfidential() ) ).endTag( NAMESPACE, "confidential" );
389         }
390         if ( documentMeta.isDraft() != false )
391         {
392             serializer.startTag( NAMESPACE, "draft" ).text( String.valueOf( documentMeta.isDraft() ) ).endTag( NAMESPACE, "draft" );
393         }
394         serializer.endTag( NAMESPACE, tagName );
395     } //-- void writeDocumentMeta( DocumentMeta, String, XmlSerializer )
396 
397     /**
398      * Method writeDocumentModel.
399      * 
400      * @param documentModel
401      * @param serializer
402      * @param tagName
403      * @throws java.io.IOException
404      */
405     private void writeDocumentModel( DocumentModel documentModel, String tagName, XmlSerializer serializer )
406         throws java.io.IOException
407     {
408         if ( this.fileComment != null )
409         {
410         serializer.comment(this.fileComment);
411         }
412         serializer.setPrefix( "", "http://maven.apache.org/DOCUMENT/1.0.1" );
413         serializer.setPrefix( "xsi", "http://www.w3.org/2001/XMLSchema-instance" );
414         serializer.startTag( NAMESPACE, tagName );
415         serializer.attribute( "", "xsi:schemaLocation", "http://maven.apache.org/DOCUMENT/1.0.1 https://maven.apache.org/xsd/document-1.0.1.xsd" );
416         if ( documentModel.getOutputName() != null )
417         {
418             serializer.attribute( NAMESPACE, "outputName", documentModel.getOutputName() );
419         }
420         if ( documentModel.getMeta() != null )
421         {
422             writeDocumentMeta( (DocumentMeta) documentModel.getMeta(), "meta", serializer );
423         }
424         if ( documentModel.getToc() != null )
425         {
426             writeDocumentTOC( (DocumentTOC) documentModel.getToc(), "toc", serializer );
427         }
428         if ( documentModel.getCover() != null )
429         {
430             writeDocumentCover( (DocumentCover) documentModel.getCover(), "cover", serializer );
431         }
432         serializer.endTag( NAMESPACE, tagName );
433     } //-- void writeDocumentModel( DocumentModel, String, XmlSerializer )
434 
435     /**
436      * Method writeDocumentStatistic.
437      * 
438      * @param documentStatistic
439      * @param serializer
440      * @param tagName
441      * @throws java.io.IOException
442      */
443     private void writeDocumentStatistic( DocumentStatistic documentStatistic, String tagName, XmlSerializer serializer )
444         throws java.io.IOException
445     {
446         serializer.startTag( NAMESPACE, tagName );
447         if ( documentStatistic.getPageCount() != 0L )
448         {
449             serializer.attribute( NAMESPACE, "pageCount", String.valueOf( documentStatistic.getPageCount() ) );
450         }
451         if ( documentStatistic.getTableCount() != 0L )
452         {
453             serializer.attribute( NAMESPACE, "tableCount", String.valueOf( documentStatistic.getTableCount() ) );
454         }
455         if ( documentStatistic.getDrawCount() != 0L )
456         {
457             serializer.attribute( NAMESPACE, "drawCount", String.valueOf( documentStatistic.getDrawCount() ) );
458         }
459         if ( documentStatistic.getImageCount() != 0L )
460         {
461             serializer.attribute( NAMESPACE, "imageCount", String.valueOf( documentStatistic.getImageCount() ) );
462         }
463         if ( documentStatistic.getObjectCount() != 0L )
464         {
465             serializer.attribute( NAMESPACE, "objectCount", String.valueOf( documentStatistic.getObjectCount() ) );
466         }
467         if ( documentStatistic.getOleObjectCount() != 0L )
468         {
469             serializer.attribute( NAMESPACE, "oleObjectCount", String.valueOf( documentStatistic.getOleObjectCount() ) );
470         }
471         if ( documentStatistic.getParagraphCount() != 0L )
472         {
473             serializer.attribute( NAMESPACE, "paragraphCount", String.valueOf( documentStatistic.getParagraphCount() ) );
474         }
475         if ( documentStatistic.getWordCount() != 0L )
476         {
477             serializer.attribute( NAMESPACE, "wordCount", String.valueOf( documentStatistic.getWordCount() ) );
478         }
479         if ( documentStatistic.getCharacterCount() != 0L )
480         {
481             serializer.attribute( NAMESPACE, "characterCount", String.valueOf( documentStatistic.getCharacterCount() ) );
482         }
483         if ( documentStatistic.getRowCount() != 0L )
484         {
485             serializer.attribute( NAMESPACE, "rowCount", String.valueOf( documentStatistic.getRowCount() ) );
486         }
487         if ( documentStatistic.getFrameCount() != 0L )
488         {
489             serializer.attribute( NAMESPACE, "frameCount", String.valueOf( documentStatistic.getFrameCount() ) );
490         }
491         if ( documentStatistic.getSentenceCount() != 0L )
492         {
493             serializer.attribute( NAMESPACE, "sentenceCount", String.valueOf( documentStatistic.getSentenceCount() ) );
494         }
495         if ( documentStatistic.getSyllableCount() != 0L )
496         {
497             serializer.attribute( NAMESPACE, "syllableCount", String.valueOf( documentStatistic.getSyllableCount() ) );
498         }
499         if ( documentStatistic.getNonWhitespaceCharacterCount() != 0L )
500         {
501             serializer.attribute( NAMESPACE, "nonWhitespaceCharacterCount", String.valueOf( documentStatistic.getNonWhitespaceCharacterCount() ) );
502         }
503         serializer.endTag( NAMESPACE, tagName );
504     } //-- void writeDocumentStatistic( DocumentStatistic, String, XmlSerializer )
505 
506     /**
507      * Method writeDocumentTOC.
508      * 
509      * @param documentTOC
510      * @param serializer
511      * @param tagName
512      * @throws java.io.IOException
513      */
514     private void writeDocumentTOC( DocumentTOC documentTOC, String tagName, XmlSerializer serializer )
515         throws java.io.IOException
516     {
517         serializer.startTag( NAMESPACE, tagName );
518         if ( documentTOC.getName() != null )
519         {
520             serializer.attribute( NAMESPACE, "name", documentTOC.getName() );
521         }
522         if ( documentTOC.getDepth() != 0 )
523         {
524             serializer.attribute( NAMESPACE, "depth", String.valueOf( documentTOC.getDepth() ) );
525         }
526         if ( ( documentTOC.getItems() != null ) && ( documentTOC.getItems().size() > 0 ) )
527         {
528             for ( Iterator iter = documentTOC.getItems().iterator(); iter.hasNext(); )
529             {
530                 DocumentTOCItem o = (DocumentTOCItem) iter.next();
531                 writeDocumentTOCItem( o, "item", serializer );
532             }
533         }
534         serializer.endTag( NAMESPACE, tagName );
535     } //-- void writeDocumentTOC( DocumentTOC, String, XmlSerializer )
536 
537     /**
538      * Method writeDocumentTOCItem.
539      * 
540      * @param documentTOCItem
541      * @param serializer
542      * @param tagName
543      * @throws java.io.IOException
544      */
545     private void writeDocumentTOCItem( DocumentTOCItem documentTOCItem, String tagName, XmlSerializer serializer )
546         throws java.io.IOException
547     {
548         serializer.startTag( NAMESPACE, tagName );
549         if ( documentTOCItem.getName() != null )
550         {
551             serializer.attribute( NAMESPACE, "name", documentTOCItem.getName() );
552         }
553         if ( documentTOCItem.getRef() != null )
554         {
555             serializer.attribute( NAMESPACE, "ref", documentTOCItem.getRef() );
556         }
557         if ( documentTOCItem.isCollapse() != false )
558         {
559             serializer.attribute( NAMESPACE, "collapse", String.valueOf( documentTOCItem.isCollapse() ) );
560         }
561         if ( ( documentTOCItem.getItems() != null ) && ( documentTOCItem.getItems().size() > 0 ) )
562         {
563             for ( Iterator iter = documentTOCItem.getItems().iterator(); iter.hasNext(); )
564             {
565                 DocumentTOCItem o = (DocumentTOCItem) iter.next();
566                 writeDocumentTOCItem( o, "item", serializer );
567             }
568         }
569         serializer.endTag( NAMESPACE, tagName );
570     } //-- void writeDocumentTOCItem( DocumentTOCItem, String, XmlSerializer )
571 
572     /**
573      * Method writeDocumentTemplate.
574      * 
575      * @param documentTemplate
576      * @param serializer
577      * @param tagName
578      * @throws java.io.IOException
579      */
580     private void writeDocumentTemplate( DocumentTemplate documentTemplate, String tagName, XmlSerializer serializer )
581         throws java.io.IOException
582     {
583         serializer.startTag( NAMESPACE, tagName );
584         if ( documentTemplate.getHref() != null )
585         {
586             serializer.attribute( NAMESPACE, "href", documentTemplate.getHref() );
587         }
588         if ( documentTemplate.getTitle() != null )
589         {
590             serializer.attribute( NAMESPACE, "title", documentTemplate.getTitle() );
591         }
592         if ( documentTemplate.getDate() != null )
593         {
594             serializer.attribute( NAMESPACE, "date", new java.text.SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSS", java.util.Locale.US ).format( documentTemplate.getDate() ) );
595         }
596         if ( documentTemplate.getModifydate() != null )
597         {
598             serializer.attribute( NAMESPACE, "modifydate", documentTemplate.getModifydate() );
599         }
600         serializer.endTag( NAMESPACE, tagName );
601     } //-- void writeDocumentTemplate( DocumentTemplate, String, XmlSerializer )
602 
603 }