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_FULL;
import static nz.net.ultraq.thymeleaf.include.IncludeProcessor.PROCESSOR_NAME_INCLUDE_FULL;
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 all fragments within the given elements without delving into layout:include elements.

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

Recursive search for all fragment elements without delving into layout:include elements.

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

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