001    // Copyright 2004, 2005 The Apache Software Foundation
002    //
003    // Licensed under the Apache License, Version 2.0 (the "License");
004    // you may not use this file except in compliance with the License.
005    // You may obtain a copy of the License at
006    //
007    //     http://www.apache.org/licenses/LICENSE-2.0
008    //
009    // Unless required by applicable law or agreed to in writing, software
010    // distributed under the License is distributed on an "AS IS" BASIS,
011    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012    // See the License for the specific language governing permissions and
013    // limitations under the License.
014    
015    package org.apache.tapestry.parse;
016    
017    import java.util.Map;
018    
019    import org.apache.hivemind.Location;
020    
021    /**
022     *  Represents localized text from the template.
023     *
024     *  @see TokenType#LOCALIZATION
025     * 
026     *  @author Howard Lewis Ship
027     *  @since 3.0
028     *
029     **/
030    
031    public class LocalizationToken extends TemplateToken
032    {
033        private String _tag;
034        private String _key;
035        private boolean _raw;
036        private Map _attributes;
037        
038        /**
039         *  Creates a new token.
040         * 
041         * 
042         *  @param tag the tag of the element from the template
043         *  @param key the localization key specified
044         *  @param raw if true, then the localized value contains markup that should not be escaped
045         *  @param attributes any additional attributes (beyond those used to define key and raw)
046         *  that were specified.  This value is retained, not copied.
047         *  @param location location of the tag which defines this token
048         * 
049         **/
050        
051        public LocalizationToken(String tag, String key, boolean raw, Map attributes, Location location)
052        {
053            super(TokenType.LOCALIZATION, location);
054            
055            _tag = tag;
056            _key = key;
057            _raw = raw;
058            _attributes = attributes;
059        }
060        
061        /**
062         *  Returns any attributes for the token, which may be null.  Do not modify
063         *  the return value.
064         * 
065         **/
066        
067        public Map getAttributes()
068        {
069            return _attributes;
070        }
071    
072        public boolean isRaw()
073        {
074            return _raw;
075        }
076    
077        public String getTag()
078        {
079            return _tag;
080        }
081    
082        public String getKey()
083        {
084            return _key;
085        }
086    }