View Javadoc

1   /*
2    * Common Library for TBAS Softwares
3    * Language: Java
4    *
5    * All Rights Reserved.
6    * Copyright (c) 2003 Tsukuba Bunko.
7    *
8    * $Id: StringUtil.java,v 1.1 2005/07/11 12:49:19 ppoi Exp $
9    */
10  package tsukuba_bunko.text;
11  
12  /***
13   * 基本的な文字列操作のためのユーティリティクラスです。
14   * @author	$Author: ppoi $
15   * @version	$Revision: 1.1 $
16   */
17  public final class StringUtil	{
18  
19  	/***
20  	 * 文字列の前後の不要な空白を除去します。
21  	 * @param	text	処理対象の文字列
22  	 * @param	voidToNull	<code>true</code> の場合、処理結果が空文字列の場合に <code>null</code> を返し、それ以外の場合、そのまま処理結果を返す。
23  	 * @return	処理結果
24  	 */
25  	public static String trimString( String text, boolean voidToNull )
26  	{
27  		if( text != null )	{
28  			text = text.trim();
29  			if( voidToNull && (text.length() == 0) )	{
30  				text = null;
31  			}
32  		}
33  		return text;
34  	}
35  }