//# 0 errors, 100 messages
//#
/*
    //#MessageModel.java:1:1: class: org.apache.roller.weblogger.ui.rendering.model.MessageModel
    //#MessageModel.java:1:1: method: org.apache.roller.weblogger.ui.rendering.model.MessageModel.org.apache.roller.weblogger.ui.rendering.model.MessageModel__static_init
 * Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  The ASF licenses this file to You
 * under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.  For additional information regarding
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */

package org.apache.roller.weblogger.ui.rendering.model;

import java.util.List;
import java.util.Map;
import org.apache.roller.weblogger.WebloggerException;
import org.apache.roller.weblogger.ui.rendering.util.WeblogRequest;
import org.apache.roller.weblogger.util.I18nMessages;


/**
 * Provides access to application resources required for I18N.
 * Uses model name 'text' because that's what the Velocity Tools did.
 */
public class MessageModel implements Model {  
    //#MessageModel.java:32: method: void org.apache.roller.weblogger.ui.rendering.model.MessageModel.org.apache.roller.weblogger.ui.rendering.model.MessageModel()
    //#input(void org.apache.roller.weblogger.ui.rendering.model.MessageModel()): this
    //#output(void org.apache.roller.weblogger.ui.rendering.model.MessageModel()): this.messages
    //#post(void org.apache.roller.weblogger.ui.rendering.model.MessageModel()): this.messages == null
    
