1 /*
2 * Copyright 2013 the original author or authors.
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, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package com.orangesignal.csv.manager;
18
19 import java.util.ServiceLoader;
20
21 /**
22 * アプリケーションで区切り文字形式データの統合アクセスインタフェースを取得できるファクトリ API を定義します。
23 *
24 * @author Koji Sugisawa
25 */
26 public abstract class CsvManagerFactory {
27
28 /**
29 * デフォルトコンストラクタです。
30 */
31 protected CsvManagerFactory() {
32 }
33
34 /**
35 * {@link CsvManager} の新しいインスタンスを取得します。
36 * この static メソッドは新しい統合アクセスインスタンスを作成します。
37 * このメソッドは次の順序の検索手順で、ロードする {@link CsvManager} 実装クラスを決定します。
38 * <ul>
39 * <li>
40 * 可能であれば、JAR 仕様で詳細に説明されているサービス API を使用して、クラス名を判定する。
41 * Services API は、実行時に使用できる jar 内の META-INF/services/com.orangesignal.csv.manager.CsvManager ファイルからクラス名を検索する
42 * </li>
43 * <li>
44 * プラットフォームのデフォルトの {@link CsvManager} インスタンス
45 * </li>
46 * </ul>
47 *
48 * @return {@link CsvManager} の新しいインスタンス
49 */
50 public static CsvManager newCsvManager() {
51 for (final CsvManager manager : ServiceLoader.load(CsvManager.class)) {
52 return manager;
53 }
54 return new CsvBeanManager();
55 }
56
57 }