Coverage Report - org.seasar.uruma.util.MnemonicUtil
 
Classes in this File Line Coverage Branch Coverage Complexity
MnemonicUtil
0%
0/12
0%
0/4
1.8
 
 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.util;
 17  
 
 18  
 import org.seasar.uruma.core.UrumaConstants;
 19  
 
 20  
 /**
 21  
  * メニューのニーモニックを扱うためのユーティリティクラスです。<br />
 22  
  * 
 23  
  * @author y-komori
 24  
  */
 25  
 public class MnemonicUtil implements UrumaConstants {
 26  0
     private MnemonicUtil() {
 27  
 
 28  0
     }
 29  
 
 30  
     /**
 31  
      * テキストからニーモニックとアクセラレータを削除します。<br />
 32  
      * 
 33  
      * @param text
 34  
      *            テキスト
 35  
      * @return 削除結果
 36  
      */
 37  
     public static String chopMnemonicAndAccelerator(final String text) {
 38  0
         return chopMnemonic(chopAccelerator(text));
 39  
     }
 40  
 
 41  
     /**
 42  
      * テキストからニーモニックプレフィックス(&記号)を削除します。<br />
 43  
      * 【例】「ファイル(&F)」の場合、結果は「ファイル(F)」となります。
 44  
      * 
 45  
      * @param text
 46  
      *            テキスト
 47  
      * @return 削除結果
 48  
      */
 49  
     public static String chopMnemonic(final String text) {
 50  0
         return text.replace(AMPERSAND, NULL_STRING);
 51  
     }
 52  
 
 53  
     /**
 54  
      * テキストからアクセラレータ部分を削除します。<br />
 55  
      * 【例】「開く(&O)\tCtrl-O」の場合、結果は「Ctrl-O」となります。
 56  
      * 
 57  
      * @param title
 58  
      *            テキスト
 59  
      * @return 削除結果
 60  
      */
 61  
     public static String chopAccelerator(final String title) {
 62  0
         int startPos = title.indexOf("\\t");
 63  0
         if (startPos > 0) {
 64  0
             return title.substring(0, startPos);
 65  
         }
 66  0
         return title;
 67  
     }
 68  
 
 69  
     /**
 70  
      * テキストからニーモニックを取り出します。<br />
 71  
      * ニーモニックは最初の「&」(アンパサンド)に続く一文字です。<br />
 72  
      * 【例】「ファイル(&F)」の場合、結果は「F」となります。
 73  
      * 
 74  
      * @param text
 75  
      *            テキスト
 76  
      * @return ニーモニック。見つからない場合は空文字列。
 77  
      */
 78  
     public static String getMnemonic(final String text) {
 79  0
         int startPos = text.indexOf(AMPERSAND);
 80  0
         if (startPos > 0) {
 81  0
             return text.substring(startPos + 1, startPos + 2);
 82  
         }
 83  0
         return NULL_STRING;
 84  
     }
 85  
 }