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.search;
020
021
022public class AddionalAttrs {
023
024
025
026        private static ThreadLocal addAttrs=new ThreadLocal();
027        private int contextBytes;
028        private String contextHighlightBegin;
029        private int contextPassages;
030        private String contextHighlightEnd;
031        private int startrow=1;
032        private int maxrows=-1;
033        private boolean hasRowHandling;
034        
035        public AddionalAttrs(int contextBytes, int contextPassages,String contextHighlightBegin, String contextHighlightEnd) {
036                this.contextBytes=contextBytes;
037                this.contextPassages=contextPassages;
038                this.contextHighlightBegin=contextHighlightBegin;
039                this.contextHighlightEnd=contextHighlightEnd;
040        }
041        
042        public static AddionalAttrs getAddionlAttrs(){
043                AddionalAttrs aa = (AddionalAttrs) addAttrs.get();
044                if(aa==null)aa=new AddionalAttrs(300,0,"<b>","</b>");
045                return aa;
046        }
047        public static void setAddionalAttrs(AddionalAttrs aa){
048                addAttrs.set(aa);
049        }
050        
051        public static void setAddionalAttrs(int contextBytes, int contextPassages, String contextHighlightBegin, String contextHighlightEnd) {
052                setAddionalAttrs(new AddionalAttrs(contextBytes,contextPassages,contextHighlightBegin,contextHighlightEnd));
053        }
054
055        public static void removeAddionalAttrs(){
056                addAttrs.set(null);
057        }
058        
059
060        /**
061         * @return the contextBytes
062         */
063        public int getContextBytes() {
064                return contextBytes;
065        }
066
067        /**
068         * @return the contextHighlightBegin
069         */
070        public String getContextHighlightBegin() {
071                return contextHighlightBegin;
072        }
073
074        /**
075         * @return the contextPassages
076         */
077        public int getContextPassages() {
078                return contextPassages;
079        }
080
081        /**
082         * @return the contextHighlightEnd
083         */
084        public String getContextHighlightEnd() {
085                return contextHighlightEnd;
086        }
087
088        /**
089         * @return the startrow
090         */
091        public int getStartrow() {
092                return startrow;
093        }
094
095        /**
096         * @param startrow the startrow to set
097         */
098        public void setStartrow(int startrow) {
099                this.startrow = startrow;
100        }
101
102        /**
103         * @return the maxrows
104         */
105        public int getMaxrows() {
106                return maxrows;
107        }
108
109        /**
110         * @param maxrows the maxrows to set
111         */
112        public void setMaxrows(int maxrows) {
113                this.maxrows = maxrows;
114        }
115
116        public boolean hasRowHandling() {
117                return hasRowHandling;
118        }
119        public void setHasRowHandling(boolean hasRowHandling) {
120                this.hasRowHandling= hasRowHandling;
121        }
122}