org.apache.shindig.gadgets.rewrite
Class ConcatVisitor

java.lang.Object
  extended by org.apache.shindig.gadgets.rewrite.ConcatVisitor
All Implemented Interfaces:
DomWalker.Visitor
Direct Known Subclasses:
ConcatVisitor.Css, ConcatVisitor.Js

public class ConcatVisitor
extends Object
implements DomWalker.Visitor

DOM mutator that concatenates resources using the concat servlet

Since:
2.0.0

Nested Class Summary
static class ConcatVisitor.Css
           
static class ConcatVisitor.Js
           
 
Nested classes/interfaces inherited from interface org.apache.shindig.gadgets.rewrite.DomWalker.Visitor
DomWalker.Visitor.VisitStatus
 
Method Summary
 boolean revisit(Gadget gadget, List<Node> nodes)
          For css: Link tags are first split into buckets separated by tags with mediaType == "all" / title attribute different from their previous link tag / nodes that are not 'link' tags.
 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
 

Method Detail

visit

public DomWalker.Visitor.VisitStatus visit(Gadget gadget,
                                           Node node)
                                    throws RewritingException
Description copied from interface: DomWalker.Visitor
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
For css: Link tags are first split into buckets separated by tags with mediaType == "all" / title attribute different from their previous link tag / nodes that are not 'link' tags. This ensures that the buckets can be processed separately without losing title / "all" mediaType information. Link tags with same mediaType are concatenated within each bucket. This exercise ensures that css information is loaded in the same relative order as that of the original html page, and that the css information within mediaType=="all" is retained and applies to all media types. Look at the areLinkNodesBucketable method for details on mediaType=="all" and title attribute Example: Assume we have the following node list. (all have same parent, nodes between Node6 and Node12 are non link nodes, and hence did not come to revisit() call) -- Node1 -- Node2 -- Node3 -- Node4 -- Node5 -- Node6 -- Node12 -- Node13 First we split to buckets bassed on the adjacency and other conditions. buckets - [ [ Node1, Node2, Node3 ], [ Node4, Node 5 ], [ Node6 ], [ Node12, Node13 ] Within each bucket we group them based on media type. batches - [ Node1, Node2, Node3 ] --> [ [Node1, Node3], [Node2] ] - [ Node4, Node 5 ] --> [ [ Node4, Node 5 ] ] - [ Node6 ] --> [ [ Node6 ] ] - [ Node12, Node13 ] --> [ [ Node12, Node13 ] ] Refer Tests for more examples.

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


Copyright © 2007-2012. All Rights Reserved.