KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > clipbuilder > html > XML > ClipperParser


1 package org.jahia.clipbuilder.html.XML;
2
3 import org.jdom.*;
4 import java.util.*;
5 import org.jahia.clipbuilder.html.util.DESUtilities;
6
7 /**
8  * Description of the Class
9  *
10  *@author Tlili Khaled
11  */

12 public class ClipperParser {
13     private ClipperDocument clipperDoc;
14     private Element sequenceUrlEle;
15     private Element filterEle;
16     private Element configEle;
17     private Hashtable urlHashtable = new Hashtable();
18     private Hashtable urlFormParamHashtable = new Hashtable();
19     private Hashtable urlQueryParamHashtable = new Hashtable();
20     private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(ClipperParser.class);
21
22
23     /**
24      * Constructor for the ClipperParser object
25      *
26      *@param doc Clipper document object
27      */

28     public ClipperParser(ClipperDocument doc) {
29         setClipperDoc(doc);
30     }
31
32
33     /**
34      * Sets the ClipperDoc attribute of the ClipperParser object
35      *
36      *@param clipperDoc The new ClipperDoc value
37      */

38     public void setClipperDoc(ClipperDocument clipperDoc) {
39         this.clipperDoc = clipperDoc;
40     }
41
42
43     /**
44      * Gets the ClipperDoc attribute of the ClipperParser object
45      *
46      *@return The ClipperDoc value
47      */

48     public ClipperDocument getClipperDoc() {
49         return clipperDoc;
50     }
51
52
53     /**
54      * Gets the Clipper attribute of the ClipperParser object
55      *
56      *@return The Clipper value
57      */

58     public Element getClipper() {
59         return clipperDoc.getRootElement();
60     }
61
62
63     /**
64      * Gets the ClipperName attribute of the ClipperParser object
65      *
66      *@return The ClipperName value
67      */

68     public Element getClipperName() {
69         return getClipper().getChild(Label.NAME);
70     }
71
72
73     /**
74      * Gets the ConfigProxy attribute of the ClipperParser object
75      *
76      *@return The ConfigProxy value
77      */

78     public String JavaDoc getConfigProxy() {
79         return this.getConfiguration().getChild(Label.PROXY).getTextTrim();
80     }
81
82
83     /**
84      * Gets the ConfigEnableSSL attribute of the ClipperParser object
85      *
86      *@return The ConfigEnableSSL value
87      */

88     public String JavaDoc getConfigEnableSSL() {
89         return this.getConfiguration().getChild(Label.ENABLESSL).getTextTrim();
90     }
91
92
93     /**
94      * Gets the ConfigEnableJavascript attribute of the ClipperParser object
95      *
96      *@return The ConfigEnableJavascript value
97      */

98     public String JavaDoc getConfigEnableJavascript() {
99         return this.getConfiguration().getChild(Label.ENABLEJAVASCRIPT).getTextTrim();
100     }
101
102
103     /**
104      * Gets the ConfigClient attribute of the ClipperParser object
105      *
106      *@return The ConfigClient value
107      */

108     public String JavaDoc getConfigClient() {
109         return this.getConfiguration().getChild(Label.CLIENT).getTextTrim();
110     }
111
112
113     /**
114      * Gets the ConfigHtmlDocument attribute of the ClipperParser object
115      *
116      *@return The ConfigHtmlDocument value
117      */

118     public String JavaDoc getConfigHtmlDocument() {
119         return this.getConfiguration().getChild(Label.HTMLDOCUMENT).getTextTrim();
120     }
121
122
123     /**
124      * Gets the ConfigEnableCSS attribute of the ClipperParser object
125      *
126      *@return The ConfigEnableCSS value
127      */

128     public String JavaDoc getConfigEnableCSS() {
129         return this.getConfiguration().getChild(Label.ENABLECSS).getTextTrim();
130     }
131
132
133     /**
134      * Gets the ConfigBrowserJavascriptEvent attribute of the ClipperParser
135      * object
136      *
137      *@return The ConfigBrowserJavascriptEvent value
138      */

139     public String JavaDoc getConfigBrowserJavascriptEvent() {
140         return this.getConfiguration().getChild(Label.BROWSER_JAVASCRIPT_EVENT).getTextTrim();
141     }
142
143
144     /**
145      * Gets the ConfigBrowserJavascriptCode attribute of the ClipperParser
146      * object
147      *
148      *@return The ConfigBrowserJavascriptCode value
149      */

150     public String JavaDoc getConfigBrowserJavascriptCode() {
151         return this.getConfiguration().getChild(Label.BROWSER_JAVASCRIPT_CODE).getTextTrim();
152     }
153
154
155     /**
156      * Gets the PortletEnableSSL attribute of the ClipperParser object
157      *
158      *@return The PortletEnableSSL value
159      */

160     public String JavaDoc getPortletEnableSSL() {
161         return this.getConfiguration().getChild(Label.PORTLET_SSL).getTextTrim();
162     }
163
164
165     /**
166      * Gets the PortletContinualClipping attribute of the ClipperParser object
167      *
168      *@return The PortletContinualClipping value
169      */

170     public String JavaDoc getPortletContinualClipping() {
171         return this.getConfiguration().getChild(Label.PORTLET_CLIPPING).getTextTrim();
172     }
173
174
175     /**
176      * Gets the PortletCacheExpiration attribute of the ClipperParser object
177      *
178      *@return The PortletCacheExpiration value
179      */

180     public String JavaDoc getPortletCacheExpiration() {
181         return this.getConfiguration().getChild(Label.PORTLET_CACHE_EXPIRATION).getTextTrim();
182     }
183
184
185     /**
186      * Gets the PortletCacheContext attribute of the ClipperParser object
187      *
188      *@return The PortletCacheContext value
189      */

190     public String JavaDoc getPortletCacheContext() {
191         return this.getConfiguration().getChild(Label.PORTLET_CACHE_CONTEXT).getTextTrim();
192     }
193
194
195
196     /**
197      * Gets the ClipperDescription attribute of the ClipperParser object
198      *
199      *@return The ClipperDescription value
200      */

201     public Element getClipperDescription() {
202         return getClipper().getChild(Label.DESCRIPTION);
203     }
204
205
206     /**
207      * Gets the Name attribute of the ClipperDocument object
208      *
209      *@return The Name value
210      */

211     public String JavaDoc getName() {
212         return getClipperName().getTextTrim();
213     }
214
215
216     /**
217      * Gets the Url attribute of the ClipperParser object
218      *
219      *@param pos Description of Parameter
220      *@return The Url value
221      */

222     public Element getUrl(int pos) {
223         List allUrlEle = getUrlList();
224
225         if (pos >= allUrlEle.size()) {
226             logger.debug("[ No url at position " + pos + " ]");
227             return null;
228         }
229
230         return (Element) allUrlEle.get(pos);
231     }
232
233
234     /**
235      * Gets the FilterType attribute of the ClipperParser object
236      *
237      *@return The FilterType value
238      */

239     public String JavaDoc getFilterType() {
240         Element filter = getFilter();
241         String JavaDoc type = filter.getAttributeValue(Label.FILTER_TYPE);
242         logger.debug("[ Filter type is :" + type + " ]");
243         return type;
244     }
245
246
247
248     /**
249      * Gets the KeysMap attribute of the ClipperParser object
250      *
251      *@return The KeysMap value
252      */

253     public Map getKeysMap() {
254         Element filter = getFilter();
255         List keys = filter.getChildren(Label.KEY);
256         Map m = new HashMap();
257         for (int i = 0; i < keys.size(); i++) {
258             Element key = (Element) keys.get(i);
259             String JavaDoc name = key.getAttributeValue(Label.KEY_NAME);
260             String JavaDoc value = key.getText();
261             m.put(name, value);
262         }
263         return m;
264     }
265
266
267
268     /**
269      * Gets the UrlValue attribute of the ClipperParser object
270      *
271      *@param pos Description of Parameter
272      *@return The UrlValue value
273      */

274     public String JavaDoc getBaseUrlValue(int pos) {
275         Element urlEle = this.getUrl(pos);
276         return this.getBaseURL(urlEle);
277     }
278
279
280     /**
281      * Gets the RelativeUrlValue attribute of the ClipperParser object
282      *
283      *@param pos Description of Parameter
284      *@return The RelativeUrlValue value
285      */

286     public String JavaDoc getRelativeUrlValue(int pos) {
287         Element urlEle = this.getUrl(pos);
288         return this.getRelativeURL(urlEle);
289     }
290
291
292
293     /**
294      * Gets the RedirectUrlValue attribute of the ClipperParser object
295      *
296      *@param pos Description of Parameter
297      *@return The RedirectUrlValue value
298      */

299     public String JavaDoc getRedirectUrlValue(int pos) {
300         Element urlEle = this.getUrl(pos);
301         return this.getRedirectUrlValue(urlEle);
302     }
303
304
305     /**
306      * Gets the UrlFrom attribute of the ClipperParser object
307      *
308      *@param pos Description of Parameter
309      *@return The UrlFrom value
310      */

311     public String JavaDoc getUrlFrom(int pos) {
312         Element urlEle = this.getUrl(pos);
313         return this.getUrlFrom(urlEle);
314     }
315
316
317     /**
318      * Gets the UrlHash attribute of the ClipperParser object
319      *
320      *@param pos Description of Parameter
321      *@return The UrlHash value
322      */

323     public String JavaDoc getUrlHash(int pos) {
324         Element urlEle = getUrl(pos);
325         return getUrlHash(urlEle);
326     }
327
328
329
330     /**
331      * Gets the UrlQueryMap attribute of the ClipperParser object
332      *
333      *@param pos Description of Parameter
334      *@return The UrlQueryMap value
335      */

336     public Map getUrlQueryMap(int pos) {
337         Map queryMap = new TreeMap();
338         Element urlEle = this.getUrl(pos);
339
340         // get the form param ele
341
Element queryParamsList = getListQueryParam(urlEle);
342
343         return queryMap;
344     }
345
346
347     /**
348      * Gets the Query attribute of the ClipperParser object
349      *
350      *@param posUrl Description of Parameter
351      *@param posParam Description of Parameter
352      *@return The Query value
353      */

354     public Element getQueryParam(int posUrl, int posParam) {
355         Element urlEle = this.getUrl(posUrl);
356         Element queryListEle = getListQueryParam(urlEle);
357         return (Element) queryListEle.getChildren().get(posParam);
358     }
359
360
361
362     /**
363      * Gets the QueryParam attribute of the ClipperParser object
364      *
365      *@param posUrl Description of Parameter
366      *@param name Description of Parameter
367      *@return The QueryParam value
368      */

369     public Element getQueryParam(int posUrl, String JavaDoc name) {
370         Element urlEle = getUrl(posUrl);
371         //Get the queryList element
372
Element queryListEle = getListQueryParam(urlEle);
373         //Get all the parameter element
374
List queryParamList = queryListEle.getChildren();
375         //Look for the one who's got name as name attribut
376
Element currentParam = null;
377         for (int i = 0; i < queryParamList.size(); i++) {
378             currentParam = (Element) queryParamList.get(i);
379             String JavaDoc currentName = currentParam.getAttributeValue(Label.PARAMETER_NAME);
380             if (currentName.equalsIgnoreCase(name)) {
381                 break;
382             }
383         }
384
385         return currentParam;
386     }
387
388
389     /**
390      * Gets the Form attribute of the ClipperParser object
391      *
392      *@param posUrl Description of Parameter
393      *@param posParam Description of Parameter
394      *@return The Form value
395      */

396     public Element getForm(int posUrl, int posParam) {
397         Element urlEle = this.getUrl(posUrl);
398         Element formListEle = getListFormParam(urlEle);
399         return (Element) formListEle.getChildren().get(posParam);
400     }
401
402
403     /**
404      * Gets the QueryName attribute of the ClipperParser object
405      *
406      *@param posUrl Description of Parameter
407      *@param posParam Description of Parameter
408      *@return The QueryName value
409      */

410     public String JavaDoc getFromName(int posUrl, int posParam) {
411         Element formEle = getForm(posUrl, posParam);
412         return formEle.getAttributeValue(Label.PARAMETER_NAME);
413     }
414
415
416     /**
417      * Gets the FromPossibleValue attribute of the ClipperParser object
418      *
419      *@param posUrl Description of Parameter
420      *@param posParam Description of Parameter
421      *@return The FromPossibleValue value
422      */

423     public List getFromPossibleValue(int posUrl, int posParam) {
424         Element formEle = getForm(posUrl, posParam);
425         return formEle.getChildren(Label.PARAMETER_VALUE);
426     }
427
428
429     /**
430      * Gets the QueryMapping attribute of the ClipperParser object
431      *
432      *@param posUrl Description of Parameter
433      *@param posParam Description of Parameter
434      *@return The QueryMapping value
435      */

436     public String JavaDoc getFormParamMapping(int posUrl, int posParam) {
437         Element formEle = getForm(posUrl, posParam);
438         return formEle.getAttributeValue(Label.PARAMETER_MAPPING);
439     }
440
441
442     /**
443      * Gets the FormFormParentName attribute of the ClipperParser object
444      *
445      *@param posUrl Description of Parameter
446      *@param posParam Description of Parameter
447      *@return The FormFormParentName value
448      */

449     public String JavaDoc getFormFormParentName(int posUrl, int posParam) {
450         Element formEle = getForm(posUrl, posParam);
451         return formEle.getAttributeValue(Label.FORM_PARENT_NAME);
452     }
453
454
455     /**
456      * Gets the FormFormParentId attribute of the ClipperParser object
457      *
458      *@param posUrl Description of Parameter
459      *@param posParam Description of Parameter
460      *@return The FormFormParentId value
461      */

462     public String JavaDoc getFormFormParentId(int posUrl, int posParam) {
463         Element formEle = getForm(posUrl, posParam);
464         return formEle.getAttributeValue(Label.FORM_PARENT_ID);
465     }
466
467
468     /**
469      * Gets the FormFormParentPosition attribute of the ClipperParser object
470      *
471      *@param posUrl Description of Parameter
472      *@param posParam Description of Parameter
473      *@return The FormFormParentPosition value
474      */

475     public String JavaDoc getFormFormParentPosition(int posUrl, int posParam) {
476         Element formEle = getForm(posUrl, posParam);
477         return formEle.getAttributeValue(Label.FORM_PARENT_POSITION);
478     }
479
480
481
482     /**
483      * Gets the QueryName attribute of the ClipperParser object
484      *
485      *@param posUrl Description of Parameter
486      *@param posParam Description of Parameter
487      *@return The QueryName value
488      */

489     public String JavaDoc getQueryName(int posUrl, int posParam) {
490         Element queryEle = getQueryParam(posUrl, posParam);
491         return queryEle.getAttributeValue(Label.PARAMETER_NAME);
492     }
493
494
495     /**
496      * Gets the FromPossibleValue attribute of the ClipperParser object
497      *
498      *@param posUrl Description of Parameter
499      *@param posParam Description of Parameter
500      *@return The FromPossibleValue value
501      */

502     public String JavaDoc getQueryDefault(int posUrl, int posParam) {
503         Element queryEle = getQueryParam(posUrl, posParam);
504         String JavaDoc encrypted = queryEle.getAttributeValue(Label.PARAMETER_DEFAULT);
505         if (encrypted != null) {
506             String JavaDoc defaultValue = DESUtilities.getInstance().decrypt(Label.KEY_ENCRYPT, encrypted);
507             return defaultValue;
508         }
509         else {
510             return null;
511         }
512     }
513
514
515     /**
516      * Gets the QueryPosition attribute of the ClipperParser object
517      *
518      *@param posUrl Description of Parameter
519      *@param posParam Description of Parameter
520      *@return The QueryPosition value
521      */

522     public String JavaDoc getQueryPosition(int posUrl, int posParam) {
523         Element queryEle = getQueryParam(posUrl, posParam);
524         String JavaDoc pos = queryEle.getAttributeValue(Label.PARAMETER_POSITION);
525         return pos;
526     }
527
528
529
530     /**
531      * Gets the QueryMapping attribute of the ClipperParser object
532      *
533      *@param posUrl Description of Parameter
534      *@param posParam Description of Parameter
535      *@return The QueryMapping value
536      */

537     public String JavaDoc getFormParamVisibility(int posUrl, int posParam) {
538         Element formEle = getForm(posUrl, posParam);
539         return formEle.getAttributeValue(Label.PARAMETER_VISIBILITY);
540     }
541
542
543     /**
544      * Gets the FormParamUpdate attribute of the ClipperParser object
545      *
546      *@param posUrl Description of Parameter
547      *@param posParam Description of Parameter
548      *@return The FormParamUpdate value
549      */

550     public String JavaDoc getFormParamUpdate(int posUrl, int posParam) {
551         Element formEle = getForm(posUrl, posParam);
552         return formEle.getAttributeValue(Label.PARAMETER_UPDATE);
553     }
554
555
556
557     /**
558      * Gets the FormParamPosition attribute of the ClipperParser object
559      *
560      *@param posUrl Description of Parameter
561      *@param posParam Description of Parameter
562      *@return The FormParamPosition value
563      */

564     public String JavaDoc getFormParamPosition(int posUrl, int posParam) {
565         Element formEle = getForm(posUrl, posParam);
566         return formEle.getAttributeValue(Label.PARAMETER_POSITION);
567     }
568
569
570
571     /**
572      * Gets the QueryType attribute of the ClipperParser object
573      *
574      *@param posUrl Description of Parameter
575      *@param posParam Description of Parameter
576      *@return The QueryType value
577      */

578     public String JavaDoc getFormType(int posUrl, int posParam) {
579         Element formEle = getForm(posUrl, posParam);
580         return formEle.getAttributeValue(Label.PARAMETER_TYPE);
581     }
582
583
584     /**
585      * Gets the TargetUrl attribute of the ClipperParser object
586      *
587      *@return The TargetUrl value
588      */

589     public String JavaDoc getTargetUrl() {
590         Element urlEle = getUrl(0);
591         return getBaseURL(urlEle);
592     }
593
594
595     /**
596      * Gets the UrlListSize attribute of the ClipperParser object
597      *
598      *@return The UrlListSize value
599      */

600     public int getUrlListSize() {
601         return getUrlList().size();
602     }
603
604
605     /**
606      * Gets the UrlListFormParamSize attribute of the ClipperParser object
607      *
608      *@param posUrl Description of Parameter
609      *@return The UrlListFormParamSize value
610      */

611     public int getUrlListFormParamSize(int posUrl) {
612         Element urlEle = this.getUrl(posUrl);
613         Element formListEle = getListFormParam(urlEle);
614         return formListEle.getChildren().size();
615     }
616
617
618     /**
619      * Gets the UrlListQueryParamSize attribute of the ClipperParser object
620      *
621      *@param posUrl Description of Parameter
622      *@return The UrlListQueryParamSize value
623      */

624     public int getUrlListQueryParamSize(int posUrl) {
625         Element urlEle = this.getUrl(posUrl);
626         Element queryListEle = getListQueryParam(urlEle);
627         return queryListEle.getChildren().size();
628     }
629
630
631     /**
632      * Gets the PossibleValue attribute of the ClipperParser object
633      *
634      *@param possibleValueEle Description of Parameter
635      *@return The PossibleValue value
636      */

637     public String JavaDoc getPossibleValue(Object JavaDoc possibleValueEle) {
638         return ((Element) possibleValueEle).getTextTrim();
639     }
640
641
642     /**
643      * Gets the FormDefaultValue attribute of the ClipperParser object
644      *
645      *@param posUrl Description of Parameter
646      *@param name Description of Parameter
647      *@return The FormDefaultValue value
648      */

649     public String JavaDoc getFormDefaultValue(int posUrl, String JavaDoc name) {
650         // if it's the last url, than there is not default value
651
if (posUrl >= (getUrlListSize() - 1)) {
652             logger.debug("[ Last url]");
653             return "";
654         }
655         // retrieve the query param of the next url whith name as asttribute
656
Element queryParamEle = getQueryParam(posUrl + 1, name);
657         //return the default value
658
if (queryParamEle == null) {
659             return "";
660         }
661         return queryParamEle.getAttributeValue(Label.PARAMETER_DEFAULT);
662     }
663
664
665     /**
666      * Gets the UrlValue attribute of the ClipperParser object
667      *
668      *@param urlEle Description of Parameter
669      *@return The UrlValue value
670      */

671     public String JavaDoc getBaseURL(Element urlEle) {
672         Element value = urlEle.getChild(Label.BASE);
673         return value.getTextTrim();
674     }
675
676
677     /**
678      * Gets the RelativeURL attribute of the ClipperParser object
679      *
680      *@param urlEle Description of Parameter
681      *@return The RelativeURL value
682      */

683     public String JavaDoc getRelativeURL(Element urlEle) {
684         Element value = urlEle.getChild(Label.VALUE);
685         return value.getTextTrim();
686     }
687
688
689
690     /**
691      * Gets the RedirectUrlValue attribute of the ClipperParser object
692      *
693      *@param urlEle Description of Parameter
694      *@return The RedirectUrlValue value
695      */

696     public String JavaDoc getRedirectUrlValue(Element urlEle) {
697         Element value = urlEle.getChild(Label.FINAL_VALUE);
698         return value.getTextTrim();
699     }
700
701
702     /**
703      * Gets the UrlFrom attribute of the ClipperParser object
704      *
705      *@param urlEle Description of Parameter
706      *@return The UrlFrom value
707      */

708     public String JavaDoc getUrlFrom(Element urlEle) {
709         String JavaDoc value = urlEle.getAttributeValue(Label.URL_FROM);
710         return value;
711     }
712
713
714     /**
715      * Gets the UrlHash attribute of the ClipperParser object
716      *
717      *@param urlEle Description of Parameter
718      *@return The UrlHash value
719      */

720     public String JavaDoc getUrlHash(Element urlEle) {
721         String JavaDoc value = urlEle.getAttributeValue(Label.URL_HASH);
722         return value;
723     }
724
725
726
727     /**
728      * Gets the Description attribute of the ClipperDocument object
729      *
730      *@return The Description value
731      */

732     public String JavaDoc getDescription() {
733         return getClipperDescription().getTextTrim();
734     }
735
736
737     /**
738      * Gets the SequenceUrl attribute of the ElementManager object
739      *
740      *@return The SequenceUrl value
741      */

742     public Element getSequenceUrl() {
743         Element clipperEle = getClipperDoc().getRootElement();
744         if (sequenceUrlEle == null) {
745             sequenceUrlEle = clipperEle.getChild(Label.SEQUENCEURL);
746         }
747         return sequenceUrlEle;
748     }
749
750
751     /**
752      * Gets the Filter attribute of the ClipperParser object
753      *
754      *@return The Filter value
755      */

756     public Element getFilter() {
757         Element clipperEle = getClipperDoc().getRootElement();
758         if (this.filterEle == null) {
759             filterEle = clipperEle.getChild(Label.FILTER);
760         }
761         return filterEle;
762     }
763
764
765     /**
766      * Gets the Configuration attribute of the ClipperParser object
767      *
768      *@return The Configuration value
769      */

770     public Element getConfiguration() {
771         Element clipperEle = getClipperDoc().getRootElement();
772         if (this.configEle == null) {
773             configEle = clipperEle.getChild(Label.CONFIGURATION);
774         }
775         return configEle;
776     }
777
778
779
780     /**
781      * Gets the ListParam attribute of the ElementManager object
782      *
783      *@param url Description of Parameter
784      *@return The ListParam value
785      */

786     public Element getListFormParam(String JavaDoc url) {
787         // looking in the hashtable
788
Object JavaDoc o = urlFormParamHashtable.get(url);
789         if (o != null) {
790             return (Element) o;
791         }
792
793         // else parse the document
794
Element urlEle = getUrl(url);
795         Element formParamEle = getListFormParam(urlEle);
796         if (formParamEle == null) {
797             logger.error("[can't retrieve <form-param>]");
798             return null;
799         }
800         urlFormParamHashtable.put(url, formParamEle);
801         return formParamEle;
802     }
803
804
805     /**
806      * Gets the ListFormParam attribute of the ClipperParser object
807      *
808      *@param urlEle Description of Parameter
809      *@return The ListFormParam value
810      */

811     public Element getListFormParam(Element urlEle) {
812         return urlEle.getChild(Label.USERPARAM);
813     }
814
815
816     /**
817      * Gets the ListQueryParam attribute of the ClipperParser object
818      *
819      *@param urlEle Description of Parameter
820      *@return The ListQueryParam value
821      */

822     public Element getListQueryParam(Element urlEle) {
823         return urlEle.getChild(Label.QUERYPARAM);
824     }
825
826
827     /**
828      * Gets the QueryParam attribute of the ElementManager object
829      *
830      *@param url Description of Parameter
831      *@return The QueryParam value
832      */

833     public Element getListQueryParam(String JavaDoc url) {
834         // looking in the hashtable
835
Object JavaDoc o = urlQueryParamHashtable.get(url);
836         if (o != null) {
837             return (Element) o;
838         }
839
840         // else parse the document
841
Element urlEle = getUrl(url);
842         Element queryParamEle = getListQueryParam(urlEle);
843         if (queryParamEle == null) {
844             logger.error("[can't retrieve <query-param>]");
845             return null;
846         }
847         urlQueryParamHashtable.put(url, queryParamEle);
848         return queryParamEle;
849     }
850
851
852     /**
853      * Gets the Url attribute of the ElementManager object
854      *
855      *@param url Description of Parameter
856      *@return The Url value
857      */

858     public Element getUrl(String JavaDoc url) {
859         Object JavaDoc o = urlHashtable.get(url);
860         // first look in the hastable
861
if (url != null) {
862             return (Element) o;
863         }
864         // else parse the document
865
else {
866             // ...SequenceUrl=>Url
867
Element sequenceUrlEle = getSequenceUrl();
868             // SequenceUrl=>Url
869
List allUrlEle = sequenceUrlEle.getChildren();
870             Element ele = null;
871             for (int i = 0; i < allUrlEle.size(); i++) {
872                 ele = (Element) allUrlEle.get(i);
873                 // SequenceUrl=>Url->Value
874
Element valueEle = ele.getChild(Label.VALUE);
875                 if (valueEle.getTextTrim().equalsIgnoreCase(url)) {
876                     // put in the hashtable
877
urlHashtable.put(url, ele);
878                     break;
879                 }
880             }
881             return ele;
882         }
883     }
884
885
886     /**
887      * Gets the UrlListBean attribute of the ClipperDocument object
888      *
889      *@return The UrlListBean value
890      */

891     public ArrayList getUrlListBean() {
892         ArrayList urlBeanList = new ArrayList();
893         return urlBeanList;
894     }
895
896
897     /**
898      * Gets the UrlListBeanWithParams attribute of the ClipperDocument object
899      *
900      *@return The UrlListBeanWithParams value
901      */

902     public ArrayList getUrlListBeanWithParams() {
903         ArrayList urlBeanList = new ArrayList();
904         return urlBeanList;
905     }
906
907
908     /**
909      * Adds a feature to the Url attribute of the ElementManager object
910      *
911      *@param url The feature to be added to the Url attribute
912      *@param urlEle The feature to be added to the Url attribute
913      */

914     public void addUrl(String JavaDoc url, Element urlEle) {
915         this.urlHashtable.put(url, urlEle);
916     }
917
918
919     /**
920      * Gets the UrlList attribute of the ClipperParser object
921      *
922      *@return The UrlList value
923      */

924     private List getUrlList() {
925         Element sequenceUrlEle = getSequenceUrl();
926         // SequenceUrl=>Url
927
List allUrlEle = sequenceUrlEle.getChildren();
928         return allUrlEle;
929     }
930
931 }
932
Popular Tags