001    /*
002     * Copyright (c) 2009 The openGion Project.
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     *     http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
013     * either express or implied. See the License for the specific language
014     * governing permissions and limitations under the License.
015     */
016    package org.opengion.fukurou.taglet;
017    
018    /**
019     * 属æ?æƒ??を管ç�?�™るã?AttKeySet クラスですã?
020     *
021     * @version  4.0
022     * @author   Kazuhiko Hasegawa
023     * @since    JDK5.0,
024     */
025    class AttKeySet {
026            private final String searchKey ;
027            private final int    len ;
028            private final String seq ;
029            private final String valueName ;
030    
031            /**
032             * コンストラクター
033             *
034             * @param searchKey  String
035             * @param seq        int
036             * @param valueName  String
037             *
038             */
039            AttKeySet( final String searchKey,final int seq,final String valueName ) {
040                    this.searchKey          = searchKey ;
041                    this.seq                = String.valueOf( seq );
042                    this.valueName          = valueName ;
043    
044                    len = searchKey.length();
045            }
046    
047            /**
048             * シーケンス番号を返しますã?
049             *
050             * @return シーケンス番号
051             *
052             */
053            String getSeq() {
054                    return seq;
055            }
056    
057            /**
058             * 属æ?名を返しますã?
059             *
060             * @return 属æ?å�?
061             *
062             */
063            String getValueName() {
064                    return valueName;
065            }
066    
067            /**
068             * クラス名ã?先é?ä¸??の場合ã?ã€?*** 部åˆ?‚’返しますã?
069             * インターフェースも扱えるように修正しましたので、å?頭ã�?_ の場合ã?ã€?
070             * _ を削除して返しますã?
071             *
072             * @param name クラスの名称(例:DBCellEditor_**** , ViewForm_****)
073             * @return クラス名ã?**** 部åˆ?
074             */
075            String getAttKey( final String name ) {
076                    String rtn = null;              // ä¸??しなかったã?
077    
078                    if( name.equals( searchKey ) ) {        // 完å?ä¸???šインターフェース
079                            return "(Interface)" + name ;
080                    }
081    
082                    int start = name.indexOf( searchKey );
083                    if( start == 0 ) {              // 先é?ä¸??したã€?
084                            rtn = name.substring( len );
085                    }
086    
087                    if( rtn != null && rtn.charAt(0) == '_' ) { return rtn.substring( 1 ); }
088                    return rtn ;
089            }
090    }