Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  // Copyright 2009 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
 // distributed under the License is distributed on an "AS IS" BASIS,
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
 package org.apache.tapestry5.internal.pageload;
 
 
 import java.util.List;

Used when constructing a AssemblerContext, encapsulating the assembler, the TokenStream for the component's template, and helping to consolidate composable render commands (that is, a series of render commands that are not components can be replaced with a single CompositeRenderCommand which reduces the number of render operations for the page).
 
 class AssemblerContext implements TokenStream
 {
     final ComponentAssembler assembler;
 
     final TokenStream stream;
 
     private final List<RenderCommandcomposable = CollectionFactory.newList();
 
     AssemblerContext(ComponentAssembler assemblerTokenStream stream)
     {
         this. = assembler;
         this. = stream;
     }
 
     public boolean more()
     {
         return .more();
     }
 
     public TemplateToken next()
     {
         return .next();
     }
 
     public <T extends TemplateToken> T next(Class<T> type)
     {
         return .next(type);
     }
 
     public TokenType peekType()
     {
         return .peekType();
     }
 
     void addComposable(RenderCommand command)
     {
         .add(command);
     }
 
     void flushComposable()
     {
         switch (.size())
         {
             case 0:
                 return;
 
             case 1:
                 addRenderCommand(.get(0));
                 break;
 
             default:
                 addRenderCommand(new CompositeRenderCommand(.toArray(new RenderCommand[.size()])));
                 break;
         }
 
         .clear();
     }
 
     void add(PageAssemblyAction action)
     {
         flushComposable();
 
         .add(action);
     }
 
     private void addRenderCommand(final RenderCommand command)
     {
         .add(new PageAssemblyAction()
         {
            public void execute(PageAssembly pageAssembly)
            {
                pageAssembly.addRenderCommand(command);
            }
        });
    }
New to GrepCode? Check out our FAQ X