KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > clipbuilder > html > web > html > Impl > DefaultHTMLTransformer


1 package org.jahia.clipbuilder.html.web.html.Impl;
2 import java.util.*;
3 import java.util.Map JavaDoc;
4
5 import javax.swing.text.html.*;
6
7 import org.jahia.clipbuilder.html.bean.*;
8 import org.jahia.clipbuilder.html.util.*;
9 import org.jahia.clipbuilder.html.web.Constant.*;
10 import org.jahia.clipbuilder.html.web.Url.*;
11 import org.jahia.clipbuilder.html.web.html.*;
12 import org.jahia.clipbuilder.html.web.html.Impl.ExtractorFilter.*;
13 import org.jahia.clipbuilder.html.web.HTMLDocumentBuilder;
14
15 /**
16  * Default implementation of an HTMLTransformer
17  *
18  *@author Tlili Khaled
19  */

20 public abstract class DefaultHTMLTransformer implements HTMLTransformer {
21
22     private List lastParsingErrors = new ArrayList();
23     private boolean enableCSS;
24     private Hashtable inputNameHash = new Hashtable();
25     private boolean removeMetaTag;
26     private boolean removeHeadScriptTag;
27     private boolean removeBodyScript;
28     private boolean removeJavascriptEvent;
29     private boolean refactorJavascriptCode;
30     private boolean refactorJavascriptEvent;
31     private HTMLDocumentBuilder builder;
32
33     /**
34      * Description of the Field
35      */

36     public static String JavaDoc PARAM_CHEW_WEBCLIPPING_ACTION = "webClippingAction=chewPreview";
37     private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(DefaultHTMLTransformer.class);
38     //private static String[] notEditableParameter = {WebConstants.TYPE_BUTTON, WebConstants.TYPE_HIDDEN, WebConstants.TYPE_IMAGE, WebConstants.TYPE_RESET, WebConstants.TYPE_SUBMIT, WebConstants.TYPE_FILE};
39
private static String JavaDoc[] notEditableParameter = {WebConstants.TYPE_HIDDEN, WebConstants.TYPE_FILE, WebConstants.TYPE_SUBMIT};
40
41
42
43     /**
44      * Constructor for the DefaultHTMLTransformer object
45      *
46      *@param builder Description of Parameter
47      *@param enableCSS Description of Parameter
48      */

49     public DefaultHTMLTransformer(HTMLDocumentBuilder builder, boolean enableCSS) {
50         enableCSS(enableCSS);
51         this.setBuilder(builder);
52     }
53
54
55     /**
56      * Sets the Builder attribute of the DefaultHTMLTransformer object
57      *
58      *@param builder The new Builder value
59      */

60     public void setBuilder(HTMLDocumentBuilder builder) {
61         this.builder = builder;
62     }
63
64
65     /**
66      * Gets the UrlEncoder attribute of the DefaultHTMLTransformer object
67      *
68      *@return The UrlEncoder value
69      */

70     public UrlEncoderIF getUrlEncoder() {
71         return getBuilder().getUrlEncoder();
72     }
73
74
75
76     /**
77      * Gets the HrefChewLink attribute of the DefaultHTMLTransformer object
78      *
79      *@param hash Description of Parameter
80      *@return The HrefChewLink value
81      */

82     public String JavaDoc getHrefChewLink(String JavaDoc hash) {
83         String JavaDoc paramWebClipping = PARAM_CHEW_WEBCLIPPING_ACTION;
84         //return getHttpServletRequest().getContextPath() + "/selectPart.do?" + paramWebClipping + "&" + ChewExtractorFilter.getHashParamName() + "=" + hash;
85
return getUrlEncoder().getLocalUrl("/selectPart.do?" + paramWebClipping + "&" + ChewExtractorFilter.getHashParamName() + "=" + hash);
86     }
87
88
89     /**
90      * Gets the ImageChewLink attribute of the DefaultHTMLTransformer object
91      *
92      *@return The ImageChewLink value
93      */

94     public String JavaDoc getImageChewLinkSrcValue() {
95         //return getHttpServletRequest().getContextPath() + "/jsp/clipbuilder/html/images/select.gif";
96
return getUrlEncoder().getLocalUriResource("/jsp/clipbuilder/html/images/select.gif");
97     }
98
99
100     /**
101      * Gets the EnableCSS attribute of the DefaultHTMLTransformer object
102      *
103      *@return The EnableCSS value
104      */

105     public boolean isEnableCSS() {
106         return this.enableCSS;
107     }
108
109
110     /**
111      * Gets the AllNewInputAttributeForForm attribute of the
112      * DefaultHTMLTransformer object
113      */

114     /*
115      * public List getNewActionInputAtts() {
116      * return getListAtt("hidden", "webClippingAction", "browse");
117      * }
118      */

119     /**
120      * Gets the NewSourceUrlInputAtts attribute of the DefaultHTMLTransformer
121      * object
122      */

123     /*
124      * public List getNewSourceUrlInputAtts(String url) throws Exception {
125      * return getListAtt("hidden", "sourceUrl", relatifToAbsolute(url));
126      * }
127      */

128     /**
129      * Gets the RewritedActionValue attribute of the JDomHTMLTransformer object
130      */

131     /*
132      * public String getRewritedActionValue(String url) throws Exception {
133      * url = URLUtilities.getHrefAbsoluteValue(getUrlBean().getURL(), url);
134      * String[] params = {url};
135      * UrlEncoder encoder = new UrlEncoder(getHttpServletRequest(), getHttpServletResponse(), "browse", params, false, "POST");
136      * return encoder.getEncodedUrl();
137      * }
138      */

139     /**
140      * Gets the RewritedHrefValue attribute of the DefaultHTMLTransformer object
141      *
142      *@param ownerTag Description of Parameter
143      *@param href Description of Parameter
144      *@param id Description of Parameter
145      *@param position Description of Parameter
146      *@param webBrowserAction Description of Parameter
147      *@return The RewritedHrefValue value
148      *@exception Exception Description of Exception
149      */

150     public String JavaDoc getRewritedHrefValue(String JavaDoc ownerTag, String JavaDoc href, String JavaDoc id, String JavaDoc position, String JavaDoc webBrowserAction) throws Exception JavaDoc {
151         // don't rewrite non url string
152
if (!isRewritableUrl(href)) {
153             return href;
154         }
155
156         //Set from and hash
157
String JavaDoc from = "";
158         String JavaDoc hash = "";
159         if (ownerTag.equalsIgnoreCase(HTML.Tag.A.toString())) {
160             from = WebConstants.FROM_LINK;
161             hash = HashUtilities.buildLinkHash(href, id, position);
162
163         }
164         else if (ownerTag.equalsIgnoreCase(HTML.Tag.AREA.toString())) {
165             from = WebConstants.FROM_AREA;
166             hash = HashUtilities.buildLinkHash(href, id, position);
167         }
168         else if (ownerTag.equalsIgnoreCase(HTML.Tag.META.toString())) {
169             from = WebConstants.FROM_META;
170             hash = HashUtilities.buildLinkHash(href, id, position);
171         }
172         else if (ownerTag.equalsIgnoreCase("link")) {
173             return href = URLUtilities.getUrlAbsoluteValue(getUrlBean().getRedirectUrl().toExternalForm(), href);
174         }
175
176         // rewrite the url
177
if (isAnUrl(href)) {
178             //build a wrapper and add it to the urlMap
179
String JavaDoc mimeType = "";
180             URLWrapper wrapper = new URLWrapper(href, from, "GET", mimeType, hash);
181
182             //encode the url
183
//UrlEncoder encoder = new UrlEncoder(getHttpServletRequest(), getHttpServletResponse(), webBrowserAction, wrapper);
184
UrlEncoderIF encoder = getUrlEncoder();
185             encoder.setAction(webBrowserAction);
186             encoder.setUrlWrapper(wrapper);
187             return href = encoder.getEncodedUrl();
188         }
189
190         //other than meta or link
191
href = URLUtilities.getUrlAbsoluteValue(getUrlBean().getRedirectUrl().toExternalForm(), href);
192         return href;
193     }
194
195
196
197     /**
198      * Gets the FormParamBean attribute of the DefaultHTMLTransformer object
199      *
200      *@param formParentName Description of Parameter
201      *@param formParentId Description of Parameter
202      *@param formParentPos Description of Parameter
203      *@param name Description of Parameter
204      *@param paramPosition Description of Parameter
205      *@return The FormParamBean value
206      */

207     public FormParamBean getFormParamBean(String JavaDoc formParentName, String JavaDoc formParentId, int formParentPos, String JavaDoc name, int paramPosition) {
208         FormParamBean fBean = getUrlBean().getFormParamBeanByNameAndFormParentNameAndFormParentId(formParentName, formParentId, formParentPos, name, paramPosition);
209         return fBean;
210     }
211
212
213     /**
214      * Gets the PosAndUpdateInputHash attribute of the DefaultHTMLTransformer
215      * object
216      *
217      *@param name Description of Parameter
218      *@return The PosAndUpdateInputHash value
219      */

220     public int getPosAndUpdateInputHash(String JavaDoc name) {
221         Integer JavaDoc pos = (Integer JavaDoc) inputNameHash.get(name);
222         if (pos == null) {
223             pos = new Integer JavaDoc(0);
224
225         }
226         else {
227             pos = new Integer JavaDoc(pos.intValue() + 1);
228         }
229         inputNameHash.put(name, pos);
230         return pos.intValue();
231     }
232
233
234
235     /**
236      * Gets the RewritedActionValue attribute of the DefaultHTMLTransformer
237      * object
238      *
239      *@param action Description of Parameter
240      *@param method Description of Parameter
241      *@param formName Description of Parameter
242      *@param formId Description of Parameter
243      *@param encType Description of Parameter
244      *@param formPos Description of Parameter
245      *@param webBrowserAction Description of Parameter
246      *@return The RewritedActionValue value
247      *@exception Exception Description of Exception
248      */

249     public String JavaDoc getRewritedActionValue(String JavaDoc action, String JavaDoc method, String JavaDoc formName, String JavaDoc formId, String JavaDoc encType, int formPos, String JavaDoc webBrowserAction) throws Exception JavaDoc {
250         // aseert not null
251
if (method == null || method.equalsIgnoreCase("")) {
252             method = "GET";
253         }
254         if (formName == null) {
255             formName = "";
256         }
257         if (formId == null) {
258             formId = "";
259         }
260
261         formName = notNullValueForType(formName);
262         formId = notNullValueForType(formId);
263         logger.debug("Rewrite action form: " + action + "," + method + "," + formName + "," + formId);
264
265         //test if it's a rewritable url
266
if (!isRewritableUrl(action)) {
267             return action;
268         }
269
270         //get the absolute value
271
action = URLUtilities.getHrefAbsoluteValue(getUrlBean().getRedirectUrl(), action);
272
273         //encode the url
274
String JavaDoc hash = HashUtilities.buildFormHash(formName, formId, formPos);
275         URLWrapper wrapper = new URLWrapper(action, WebConstants.FROM_FORM, method, encType, hash);
276         //UrlEncoder encoder = new UrlEncoder(getHttpServletRequest(), getHttpServletResponse(), webBrowserAction, urlWrapper);
277
UrlEncoderIF encoder = getUrlEncoder();
278         encoder.setAction(webBrowserAction);
279         encoder.setUrlWrapper(wrapper);
280
281         return encoder.getEncodedUrl();
282     }
283
284
285
286     /**
287      * Gets the ImportCssContent attribute of the DefaultHTMLTransformer object
288      *
289      *@param url Description of Parameter
290      *@param media Description of Parameter
291      *@return The ImportCssContent value
292      *@exception Exception Description of Exception
293      */

294     public String JavaDoc getImportCssContent(String JavaDoc url, String JavaDoc media) throws Exception JavaDoc {
295         url = relatifToAbsolute(url);
296         String JavaDoc content = org.jahia.clipbuilder.html.web.http.SimpleHttpSecureClient.getContentAsString(url);
297
298         // Create an instance of HttpClient.
299
String JavaDoc refactoredContent = CssUtilities.getRefactoredCssContent(url, content, media);
300         logger.debug("[ Refactored css Content from " + url + "\n " + refactoredContent + "]");
301         return refactoredContent;
302     }
303
304
305     /**
306      * Gets the ImportJavascriptContent attribute of the DefaultHTMLTransformer
307      * object
308      *
309      *@param src Description of Parameter
310      *@param webBrowserAction Description of Parameter
311      *@return The ImportJavascriptContent value
312      *@exception Exception Description of Exception
313      */

314     public String JavaDoc getImportJavascriptContent(String JavaDoc src, String JavaDoc webBrowserAction) throws Exception JavaDoc {
315         logger.debug("Imported Javacript from: " + src);
316         src = relatifToAbsolute(src);
317
318         String JavaDoc content = org.jahia.clipbuilder.html.web.http.SimpleHttpSecureClient.getContentAsString(src);
319         String JavaDoc refactoredContent = getRefactoredJavascript(src, webBrowserAction, content);
320         return refactoredContent;
321     }
322
323
324
325     /**
326      * Gets the LastParsingErrors attribute of the DefaultHTMLTransformer object
327      *
328      *@return The LastParsingErrors value
329      */

330     public java.util.List JavaDoc getLastParsingErrors() {
331         return lastParsingErrors;
332     }
333
334
335     /**
336      * Gets the RemoveMetaTag attribute of the DefaultHTMLTransformer object
337      *
338      *@return The RemoveMetaTag value
339      */

340     public boolean isRemoveMetaTag() {
341         return removeMetaTag;
342     }
343
344
345     /**
346      * Gets the RemoveHeadScriptTag attribute of the DefaultHTMLTransformer
347      * object
348      *
349      *@return The RemoveHeadScriptTag value
350      */

351     public boolean isRemoveHeadScriptTag() {
352         return removeHeadScriptTag;
353     }
354
355
356     /**
357      * Gets the RemoveBodyScript attribute of the DefaultHTMLTransformer object
358      *
359      *@return The RemoveBodyScript value
360      */

361     public boolean isRemoveBodyScript() {
362         return removeBodyScript;
363     }
364
365
366     /**
367      * Gets the RemoveJavascriptEvent attribute of the DefaultHTMLTransformer
368      * object
369      *
370      *@return The RemoveJavascriptEvent value
371      */

372     public boolean isRemoveJavascriptEvent() {
373         return removeJavascriptEvent;
374     }
375
376
377     /**
378      * Gets the RefactorJavascriptCode attribute of the DefaultHTMLTransformer
379      * object
380      *
381      *@return The RefactorJavascriptCode value
382      */

383     public boolean isRefactorJavascriptCode() {
384         return refactorJavascriptCode;
385     }
386
387
388     /**
389      * Gets the RefactorJavascriptEvent attribute of the DefaultHTMLTransformer
390      * object
391      *
392      *@return The RefactorJavascriptEvent value
393      */

394     public boolean isRefactorJavascriptEvent() {
395         return refactorJavascriptEvent;
396     }
397
398
399     /**
400      * Gets the Builder attribute of the DefaultHTMLTransformer object
401      *
402      *@return The Builder value
403      */

404     public HTMLDocumentBuilder getBuilder() {
405         return builder;
406     }
407
408
409
410     /**
411      * Gets the InlineCssContent attribute of the DefaultHTMLTransformer object
412      *
413      *@param cssContent Description of Parameter
414      *@return The InlineCssContent value
415      *@exception Exception Description of Exception
416      */

417     public String JavaDoc getInlineCssContent(String JavaDoc cssContent) throws Exception JavaDoc {
418         //logger.debug("[ Css Content:\n " + cssContent + "]");
419
String JavaDoc content = CssUtilities.getRefactoredCssContent(getUrlBean().getAbsoluteUrlValue(), cssContent, null);
420         //logger.debug("[ Refactor Css Content:\n " + content + "]");
421
return content;
422     }
423
424
425
426     /**
427      * Gets the RefactoredJavascript attribute of the DefaultHTMLTransformer
428      * object
429      *
430      *@param url Description of Parameter
431      *@param webBrowserAction Description of Parameter
432      *@param content Description of Parameter
433      *@return The RefactoredJavascript value
434      */

435     public String JavaDoc getRefactoredJavascript(String JavaDoc url, String JavaDoc webBrowserAction, String JavaDoc content) {
436         String JavaDoc refactoredContent = JavascriptUtilities.getRefactoredJavascript(getUrlEncoder(), url, webBrowserAction, content);
437         return refactoredContent;
438     }
439
440
441     /**
442      * Description of the Method
443      *
444      *@param styleRule Description of Parameter
445      *@return Description of the Returned Value
446      *@exception Exception Description of Exception
447      */

448     public String JavaDoc refactorCssStyleRule(String JavaDoc styleRule) throws Exception JavaDoc {
449         //logger.debug("[ Css Content:\n " + cssContent + "]");
450
String JavaDoc content = CssUtilities.getRefactoredStyleRule(getUrlBean().getAbsoluteUrlValue(), styleRule);
451         //logger.debug("[ Refactor Css Content:\n " + content + "]");
452
return content;
453     }
454
455
456     /**
457      * Sets the RemoveJavascriptEvent attribute of the DefaultHTMLTransformer
458      * object
459      *
460      *@param removeJavascriptEvent The new RemoveJavascriptEvent value
461      */

462     public void removeJavascriptEvent(boolean removeJavascriptEvent) {
463         this.removeJavascriptEvent = removeJavascriptEvent;
464     }
465
466
467     /**
468      * Sets the RefactorJavascriptEvent attribute of the DefaultHTMLTransformer
469      * object
470      *
471      *@param refactorJavascriptEvent The new RefactorJavascriptEvent value
472      */

473     public void refactorJavascriptEvent(boolean refactorJavascriptEvent) {
474         this.refactorJavascriptEvent = refactorJavascriptEvent;
475     }
476
477
478     /**
479      * Sets the RefactorJavascriptCode attribute of the DefaultHTMLTransformer
480      * object
481      *
482      *@param refactorJavascriptCode The new RefactorJavascriptCode value
483      */

484     public void refactorJavascriptCode(boolean refactorJavascriptCode) {
485         this.refactorJavascriptCode = refactorJavascriptCode;
486     }
487
488
489     /**
490      * Description of the Method
491      *
492      *@param remove Description of Parameter
493      */

494     public void removeMetaTag(boolean remove) {
495         this.removeMetaTag = remove;
496     }
497
498
499     /**
500      * Description of the Method
501      *
502      *@param remove Description of Parameter
503      */

504     public void removeHeadScriptTag(boolean remove) {
505         this.removeHeadScriptTag = remove;
506     }
507
508
509     /**
510      * Description of the Method
511      *
512      *@param remove Description of Parameter
513      */

514     public void removeBodyScript(boolean remove) {
515         this.removeBodyScript = remove;
516     }
517
518
519     /**
520      * Description of the Method
521      */

522     public void resetInputHash() {
523         inputNameHash = new Hashtable();
524     }
525
526
527     /**
528      * Description of the Method
529      *
530      *@param fBean Description of Parameter
531      *@param inputValue Description of Parameter
532      */

533     public void updateInputValue(FormParamBean fBean, String JavaDoc inputValue) {
534         logger.warn("FormParamBean type = hidden. Update Used Value value.");
535         String JavaDoc oldValue = fBean.getUsedValue();
536
537         // this may happen if an hidden input is set thanks to a javascript and the client
538
// doesn't handled the javascript
539

540         if (inputValue == null || inputValue.equalsIgnoreCase("")) {
541             fBean.setUsedValue(oldValue);
542         }
543         else {
544             fBean.setUsedValue(inputValue);
545         }
546     }
547
548
549     /**
550      * Description of the Method
551      *
552      *@param enableCSS Description of Parameter
553      */

554     public void enableCSS(boolean enableCSS) {
555         this.enableCSS = enableCSS;
556     }
557
558
559     /**
560      * Adds a feature to the ParsingErrors attribute of the
561      * DefaultHTMLTransformer object
562      *
563      *@param error The feature to be added to the ParsingErrors attribute
564      */

565     public void addParsingErrors(String JavaDoc error) {
566         getLastParsingErrors().add(error);
567     }
568
569
570     /**
571      * Description of the Method
572      */

573     public void clearParsingErrors() {
574         getLastParsingErrors().clear();
575     }
576
577
578
579     /**
580      * Description of the Method
581      *
582      *@param type Description of Parameter
583      *@param formParentName Description of Parameter
584      *@param formParentId Description of Parameter
585      *@param formParentPosition Description of Parameter
586      *@param name Description of Parameter
587      *@param possibleValue Description of Parameter
588      *@param visibility Description of Parameter
589      *@param paramPosition Description of Parameter
590      *@exception Exception Description of Exception
591      */

592     public void recordFormParam(String JavaDoc type, String JavaDoc formParentName, String JavaDoc formParentId, int formParentPosition, String JavaDoc name, String JavaDoc possibleValue, String JavaDoc visibility, int paramPosition) throws Exception JavaDoc {
593         // add the form param to the current urlBean
594
UrlBean uBean = getUrlBean();
595         String JavaDoc automaticUpdate = "false";
596         visibility = "false";
597
598         // webClipping param
599
if (name.equalsIgnoreCase("sourceUrl")) {
600             logger.debug("source input");
601             return;
602         }
603         if (name.equalsIgnoreCase("httpMethod")) {
604             logger.debug("httpMethod input");
605             return;
606         }
607
608         if (name.equalsIgnoreCase("webClippingAction")) {
609             logger.debug("webClippingAction input");
610             return;
611         }
612
613         // default properties
614
if (type != null) {
615             if (!editableInputParameter(type)) {
616                 automaticUpdate = "true";
617             }
618
619         }
620
621         if (formParentName == null) {
622             formParentName = "";
623         }
624         if (formParentId == null) {
625             formParentId = "";
626             logger.debug(" Form Parent Id null ---> set empty");
627         }
628
629         FormParamBean fBean = uBean.addFormParameter(formParentName, formParentId, formParentPosition, name, possibleValue, type, visibility, paramPosition);
630         fBean.setUpdate(automaticUpdate);
631     }
632
633
634
635     /**
636      * Description of the Method
637      *
638      *@param attValue Description of Parameter
639      *@return Description of the Returned Value
640      *@exception Exception Description of Exception
641      */

642     public String JavaDoc relatifToAbsolute(String JavaDoc attValue) throws Exception JavaDoc {
643         logger.debug("relatif To Absolute of :" + attValue);
644         return URLUtilities.getUrlAbsoluteValue(getUrlBean().getRedirectUrl().toExternalForm(), attValue);
645     }
646
647
648     /**
649      * Assert that value is not null
650      *
651      *@param value string null or not
652      *@return value if value is not null else "no_value_found"
653      */

654     public String JavaDoc notNullValueForType(String JavaDoc value) {
655         if (value == null) {
656             value = WebConstants.TYPE_TEXT;
657         }
658         return value;
659     }
660
661
662     /**
663      * Test if the type on the input elemenst is allowed or not
664      *
665      *@param type Description of Parameter
666      *@return true if the type attribute is not hidden,
667      * submit,reset,file,image,...
668      */

669     public boolean editableInputParameter(String JavaDoc type) {
670         //logger.debug("[Input element found whith type: " + type + " ]");
671
if (type != null) {
672             for (int j = 0; j < notEditableParameter.length; j++) {
673                 if (type.equalsIgnoreCase(notEditableParameter[j])) {
674                     return false;
675                 }
676             }
677         }
678         else {
679             // if type is null then type is submit
680
return false;
681         }
682         return true;
683     }
684
685
686     /**
687      * Adds a feature to the Frame attribute of the DefaultHTMLTransformer
688      * object
689      *
690      *@param framesList The feature to be added to the Frame attribute
691      *@param name The feature to be added to the Frame attribute
692      *@param id The feature to be added to the Frame attribute
693      *@param src The feature to be added to the Frame attribute
694      */

695     public void addFrame(List framesList, String JavaDoc name, String JavaDoc id, String JavaDoc src) {
696         //add frame bean
697
FrameBean frameBean = new FrameBean();
698         frameBean.setName(name);
699         frameBean.setId(id);
700         frameBean.setSrc(src);
701         String JavaDoc hash = HashUtilities.buildFrameHash(name, id, src);
702         frameBean.setHash(hash);
703         framesList.add(frameBean);
704
705         // add to the url map
706
URLWrapper uw = new URLWrapper();
707         uw.setFrom(WebConstants.FROM_FRAME);
708         uw.setSourceUrl(src);
709         uw.setMethod("Get");
710         URLMap map = getBuilder().getUrlMap();
711         map.addSourceUrl(uw, hash);
712     }
713
714
715
716     /**
717      * Gets the RewritableUrl attribute of the DefaultHTMLTransformer object
718      *
719      *@param href Description of Parameter
720      *@return The RewritableUrl value
721      */

722     private boolean isRewritableUrl(String JavaDoc href) {
723         for (int i = 0; i < WebConstants.NOT_URL.length; i++) {
724             if (href.indexOf(WebConstants.NOT_URL[i]) == 0) {
725                 return false;
726             }
727         }
728         return true;
729     }
730
731
732     /**
733      * Gets the AnUrl attribute of the DefaultHTMLTransformer object
734      *
735      *@param href Description of Parameter
736      *@return The AnUrl value
737      */

738     private boolean isAnUrl(String JavaDoc href) {
739         if (href.indexOf("javascript:") > 0) {
740             return false;
741         }
742         if (href.indexOf(";") > 0) {
743             return false;
744         }
745
746         return true;
747     }
748
749
750     /**
751      * Gets the LabelText attribute of the DefaultHTMLTransformer class
752      *
753      *@param name Description of Parameter
754      *@param value Description of Parameter
755      *@param type Description of Parameter
756      *@return The LabelText value
757      */

758     public static String JavaDoc getLabelText(String JavaDoc name, String JavaDoc value, String JavaDoc type) {
759         String JavaDoc text = "[Param=" + name + "]";
760         if (type != null && type.equalsIgnoreCase(WebConstants.TYPE_RADIO)) {
761             text = "[Param=" + name + ", value=\'" + value + "\']";
762         }
763         return text;
764     }
765
766
767
768     /**
769      * Throwed whem the original document was'nt processed
770      *
771      *@author Tlili Khaled
772      */

773     public static class NotYetTransformed
774              extends Exception JavaDoc {
775         /**
776          * Message of the Exception
777          */

778         public static final String JavaDoc MESSAGE = "The transform has'nt been performed !. \n processTransform() must be called at least once after setDocument() or new JDomHTMLTransformer(jdoc,false).";
779
780
781         /**
782          * Constructor for the NotYetTransformed object
783          */

784         public NotYetTransformed() {
785             super(MESSAGE);
786         }
787     }
788
789 }
790
Popular Tags