1 16 package org.apache.cocoon.sitemap; 17 18 import org.apache.avalon.framework.parameters.Parameters; 19 import org.apache.cocoon.Constants; 20 import org.apache.cocoon.ProcessingException; 21 import org.apache.cocoon.caching.CacheableProcessingComponent; 22 import org.apache.cocoon.environment.SourceResolver; 23 import org.apache.cocoon.transformation.Transformer; 24 import org.apache.cocoon.xml.xlink.ExtendedXLinkPipe; 25 import org.apache.excalibur.source.SourceValidity; 26 import org.apache.excalibur.source.impl.validity.NOPValidity; 27 28 import org.xml.sax.Attributes ; 29 import org.xml.sax.SAXException ; 30 31 import java.io.IOException ; 32 import java.util.Map ; 33 34 38 public class LinkTranslator extends ExtendedXLinkPipe implements Transformer, CacheableProcessingComponent { 39 40 private Map links; 41 42 46 public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) 47 throws ProcessingException, SAXException , IOException { 48 this.links = (Map )objectModel.get(Constants.LINK_OBJECT); 49 } 50 51 57 public java.io.Serializable getKey() { 58 return "1"; 59 } 60 61 67 public SourceValidity getValidity() { 68 return NOPValidity.SHARED_INSTANCE; 69 } 70 71 public void simpleLink(String href, String role, String arcrole, 72 String title, String show, String actuate, String uri, 73 String name, String raw, Attributes attr) 74 throws SAXException { 75 final String newHref = (String )this.links.get(href); 76 super.simpleLink((newHref != null) ? newHref : href, role, arcrole, title, show, actuate, uri, name, raw, attr); 77 } 78 79 public void startLocator(String href, String role, String title, 80 String label, String uri, String name, String raw, 81 Attributes attr) 82 throws SAXException { 83 final String newHref = (String )this.links.get(href); 84 super.startLocator((newHref != null) ? newHref : href, role, title, label, uri, name, raw, attr); 85 } 86 } 87 | Popular Tags |