All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sun.jsftemplating.layout.template.InsertParserCommand Maven / Gradle / Ivy

/*
 * The contents of this file are subject to the terms 
 * of the Common Development and Distribution License 
 * (the License).  You may not use this file except in
 * compliance with the License.
 * 
 * You can obtain a copy of the license at 
 * https://jsftemplating.dev.java.net/cddl1.html or
 * jsftemplating/cddl1.txt.
 * See the License for the specific language governing 
 * permissions and limitations under the License.
 * 
 * When distributing Covered Code, include this CDDL 
 * Header Notice in each file and include the License file 
 * at jsftemplating/cddl1.txt.  
 * If applicable, add the following below the CDDL Header, 
 * with the fields enclosed by brackets [] replaced by
 * you own identifying information: 
 * "Portions Copyrighted [year] [name of copyright owner]"
 * 
 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
 */
package com.sun.jsftemplating.layout.template;

import com.sun.jsftemplating.layout.ProcessingCompleteException;
import com.sun.jsftemplating.layout.SyntaxException;
import com.sun.jsftemplating.layout.descriptors.LayoutInsert;
import com.sun.jsftemplating.layout.descriptors.LayoutDefinition;
import com.sun.jsftemplating.layout.descriptors.LayoutElement;
import com.sun.jsftemplating.util.LayoutElementUtil;

import java.io.IOException;


/**
 *  

This {@link CustomParserCommand} handles "insert" statements. * TBD... *

* * @author Ken Paulsen ([email protected]) */ public class InsertParserCommand implements CustomParserCommand { /** *

This method processes a "custom" command. These are commands that * start with a !. When this method receives control, the * name (i.e. the token after the '!' character) has * already been read. It is passed via the name * parameter.

* *

The {@link ProcessingContext} and * {@link ProcessingContextEnvironment} are both available.

*/ public void process(ProcessingContext ctx, ProcessingContextEnvironment env, String name) throws IOException { // Get the reader and parser TemplateReader reader = env.getReader(); TemplateParser parser = reader.getTemplateParser(); // Skip any white space... parser.skipCommentsAndWhiteSpace(TemplateParser.SIMPLE_WHITE_SPACE); // Get the parent and insert name LayoutElement parent = env.getParent(); String id = (String) parser.getNVP(NAME_ATTRIBUTE, true).getValue(); // Create new LayoutInsert LayoutInsert compElt = new LayoutInsert(parent, id); compElt.setName(id); parent.addChildLayoutElement(compElt); // Skip any white space or extra junk... String theRest = parser.readUntil('>', true).trim(); if (theRest.endsWith("/")) { reader.popTag(); // Don't look for end tag } else { // Process child LayoutElements (recurse) reader.process( LAYOUT_INSERT_CONTEXT, compElt, LayoutElementUtil.isLayoutComponentChild(compElt)); } } /** *

This is the {@link ProcessingContext} for * {@link LayoutInsert}s.

*/ protected static class LayoutInsertContext extends BaseProcessingContext { } /** *

A String containing "template". This is the attribute name of the * template file to use in the {@link LayoutInsert}.

*/ public static final String NAME_ATTRIBUTE = "name"; /** *

The {@link ProcessingContext} to be used when processing children * of a {@link LayoutInsert}. This {@link ProcessingContext} may * have special meaning for {@link LayoutInsert}s and other tags.

*/ public static final ProcessingContext LAYOUT_INSERT_CONTEXT = new LayoutInsertContext(); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy