KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > wcf > ui > FileUploadCtrl


1 /*
2  * ====================================================================
3  * Copyright (c) 2003 TONBELLER AG.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  *
18  * 3. The end-user documentation included with the redistribution,
19  * if any, must include the following acknowledgment:
20  * "This product includes software developed by
21  * TONBELLER AG (http://www.tonbeller.com)"
22  * Alternately, this acknowledgment may appear in the software itself,
23  * if and wherever such third-party acknowledgments normally appear.
24  *
25  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
26  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
27  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28  * DISCLAIMED. IN NO EVENT SHALL THE TON BELLER AG OR
29  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
32  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
33  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
34  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
35  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36  * SUCH DAMAGE.
37  * ====================================================================
38  *
39  *
40  */

41 package com.tonbeller.wcf.ui;
42
43 import org.w3c.dom.Document JavaDoc;
44 import org.w3c.dom.Element JavaDoc;
45
46 import com.tonbeller.wcf.utils.XoplonNS;
47
48 public class FileUploadCtrl extends XoplonCtrl {
49
50   public static final String JavaDoc NODENAME = "fileUpload";
51
52   public static boolean isFileUpload(Element JavaDoc elem) {
53     return elem.getNodeName().equals(NODENAME);
54   }
55
56   /** factory function */
57   public static Element JavaDoc createFileUpload(Document JavaDoc doc) {
58     Element JavaDoc fu = Item.createItem(doc, NODENAME);
59     return fu;
60   }
61
62   /**
63    * client file path
64    */

65   public static void setFileName(Element JavaDoc element, String JavaDoc fileName) {
66     XoplonNS.setAttribute(element, "filename", fileName);
67   }
68
69   /**
70    * client file path
71    */

72   public static String JavaDoc getFileName(Element JavaDoc element) {
73     return XoplonNS.getAttribute(element, "filename");
74   }
75
76   /**
77    * maximum accepted file size in bytes
78    */

79   public static void setMaxLength(Element JavaDoc element, long maxLength) {
80     XoplonNS.setAttribute(element, "maxlength", String.valueOf(maxLength));
81   }
82
83   /**
84    * maximum accepted file size in bytes
85    */

86   public static String JavaDoc getMaxLength(Element JavaDoc element) {
87     return XoplonNS.getAttribute(element, "maxlength");
88   }
89
90   /**
91    * Content type pattern of files accepted as input, e.g. text/*
92    */

93   public static void setAccept(Element JavaDoc element, String JavaDoc accept) {
94     XoplonNS.setAttribute(element, "accept", accept);
95   }
96
97   /**
98    * Content type pattern of files accepted as input, e.g. text/*
99    */

100   public static String JavaDoc getAccept(Element JavaDoc element) {
101     return XoplonNS.getAttribute(element, "accept");
102   }
103
104 }
Popular Tags