Coverage Report - org.seasar.uruma.component.factory.desc.UrumaComponentDesc
 
Classes in this File Line Coverage Branch Coverage Complexity
UrumaComponentDesc
89%
41/46
67%
12/18
0
 
 1  
 /*
 2  
  * Copyright 2004-2008 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  
 package org.seasar.uruma.component.factory.desc;
 17  
 
 18  
 import java.util.ArrayList;
 19  
 import java.util.Collections;
 20  
 import java.util.List;
 21  
 
 22  
 /**
 23  
  * <code>urumaComponent</code> 要素の情報を保持するためのクラスです。<br />
 24  
  * 
 25  
  * @author y-komori
 26  
  */
 27  8
 public class UrumaComponentDesc {
 28  
     private String tagName;
 29  
 
 30  
     private String tagHandlerClass;
 31  
 
 32  
     private String rendererClass;
 33  
 
 34  
     private List<String> tagHandlerArgs;
 35  
 
 36  
     private List<String> rendererArgs;
 37  
 
 38  
     /**
 39  
      * タグ名称を返します。<br />
 40  
      * 
 41  
      * @return タグ名称
 42  
      */
 43  
     public String getTagName() {
 44  4
         return this.tagName;
 45  
     }
 46  
 
 47  
     /**
 48  
      * タグ名称を設定します。<br />
 49  
      * 
 50  
      * @param tagName
 51  
      *            タグ名称
 52  
      */
 53  
     public void setTagName(final String tagName) {
 54  8
         this.tagName = tagName;
 55  8
     }
 56  
 
 57  
     /**
 58  
      * タグハンドラのクラス名を返します。<br />
 59  
      * 
 60  
      * @return タグハンドラのクラス名
 61  
      */
 62  
     public String getTagHandlerClass() {
 63  4
         return this.tagHandlerClass;
 64  
     }
 65  
 
 66  
     /**
 67  
      * タグハンドラのクラス名を設定します。<br />
 68  
      * 
 69  
      * @param tagHandlerClass
 70  
      *            タグハンドラのクラス名
 71  
      */
 72  
     public void setTagHandlerClass(final String tagHandlerClass) {
 73  8
         this.tagHandlerClass = tagHandlerClass;
 74  8
     }
 75  
 
 76  
     /**
 77  
      * レンダラのクラス名を返します。<br />
 78  
      * 
 79  
      * @return レンダラのクラス名
 80  
      */
 81  
     public String getRendererClass() {
 82  4
         return this.rendererClass;
 83  
     }
 84  
 
 85  
     /**
 86  
      * レンダラのクラス名を設定します。<br />
 87  
      * 
 88  
      * @param rendererClass
 89  
      *            レンダラのクラス名
 90  
      */
 91  
     public void setRendererClass(final String rendererClass) {
 92  8
         this.rendererClass = rendererClass;
 93  8
     }
 94  
 
 95  
     /**
 96  
      * タグハンドラクラスの引数を追加します。<br />
 97  
      * 
 98  
      * @param arg
 99  
      *            引数
 100  
      */
 101  
     public void addTagHandlerArg(final String arg) {
 102  16
         if (arg == null) {
 103  0
             return;
 104  
         }
 105  16
         if (tagHandlerArgs == null) {
 106  8
             tagHandlerArgs = new ArrayList<String>();
 107  
         }
 108  16
         tagHandlerArgs.add(arg);
 109  16
     }
 110  
 
 111  
     /**
 112  
      * タグハンドラクラスの引数リストを返します。<br />
 113  
      * 
 114  
      * @return 引数リスト
 115  
      */
 116  
     @SuppressWarnings("unchecked")
 117  
     public List<String> getTagHandlerArgs() {
 118  4
         if (tagHandlerArgs != null) {
 119  4
             return tagHandlerArgs;
 120  
         } else {
 121  0
             return Collections.EMPTY_LIST;
 122  
         }
 123  
     }
 124  
 
 125  
     /**
 126  
      * レンダラクラスの引数を追加します。<br />
 127  
      * 
 128  
      * @param arg
 129  
      *            引数
 130  
      */
 131  
     public void addRendererArg(final String arg) {
 132  24
         if (arg == null) {
 133  0
             return;
 134  
         }
 135  24
         if (rendererArgs == null) {
 136  8
             rendererArgs = new ArrayList<String>();
 137  
         }
 138  24
         rendererArgs.add(arg);
 139  24
     }
 140  
 
 141  
     /**
 142  
      * レンダラクラスの引数リストを返します。<br />
 143  
      * 
 144  
      * @return 引数リスト
 145  
      */
 146  
     @SuppressWarnings("unchecked")
 147  
     public List<String> getRendererArgs() {
 148  4
         if (rendererArgs != null) {
 149  4
             return rendererArgs;
 150  
         } else {
 151  0
             return Collections.EMPTY_LIST;
 152  
         }
 153  
     }
 154  
 
 155  
     /*
 156  
      * @see java.lang.Object#toString()
 157  
      */
 158  
     @Override
 159  
     public String toString() {
 160  4
         StringBuilder builder = new StringBuilder(512);
 161  4
         builder.append("tagName:" + getTagName());
 162  4
         builder.append(" tagHandler:" + getTagHandlerClass());
 163  4
         builder.append(listToString(getTagHandlerArgs()));
 164  4
         builder.append(" renderer:" + getRendererClass());
 165  4
         builder.append(listToString(getRendererArgs()));
 166  4
         return builder.toString();
 167  
     }
 168  
 
 169  
     private String listToString(final List<?> list) {
 170  8
         if (list == null) {
 171  0
             return "()";
 172  
         }
 173  
 
 174  8
         StringBuilder builder = new StringBuilder(512);
 175  8
         builder.append("(");
 176  8
         for (Object obj : list) {
 177  20
             builder.append(obj.toString());
 178  20
             builder.append(", ");
 179  
         }
 180  8
         if (list.size() > 0) {
 181  8
             builder.delete(builder.length() - 2, builder.length());
 182  
         }
 183  8
         builder.append(")");
 184  8
         return builder.toString();
 185  
     }
 186  
 }