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.rest;
020
021
022import java.util.List;
023
024import lucee.commons.lang.mimetype.MimeType;
025import lucee.runtime.type.Struct;
026
027public class Result {
028
029        private final Source source;
030        private final String[] path;
031        private final Struct variables;
032        private final int format;
033        private final Struct matrix;
034        private Struct rsp;
035        private final List<MimeType> accept;
036        private final MimeType contentType;
037        private final boolean hasFormatExtension;
038
039        public Result(Source source, Struct variables, String[] path,  Struct matrix,int format,boolean hasFormatExtension,List<MimeType> accept,MimeType contentType) {
040                this.source=source;
041                this.variables=variables;
042                this.path=path;
043                this.format=format;
044                this.matrix=matrix;
045                this.hasFormatExtension=hasFormatExtension;
046                this.accept=accept;
047                this.contentType=contentType;
048        }
049
050        /**
051         * @return the hasFormatExtension
052         */
053        public boolean hasFormatExtension() {
054                return hasFormatExtension;
055        }
056
057        /**
058         * @return the accept
059         */
060        public MimeType[] getAccept() {
061                return accept.toArray(new MimeType[accept.size()]);
062        }
063
064        /**
065         * @return the accept
066         */
067        public MimeType getContentType() {
068                return contentType==null?MimeType.ALL:contentType;
069        }
070
071        /**
072         * @return the variables
073         */
074        public Struct getVariables() {
075                return variables;
076        }
077
078        /**
079         * @return the source
080         */
081        public Source getSource() {
082                return source;
083        }
084
085        /**
086         * @return the path
087         */
088        public String[] getPath() {
089                return path;
090        }
091
092        /**
093         * @return the format
094         */
095        public int getFormat() {
096                return format;
097        }
098
099        /**
100         * @return the matrix
101         */
102        public Struct getMatrix() {
103                return matrix;
104        }
105
106        public void setCustomResponse(Struct rsp) {
107                this.rsp=rsp;
108        }
109        public Struct getCustomResponse() {
110                return rsp;
111        }
112
113}