org.apache.shindig.gadgets.rewrite
Class ResourceMutateVisitor

java.lang.Object
  extended by org.apache.shindig.gadgets.rewrite.ResourceMutateVisitor
All Implemented Interfaces:
DomWalker.Visitor
Direct Known Subclasses:
ProxyingVisitor

public abstract class ResourceMutateVisitor
extends Object
implements DomWalker.Visitor

Abstract visitor that walks over html tags as specified by resourceTags and prepares list of html tag nodes whose uri attributes can be mutated. Implementations can override mutateUris(org.apache.shindig.gadgets.Gadget, java.util.Collection) for uses cases like proxying resources, making url's absolute, prefetching images etc. TODO: Refactor AbsolutePathReferenceVisitor to extend ResourceMutateVisitor.

Since:
2.0.0

Nested Class Summary
static class ResourceMutateVisitor.Tags
          Enum for resource tags and associated attributes that should be mutated.
 
Nested classes/interfaces inherited from interface org.apache.shindig.gadgets.rewrite.DomWalker.Visitor
DomWalker.Visitor.VisitStatus
 
Field Summary
protected  ContentRewriterFeature.Config featureConfig
           
protected  Map<String,String> resourceTags
           
 
Constructor Summary
ResourceMutateVisitor(ContentRewriterFeature.Config featureConfig, ResourceMutateVisitor.Tags... resourceTags)
           
 
Method Summary
protected abstract  Collection<Pair<Node,Uri>> mutateUris(Gadget gadget, Collection<Node> nodes)
           
 boolean revisit(Gadget gadget, List<Node> nodes)
          Revisit a node in the DOM that was marked by the visit(Gadget, Node) as reserved during DOM traversal.
 DomWalker.Visitor.VisitStatus visit(Gadget gadget, Node node)
          Visit a particular Node in the DOM.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resourceTags

protected final Map<String,String> resourceTags

featureConfig

protected final ContentRewriterFeature.Config featureConfig
Constructor Detail

ResourceMutateVisitor

public ResourceMutateVisitor(ContentRewriterFeature.Config featureConfig,
                             ResourceMutateVisitor.Tags... resourceTags)
Method Detail

visit

public DomWalker.Visitor.VisitStatus visit(Gadget gadget,
                                           Node node)
                                    throws RewritingException
Visit a particular Node in the DOM.

Specified by:
visit in interface DomWalker.Visitor
Parameters:
gadget - Context for the request.
node - Node being visited.
Returns:
Status, see VisitStatus
Throws:
RewritingException

revisit

public boolean revisit(Gadget gadget,
                       List<Node> nodes)
                throws RewritingException
Revisit a node in the DOM that was marked by the visit(Gadget, Node) as reserved during DOM traversal.

Specified by:
revisit in interface DomWalker.Visitor
Parameters:
gadget - Context for the request.
nodes - Nodes being revisited, previously marked as reserved.
Returns:
True if any node modified, false otherwise.
Throws:
RewritingException

mutateUris

protected abstract Collection<Pair<Node,Uri>> mutateUris(Gadget gadget,
                                                         Collection<Node> nodes)


Copyright © 2007-2012. All Rights Reserved.