Coverage Report - org.seasar.cubby.routing.impl.RoutingImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
RoutingImpl
100%
22/22
N/A
0
 
 1  
 package org.seasar.cubby.routing.impl;
 2  
 
 3  
 import java.lang.reflect.Method;
 4  
 import java.util.List;
 5  
 import java.util.regex.Pattern;
 6  
 
 7  
 import org.seasar.cubby.action.Action;
 8  
 import org.seasar.cubby.action.RequestMethod;
 9  
 import org.seasar.cubby.routing.Routing;
 10  
 import org.seasar.framework.util.StringUtil;
 11  
 
 12  
 /**
 13  
  * ルーティングの実装。
 14  
  * 
 15  
  * @author baba
 16  
  * @since 1.1.0
 17  
  */
 18  
 class RoutingImpl implements Routing {
 19  
 
 20  
         /** アクションクラス。 */
 21  
         private final Class<? extends Action> actionClass;
 22  
 
 23  
         /** アクソンメソッド。 */
 24  
         private final Method method;
 25  
 
 26  
         /** アクションのパス。 */
 27  
         private final String actionPath;
 28  
 
 29  
         /** URI パラメータ名。 */
 30  
         private final List<String> uriParameterNames;
 31  
 
 32  
         /** 正規表現パターン。 */
 33  
         private final Pattern pattern;
 34  
 
 35  
         /** リクエストメソッド。 */
 36  
         private final RequestMethod requestMethod;
 37  
 
 38  
         /** このルーティングを使用することを判断するためのパラメータ名。 */
 39  
         private final String onSubmit;
 40  
 
 41  
         /** 優先順位。 */
 42  
         private final int priority;
 43  
 
 44  
         /** 自動登録されたかどうか。 */
 45  
         private final boolean auto;
 46  
 
 47  
         /**
 48  
          * インスタンス化します。
 49  
          * 
 50  
          * @param actionClass
 51  
          *            アクションクラス
 52  
          * @param method
 53  
          *            アクションメソッド
 54  
          * @param actionPath
 55  
          *            アクションのパス
 56  
          * @param uriParameterNames
 57  
          *            URI パラメータ名
 58  
          * @param pattern
 59  
          *            正規表現パターン
 60  
          * @param requestMethod
 61  
          *            リクエストメソッド
 62  
          * @param onSubmit
 63  
          *            このルーティングを使用することを判断するためのパラメータ名
 64  
          * @param priority
 65  
          *            優先順位。手動登録の場合は登録順の連番。自動登録の場合は{@link Integer#MAX_VALUE}が常にセットされます。
 66  
          * @param auto
 67  
          *            自動登録されたかどうか
 68  
          */
 69  
         RoutingImpl(final Class<? extends Action> actionClass, final Method method,
 70  
                         final String actionPath, final List<String> uriParameterNames,
 71  
                         final Pattern pattern, final RequestMethod requestMethod,
 72  563
                         final String onSubmit, final int priority, final boolean auto) {
 73  563
                 this.actionClass = actionClass;
 74  563
                 this.method = method;
 75  563
                 this.actionPath = actionPath;
 76  563
                 this.uriParameterNames = uriParameterNames;
 77  563
                 this.pattern = pattern;
 78  563
                 this.requestMethod = requestMethod;
 79  563
                 this.onSubmit = onSubmit;
 80  563
                 this.priority = priority;
 81  563
                 this.auto = auto;
 82  563
         }
 83  
 
 84  
         /**
 85  
          * {@inheritDoc}
 86  
          */
 87  
         public Class<? extends Action> getActionClass() {
 88  62
                 return actionClass;
 89  
         }
 90  
 
 91  
         /**
 92  
          * {@inheritDoc}
 93  
          */
 94  
         public Method getMethod() {
 95  62
                 return method;
 96  
         }
 97  
 
 98  
         /**
 99  
          * {@inheritDoc}
 100  
          */
 101  
         public String getActionPath() {
 102  21
                 return actionPath;
 103  
         }
 104  
 
 105  
         /**
 106  
          * {@inheritDoc}
 107  
          */
 108  
         public List<String> getUriParameterNames() {
 109  7378
                 return uriParameterNames;
 110  
         }
 111  
 
 112  
         /**
 113  
          * {@inheritDoc}
 114  
          */
 115  
         public Pattern getPattern() {
 116  5829
                 return pattern;
 117  
         }
 118  
 
 119  
         /**
 120  
          * {@inheritDoc}
 121  
          */
 122  
         public RequestMethod getRequestMethod() {
 123  2001
                 return requestMethod;
 124  
         }
 125  
 
 126  
         /**
 127  
          * {@inheritDoc}
 128  
          */
 129  
         public String getOnSubmit() {
 130  723
                 return onSubmit;
 131  
         }
 132  
 
 133  
         /**
 134  
          * {@inheritDoc}
 135  
          */
 136  
         public int getPriority() {
 137  9057
                 return this.priority;
 138  
         }
 139  
 
 140  
         /**
 141  
          * {@inheritDoc}
 142  
          */
 143  
         public boolean isAuto() {
 144  362
                 return auto;
 145  
         }
 146  
 
 147  
         /**
 148  
          * {@inheritDoc}
 149  
          */
 150  
         public boolean isAcceptable(final String requestMethod) {
 151  12
                 return StringUtil.equalsIgnoreCase(this.requestMethod.name(),
 152  
                                 requestMethod);
 153  
         }
 154  
 
 155  
         /**
 156  
          * このオブジェクトの文字列表現を返します。
 157  
          * 
 158  
          * @return このオブジェクトの正規表現
 159  
          */
 160  
         @Override
 161  
         public String toString() {
 162  548
                 return new StringBuilder().append("[regex=").append(this.pattern)
 163  
                                 .append(",method=").append(this.method).append(
 164  
                                                 ",uriParameterNames=").append(this.uriParameterNames)
 165  
                                 .append(",requestMethod=").append(this.requestMethod).append(
 166  
                                                 ",onSubmit=").append(onSubmit).append(",priority=")
 167  
                                 .append(this.priority).append(",auto=").append(this.auto)
 168  
                                 .append("]").toString();
 169  
         }
 170  
 }