KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > resolver > DefaultResolver


1 /*
2  * Copyright 1999-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 package org.apache.cocoon.components.resolver;
17
18 import org.apache.excalibur.xml.DefaultEntityResolver;
19
20
21 /**
22  * A component that uses catalogs for resolving entities.
23  * This component simply inherits from the excalibur implementation and
24  * adds the context: protocol to each relative uri.
25  *
26  * The catalog is by default loaded from "WEB-INF/entities/catalog".
27  * This can be configured by the "catalog" parameter in the cocoon.xconf:
28  * <entity-resolver>
29  * <parameter name="catalog" value="mycatalog"/>
30  * </entity-resolver>
31  *
32  * @author <a HREF="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
33  * @version CVS $Id: DefaultResolver.java 30932 2004-07-29 17:35:38Z vgritsenko $
34  * @since 2.1
35  */

36 public class DefaultResolver
37   extends DefaultEntityResolver {
38
39     /**
40      * Parse a catalog
41      */

42     protected void parseCatalog(String JavaDoc uri) {
43         // check for relative URIs
44
// if the URI has ':/' then it's a URI
45
// if the URI starts with '/ it's an absolute (UNIX) path
46
// if the URI has a ':' at position 1, it's an absolute windows path
47
// otherwise we have a relative URI, that is resolved relative
48
// to the context
49
if (uri.indexOf(":/") == -1
50             && !uri.startsWith("/")
51             && !(uri.length() > 1 && uri.charAt(1) == ':')) {
52                 uri = "context://" + uri;
53         }
54         super.parseCatalog( uri );
55     }
56     
57     /**
58      * Default catalog path
59      */

60     protected String JavaDoc defaultCatalog() {
61         return "WEB-INF/entities/catalog";
62     }
63 }
64
Popular Tags