Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2012, Emanuel Rabina (http://www.ultraq.net.nz/)
   * 
   * 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 nz.net.ultraq.thymeleaf;
 
 import static nz.net.ultraq.thymeleaf.FragmentProcessor.FRAGMENT_NAME_PREFIX;
 import static nz.net.ultraq.thymeleaf.FragmentProcessor.PROCESSOR_NAME_FRAGMENT;
 import static nz.net.ultraq.thymeleaf.LayoutDialect.DIALECT_PREFIX_LAYOUT;
 import static nz.net.ultraq.thymeleaf.LayoutUtilities.*;
 import static nz.net.ultraq.thymeleaf.include.IncludeProcessor.PROCESSOR_NAME_INCLUDE;
 import static nz.net.ultraq.thymeleaf.include.ReplaceProcessor.PROCESSOR_NAME_REPLACE;
 import static nz.net.ultraq.thymeleaf.include.SubstituteByProcessor.PROCESSOR_NAME_SUBSTITUTEBY;
 
 
 import java.util.List;
 import java.util.Map;

Common code for processors that fetch the content of other pages to include into the current template.

Author(s):
Emanuel Rabina
 
 public abstract class AbstractContentProcessor extends AbstractAttrProcessor {

Subclass constructor, set the attribute name that this processor will respond to.

Parameters:
attribute
 
 	protected AbstractContentProcessor(String attribute) {
 
 		super(attribute);
 	}

Find and return clones of all fragments within the given elements without delving into layout:include, layout:replace, or layout:substituteby elements.

Parameters:
elements
Returns:
Map of prefixed fragment names and their fragment elements.
 
 	protected static Map<String,ObjectfindFragments(List<Elementelements) {
 
 		HashMap<String,Objectfragments = new HashMap<String,Object>();
 		findFragments(fragmentselements);
 		return fragments;
 	}

Recursive clone of all fragment elements without delving into delving into layout:include, layout:replace, or layout:substituteby elements.

Parameters:
fragments
elements
 
 	private static void findFragments(HashMap<String,ObjectfragmentsList<Elementelements) {
 
 		for (Element elementelements) {
 			if (fragmentname != null) {
 				Element fragment = (Element)element.cloneNode(nulltrue);
 				fragments.put( + fragmentnamefragment);
 			}
 				findFragments(fragmentselement.getElementChildren());
 			}
 		}
 	}

 
 	public int getPrecedence() {
 
 		return 0;
	}
New to GrepCode? Check out our FAQ X