Coverage Report - org.seasar.cubby.action.ActionContextHelper
 
Classes in this File Line Coverage Branch Coverage Complexity
ActionContextHelper
0%
0/10
0%
0/4
2.5
 
 1  
 /*
 2  
  * Copyright 2004-2010 the Seasar Foundation and the Others.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 13  
  * either express or implied. See the License for the specific language
 14  
  * governing permissions and limitations under the License.
 15  
  */
 16  
 
 17  
 package org.seasar.cubby.action;
 18  
 
 19  
 import javax.servlet.ServletRequest;
 20  
 
 21  
 import org.seasar.cubby.CubbyConstants;
 22  
 
 23  
 /**
 24  
  * 要求の属性に設定されたアクションコンテキストへアクセスするためのヘルパークラスです。
 25  
  * 
 26  
  * @since 2.0.5
 27  
  * @author baba
 28  
  */
 29  
 class ActionContextHelper {
 30  
 
 31  
         /** 要求 */
 32  
         private final ServletRequest request;
 33  
 
 34  
         /** アクションのコンテキスト */
 35  
         private ActionContext actionContext;
 36  
 
 37  
         /**
 38  
          * 指定された要求の属性に設定されたアクションコンテキストへアクセスするヘルパーを生成します。
 39  
          * 
 40  
          * @param request
 41  
          *            要求
 42  
          */
 43  0
         public ActionContextHelper(final ServletRequest request) {
 44  0
                 this.request = request;
 45  0
                 this.actionContext = null;
 46  0
         }
 47  
 
 48  
         /**
 49  
          * 要求の属性からアクションコンテキストを取得します。
 50  
          * 
 51  
          * @return アクションコンテキスト
 52  
          */
 53  
         public ActionContext getActionContext() {
 54  
                 // lazy initialization
 55  0
                 if (this.actionContext == null) {
 56  0
                         final ActionContext actionContext = (ActionContext) request
 57  
                                         .getAttribute(CubbyConstants.ATTR_ACTION_CONTEXT);
 58  0
                         if (actionContext == null) {
 59  0
                                 throw new IllegalStateException(
 60  
                                                 "ActionContext might not been initialized yet");
 61  
                         }
 62  0
                         this.actionContext = actionContext;
 63  
                 }
 64  0
                 return actionContext;
 65  
         }
 66  
 
 67  
 }