KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > datatypes > URISpecification


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 /* $Id$ */
19
20 package org.apache.fop.datatypes;
21
22 /**
23  * This class contains method to deal with the <uri-specification> datatype from XSL-FO.
24  */

25 public class URISpecification {
26
27     /**
28      * Get the URL string from a wrapped URL.
29      *
30      * @param href the input wrapped URL
31      * @return the raw URL
32      */

33     public static String JavaDoc getURL(String JavaDoc href) {
34         /*
35          * According to section 5.11 a <uri-specification> is:
36          * "url(" + URI + ")"
37          * according to 7.28.7 a <uri-specification> is:
38          * URI
39          * So handle both.
40          */

41         href = href.trim();
42         if (href.startsWith("url(") && (href.indexOf(")") != -1)) {
43             href = href.substring(4, href.indexOf(")")).trim();
44             if (href.startsWith("'") && href.endsWith("'")) {
45                 href = href.substring(1, href.length() - 1);
46             } else if (href.startsWith("\"") && href.endsWith("\"")) {
47                 href = href.substring(1, href.length() - 1);
48             }
49         } else {
50             // warn
51
}
52         return href;
53     }
54
55     
56 }
57
Popular Tags