%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.commons.jelly.tags.http.PartTag$MyStringPart |
|
|
1 | /* |
|
2 | * Copyright 2002,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.commons.jelly.tags.http; |
|
18 | ||
19 | import org.apache.commons.jelly.JellyTagException; |
|
20 | import org.apache.commons.jelly.TagSupport; |
|
21 | import org.apache.commons.jelly.XMLOutput; |
|
22 | import org.apache.commons.httpclient.methods.multipart.StringPart; |
|
23 | ||
24 | /** |
|
25 | * A tag to hold a part of a multiPartPost |
|
26 | * |
|
27 | */ |
|
28 | public class PartTag extends TagSupport { |
|
29 | /** parameter name */ |
|
30 | private String _name; |
|
31 | /** parameter value */ |
|
32 | private String _value; |
|
33 | /** parameter type (like text/plain) */ |
|
34 | private String _contentType = "text/plain"; |
|
35 | ||
36 | /** Creates a new instance of PartTag */ |
|
37 | public PartTag() { |
|
38 | } |
|
39 | ||
40 | /** |
|
41 | * Extend StringPart so that I can specify the content type (ex: text/plain) |
|
42 | */ |
|
43 | private class MyStringPart extends StringPart { |
|
44 | String _contentType; |
|
45 | 0 | public MyStringPart(String name, String value, String contentType) { |
46 | 0 | super(name, value, "utf-8"); |
47 | 0 | _contentType=contentType; |
48 | 0 | } |
49 | 0 | public String getContentType() { return _contentType; } |
50 | } |
|
51 | ||
52 | /** |
|
53 | * Perform the tag functionality. In this case, store this parameter |
|
54 | * in the <mppost> tag above me |
|
55 | * |
|
56 | * @param xmlOutput where to send output |
|
57 | * @throws Exception when an error occurs |
|
58 | */ |
|
59 | public void doTag(XMLOutput xmlOutput) throws JellyTagException { |
|
60 | MultipartPostTag http = (MultipartPostTag) findAncestorWithClass(MultipartPostTag.class); |
|
61 | StringPart sp = new MyStringPart(getName(), getValue(), getContentType()); |
|
62 | http.addPart(sp); |
|
63 | invokeBody(xmlOutput); |
|
64 | } |
|
65 | ||
66 | //-------------------------------------------------------------------------- |
|
67 | // Property accessors/mutators |
|
68 | //-------------------------------------------------------------------------- |
|
69 | /** |
|
70 | * Getter for property name. |
|
71 | * |
|
72 | * @return Value of property name. |
|
73 | */ |
|
74 | public String getName() { |
|
75 | return _name; |
|
76 | } |
|
77 | ||
78 | /** |
|
79 | * Setter for property name. |
|
80 | * |
|
81 | * @param name New value of property name. |
|
82 | */ |
|
83 | public void setName(String name) { |
|
84 | _name = name; |
|
85 | } |
|
86 | ||
87 | /** |
|
88 | * Getter for property value. |
|
89 | * |
|
90 | * @return Value of property value. |
|
91 | */ |
|
92 | public String getValue() { |
|
93 | return _value; |
|
94 | } |
|
95 | ||
96 | /** |
|
97 | * Setter for property value. |
|
98 | * |
|
99 | * @param value New value of property value. |
|
100 | */ |
|
101 | public void setValue(String value) { |
|
102 | _value = value; |
|
103 | } |
|
104 | ||
105 | /** |
|
106 | * Getter for property contentType. |
|
107 | * |
|
108 | * @return Value of contentType. |
|
109 | */ |
|
110 | public String getContentType() { |
|
111 | return _contentType; |
|
112 | } |
|
113 | ||
114 | /** |
|
115 | * Setter for property contentType. |
|
116 | * |
|
117 | * @param value New value of contentType. |
|
118 | */ |
|
119 | public void setContentType(String contentType) { |
|
120 | _contentType = contentType; |
|
121 | } |
|
122 | ||
123 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |