001// =================== DO NOT EDIT THIS FILE ====================
002// Generated by Modello 1.9.1,
003// any modifications will be overwritten.
004// ==============================================================
005
006package org.apache.maven.doxia.document.io.xpp3;
007
008  //---------------------------------/
009 //- Imported classes and packages -/
010//---------------------------------/
011
012import java.io.OutputStream;
013import java.io.Writer;
014import java.util.Iterator;
015import org.apache.maven.doxia.document.DocumentAuthor;
016import org.apache.maven.doxia.document.DocumentCover;
017import org.apache.maven.doxia.document.DocumentHyperlinkBehaviour;
018import org.apache.maven.doxia.document.DocumentMeta;
019import org.apache.maven.doxia.document.DocumentModel;
020import org.apache.maven.doxia.document.DocumentStatistic;
021import org.apache.maven.doxia.document.DocumentTOC;
022import org.apache.maven.doxia.document.DocumentTOCItem;
023import org.apache.maven.doxia.document.DocumentTemplate;
024import org.codehaus.plexus.util.xml.pull.MXSerializer;
025import org.codehaus.plexus.util.xml.pull.XmlSerializer;
026
027/**
028 * Class DocumentXpp3Writer.
029 * 
030 * @version $Revision$ $Date$
031 */
032@SuppressWarnings( "all" )
033public class DocumentXpp3Writer
034{
035
036      //--------------------------/
037     //- Class/Member Variables -/
038    //--------------------------/
039
040    /**
041     * Field NAMESPACE.
042     */
043    private static final String NAMESPACE = null;
044
045    /**
046     * Field fileComment.
047     */
048    private String fileComment = null;
049
050
051      //-----------/
052     //- Methods -/
053    //-----------/
054
055    /**
056     * Method setFileComment.
057     * 
058     * @param fileComment
059     */
060    public void setFileComment( String fileComment )
061    {
062        this.fileComment = fileComment;
063    } //-- void setFileComment( String )
064
065    /**
066     * Method write.
067     * 
068     * @param writer
069     * @param documentModel
070     * @throws java.io.IOException
071     */
072    public void write( Writer writer, DocumentModel documentModel )
073        throws java.io.IOException
074    {
075        XmlSerializer serializer = new MXSerializer();
076        serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
077        serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
078        serializer.setOutput( writer );
079        serializer.startDocument( documentModel.getModelEncoding(), null );
080        writeDocumentModel( documentModel, "document", serializer );
081        serializer.endDocument();
082    } //-- void write( Writer, DocumentModel )
083
084    /**
085     * Method write.
086     * 
087     * @param stream
088     * @param documentModel
089     * @throws java.io.IOException
090     */
091    public void write( OutputStream stream, DocumentModel documentModel )
092        throws java.io.IOException
093    {
094        XmlSerializer serializer = new MXSerializer();
095        serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "  " );
096        serializer.setProperty( "http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n" );
097        serializer.setOutput( stream, documentModel.getModelEncoding() );
098        serializer.startDocument( documentModel.getModelEncoding(), null );
099        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}