KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > area > LinkResolver


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: LinkResolver.java 426576 2006-07-28 15:44:37Z jeremias $ */
19
20 package org.apache.fop.area;
21
22 // Java
23
import java.util.List JavaDoc;
24 import java.io.Serializable JavaDoc;
25
26 // FOP
27
import org.apache.fop.area.Trait;
28 import org.apache.fop.area.Resolvable;
29 import org.apache.fop.area.PageViewport;
30 import org.apache.fop.area.Area;
31
32 /**
33  * Link resolving for resolving internal links.
34  */

35 public class LinkResolver implements Resolvable, Serializable JavaDoc {
36     private boolean resolved = false;
37     private String JavaDoc idRef;
38     private Area area;
39
40     /**
41      * Create a new link resolver.
42      *
43      * @param id the id to resolve
44      * @param a the area that will have the link attribute
45      */

46     public LinkResolver(String JavaDoc id, Area a) {
47         idRef = id;
48         area = a;
49     }
50
51     /**
52      * @return true if this link is resolved
53      */

54     public boolean isResolved() {
55         return resolved;
56     }
57
58     /**
59      * Get the references for this link.
60      *
61      * @return the String array of references.
62      */

63     public String JavaDoc[] getIDRefs() {
64         return new String JavaDoc[] {idRef};
65     }
66
67     /**
68      * Resolve by adding an internal link.
69      *
70      * @see org.apache.fop.area.Resolvable#resolveIDRef(String, List)
71      */

72     public void resolveIDRef(String JavaDoc id, List JavaDoc pages) {
73         if (idRef.equals(id) && pages != null) {
74             resolved = true;
75             PageViewport page = (PageViewport)pages.get(0);
76             area.addTrait(Trait.INTERNAL_LINK, page.getKey());
77         }
78     }
79 }
80
Popular Tags