KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > search > SearchToken


1 /*
2  * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/search/SearchToken.java,v 1.6.2.1 2004/09/25 20:28:55 luetzkendorf Exp $
3  * $Revision: 1.6.2.1 $
4  * $Date: 2004/09/25 20:28:55 $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2002 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23
24 package org.apache.slide.search;
25
26 import org.apache.slide.common.SlideToken;
27 import org.apache.slide.common.Namespace;
28 import org.apache.slide.content.Content;
29 import org.apache.slide.structure.Structure;
30
31 /**
32  * Represents the context of a search requerst.
33  *
34  * @version $Revision: 1.6.2.1 $
35  */

36 public class SearchToken {
37     
38     private SlideToken slideToken;
39     private Content contentHelper;
40     private Structure structureHelper;
41     
42     private SlideUri slideContext;
43     
44     private int maxDepth = Integer.MAX_VALUE;
45     
46     private Namespace namespace;
47     
48     /**
49      * SearchToken factory.
50      *
51      * @param token the slideToken
52      * @param content content helper
53      * @param structure structure helper
54      * @param maxDepth the maximum search depth as configurede in Domain.xml
55      *
56      * @return a SearchToken
57      */

58     public static SearchToken createSearchToken
59         (SlideToken token, Content content,
60          Structure structure, int maxDepth,
61          String JavaDoc requestUri, Namespace namespace)
62     {
63         return new SearchToken (token, content, structure, maxDepth, requestUri, namespace);
64     }
65     
66     /**
67      * SearchToken factory for test purpose.
68      *
69      * @param maxDepth the maximum search depth as configurede in Domain.xml
70      *
71      * @return a SearchToken
72      *
73      */

74     public static SearchToken createSearchTokenForTestOnly (int maxDepth, String JavaDoc requestUri) {
75         return new SearchToken (null, null, null, maxDepth, requestUri, null);
76     }
77     
78     
79     /**
80      * Constructor, force use of factory method.
81      *
82      * @param token the slideToken
83      * @param content content helper
84      * @param structure structure helper
85      * @param maxDepth the maximum search depth as configurede in Domain.xml
86      *
87      */

88     private SearchToken (SlideToken token, Content content,
89                          Structure structure, int maxDepth,
90                          String JavaDoc requestUri, Namespace namespace) {
91         
92         this.slideToken = token;
93         this.contentHelper = content;
94         this.structureHelper = structure;
95         this.maxDepth = maxDepth;
96       this.slideContext = SlideUri.createWithRequestUri(
97               (String JavaDoc)token.getParameter("slideContextPath"), requestUri);
98       this.namespace = namespace;
99     }
100     
101     /**
102      * Method getNamespace
103      *
104      * @return the namespace
105      *
106      */

107     public Namespace getNamespace () {
108         return namespace;
109     }
110     
111     /**
112      * Method getSlideToken
113      *
114      * @return the slideToken
115      *
116      */

117     public SlideToken getSlideToken() {
118         return slideToken;
119     }
120     
121     /**
122      * Method getContentHelper
123      *
124      * @return the contentHelper
125      *
126      */

127     public Content getContentHelper() {
128         return contentHelper;
129     }
130     
131     /**
132      * Method getStructureHelper
133      *
134      * @return the structureHelper
135      *
136      */

137     public Structure getStructureHelper() {
138         return structureHelper;
139     }
140     
141     /**
142      * Method getMaxDepth
143      *
144      * @return max depth as configured in Domain.xml
145      *
146      */

147     public int getMaxDepth() {
148         return maxDepth;
149     }
150     
151     /**
152      * Method getSlideContext
153      *
154      * @return a SlideUri
155      *
156      */

157     public SlideUri getSlideContext () {
158         return slideContext;
159     }
160 }
161
162
Popular Tags