myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sless...@apache.org
Subject svn commit: r740940 [5/9] - in /myfaces/core/branches/2_0_0: api/src/main/java/javax/faces/webapp/pdl/facelets/ api/src/main/resources/META-INF/ impl/src/main/java/com/ impl/src/main/java/com/sun/ impl/src/main/java/com/sun/facelets/ impl/src/main/java...
Date Wed, 04 Feb 2009 23:55:29 GMT
Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/AbstractTagLibrary.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/AbstractTagLibrary.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/AbstractTagLibrary.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/AbstractTagLibrary.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,634 @@
+/**
+ * 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 com.sun.facelets.tag;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.convert.Converter;
+import javax.faces.validator.Validator;
+
+import javax.faces.webapp.pdl.facelets.FaceletContext;
+import javax.faces.webapp.pdl.facelets.FaceletException;
+import javax.faces.webapp.pdl.facelets.FaceletHandler;
+import com.sun.facelets.tag.jsf.ComponentConfig;
+import com.sun.facelets.tag.jsf.ComponentHandler;
+import com.sun.facelets.tag.jsf.ConvertHandler;
+import com.sun.facelets.tag.jsf.ConverterConfig;
+import com.sun.facelets.tag.jsf.ValidateHandler;
+import com.sun.facelets.tag.jsf.ValidatorConfig;
+
+/**
+ * Base class for defining TagLibraries in Java
+ * 
+ * @author Jacob Hookom
+ * @version $Id: AbstractTagLibrary.java,v 1.10 2008/07/13 19:01:36 rlubke Exp $
+ */
+public abstract class AbstractTagLibrary implements TagLibrary
+{
+
+    private static class ValidatorConfigWrapper implements ValidatorConfig
+    {
+
+        private final TagConfig parent;
+        private final String validatorId;
+
+        public ValidatorConfigWrapper(TagConfig parent, String validatorId)
+        {
+            this.parent = parent;
+            this.validatorId = validatorId;
+        }
+
+        public String getValidatorId()
+        {
+            return this.validatorId;
+        }
+
+        public FaceletHandler getNextHandler()
+        {
+            return this.parent.getNextHandler();
+        }
+
+        public Tag getTag()
+        {
+            return this.parent.getTag();
+        }
+
+        public String getTagId()
+        {
+            return this.parent.getTagId();
+        }
+    }
+
+    private static class ConverterConfigWrapper implements ConverterConfig
+    {
+        private final TagConfig parent;
+        private final String converterId;
+
+        public ConverterConfigWrapper(TagConfig parent, String converterId)
+        {
+            this.parent = parent;
+            this.converterId = converterId;
+        }
+
+        public String getConverterId()
+        {
+            return this.converterId;
+        }
+
+        public FaceletHandler getNextHandler()
+        {
+            return this.parent.getNextHandler();
+        }
+
+        public Tag getTag()
+        {
+            return this.parent.getTag();
+        }
+
+        public String getTagId()
+        {
+            return this.parent.getTagId();
+        }
+    }
+
+    private static class HandlerFactory implements TagHandlerFactory
+    {
+        private final static Class[] CONSTRUCTOR_SIG = new Class[] { TagConfig.class };
+
+        protected final Class handlerType;
+
+        public HandlerFactory(Class handlerType)
+        {
+            this.handlerType = handlerType;
+        }
+
+        public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
+        {
+            try
+            {
+                return (TagHandler) this.handlerType.getConstructor(CONSTRUCTOR_SIG).newInstance(new Object[] { cfg });
+            }
+            catch (InvocationTargetException ite)
+            {
+                Throwable t = ite.getCause();
+                if (t instanceof FacesException)
+                {
+                    throw (FacesException) t;
+                }
+                else if (t instanceof ELException)
+                {
+                    throw (ELException) t;
+                }
+                else
+                {
+                    throw new FacesException("Error Instantiating: " + this.handlerType.getName(), t);
+                }
+            }
+            catch (Exception e)
+            {
+                throw new FacesException("Error Instantiating: " + this.handlerType.getName(), e);
+            }
+        }
+    }
+
+    private static class ComponentConfigWrapper implements ComponentConfig
+    {
+
+        protected final TagConfig parent;
+
+        protected final String componentType;
+
+        protected final String rendererType;
+
+        public ComponentConfigWrapper(TagConfig parent, String componentType, String rendererType)
+        {
+            this.parent = parent;
+            this.componentType = componentType;
+            this.rendererType = rendererType;
+        }
+
+        public String getComponentType()
+        {
+            return this.componentType;
+        }
+
+        public String getRendererType()
+        {
+            return this.rendererType;
+        }
+
+        public FaceletHandler getNextHandler()
+        {
+            return this.parent.getNextHandler();
+        }
+
+        public Tag getTag()
+        {
+            return this.parent.getTag();
+        }
+
+        public String getTagId()
+        {
+            return this.parent.getTagId();
+        }
+    }
+
+    private static class UserTagFactory implements TagHandlerFactory
+    {
+        protected final URL location;
+
+        public UserTagFactory(URL location)
+        {
+            this.location = location;
+        }
+
+        public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
+        {
+            return new UserTagHandler(cfg, this.location);
+        }
+    }
+
+    private static class ComponentHandlerFactory implements TagHandlerFactory
+    {
+
+        protected final String componentType;
+
+        protected final String renderType;
+
+        /**
+         * @param handlerType
+         */
+        public ComponentHandlerFactory(String componentType, String renderType)
+        {
+            this.componentType = componentType;
+            this.renderType = renderType;
+        }
+
+        public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
+        {
+            ComponentConfig ccfg = new ComponentConfigWrapper(cfg, this.componentType, this.renderType);
+            return new ComponentHandler(ccfg);
+        }
+    }
+
+    private static class UserComponentHandlerFactory implements TagHandlerFactory
+    {
+
+        private final static Class[] CONS_SIG = new Class[] { ComponentConfig.class };
+
+        protected final String componentType;
+
+        protected final String renderType;
+
+        protected final Class type;
+
+        protected final Constructor constructor;
+
+        /**
+         * @param handlerType
+         */
+        public UserComponentHandlerFactory(String componentType, String renderType, Class type)
+        {
+            this.componentType = componentType;
+            this.renderType = renderType;
+            this.type = type;
+            try
+            {
+                this.constructor = this.type.getConstructor(CONS_SIG);
+            }
+            catch (Exception e)
+            {
+                throw new FaceletException("Must have a Constructor that takes in a ComponentConfig", e);
+            }
+        }
+
+        public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
+        {
+            try
+            {
+                ComponentConfig ccfg = new ComponentConfigWrapper(cfg, this.componentType, this.renderType);
+                return (TagHandler) this.constructor.newInstance(new Object[] { ccfg });
+            }
+            catch (InvocationTargetException e)
+            {
+                throw new FaceletException(e.getCause().getMessage(), e.getCause().getCause());
+            }
+            catch (Exception e)
+            {
+                throw new FaceletException("Error Instantiating ComponentHandler: " + this.type.getName(), e);
+            }
+        }
+    }
+
+    private static class ValidatorHandlerFactory implements TagHandlerFactory
+    {
+
+        protected final String validatorId;
+
+        public ValidatorHandlerFactory(String validatorId)
+        {
+            this.validatorId = validatorId;
+        }
+
+        public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
+        {
+            return new ValidateHandler(new ValidatorConfigWrapper(cfg, this.validatorId));
+        }
+    }
+
+    private static class ConverterHandlerFactory implements TagHandlerFactory
+    {
+
+        protected final String converterId;
+
+        public ConverterHandlerFactory(String converterId)
+        {
+            this.converterId = converterId;
+        }
+
+        public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
+        {
+            return new ConvertHandler(new ConverterConfigWrapper(cfg, this.converterId));
+        }
+    }
+
+    private static class UserConverterHandlerFactory implements TagHandlerFactory
+    {
+        private final static Class[] CONS_SIG = new Class[] { ConverterConfig.class };
+
+        protected final String converterId;
+
+        protected final Class type;
+
+        protected final Constructor constructor;
+
+        public UserConverterHandlerFactory(String converterId, Class type)
+        {
+            this.converterId = converterId;
+            this.type = type;
+            try
+            {
+                this.constructor = this.type.getConstructor(CONS_SIG);
+            }
+            catch (Exception e)
+            {
+                throw new FaceletException("Must have a Constructor that takes in a ConverterConfig", e);
+            }
+        }
+
+        public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
+        {
+            try
+            {
+                ConverterConfig ccfg = new ConverterConfigWrapper(cfg, this.converterId);
+                return (TagHandler) this.constructor.newInstance(new Object[] { ccfg });
+            }
+            catch (InvocationTargetException e)
+            {
+                throw new FaceletException(e.getCause().getMessage(), e.getCause().getCause());
+            }
+            catch (Exception e)
+            {
+                throw new FaceletException("Error Instantiating ConverterHandler: " + this.type.getName(), e);
+            }
+        }
+    }
+
+    private static class UserValidatorHandlerFactory implements TagHandlerFactory
+    {
+        private final static Class[] CONS_SIG = new Class[] { ValidatorConfig.class };
+
+        protected final String validatorId;
+
+        protected final Class type;
+
+        protected final Constructor constructor;
+
+        public UserValidatorHandlerFactory(String validatorId, Class type)
+        {
+            this.validatorId = validatorId;
+            this.type = type;
+            try
+            {
+                this.constructor = this.type.getConstructor(CONS_SIG);
+            }
+            catch (Exception e)
+            {
+                throw new FaceletException("Must have a Constructor that takes in a ConverterConfig", e);
+            }
+        }
+
+        public TagHandler createHandler(TagConfig cfg) throws FacesException, ELException
+        {
+            try
+            {
+                ValidatorConfig ccfg = new ValidatorConfigWrapper(cfg, this.validatorId);
+                return (TagHandler) this.constructor.newInstance(new Object[] { ccfg });
+            }
+            catch (InvocationTargetException e)
+            {
+                throw new FaceletException(e.getCause().getMessage(), e.getCause().getCause());
+            }
+            catch (Exception e)
+            {
+                throw new FaceletException("Error Instantiating ValidatorHandler: " + this.type.getName(), e);
+            }
+        }
+    }
+
+    private final Map factories;
+
+    private final String namespace;
+
+    private final Map functions;
+
+    public AbstractTagLibrary(String namespace)
+    {
+        this.namespace = namespace;
+        this.factories = new HashMap();
+        this.functions = new HashMap();
+    }
+
+    /**
+     * Add a ComponentHandler with the specified componentType and rendererType, aliased by the tag name.
+     * 
+     * @see ComponentHandler
+     * @see javax.faces.application.Application#createComponent(java.lang.String)
+     * @param name
+     *            name to use, "foo" would be <my:foo />
+     * @param componentType
+     *            componentType to use
+     * @param rendererType
+     *            rendererType to use
+     */
+    protected final void addComponent(String name, String componentType, String rendererType)
+    {
+        this.factories.put(name, new ComponentHandlerFactory(componentType, rendererType));
+    }
+
+    /**
+     * Add a ComponentHandler with the specified componentType and rendererType, aliased by the tag name. The Facelet
+     * will be compiled with the specified HandlerType (which must extend AbstractComponentHandler).
+     * 
+     * @see AbstractComponentHandler
+     * @param name
+     *            name to use, "foo" would be <my:foo />
+     * @param componentType
+     *            componentType to use
+     * @param rendererType
+     *            rendererType to use
+     * @param handlerType
+     *            a Class that extends AbstractComponentHandler
+     */
+    protected final void addComponent(String name, String componentType, String rendererType, Class handlerType)
+    {
+        this.factories.put(name, new UserComponentHandlerFactory(componentType, rendererType, handlerType));
+    }
+
+    /**
+     * Add a ConvertHandler for the specified converterId
+     * 
+     * @see ConvertHandler
+     * @see javax.faces.application.Application#createConverter(java.lang.String)
+     * @param name
+     *            name to use, "foo" would be <my:foo />
+     * @param converterId
+     *            id to pass to Application instance
+     */
+    protected final void addConverter(String name, String converterId)
+    {
+        this.factories.put(name, new ConverterHandlerFactory(converterId));
+    }
+
+    /**
+     * Add a ConvertHandler for the specified converterId of a TagHandler type
+     * 
+     * @see ConvertHandler
+     * @see ConverterConfig
+     * @see javax.faces.application.Application#createConverter(java.lang.String)
+     * @param name
+     *            name to use, "foo" would be <my:foo />
+     * @param converterId
+     *            id to pass to Application instance
+     * @param type
+     *            TagHandler type that takes in a ConverterConfig
+     */
+    protected final void addConverter(String name, String converterId, Class type)
+    {
+        this.factories.put(name, new UserConverterHandlerFactory(converterId, type));
+    }
+
+    /**
+     * Add a ValidateHandler for the specified validatorId
+     * 
+     * @see ValidateHandler
+     * @see javax.faces.application.Application#createValidator(java.lang.String)
+     * @param name
+     *            name to use, "foo" would be <my:foo />
+     * @param validatorId
+     *            id to pass to Application instance
+     */
+    protected final void addValidator(String name, String validatorId)
+    {
+        this.factories.put(name, new ValidatorHandlerFactory(validatorId));
+    }
+
+    /**
+     * Add a ValidateHandler for the specified validatorId
+     * 
+     * @see ValidateHandler
+     * @see ValidatorConfig
+     * @see javax.faces.application.Application#createValidator(java.lang.String)
+     * @param name
+     *            name to use, "foo" would be <my:foo />
+     * @param validatorId
+     *            id to pass to Application instance
+     * @param type
+     *            TagHandler type that takes in a ValidatorConfig
+     */
+    protected final void addValidator(String name, String validatorId, Class type)
+    {
+        this.factories.put(name, new UserValidatorHandlerFactory(validatorId, type));
+    }
+
+    /**
+     * Use the specified HandlerType in compiling Facelets. HandlerType must extend TagHandler.
+     * 
+     * @see TagHandler
+     * @param name
+     *            name to use, "foo" would be <my:foo />
+     * @param handlerType
+     *            must extend TagHandler
+     */
+    protected final void addTagHandler(String name, Class handlerType)
+    {
+        this.factories.put(name, new HandlerFactory(handlerType));
+    }
+
+    /**
+     * Add a UserTagHandler specified a the URL source.
+     * 
+     * @see UserTagHandler
+     * @param name
+     *            name to use, "foo" would be <my:foo />
+     * @param source
+     *            source where the Facelet (Tag) source is
+     */
+    protected final void addUserTag(String name, URL source)
+    {
+        this.factories.put(name, new UserTagFactory(source));
+    }
+
+    /**
+     * Add a Method to be used as a Function at Compilation.
+     * 
+     * @see javax.el.FunctionMapper
+     * 
+     * @param name
+     *            (suffix) of function name
+     * @param method
+     *            method instance
+     */
+    protected final void addFunction(String name, Method method)
+    {
+        this.functions.put(name, method);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.sun.facelets.tag.TagLibrary#containsNamespace(java.lang.String)
+     */
+    public boolean containsNamespace(String ns)
+    {
+        return this.namespace.equals(ns);
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.sun.facelets.tag.TagLibrary#containsTagHandler(java.lang.String, java.lang.String)
+     */
+    public boolean containsTagHandler(String ns, String localName)
+    {
+        if (this.namespace.equals(ns))
+        {
+            if (this.factories.containsKey(localName))
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.sun.facelets.tag.TagLibrary#createTagHandler(java.lang.String, java.lang.String,
+     * com.sun.facelets.tag.TagConfig)
+     */
+    public TagHandler createTagHandler(String ns, String localName, TagConfig tag) throws FacesException
+    {
+        if (this.namespace.equals(ns))
+        {
+            TagHandlerFactory f = (TagHandlerFactory) this.factories.get(localName);
+            if (f != null)
+            {
+                return f.createHandler(tag);
+            }
+        }
+        return null;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.sun.facelets.tag.TagLibrary#containsFunction(java.lang.String, java.lang.String)
+     */
+    public boolean containsFunction(String ns, String name)
+    {
+        if (this.namespace.equals(ns))
+        {
+            return this.functions.containsKey(name);
+        }
+        return false;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.sun.facelets.tag.TagLibrary#createFunction(java.lang.String, java.lang.String)
+     */
+    public Method createFunction(String ns, String name)
+    {
+        if (this.namespace.equals(ns))
+        {
+            return (Method) this.functions.get(name);
+        }
+        return null;
+    }
+
+    public String getNamespace()
+    {
+        return namespace;
+    }
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/BeanPropertyTagRule.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/BeanPropertyTagRule.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/BeanPropertyTagRule.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/BeanPropertyTagRule.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,123 @@
+/**
+ * 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 com.sun.facelets.tag;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import javax.faces.webapp.pdl.facelets.FaceletContext;
+
+/**
+ * 
+ * @author Jacob Hookom
+ * @version $Id: BeanPropertyTagRule.java,v 1.3 2008/07/13 19:01:35 rlubke Exp $
+ */
+final class BeanPropertyTagRule extends MetaRule
+{
+
+    final static class LiteralPropertyMetadata extends Metadata
+    {
+
+        private final Method method;
+
+        private final TagAttribute attribute;
+
+        private Object[] value;
+
+        public LiteralPropertyMetadata(Method method, TagAttribute attribute)
+        {
+            this.method = method;
+            this.attribute = attribute;
+        }
+
+        public void applyMetadata(FaceletContext ctx, Object instance)
+        {
+            if (value == null)
+            {
+                String str = this.attribute.getValue();
+                value = new Object[] { ctx.getExpressionFactory().coerceToType(str, method.getParameterTypes()[0]) };
+            }
+            try
+            {
+                method.invoke(instance, this.value);
+            }
+            catch (InvocationTargetException e)
+            {
+                throw new TagAttributeException(this.attribute, e.getCause());
+            }
+            catch (Exception e)
+            {
+                throw new TagAttributeException(this.attribute, e);
+            }
+        }
+
+    }
+
+    final static class DynamicPropertyMetadata extends Metadata
+    {
+
+        private final Method method;
+
+        private final TagAttribute attribute;
+
+        private final Class type;
+
+        public DynamicPropertyMetadata(Method method, TagAttribute attribute)
+        {
+            this.method = method;
+            this.type = method.getParameterTypes()[0];
+            this.attribute = attribute;
+        }
+
+        public void applyMetadata(FaceletContext ctx, Object instance)
+        {
+            try
+            {
+                this.method.invoke(instance, new Object[] { this.attribute.getObject(ctx, this.type) });
+            }
+            catch (InvocationTargetException e)
+            {
+                throw new TagAttributeException(this.attribute, e.getCause());
+            }
+            catch (Exception e)
+            {
+                throw new TagAttributeException(this.attribute, e);
+            }
+        }
+    }
+
+    public final static BeanPropertyTagRule Instance = new BeanPropertyTagRule();
+
+    public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta)
+    {
+        Method m = meta.getWriteMethod(name);
+
+        // if the property is writable
+        if (m != null)
+        {
+            if (attribute.isLiteral())
+            {
+                return new LiteralPropertyMetadata(m, attribute);
+            }
+            else
+            {
+                return new DynamicPropertyMetadata(m, attribute);
+            }
+        }
+
+        return null;
+    }
+
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/CompositeFaceletHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/CompositeFaceletHandler.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/CompositeFaceletHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/CompositeFaceletHandler.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 com.sun.facelets.tag;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+
+import javax.faces.webapp.pdl.facelets.FaceletContext;
+import javax.faces.webapp.pdl.facelets.FaceletException;
+import javax.faces.webapp.pdl.facelets.FaceletHandler;
+
+/**
+ * A FaceletHandler that is derived of 1 or more, inner FaceletHandlers. This class would be found if the next
+ * FaceletHandler is structually, a body with multiple child elements as defined in XML.
+ * 
+ * @author Jacob Hookom
+ * @version $Id: CompositeFaceletHandler.java,v 1.5 2008/07/13 19:01:36 rlubke Exp $
+ */
+public final class CompositeFaceletHandler implements FaceletHandler
+{
+
+    private final FaceletHandler[] children;
+    private final int len;
+
+    public CompositeFaceletHandler(FaceletHandler[] children)
+    {
+        this.children = children;
+        this.len = children.length;
+    }
+
+    public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException,
+            ELException
+    {
+        for (int i = 0; i < len; i++)
+        {
+            this.children[i].apply(ctx, parent);
+        }
+    }
+
+    public FaceletHandler[] getHandlers()
+    {
+        return this.children;
+    }
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/CompositeTagDecorator.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/CompositeTagDecorator.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/CompositeTagDecorator.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/CompositeTagDecorator.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,57 @@
+/**
+ * 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 com.sun.facelets.tag;
+
+import com.sun.facelets.util.ParameterCheck;
+
+/**
+ * A TagDecorator that is composed of 1 or more TagDecorator instances. It uses the chain of responsibility pattern to
+ * stop processing if any of the TagDecorators return a value other than null.
+ * 
+ * @author Jacob Hookom
+ * @version $Id: CompositeTagDecorator.java,v 1.5 2008/07/13 19:01:35 rlubke Exp $
+ */
+public final class CompositeTagDecorator implements TagDecorator
+{
+
+    private final TagDecorator[] decorators;
+
+    public CompositeTagDecorator(TagDecorator[] decorators)
+    {
+        ParameterCheck.notNull("decorators", decorators);
+        this.decorators = decorators;
+    }
+
+    /**
+     * Uses the chain of responsibility pattern to stop processing if any of the TagDecorators return a value other than
+     * null.
+     * 
+     * @see com.sun.facelets.tag.TagDecorator#decorate(com.sun.facelets.tag.Tag)
+     */
+    public Tag decorate(Tag tag)
+    {
+        Tag t = null;
+        for (int i = 0; i < this.decorators.length; i++)
+        {
+            t = this.decorators[i].decorate(tag);
+            if (t != null)
+            {
+                return t;
+            }
+        }
+        return tag;
+    }
+
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/CompositeTagLibrary.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/CompositeTagLibrary.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/CompositeTagLibrary.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/CompositeTagLibrary.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,126 @@
+/**
+ * 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 com.sun.facelets.tag;
+
+import java.lang.reflect.Method;
+
+import javax.faces.FacesException;
+
+import com.sun.facelets.util.ParameterCheck;
+
+/**
+ * A TagLibrary that is composed of 1 or more TagLibrary children. Uses the chain of responsibility pattern to stop
+ * searching as soon as one of the children handles the requested method.
+ * 
+ * @author Jacob Hookom
+ * @version $Id: CompositeTagLibrary.java,v 1.4 2008/07/13 19:01:36 rlubke Exp $
+ */
+public final class CompositeTagLibrary implements TagLibrary
+{
+
+    private final TagLibrary[] libraries;
+
+    public CompositeTagLibrary(TagLibrary[] libraries)
+    {
+        ParameterCheck.notNull("libraries", libraries);
+        this.libraries = libraries;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.sun.facelets.tag.TagLibrary#containsNamespace(java.lang.String)
+     */
+    public boolean containsNamespace(String ns)
+    {
+        for (int i = 0; i < this.libraries.length; i++)
+        {
+            if (this.libraries[i].containsNamespace(ns))
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.sun.facelets.tag.TagLibrary#containsTagHandler(java.lang.String, java.lang.String)
+     */
+    public boolean containsTagHandler(String ns, String localName)
+    {
+        for (int i = 0; i < this.libraries.length; i++)
+        {
+            if (this.libraries[i].containsTagHandler(ns, localName))
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.sun.facelets.tag.TagLibrary#createTagHandler(java.lang.String, java.lang.String,
+     * com.sun.facelets.tag.TagConfig)
+     */
+    public TagHandler createTagHandler(String ns, String localName, TagConfig tag) throws FacesException
+    {
+        for (int i = 0; i < this.libraries.length; i++)
+        {
+            if (this.libraries[i].containsTagHandler(ns, localName))
+            {
+                return this.libraries[i].createTagHandler(ns, localName, tag);
+            }
+        }
+        return null;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.sun.facelets.tag.TagLibrary#containsFunction(java.lang.String, java.lang.String)
+     */
+    public boolean containsFunction(String ns, String name)
+    {
+        for (int i = 0; i < this.libraries.length; i++)
+        {
+            if (this.libraries[i].containsFunction(ns, name))
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.sun.facelets.tag.TagLibrary#createFunction(java.lang.String, java.lang.String)
+     */
+    public Method createFunction(String ns, String name)
+    {
+        for (int i = 0; i < this.libraries.length; i++)
+        {
+            if (this.libraries[i].containsFunction(ns, name))
+            {
+                return this.libraries[i].createFunction(ns, name);
+            }
+        }
+        return null;
+    }
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/Location.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/Location.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/Location.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/Location.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,80 @@
+/**
+ * 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 com.sun.facelets.tag;
+
+/**
+ * An object that represents the Location of a Tag or TagAttribute in a Facelet file.
+ * 
+ * @see com.sun.facelets.tag.Tag
+ * @see com.sun.facelets.tag.TagAttribute
+ * @author Jacob Hookom
+ * @version $Id: Location.java,v 1.4 2008/07/13 19:01:35 rlubke Exp $
+ */
+public final class Location
+{
+
+    private final String path;
+
+    private final int line;
+
+    private final int column;
+
+    public Location(String path, int line, int column)
+    {
+        this.path = path;
+        this.line = line;
+        this.column = column;
+    }
+
+    /**
+     * Estimated character column
+     * 
+     * @return character column
+     */
+    public int getColumn()
+    {
+        return column;
+    }
+
+    /**
+     * Line this is located at
+     * 
+     * @return link this is located at
+     */
+    public int getLine()
+    {
+        return line;
+    }
+
+    /**
+     * File path to this location
+     * 
+     * @return file path
+     */
+    public String getPath()
+    {
+        return path;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see java.lang.Object#toString()
+     */
+    public String toString()
+    {
+        return path + " @" + this.line + "," + this.column;
+    }
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetaRule.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetaRule.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetaRule.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetaRule.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,36 @@
+/**
+ * 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 com.sun.facelets.tag;
+
+/**
+ * A potential rule for Metadata on the passed MetadataTarget
+ * 
+ * @see com.sun.facelets.tag.Metadata
+ * @see com.sun.facelets.tag.MetadataTarget
+ * @author Jacob Hookom
+ * @version $Id: MetaRule.java,v 1.3 2008/07/13 19:01:36 rlubke Exp $
+ */
+public abstract class MetaRule
+{
+
+    /**
+     * @param name
+     * @param attribute
+     * @param meta
+     * @return
+     */
+    public abstract Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta);
+
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetaRuleset.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetaRuleset.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetaRuleset.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetaRuleset.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,60 @@
+/**
+ * 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 com.sun.facelets.tag;
+
+/**
+ * A mutable set of rules to be used in auto-wiring state to a particular object instance. Rules assigned to this object
+ * will be composed into a single Metadata instance.
+ * 
+ * @author Jacob Hookom
+ * @version $Id: MetaRuleset.java,v 1.3 2008/07/13 19:01:35 rlubke Exp $
+ */
+public abstract class MetaRuleset
+{
+    /**
+     * @param attribute
+     * @return
+     */
+    public abstract MetaRuleset ignore(String attribute);
+
+    /**
+     * @return
+     */
+    public abstract MetaRuleset ignoreAll();
+
+    /**
+     * @param attribute
+     * @param property
+     * @return
+     */
+    public abstract MetaRuleset alias(String attribute, String property);
+
+    /**
+     * @param mapper
+     * @return
+     */
+    public abstract MetaRuleset add(Metadata mapper);
+
+    /**
+     * @param rule
+     * @return
+     */
+    public abstract MetaRuleset addRule(MetaRule rule);
+
+    /**
+     * @return
+     */
+    public abstract Metadata finish();
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetaRulesetImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetaRulesetImpl.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetaRulesetImpl.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetaRulesetImpl.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,198 @@
+/**
+ * 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 com.sun.facelets.tag;
+
+import java.beans.IntrospectionException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.WeakHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.faces.webapp.pdl.facelets.FaceletContext;
+import com.sun.facelets.util.ParameterCheck;
+
+/**
+ * 
+ * @author Jacob Hookom
+ * @version $Id: MetaRulesetImpl.java,v 1.3 2008/07/13 19:01:35 rlubke Exp $
+ */
+final class MetaRulesetImpl extends MetaRuleset
+{
+
+    private final static WeakHashMap metadata = new WeakHashMap();
+
+    private final static Logger log = Logger.getLogger("facelets.tag.meta");
+
+    private final Tag tag;
+
+    private final Class type;
+
+    private final Map attributes;
+
+    private final List mappers;
+
+    private final List rules;
+
+    public MetaRulesetImpl(Tag tag, Class type)
+    {
+        this.tag = tag;
+        this.type = type;
+        this.attributes = new HashMap();
+        this.mappers = new ArrayList();
+        this.rules = new ArrayList();
+
+        // setup attributes
+        TagAttribute[] attrs = this.tag.getAttributes().getAll();
+        for (int i = 0; i < attrs.length; i++)
+        {
+            attributes.put(attrs[i].getLocalName(), attrs[i]);
+        }
+
+        // add default rules
+        this.rules.add(BeanPropertyTagRule.Instance);
+    }
+
+    public MetaRuleset ignore(String attribute)
+    {
+        ParameterCheck.notNull("attribute", attribute);
+        this.attributes.remove(attribute);
+        return this;
+    }
+
+    public MetaRuleset alias(String attribute, String property)
+    {
+        ParameterCheck.notNull("attribute", attribute);
+        ParameterCheck.notNull("property", property);
+        TagAttribute attr = (TagAttribute) this.attributes.remove(attribute);
+        if (attr != null)
+        {
+            this.attributes.put(property, attr);
+        }
+        return this;
+    }
+
+    public MetaRuleset add(Metadata mapper)
+    {
+        ParameterCheck.notNull("mapper", mapper);
+        if (!this.mappers.contains(mapper))
+        {
+            this.mappers.add(mapper);
+        }
+        return this;
+    }
+
+    public MetaRuleset addRule(MetaRule rule)
+    {
+        ParameterCheck.notNull("rule", rule);
+        this.rules.add(rule);
+        return this;
+    }
+
+    private final MetadataTarget getMetadataTarget()
+    {
+        String key = this.type.getName();
+        MetadataTarget meta = (MetadataTarget) metadata.get(key);
+        if (meta == null)
+        {
+            try
+            {
+                meta = new MetadataTargetImpl(type);
+            }
+            catch (IntrospectionException e)
+            {
+                throw new TagException(this.tag, "Error Creating TargetMetadata", e);
+            }
+            metadata.put(key, meta);
+        }
+        return meta;
+    }
+
+    public Metadata finish()
+    {
+        if (!this.attributes.isEmpty())
+        {
+            if (this.rules.isEmpty())
+            {
+                if (log.isLoggable(Level.SEVERE))
+                {
+                    for (Iterator itr = this.attributes.values().iterator(); itr.hasNext();)
+                    {
+                        log.severe(itr.next() + " Unhandled by MetaTagHandler for type " + this.type.getName());
+                    }
+                }
+            }
+            else
+            {
+                MetadataTarget target = this.getMetadataTarget();
+                // now iterate over attributes
+                Map.Entry entry;
+                MetaRule rule;
+                Metadata data;
+                int ruleEnd = this.rules.size() - 1;
+                for (Iterator itr = this.attributes.entrySet().iterator(); itr.hasNext();)
+                {
+                    entry = (Map.Entry) itr.next();
+                    data = null;
+                    int i = ruleEnd;
+                    while (data == null && i >= 0)
+                    {
+                        rule = (MetaRule) this.rules.get(i);
+                        data = rule.applyRule((String) entry.getKey(), (TagAttribute) entry.getValue(), target);
+                        i--;
+                    }
+                    if (data == null)
+                    {
+                        if (log.isLoggable(Level.SEVERE))
+                        {
+                            log.severe(entry.getValue() + " Unhandled by MetaTagHandler for type "
+                                    + this.type.getName());
+                        }
+                    }
+                    else
+                    {
+                        this.mappers.add(data);
+                    }
+                }
+            }
+        }
+
+        if (this.mappers.isEmpty())
+        {
+            return NONE;
+        }
+        else
+        {
+            return new MetadataImpl((Metadata[]) this.mappers.toArray(new Metadata[this.mappers.size()]));
+        }
+    }
+
+    public MetaRuleset ignoreAll()
+    {
+        this.attributes.clear();
+        return this;
+    }
+
+    private final static Metadata NONE = new Metadata()
+    {
+        public void applyMetadata(FaceletContext ctx, Object instance)
+        {
+            // do nothing
+        }
+    };
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetaTagHandler.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetaTagHandler.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetaTagHandler.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetaTagHandler.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,70 @@
+/**
+ * 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 com.sun.facelets.tag;
+
+import javax.faces.webapp.pdl.facelets.FaceletContext;
+import com.sun.facelets.util.ParameterCheck;
+
+/**
+ * A base tag for wiring state to an object instance based on rules populated at the time of creating a MetaRuleset.
+ * 
+ * @author Jacob Hookom
+ * @version $Id: MetaTagHandler.java,v 1.3 2008/07/13 19:01:35 rlubke Exp $
+ */
+public abstract class MetaTagHandler extends TagHandler
+{
+
+    private Class lastType = Object.class;
+
+    private Metadata mapper;
+
+    public MetaTagHandler(TagConfig config)
+    {
+        super(config);
+    }
+
+    /**
+     * Extend this method in order to add your own rules.
+     * 
+     * @param type
+     * @return
+     */
+    protected MetaRuleset createMetaRuleset(Class type)
+    {
+        ParameterCheck.notNull("type", type);
+        return new MetaRulesetImpl(this.tag, type);
+    }
+
+    /**
+     * Invoking/extending this method will cause the results of the created MetaRuleset to auto-wire state to the passed
+     * instance.
+     * 
+     * @param ctx
+     * @param instance
+     */
+    protected void setAttributes(FaceletContext ctx, Object instance)
+    {
+        if (instance != null)
+        {
+            Class type = instance.getClass();
+            if (mapper == null || !this.lastType.equals(type))
+            {
+                this.lastType = type;
+                this.mapper = this.createMetaRuleset(type).finish();
+            }
+            this.mapper.applyMetadata(ctx, instance);
+        }
+    }
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/Metadata.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/Metadata.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/Metadata.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/Metadata.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,34 @@
+/**
+ * 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 com.sun.facelets.tag;
+
+import javax.faces.webapp.pdl.facelets.FaceletContext;
+
+/**
+ * External information on how to wire dynamic or literal state to the passed Object instance.
+ * 
+ * @author Jacob Hookom
+ * @version $Id: Metadata.java,v 1.3 2008/07/13 19:01:35 rlubke Exp $
+ */
+public abstract class Metadata
+{
+
+    /**
+     * @param ctx
+     * @param instance
+     */
+    public abstract void applyMetadata(FaceletContext ctx, Object instance);
+
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetadataImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetadataImpl.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetadataImpl.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetadataImpl.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,44 @@
+/**
+ * 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 com.sun.facelets.tag;
+
+import javax.faces.webapp.pdl.facelets.FaceletContext;
+
+/**
+ * 
+ * @author Jacob Hookom
+ * @version $Id: MetadataImpl.java,v 1.3 2008/07/13 19:01:36 rlubke Exp $
+ */
+final class MetadataImpl extends Metadata
+{
+
+    private final Metadata[] mappers;
+    private final int size;
+
+    public MetadataImpl(Metadata[] mappers)
+    {
+        this.mappers = mappers;
+        this.size = mappers.length;
+    }
+
+    public void applyMetadata(FaceletContext ctx, Object instance)
+    {
+        for (int i = 0; i < size; i++)
+        {
+            this.mappers[i].applyMetadata(ctx, instance);
+        }
+    }
+
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetadataTarget.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetadataTarget.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetadataTarget.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetadataTarget.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,66 @@
+/**
+ * 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 com.sun.facelets.tag;
+
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+
+/**
+ * Information used with MetaRule for determining how and what Metadata should be wired.
+ * 
+ * @see com.sun.facelets.tag.MetaRule
+ * @see com.sun.facelets.tag.Metadata
+ * @author Jacob Hookom
+ * @version $Id: MetadataTarget.java,v 1.3 2008/07/13 19:01:36 rlubke Exp $
+ */
+public abstract class MetadataTarget
+{
+
+    /**
+     * @param name
+     * @return
+     */
+    public abstract PropertyDescriptor getProperty(String name);
+
+    /**
+     * @param type
+     * @return
+     */
+    public abstract boolean isTargetInstanceOf(Class type);
+
+    /**
+     * @return
+     */
+    public abstract Class getTargetClass();
+
+    /**
+     * @param name
+     * @return
+     */
+    public abstract Class getPropertyType(String name);
+
+    /**
+     * @param name
+     * @return
+     */
+    public abstract Method getWriteMethod(String name);
+
+    /**
+     * @param name
+     * @return
+     */
+    public abstract Method getReadMethod(String name);
+
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetadataTargetImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetadataTargetImpl.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetadataTargetImpl.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MetadataTargetImpl.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,93 @@
+/**
+ * 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 com.sun.facelets.tag;
+
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 
+ * @author Jacob Hookom
+ * @version $Id: MetadataTargetImpl.java,v 1.3 2008/07/13 19:01:35 rlubke Exp $
+ */
+final class MetadataTargetImpl extends MetadataTarget
+{
+
+    private final Map pd;
+    private final Class type;
+
+    public MetadataTargetImpl(Class type) throws IntrospectionException
+    {
+        this.type = type;
+        this.pd = new HashMap();
+        BeanInfo info = Introspector.getBeanInfo(type);
+        PropertyDescriptor[] pda = info.getPropertyDescriptors();
+        for (int i = 0; i < pda.length; i++)
+        {
+            this.pd.put(pda[i].getName(), pda[i]);
+        }
+    }
+
+    public PropertyDescriptor getProperty(String name)
+    {
+        return (PropertyDescriptor) this.pd.get(name);
+    }
+
+    public boolean isTargetInstanceOf(Class type)
+    {
+        return type.isAssignableFrom(this.type);
+    }
+
+    public Class getTargetClass()
+    {
+        return this.type;
+    }
+
+    public Class getPropertyType(String name)
+    {
+        PropertyDescriptor pd = this.getProperty(name);
+        if (pd != null)
+        {
+            return pd.getPropertyType();
+        }
+        return null;
+    }
+
+    public Method getWriteMethod(String name)
+    {
+        PropertyDescriptor pd = this.getProperty(name);
+        if (pd != null)
+        {
+            return pd.getWriteMethod();
+        }
+        return null;
+    }
+
+    public Method getReadMethod(String name)
+    {
+        PropertyDescriptor pd = this.getProperty(name);
+        if (pd != null)
+        {
+            return pd.getReadMethod();
+        }
+        return null;
+    }
+
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MethodRule.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MethodRule.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MethodRule.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/MethodRule.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,145 @@
+/**
+ * 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 com.sun.facelets.tag;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import javax.el.MethodExpression;
+import javax.faces.el.MethodBinding;
+
+import javax.faces.webapp.pdl.facelets.FaceletContext;
+import com.sun.facelets.el.LegacyMethodBinding;
+
+/**
+ * Optional Rule for binding Method[Binding|Expression] properties
+ * 
+ * @author Mike Kienenberger
+ * @author Jacob Hookom
+ */
+public final class MethodRule extends MetaRule
+{
+
+    private final String methodName;
+
+    private final Class returnTypeClass;
+
+    private final Class[] params;
+
+    public MethodRule(String methodName, Class returnTypeClass, Class[] params)
+    {
+        this.methodName = methodName;
+        this.returnTypeClass = returnTypeClass;
+        this.params = params;
+    }
+
+    public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta)
+    {
+        if (false == name.equals(this.methodName))
+            return null;
+
+        if (MethodBinding.class.equals(meta.getPropertyType(name)))
+        {
+            Method method = meta.getWriteMethod(name);
+            if (method != null)
+            {
+                return new MethodBindingMetadata(method, attribute, this.returnTypeClass, this.params);
+            }
+        }
+        else if (MethodExpression.class.equals(meta.getPropertyType(name)))
+        {
+            Method method = meta.getWriteMethod(name);
+            if (method != null)
+            {
+                return new MethodExpressionMetadata(method, attribute, this.returnTypeClass, this.params);
+            }
+        }
+
+        return null;
+    }
+
+    private class MethodBindingMetadata extends Metadata
+    {
+        private final Method _method;
+
+        private final TagAttribute _attribute;
+
+        private Class[] _paramList;
+
+        private Class _returnType;
+
+        public MethodBindingMetadata(Method method, TagAttribute attribute, Class returnType, Class[] paramList)
+        {
+            _method = method;
+            _attribute = attribute;
+            _paramList = paramList;
+            _returnType = returnType;
+        }
+
+        public void applyMetadata(FaceletContext ctx, Object instance)
+        {
+            MethodExpression expr = _attribute.getMethodExpression(ctx, _returnType, _paramList);
+
+            try
+            {
+                _method.invoke(instance, new Object[] { new LegacyMethodBinding(expr) });
+            }
+            catch (InvocationTargetException e)
+            {
+                throw new TagAttributeException(_attribute, e.getCause());
+            }
+            catch (Exception e)
+            {
+                throw new TagAttributeException(_attribute, e);
+            }
+        }
+    }
+
+    private class MethodExpressionMetadata extends Metadata
+    {
+        private final Method _method;
+
+        private final TagAttribute _attribute;
+
+        private Class[] _paramList;
+
+        private Class _returnType;
+
+        public MethodExpressionMetadata(Method method, TagAttribute attribute, Class returnType, Class[] paramList)
+        {
+            _method = method;
+            _attribute = attribute;
+            _paramList = paramList;
+            _returnType = returnType;
+        }
+
+        public void applyMetadata(FaceletContext ctx, Object instance)
+        {
+            MethodExpression expr = _attribute.getMethodExpression(ctx, _returnType, _paramList);
+
+            try
+            {
+                _method.invoke(instance, new Object[] { expr });
+            }
+            catch (InvocationTargetException e)
+            {
+                throw new TagAttributeException(_attribute, e.getCause());
+            }
+            catch (Exception e)
+            {
+                throw new TagAttributeException(_attribute, e);
+            }
+        }
+    }
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/Tag.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/Tag.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/Tag.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/Tag.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,108 @@
+/**
+ * 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 com.sun.facelets.tag;
+
+/**
+ * Representation of a Tag in the Facelet definition
+ * 
+ * @author Jacob Hookom
+ * @version $Id: Tag.java,v 1.5 2008/07/13 19:01:36 rlubke Exp $
+ */
+public final class Tag
+{
+    private final TagAttributes attributes;
+
+    private final Location location;
+
+    private final String namespace;
+
+    private final String localName;
+
+    private final String qName;
+
+    public Tag(Location location, String namespace, String localName, String qName, TagAttributes attributes)
+    {
+        this.location = location;
+        this.namespace = namespace;
+        this.localName = localName;
+        this.qName = qName;
+        this.attributes = attributes;
+    }
+
+    public Tag(Tag orig, TagAttributes attributes)
+    {
+        this(orig.getLocation(), orig.getNamespace(), orig.getLocalName(), orig.getQName(), attributes);
+    }
+
+    /**
+     * All TagAttributes specified
+     * 
+     * @return all TagAttributes specified
+     */
+    public TagAttributes getAttributes()
+    {
+        return attributes;
+    }
+
+    /**
+     * Local name of the tag &lt;my:tag /> would be "tag"
+     * 
+     * @return local name of the tag
+     */
+    public String getLocalName()
+    {
+        return localName;
+    }
+
+    /**
+     * Location of the Tag in the Facelet file
+     * 
+     * @return location of the Tag in the Facelet file
+     */
+    public Location getLocation()
+    {
+        return location;
+    }
+
+    /**
+     * The resolved Namespace for this tag
+     * 
+     * @return the resolved namespace for this tag
+     */
+    public String getNamespace()
+    {
+        return namespace;
+    }
+
+    /**
+     * Get the qualified name for this tag &lt;my:tag /> would be "my:tag"
+     * 
+     * @return qualified name of the tag
+     */
+    public String getQName()
+    {
+        return qName;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see java.lang.Object#toString()
+     */
+    public String toString()
+    {
+        return this.location + " <" + this.qName + ">";
+    }
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/TagAttribute.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/TagAttribute.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/TagAttribute.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/TagAttribute.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,316 @@
+/**
+ * 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 com.sun.facelets.tag;
+
+import javax.el.ELException;
+import javax.el.ExpressionFactory;
+import javax.el.MethodExpression;
+import javax.el.ValueExpression;
+
+import javax.faces.webapp.pdl.facelets.FaceletContext;
+import com.sun.facelets.el.ELText;
+import com.sun.facelets.el.TagMethodExpression;
+import com.sun.facelets.el.TagValueExpression;
+
+/**
+ * Representation of a Tag's attribute in a Facelet File
+ * 
+ * @author Jacob Hookom
+ * @version $Id: TagAttribute.java,v 1.9 2008/07/13 19:01:35 rlubke Exp $
+ */
+public final class TagAttribute
+{
+
+    private final boolean literal;
+
+    private final String localName;
+
+    private final Location location;
+
+    private final String namespace;
+
+    private final String qName;
+
+    private final String value;
+
+    private String string;
+
+    public TagAttribute(Location location, String ns, String localName, String qName, String value)
+    {
+        this.location = location;
+        this.namespace = ns;
+        this.localName = localName;
+        this.qName = qName;
+        this.value = value;
+        try
+        {
+            this.literal = ELText.isLiteral(this.value);
+        }
+        catch (ELException e)
+        {
+            throw new TagAttributeException(this, e);
+        }
+    }
+
+    /**
+     * If literal, return {@link Boolean#getBoolean(java.lang.String) Boolean.getBoolean(java.lang.String)} passing our
+     * value, otherwise call {@link #getObject(FaceletContext, Class) getObject(FaceletContext, Class)}.
+     * 
+     * @see Boolean#getBoolean(java.lang.String)
+     * @see #getObject(FaceletContext, Class)
+     * @param ctx
+     *            FaceletContext to use
+     * @return boolean value
+     */
+    public boolean getBoolean(FaceletContext ctx)
+    {
+        if (this.literal)
+        {
+            return Boolean.valueOf(this.value).booleanValue();
+        }
+        else
+        {
+            return ((Boolean) this.getObject(ctx, Boolean.class)).booleanValue();
+        }
+    }
+
+    /**
+     * If literal, call {@link Integer#parseInt(java.lang.String) Integer.parseInt(String)}, otherwise call
+     * {@link #getObject(FaceletContext, Class) getObject(FaceletContext, Class)}.
+     * 
+     * @see Integer#parseInt(java.lang.String)
+     * @see #getObject(FaceletContext, Class)
+     * @param ctx
+     *            FaceletContext to use
+     * @return int value
+     */
+    public int getInt(FaceletContext ctx)
+    {
+        if (this.literal)
+        {
+            return Integer.parseInt(this.value);
+        }
+        else
+        {
+            return ((Number) this.getObject(ctx, Integer.class)).intValue();
+        }
+    }
+
+    /**
+     * Local name of this attribute
+     * 
+     * @return local name of this attribute
+     */
+    public String getLocalName()
+    {
+        return this.localName;
+    }
+
+    /**
+     * The location of this attribute in the FaceletContext
+     * 
+     * @return the TagAttribute's location
+     */
+    public Location getLocation()
+    {
+        return this.location;
+    }
+
+    /**
+     * Create a MethodExpression, using this attribute's value as the expression String.
+     * 
+     * @see ExpressionFactory#createMethodExpression(javax.el.ELContext, java.lang.String, java.lang.Class,
+     *      java.lang.Class[])
+     * @see MethodExpression
+     * @param ctx
+     *            FaceletContext to use
+     * @param type
+     *            expected return type
+     * @param paramTypes
+     *            parameter type
+     * @return a MethodExpression instance
+     */
+    public MethodExpression getMethodExpression(FaceletContext ctx, Class type, Class[] paramTypes)
+    {
+        try
+        {
+            ExpressionFactory f = ctx.getExpressionFactory();
+            return new TagMethodExpression(this, f.createMethodExpression(ctx, this.value, type, paramTypes));
+        }
+        catch (Exception e)
+        {
+            throw new TagAttributeException(this, e);
+        }
+    }
+
+    /**
+     * The resolved Namespace for this attribute
+     * 
+     * @return resolved Namespace
+     */
+    public String getNamespace()
+    {
+        return this.namespace;
+    }
+
+    /**
+     * Delegates to getObject with Object.class as a param
+     * 
+     * @see #getObject(FaceletContext, Class)
+     * @param ctx
+     *            FaceletContext to use
+     * @return Object representation of this attribute's value
+     */
+    public Object getObject(FaceletContext ctx)
+    {
+        return this.getObject(ctx, Object.class);
+    }
+
+    /**
+     * The qualified name for this attribute
+     * 
+     * @return the qualified name for this attribute
+     */
+    public String getQName()
+    {
+        return this.qName;
+    }
+
+    /**
+     * Return the literal value of this attribute
+     * 
+     * @return literal value
+     */
+    public String getValue()
+    {
+        return this.value;
+    }
+
+    /**
+     * If literal, then return our value, otherwise delegate to getObject, passing String.class.
+     * 
+     * @see #getObject(FaceletContext, Class)
+     * @param ctx
+     *            FaceletContext to use
+     * @return String value of this attribute
+     */
+    public String getValue(FaceletContext ctx)
+    {
+        if (this.literal)
+        {
+            return this.value;
+        }
+        else
+        {
+            return (String) this.getObject(ctx, String.class);
+        }
+    }
+
+    /**
+     * If literal, simply coerce our String literal value using an ExpressionFactory, otherwise create a ValueExpression
+     * and evaluate it.
+     * 
+     * @see ExpressionFactory#coerceToType(java.lang.Object, java.lang.Class)
+     * @see ExpressionFactory#createValueExpression(javax.el.ELContext, java.lang.String, java.lang.Class)
+     * @see ValueExpression
+     * @param ctx
+     *            FaceletContext to use
+     * @param type
+     *            expected return type
+     * @return Object value of this attribute
+     */
+    public Object getObject(FaceletContext ctx, Class type)
+    {
+        if (this.literal)
+        {
+            if (String.class.equals(type))
+            {
+                return this.value;
+            }
+            else
+            {
+                try
+                {
+                    return ctx.getExpressionFactory().coerceToType(this.value, type);
+                }
+                catch (Exception e)
+                {
+                    throw new TagAttributeException(this, e);
+                }
+            }
+        }
+        else
+        {
+            ValueExpression ve = this.getValueExpression(ctx, type);
+            try
+            {
+                return ve.getValue(ctx);
+            }
+            catch (Exception e)
+            {
+                throw new TagAttributeException(this, e);
+            }
+        }
+    }
+
+    /**
+     * Create a ValueExpression, using this attribute's literal value and the passed expected type.
+     * 
+     * @see ExpressionFactory#createValueExpression(javax.el.ELContext, java.lang.String, java.lang.Class)
+     * @see ValueExpression
+     * @param ctx
+     *            FaceletContext to use
+     * @param type
+     *            expected return type
+     * @return ValueExpression instance
+     */
+    public ValueExpression getValueExpression(FaceletContext ctx, Class type)
+    {
+        try
+        {
+            ExpressionFactory f = ctx.getExpressionFactory();
+            return new TagValueExpression(this, f.createValueExpression(ctx, this.value, type));
+        }
+        catch (Exception e)
+        {
+            throw new TagAttributeException(this, e);
+        }
+    }
+
+    /**
+     * If this TagAttribute is literal (not #{..} or ${..})
+     * 
+     * @return true if this attribute is literal
+     */
+    public boolean isLiteral()
+    {
+        return this.literal;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see java.lang.Object#toString()
+     */
+    public String toString()
+    {
+        if (this.string == null)
+        {
+            this.string = this.location + " " + this.qName + "=\"" + this.value + "\"";
+        }
+        return this.string;
+    }
+
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/TagAttributeException.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/TagAttributeException.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/TagAttributeException.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/TagAttributeException.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,91 @@
+/**
+ * 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 com.sun.facelets.tag;
+
+import javax.faces.webapp.pdl.facelets.FaceletException;
+
+/**
+ * An Exception caused by a TagAttribute
+ * 
+ * @author Jacob Hookom
+ * @version $Id: TagAttributeException.java,v 1.4 2008/07/13 19:01:36 rlubke Exp $
+ */
+public final class TagAttributeException extends FaceletException
+{
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 1L;
+
+    public TagAttributeException(TagAttribute attr)
+    {
+        super(attr.toString());
+    }
+
+    public TagAttributeException(TagAttribute attr, String message)
+    {
+        super(attr + " " + message);
+    }
+
+    public TagAttributeException(TagAttribute attr, Throwable cause)
+    {
+        super(attr + " " + cause.getMessage(), cause);
+    }
+
+    public TagAttributeException(TagAttribute attr, String message, Throwable cause)
+    {
+        super(attr + " " + message, cause);
+    }
+
+    /**
+     * 
+     */
+    public TagAttributeException(Tag tag, TagAttribute attr)
+    {
+        super(print(tag, attr));
+    }
+
+    private final static String print(Tag tag, TagAttribute attr)
+    {
+        return tag.getLocation() + " <" + tag.getQName() + " " + attr.getQName() + "=\"" + attr.getValue() + "\">";
+    }
+
+    /**
+     * @param message
+     */
+    public TagAttributeException(Tag tag, TagAttribute attr, String message)
+    {
+        super(print(tag, attr) + " " + message);
+    }
+
+    /**
+     * @param cause
+     */
+    public TagAttributeException(Tag tag, TagAttribute attr, Throwable cause)
+    {
+        super(print(tag, attr) + " " + cause.getMessage(), cause);
+    }
+
+    /**
+     * @param message
+     * @param cause
+     */
+    public TagAttributeException(Tag tag, TagAttribute attr, String message, Throwable cause)
+    {
+        super(print(tag, attr) + " " + message, cause);
+    }
+
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/TagAttributes.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/TagAttributes.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/TagAttributes.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/TagAttributes.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,183 @@
+/**
+ * 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 com.sun.facelets.tag;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * A set of TagAttributes, usually representing all attributes on a Tag.
+ * 
+ * @see com.sun.facelets.tag.Tag
+ * @see com.sun.facelets.tag.TagAttribute
+ * @author Jacob Hookom
+ * @version $Id: TagAttributes.java,v 1.3 2008/07/13 19:01:35 rlubke Exp $
+ */
+public final class TagAttributes
+{
+    private final static TagAttribute[] EMPTY = new TagAttribute[0];
+
+    private final TagAttribute[] attrs;
+
+    private final String[] ns;
+
+    private final List nsattrs;
+
+    /**
+     * 
+     */
+    public TagAttributes(TagAttribute[] attrs)
+    {
+        this.attrs = attrs;
+
+        // grab namespaces
+        int i = 0;
+        Set set = new HashSet();
+        for (i = 0; i < this.attrs.length; i++)
+        {
+            set.add(this.attrs[i].getNamespace());
+        }
+        this.ns = (String[]) set.toArray(new String[set.size()]);
+        Arrays.sort(ns);
+
+        // assign attrs
+        this.nsattrs = new ArrayList();
+        for (i = 0; i < ns.length; i++)
+        {
+            nsattrs.add(i, new ArrayList());
+        }
+        int nsIdx = 0;
+        for (i = 0; i < this.attrs.length; i++)
+        {
+            nsIdx = Arrays.binarySearch(ns, this.attrs[i].getNamespace());
+            ((List) nsattrs.get(nsIdx)).add(this.attrs[i]);
+        }
+        for (i = 0; i < ns.length; i++)
+        {
+            List r = (List) nsattrs.get(i);
+            nsattrs.set(i, r.toArray(new TagAttribute[r.size()]));
+        }
+    }
+
+    /**
+     * Return an array of all TagAttributes in this set
+     * 
+     * @return a non-null array of TagAttributes
+     */
+    public TagAttribute[] getAll()
+    {
+        return this.attrs;
+    }
+
+    /**
+     * Using no namespace, find the TagAttribute
+     * 
+     * @see #get(String, String)
+     * @param localName
+     *            tag attribute name
+     * @return the TagAttribute found, otherwise null
+     */
+    public TagAttribute get(String localName)
+    {
+        return get("", localName);
+    }
+
+    /**
+     * Find a TagAttribute that matches the passed namespace and local name.
+     * 
+     * @param ns
+     *            namespace of the desired attribute
+     * @param localName
+     *            local name of the attribute
+     * @return a TagAttribute found, otherwise null
+     */
+    public TagAttribute get(String ns, String localName)
+    {
+        if (ns != null && localName != null)
+        {
+            int idx = Arrays.binarySearch(this.ns, ns);
+            if (idx >= 0)
+            {
+                TagAttribute[] uia = (TagAttribute[]) this.nsattrs.get(idx);
+                for (int i = 0; i < uia.length; i++)
+                {
+                    if (localName.equals(uia[i].getLocalName()))
+                    {
+                        return uia[i];
+                    }
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Get all TagAttributes for the passed namespace
+     * 
+     * @param namespace
+     *            namespace to search
+     * @return a non-null array of TagAttributes
+     */
+    public TagAttribute[] getAll(String namespace)
+    {
+        int idx = 0;
+        if (namespace == null)
+        {
+            idx = Arrays.binarySearch(this.ns, "");
+        }
+        else
+        {
+            idx = Arrays.binarySearch(this.ns, namespace);
+        }
+        if (idx >= 0)
+        {
+            return (TagAttribute[]) this.nsattrs.get(idx);
+        }
+        return EMPTY;
+    }
+
+    /**
+     * A list of Namespaces found in this set
+     * 
+     * @return a list of Namespaces found in this set
+     */
+    public String[] getNamespaces()
+    {
+        return this.ns;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see java.lang.Object#toString()
+     */
+    public String toString()
+    {
+        StringBuffer sb = new StringBuffer();
+        for (int i = 0; i < this.attrs.length; i++)
+        {
+            sb.append(this.attrs[i]);
+            sb.append(' ');
+        }
+        if (sb.length() > 1)
+        {
+            sb.setLength(sb.length() - 1);
+        }
+        return sb.toString();
+    }
+}

Added: myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/TagConfig.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/TagConfig.java?rev=740940&view=auto
==============================================================================
--- myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/TagConfig.java (added)
+++ myfaces/core/branches/2_0_0/impl/src/main/java/com/sun/facelets/tag/TagConfig.java Wed Feb  4 23:55:25 2009
@@ -0,0 +1,49 @@
+/**
+ * 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 com.sun.facelets.tag;
+
+import javax.faces.webapp.pdl.facelets.FaceletHandler;
+
+/**
+ * Passed to the constructor of TagHandler, it defines the document definition of the handler we are instantiating
+ * 
+ * @see com.sun.facelets.tag.TagHandler
+ * @author Jacob Hookom
+ * @version $Id: TagConfig.java,v 1.3 2008/07/13 19:01:35 rlubke Exp $
+ */
+public interface TagConfig
+{
+
+    /**
+     * A Tag representing this handler
+     * 
+     * @return a tag representing this handler
+     */
+    public Tag getTag();
+
+    /**
+     * The next FaceletHandler (child or children) to be applied
+     * 
+     * @return next FaceletHandler, never null
+     */
+    public FaceletHandler getNextHandler();
+
+    /**
+     * A document-unique id, follows the convention "_tagId##"
+     * 
+     * @return a document-unique id
+     */
+    public String getTagId();
+}



Mime
View raw message