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.transformer.bytecode.literal;
020
021import lucee.transformer.bytecode.Position;
022
023
024public class Identifier extends LitString {
025
026        public static short CASE_ORIGNAL=0;
027        public static short CASE_UPPER=1;
028        public static short CASE_LOWER=2;
029        private String raw;
030        private short _case;
031        
032
033
034        public static Identifier toIdentifier(String str, Position start,Position end) {
035                return new Identifier(str, CASE_ORIGNAL,start,end);
036        }
037
038        public static Identifier toIdentifier(String str, short _case, Position start,Position end) {
039                return new Identifier(str, _case,start,end);
040        }
041        
042        private Identifier(String str, short _case,Position start,Position end) {
043                super(convert(str,_case), start,end);
044                this.raw=str;
045                this._case=_case;
046        }
047
048        /**
049         * @return the raw
050         */
051        public String getRaw() {
052                return raw;
053        }
054
055        /**
056         * @return the _case
057         */
058        public short getCase() {
059                return _case;
060        }
061
062        private static String convert(String str, short _case) {
063                if(CASE_UPPER==_case) return str.toUpperCase();
064                if(CASE_LOWER==_case) return str.toLowerCase();
065                return str;
066        }
067
068
069        public String getUpper() {
070                if(CASE_UPPER==_case)return getString();
071                return raw.toUpperCase();
072        }
073
074        public String getLower() {
075                if(CASE_LOWER==_case)return getString();
076                return raw.toLowerCase();
077        }
078
079}