001/**
002 *
003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved.
004 *
005 * This library is free software; you can redistribute it and/or
006 * modify it under the terms of the GNU Lesser General Public
007 * License as published by the Free Software Foundation; either 
008 * version 2.1 of the License, or (at your option) any later version.
009 * 
010 * This library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013 * Lesser General Public License for more details.
014 * 
015 * You should have received a copy of the GNU Lesser General Public 
016 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
017 * 
018 **/
019package lucee.runtime.ext.tag;
020
021import java.util.ArrayList;
022import java.util.List;
023
024public class TagMetaDataImpl implements TagMetaData {
025
026        private int attrMin;
027        private int attrMax;
028        private int attrType;
029        private List attrs=new ArrayList();
030        private int bodyContent;
031        private String description;
032        private boolean isBodyRE;
033        private boolean handleException;
034        private boolean hasAppendix;
035        private boolean hasBody;
036        
037
038
039        /**
040         * Constructor of the class
041         * @param attrType TagMetaData.ATTRIBUTE_TYPE_FIX,TagMetaData.ATTRIBUTE_TYPE_DYNAMIC,TagMetaData.ATTRIBUTE_TYPE_MIXED
042         * @param attrMin minimal count of attributes needed for tag
043         * @param attrMax maximum count of attributes or -1 for infinity attributes
044         * @param bodyContent TagMetaData.BODY_CONTENT_EMPTY,TagMetaData.BODY_CONTENT_FREE,TagMetaData.BODY_CONTENT_MUST
045         * @param isBodyRE is the body of the tag parsed like inside a cfoutput
046         * @param description A description of the tag.
047         */
048        public TagMetaDataImpl(int attrType, int attrMin, int attrMax, int bodyContent, boolean isBodyRE, String description,
049                        boolean handleException, boolean hasAppendix, boolean hasBody) {
050                this.attrMax = attrMax;
051                this.attrMin = attrMin;
052                this.attrType = attrType;
053                this.description = description;
054                this.isBodyRE = isBodyRE;
055                this.handleException = handleException;
056                this.hasAppendix = hasAppendix;
057                this.hasBody = hasBody;
058        }
059        
060        @Override
061        public int getAttributeMax() {
062                return attrMax;
063        }
064
065        @Override
066        public int getAttributeMin() {
067                return attrMin;
068        }
069
070        @Override
071        public int getAttributeType() {
072                return attrType;
073        }
074
075        @Override
076        public TagMetaDataAttr[] getAttributes() {
077                return (TagMetaDataAttr[]) attrs.toArray(new TagMetaDataAttr[attrs.size()]);
078        }
079        
080        /**
081         * adds a attribute to the tag
082         * @param attr
083         */
084        public void addAttribute(TagMetaDataAttr attr) {
085                attrs.add(attr);
086        }
087
088        @Override
089        public int getBodyContent() {
090                return bodyContent;
091        }
092
093        @Override
094        public String getDescription() {
095                return description;
096        }
097
098        @Override
099        public boolean isBodyRuntimeExpressionValue() {
100                return isBodyRE;
101        }
102
103        @Override
104        public boolean handleException() {
105                return handleException;
106        }
107
108        @Override
109        public boolean hasAppendix() {
110                return hasAppendix;
111        }
112
113        @Override
114        public boolean hasBody() {
115                return hasBody;
116        }
117
118}