    I18nMessages messages = null;
    //#MessageModel.java:34: end of method: void org.apache.roller.weblogger.ui.rendering.model.MessageModel.org.apache.roller.weblogger.ui.rendering.model.MessageModel()
    
    
    /** Template context name to be used for model */
    public String getModelName() {
        return "text";
    //#MessageModel.java:39: method: String org.apache.roller.weblogger.ui.rendering.model.MessageModel.getModelName()
    //#output(String getModelName()): return_value
    //#post(String getModelName()): return_value == &"text"
    //#MessageModel.java:39: end of method: String org.apache.roller.weblogger.ui.rendering.model.MessageModel.getModelName()
    }
    
    
    /** Init page model based on request */
    public void init(Map initData) throws WebloggerException {
        
        // we expect the init data to contain a weblogRequest object
        WeblogRequest weblogRequest = (WeblogRequest) initData.get("parsedRequest");
    //#MessageModel.java:47: method: void org.apache.roller.weblogger.ui.rendering.model.MessageModel.init(Map)
    //#input(void init(Map)): "request for messages in locale = "._tainted
    //#input(void init(Map)): initData
    //#input(void init(Map)): org/apache/roller/weblogger/util/I18nMessages.__Descendant_Table[org/apache/roller/weblogger/util/I18nMessages]
    //#input(void init(Map)): org/apache/roller/weblogger/util/I18nMessages.__Descendant_Table[others]
    //#input(void init(Map)): org/apache/roller/weblogger/util/I18nMessages.log
    //#input(void init(Map)): org/apache/roller/weblogger/util/I18nMessages.messagesMap
    //#input(void init(Map)): this
    //#output(void init(Map)): new I18nMessages(getMessages#2) num objects
    //#output(void init(Map)): new I18nMessages(getMessages#2).__Tag
    //#output(void init(Map)): new I18nMessages(getMessages#2).bundle
    //#output(void init(Map)): new I18nMessages(getMessages#2).locale
    //#output(void init(Map)): this.messages
    //#new obj(void init(Map)): new I18nMessages(getMessages#2)
    //#pre[1] (void init(Map)): initData != null
    //#pre[2] (void init(Map)): org/apache/roller/weblogger/util/I18nMessages.messagesMap != null
    //#presumption(void init(Map)): java.util.Map:get(...)@47 != null
    //#presumption(void init(Map)): org.apache.roller.weblogger.ui.rendering.util.WeblogRequest:getLocaleInstance(...)@53 != null
    //#post(void init(Map)): this.messages != null
    //#post(void init(Map)): new I18nMessages(getMessages#2) num objects <= 1
    //#post(void init(Map)): new I18nMessages(getMessages#2).__Tag == org/apache/roller/weblogger/util/I18nMessages
    //#post(void init(Map)): init'ed(new I18nMessages(getMessages#2).bundle)
    //#post(void init(Map)): new I18nMessages(getMessages#2).locale != null
    //#unanalyzed(void init(Map)): Effects-of-calling:java.util.ResourceBundle:getBundle
    //#unanalyzed(void init(Map)): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(void init(Map)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(void init(Map)): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(void init(Map)): Effects-of-calling:org.apache.commons.logging.Log:debug
    //#unanalyzed(void init(Map)): Effects-of-calling:java.util.Map:get
    //#unanalyzed(void init(Map)): Effects-of-calling:java.util.Map:put
    //#unanalyzed(void init(Map)): Effects-of-calling:java.util.Locale:toString
        if(weblogRequest == null) {
            throw new WebloggerException("expected weblogRequest from init data");
        }
        
        // get messages util based on desired locale
        this.messages = I18nMessages.getMessages(weblogRequest.getLocaleInstance());
    //#MessageModel.java:53: Warning: method not available
    //#    -- call on Locale org.apache.roller.weblogger.ui.rendering.util.WeblogRequest:getLocaleInstance()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.model.MessageModel
    //#    method: void init(Map)
    //#    unanalyzed callee: Locale org.apache.roller.weblogger.ui.rendering.util.WeblogRequest:getLocaleInstance()
    }
    //#MessageModel.java:54: end of method: void org.apache.roller.weblogger.ui.rendering.model.MessageModel.init(Map)
    
    
    /** Return message string */
    public String get(String key) {
        return messages.getString(key);
    //#MessageModel.java:59: method: String org.apache.roller.weblogger.ui.rendering.model.MessageModel.get(String)
    //#input(String get(String)): "Error getting key "._tainted
    //#input(String get(String)): key
    //#input(String get(String)): key._tainted
    //#input(String get(String)): org/apache/roller/weblogger/util/I18nMessages.log
    //#input(String get(String)): this
    //#input(String get(String)): this.messages
    //#input(String get(String)): this.messages.bundle
    //#output(String get(String)): return_value
    //#pre[4] (String get(String)): this.messages != null
    //#pre[5] (String get(String)): (soft) this.messages.bundle != null
    //#post(String get(String)): init'ed(return_value)
    //#unanalyzed(String get(String)): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(String get(String)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(String get(String)): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(String get(String)): Effects-of-calling:java.util.ResourceBundle:getString
    //#unanalyzed(String get(String)): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(String get(String)): Effects-of-calling:org.apache.commons.logging.Log:warn
    //#MessageModel.java:59: end of method: String org.apache.roller.weblogger.ui.rendering.model.MessageModel.get(String)
    }
    
    
    /** Return parameterized message string */
    public String get(String key, List args) {
        return messages.getString(key, args);
    //#MessageModel.java:65: method: String org.apache.roller.weblogger.ui.rendering.model.MessageModel.get(String, List)
    //#input(String get(String, List)): "Error getting key "._tainted
    //#input(String get(String, List)): args
    //#input(String get(String, List)): key
    //#input(String get(String, List)): key._tainted
    //#input(String get(String, List)): org/apache/roller/weblogger/util/I18nMessages.log
    //#input(String get(String, List)): this
    //#input(String get(String, List)): this.messages
    //#input(String get(String, List)): this.messages.bundle
    //#output(String get(String, List)): return_value
    //#pre[5] (String get(String, List)): this.messages != null
    //#pre[1] (String get(String, List)): (soft) args != null
    //#pre[6] (String get(String, List)): (soft) this.messages.bundle != null
    //#post(String get(String, List)): init'ed(return_value)
    //#unanalyzed(String get(String, List)): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(String get(String, List)): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(String get(String, List)): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(String get(String, List)): Effects-of-calling:java.util.ResourceBundle:getString
    //#unanalyzed(String get(String, List)): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(String get(String, List)): Effects-of-calling:java.util.List:toArray
    //#unanalyzed(String get(String, List)): Effects-of-calling:java.text.MessageFormat:format
    //#unanalyzed(String get(String, List)): Effects-of-calling:org.apache.commons.logging.Log:warn
    //#MessageModel.java:65: end of method: String org.apache.roller.weblogger.ui.rendering.model.MessageModel.get(String, List)
    }

}
    //#output(org.apache.roller.weblogger.ui.rendering.model.MessageModel__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/rendering/model/MessageModel]
    //#output(org.apache.roller.weblogger.ui.rendering.model.MessageModel__static_init): __Dispatch_Table.get(Ljava/lang/String;)Ljava/lang/String;
    //#output(org.apache.roller.weblogger.ui.rendering.model.MessageModel__static_init): __Dispatch_Table.get(Ljava/lang/String;Ljava/util/List;)Ljava/lang/String;
    //#output(org.apache.roller.weblogger.ui.rendering.model.MessageModel__static_init): __Dispatch_Table.getModelName()Ljava/lang/String;
    //#output(org.apache.roller.weblogger.ui.rendering.model.MessageModel__static_init): __Dispatch_Table.init(Ljava/util/Map;)V
    //#output(org.apache.roller.weblogger.ui.rendering.model.MessageModel__static_init): org/apache/roller/weblogger/ui/rendering/model/Model.__Descendant_Table[org/apache/roller/weblogger/ui/rendering/model/MessageModel]
    //#post(org.apache.roller.weblogger.ui.rendering.model.MessageModel__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/rendering/model/MessageModel] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.ui.rendering.model.MessageModel__static_init): org/apache/roller/weblogger/ui/rendering/model/Model.__Descendant_Table[org/apache/roller/weblogger/ui/rendering/model/MessageModel] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.ui.rendering.model.MessageModel__static_init): __Dispatch_Table.get(Ljava/lang/String;)Ljava/lang/String; == &get
    //#post(org.apache.roller.weblogger.ui.rendering.model.MessageModel__static_init): __Dispatch_Table.get(Ljava/lang/String;Ljava/util/List;)Ljava/lang/String; == &get
    //#post(org.apache.roller.weblogger.ui.rendering.model.MessageModel__static_init): __Dispatch_Table.getModelName()Ljava/lang/String; == &getModelName
    //#post(org.apache.roller.weblogger.ui.rendering.model.MessageModel__static_init): __Dispatch_Table.init(Ljava/util/Map;)V == &init
    //#MessageModel.java:: end of method: org.apache.roller.weblogger.ui.rendering.model.MessageModel.org.apache.roller.weblogger.ui.rendering.model.MessageModel__static_init
    //#MessageModel.java:: end of class: org.apache.roller.weblogger.ui.rendering.model.MessageModel
