KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opencms > htmlconverter > CmsHtmlConverterObjectReplaceTags


1 /*
2 * File : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/htmlconverter/CmsHtmlConverterObjectReplaceTags.java,v $
3 * Date : $Date: 2005/05/17 13:47:32 $
4 * Version: $Revision: 1.1 $
5 *
6 * This library is part of OpenCms -
7 * the Open Source Content Mananagement System
8 *
9 * Copyright (C) 2001 The OpenCms Group
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * For further information about OpenCms, please see the
22 * OpenCms Website: http://www.opencms.org
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this library; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 */

28
29 package com.opencms.htmlconverter;
30
31 /**
32  * Object for replacing HTML tags.<p>
33  *
34  * @author Andreas Zahner
35  * @version 1.0
36  *
37  * @deprecated Will not be supported past the OpenCms 6 release.
38  */

39 final class CmsHtmlConverterObjectReplaceTags {
40
41     /** the prefix will be placed in front of every replaced tag. */
42     private String JavaDoc m_prefix;
43     /** name of tag which will be replaced. */
44     private String JavaDoc m_tagName;
45     /** Attribute of tag which will be replaced (optional). */
46     private String JavaDoc m_tagAttrib;
47     /** value of tag attribute which will be replaced (optional). */
48     private String JavaDoc m_tagAttribValue;
49     /** String which replaces the start tag. */
50     private String JavaDoc m_replaceStartTag;
51     /** String which replaces the end tag (optional). */
52     private String JavaDoc m_replaceEndTag;
53     /** the suffix will be placed behind every replaced tag. */
54     private String JavaDoc m_suffix;
55     /** if true, individual replaceStrings will be read from tag attributes. */
56     private boolean m_getReplaceFromAttrs;
57     /** tag attribute where the replaceStartTag String is stored. */
58     private String JavaDoc m_startAttribute;
59     /** tag attribute where the replaceEndTag String is stored. */
60     private String JavaDoc m_endAttribute;
61     /** tag attribute where the parameter String is stored. */
62     private String JavaDoc m_parameter;
63     /** if true, only tag attribute specified in parameter String is replaced. */
64     private boolean m_replaceParamAttr;
65     /** true, if replaceEndTag is empty. */
66     private boolean m_inline;
67
68     /**
69      * Default constructor creates object with empty Strings.<p>
70      */

71     protected CmsHtmlConverterObjectReplaceTags () {
72         m_prefix = "";
73         m_tagName = "";
74         m_tagAttrib = "";
75         m_tagAttribValue = "";
76         m_replaceStartTag = "";
77         m_replaceEndTag = "";
78         m_suffix = "";
79         m_getReplaceFromAttrs = false;
80         m_startAttribute = "";
81         m_endAttribute = "";
82         m_parameter = "";
83         m_replaceParamAttr = false;
84     }
85
86     /**
87      * Constructor creates object with parameters.<p>
88      *
89      * @param prefix String prefix
90      * @param tagName String tagName
91      * @param tagAttrib String tagAttribute
92      * @param tagAttribValue String tagAttributeValue
93      * @param replaceStartTag String replaceStartTag
94      * @param replaceEndTag String replaceEndTag
95      * @param suffix String suffix
96      * @param getReplaceFromAttrs boolean getReplaceFromAttrs
97      * @param startAttribute String startAttribute
98      * @param endAttribute String endAttribute
99      * @param param String parameter
100      * @param replaceParamAttr flag to indicate param replacement
101      */

102     protected CmsHtmlConverterObjectReplaceTags (String JavaDoc prefix, String JavaDoc tagName, String JavaDoc tagAttrib, String JavaDoc tagAttribValue, String JavaDoc replaceStartTag, String JavaDoc replaceEndTag, String JavaDoc suffix, boolean getReplaceFromAttrs, String JavaDoc startAttribute, String JavaDoc endAttribute, String JavaDoc param, boolean replaceParamAttr) {
103         m_prefix = prefix;
104         m_tagName = tagName;
105         m_tagAttrib = tagAttrib;
106         m_tagAttribValue = tagAttribValue;
107         m_replaceStartTag = replaceStartTag;
108         m_replaceEndTag = replaceEndTag;
109         m_suffix = suffix;
110         m_getReplaceFromAttrs = getReplaceFromAttrs;
111         m_startAttribute = startAttribute;
112         m_endAttribute = endAttribute;
113         m_parameter = param;
114         m_replaceParamAttr = replaceParamAttr;
115         if (replaceEndTag.equals(null) || replaceEndTag.equals("")) {
116             m_inline = true;
117         }
118     }
119
120     /**
121      * Returns prefix of actual object.<p>
122      *
123      * @return String with prefix
124      */

125     protected String JavaDoc getPrefix() {
126         return m_prefix;
127     }
128
129     /**
130      * Returns suffix of actual object.<p>
131      *
132      * @return String with suffix
133      */

134     protected String JavaDoc getSuffix() {
135         return m_suffix;
136     }
137
138     /**
139      * Returns tag name of tag which will be replaced.<p>
140      *
141      * @return String with tag name
142      */

143     protected String JavaDoc getTagName() {
144         return m_tagName;
145     }
146
147     /**
148      * Returns attribute of tag which will be replaced.<p>
149      *
150      * @return String with attribute name
151      */

152     protected String JavaDoc getTagAttrib() {
153         return m_tagAttrib;
154     }
155
156     /**
157      * Returns attribute value of tag which will be replaced.<p>
158      *
159      * @return String with attribute value
160      */

161     protected String JavaDoc getTagAttribValue() {
162         return m_tagAttribValue;
163     }
164
165     /**
166      * Returns String which replaces the start tag.<p>
167      *
168      * @return String with prefix, content and suffix
169      */

170     protected String JavaDoc getReplaceStartTag() {
171         return m_prefix + m_replaceStartTag + m_suffix;
172     }
173
174     /**
175      * Returns String which replaces the end tag.<p>
176      *
177      * @return String with prefix, content and suffix
178      */

179     protected String JavaDoc getReplaceEndTag() {
180         if (m_inline) {
181             return "";
182         }
183         return m_prefix +m_replaceEndTag +m_suffix;
184     }
185
186     /**
187      * Checks if end tag will be replaced or deleted.<p>
188      *
189      * @return true if m_replaceEndTag is "", otherwise false
190      */

191     protected boolean getInline() {
192         return m_inline;
193     }
194
195     /**
196      * Checks if replacecontents are encoded in html code attributes.<p>
197      *
198      * @return true if replacecontents are encoded, otherwise false
199      */

200     protected boolean getReplaceFromAttrs() {
201         return m_getReplaceFromAttrs;
202     }
203
204     /**
205      * Returns name of start attribute of encoded replacecontents.<p>
206      *
207      * @return String with attribute name
208      */

209     protected String JavaDoc getStartAttribute() {
210         return m_startAttribute;
211     }
212
213     /**
214      * Returns name of end attribute of encoded replacecontents.<p>
215      *
216      * @return String with attribute name
217      */

218     protected String JavaDoc getEndAttribute() {
219         return m_endAttribute;
220     }
221
222     /**
223      * Returns attribute name of parameter.<p>
224      *
225      * @return String with attribute name
226      */

227     protected String JavaDoc getParameter() {
228         return m_parameter;
229     }
230
231     /**
232      * Returns if only an attribute must be replaced.<p>
233      *
234      * @return true if only attribute has to be replaced
235      */

236     protected boolean getReplaceParamAttr() {
237         return m_replaceParamAttr;
238     }
239
240 }
Popular Tags