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.plugin.column;
017
018import org.opengion.fukurou.util.StringUtil;                            // 6.2.0.0 (2015/02/27)
019import org.opengion.hayabusa.db.AbstractRenderer;
020import org.opengion.hayabusa.db.CellRenderer;
021import org.opengion.hayabusa.db.DBColumn;
022
023/**
024 * NOTAG レンデラーは、LABEL レンデラーの値から、ファイル出力時に タグ情報のみ
025 * 削除するレンデラーです。
026 * ファイル出力対象で、データそのものにタグ情報を埋め込んでいる場合は、このレンデラーが使えます。
027 * 処理は、<xxxx ・・・>YYYY</xxxx>形式の場合、YYYY のみ出力します。
028 * <xxxx/> の様な、BODY要素を持たない場合は、ゼロ文字列になります。
029 *
030 * このクラスは、不変オブジェクトとして、共有されます。
031 *
032 * @og.group データ表示
033 *
034 * @version  6.0
035 * @author   Kazuhiko Hasegawa
036 * @since    JDK5.0,
037 */
038public class Renderer_NOTAG extends AbstractRenderer {
039        /** このプログラムのVERSION文字列を設定します。   {@value} */
040        private static final String VERSION = "6.4.2.0 (2016/01/29)" ;
041
042        private static final CellRenderer DB_CELL = new Renderer_NOTAG() ;
043
044        /**
045         * デフォルトコンストラクター
046         *
047         * @og.rev 6.4.2.0 (2016/01/29) PMD refactoring. Each class should declare at least one constructor.
048         */
049        public Renderer_NOTAG() { super(); }            // これも、自動的に呼ばれるが、空のメソッドを作成すると警告されるので、明示的にしておきます。
050
051        /**
052         * 各オブジェクトから自分のインスタンスを返します。
053         * 自分自身をキャッシュするのか、新たに作成するのかは、各サブクラスの実装に
054         * まかされます。
055         *
056         * @og.rev 6.2.0.0 (2015/02/27) 引数からタグを削除し、BODY文字列を切り出します。
057         *
058         * @param       clm     DBColumnオブジェクト
059         *
060         * @return      CellRendererオブジェクト
061         * @og.rtnNotNull
062         */
063        public CellRenderer newInstance( final DBColumn clm ) {
064                return DB_CELL;
065        }
066
067        /**
068         * データ出力用の文字列を作成します。
069         * ファイル等に出力する形式を想定しますので、HTMLタグを含まない
070         * データを返します。
071         * 基本は、#getValue( String ) をそのまま返します。
072         *
073         * @og.rev 6.2.0.0 (2015/02/27) 引数からタグを削除し、BODY文字列を切り出します。
074         *
075         * @param   value 入力値
076         *
077         * @return  データ出力用の文字列
078         * @og.rtnNotNull
079         * @see         #getValue( String )
080         */
081        @Override
082        public String getWriteValue( final String value ) {
083                return StringUtil.tagCut( ( value == null ) ? "" : value );
084        }
085}