KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > elementprocessor > impl > poi > hssf > elements > EP_Paper


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
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
17 package org.apache.cocoon.components.elementprocessor.impl.poi.hssf.elements;
18
19 import org.apache.commons.lang.StringUtils;
20 import org.apache.poi.hssf.usermodel.HSSFPrintSetup;
21
22 import java.io.IOException JavaDoc;
23
24 /**
25  * No-op implementation of ElementProcessor to handle the "paper" tag
26  *
27  * This element contains no other elements and has no attributes. Its
28  * content describes the paper to be used (e.g., A4)
29  *
30  *
31  * @author Marc Johnson (marc_johnson27591@hotmail.com)
32  * @author Victor Skladov (skladov@his.de)
33  * @version CVS $Id: EP_Paper.java 37191 2004-08-30 10:15:06Z antonio $
34  */

35 public class EP_Paper extends BaseElementProcessor {
36
37     private String JavaDoc _paper;
38
39     /**
40      * constructor
41      */

42     public EP_Paper() {
43         super(null);
44     }
45
46     public String JavaDoc getPaper(){
47         if (_paper == null) {
48             _paper = StringUtils.strip(this.getData());
49         }
50         return this._paper;
51     }
52
53     /**
54      * Setup the paper size (Letter, Legal, Executive, A4, A5, A6, ).
55      * Default Letter
56      * @exception IOException
57      */

58
59     public void endProcessing() throws IOException JavaDoc{
60         _paper = getPaper();
61         Sheet sheet = this.getSheet();
62         short paperSize = HSSFPrintSetup.LETTER_PAPERSIZE;
63         if (StringUtils.isNotEmpty(_paper)) {
64             if ("A4".equalsIgnoreCase(_paper)) {
65                 paperSize = HSSFPrintSetup.A4_PAPERSIZE;
66             } else if ("A5".equalsIgnoreCase(_paper)) {
67                 paperSize = HSSFPrintSetup.A5_PAPERSIZE;
68             } else if ("Legal".equalsIgnoreCase(_paper)) {
69                 paperSize = HSSFPrintSetup.LEGAL_PAPERSIZE;
70             } else if ("Executive".equalsIgnoreCase(_paper)) {
71                 paperSize = HSSFPrintSetup.EXECUTIVE_PAPERSIZE;
72             }
73         }
74         sheet.setPaperSize(paperSize);
75     }
76
77 } // end public class EP_Paper
78
Popular Tags