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 */
016package org.opengion.fukurou.taglet;
017
018/**
019 * 属性情報を管理する、AttKeySet クラスです。
020 *
021 * @version  4.0
022 * @author   Kazuhiko Hasegawa
023 * @since    JDK5.0,
024 */
025class 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}