001: /*
002: * Copyright 2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package javax.faces.render;
017:
018: import java.io.IOException;
019: import java.util.List;
020:
021: import javax.faces.component.UIComponent;
022: import javax.faces.context.FacesContext;
023: import javax.faces.convert.ConverterException;
024:
025: /**
026: * see Javadoc of <a href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
027: *
028: * @author Manfred Geiler (latest modification by $Author: mbr $)
029: * @version $Revision: 512227 $ $Date: 2007-02-27 13:25:16 +0100 (Di, 27 Feb 2007) $
030: */
031: public abstract class Renderer {
032: public void decode(FacesContext context, UIComponent component) {
033: if (context == null)
034: throw new NullPointerException("context");
035: if (component == null)
036: throw new NullPointerException("component");
037: }
038:
039: public void encodeBegin(FacesContext context, UIComponent component)
040: throws IOException {
041: if (context == null)
042: throw new NullPointerException("context");
043: if (component == null)
044: throw new NullPointerException("component");
045: }
046:
047: public void encodeChildren(FacesContext context,
048: UIComponent component) throws IOException {
049: if (context == null)
050: throw new NullPointerException("context");
051: if (component == null)
052: throw new NullPointerException("component");
053:
054: List children = component.getChildren();
055: for (int i = 0; i < children.size(); i++) {
056: UIComponent child = (UIComponent) children.get(i);
057:
058: if (!child.isRendered()) {
059: continue;
060: }
061:
062: child.encodeBegin(context);
063: if (child.getRendersChildren()) {
064: child.encodeChildren(context);
065: }
066: child.encodeEnd(context);
067: }
068: }
069:
070: public void encodeEnd(FacesContext context, UIComponent component)
071: throws IOException {
072: if (context == null)
073: throw new NullPointerException("context");
074: if (component == null)
075: throw new NullPointerException("component");
076: }
077:
078: public String convertClientId(FacesContext context, String clientId) {
079: if (context == null)
080: throw new NullPointerException("context");
081: if (clientId == null)
082: throw new NullPointerException("clientId");
083: return clientId;
084: }
085:
086: public boolean getRendersChildren() {
087: return false;
088: }
089:
090: public Object getConvertedValue(FacesContext context,
091: UIComponent component, Object submittedValue)
092: throws ConverterException {
093: if (context == null)
094: throw new NullPointerException("context");
095: if (component == null)
096: throw new NullPointerException("component");
097: return submittedValue;
098: }
099:
100: }
|