-#Tue Oct 14 01:31:03 JST 2008\r
+#Sat Oct 18 14:03:13 JST 2008\r
eclipse.preferences.version=1\r
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6\r
-org.eclipse.jdt.core.compiler.compliance=1.6\r
-org.eclipse.jdt.core.compiler.source=1.6\r
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled\r
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5\r
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve\r
+org.eclipse.jdt.core.compiler.compliance=1.5\r
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate\r
+org.eclipse.jdt.core.compiler.debug.localVariable=generate\r
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate\r
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error\r
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error\r
+org.eclipse.jdt.core.compiler.source=1.5\r
<groupId>org.apache.ant</groupId>\r
<artifactId>ant</artifactId>\r
</dependency>\r
+ <dependency>\r
+ <groupId>org.freemarker</groupId>\r
+ <artifactId>freemarker</artifactId>\r
+ </dependency>\r
</dependencies>\r
</project>
\ No newline at end of file
\r
String getProperty(String key);\r
String getProperty(String key, String defaultValue);\r
+ boolean getBoolean(String key);\r
}\r
in = new URL(configPath).openStream();\r
} catch (MalformedURLException e) {\r
} catch (IOException e) {\r
- _log.info("Failed to read resource:", e);\r
+ _log.warn("Failed to read resource:", e);\r
}\r
if (in == null) {\r
in = Thread.currentThread().getContextClassLoader().getResourceAsStream(configPath);\r
if (in != null) {\r
try {\r
_prop.load(in);\r
- _log.info("config initialized.");\r
+ _log.debug("config initialized.");\r
} catch (IOException e) {\r
- _log.info("Failed to read resource:" + e);\r
+ _log.warn("Failed to read resource:" + e);\r
}\r
}\r
}\r
\r
- @Override\r
public String getProperty(String key) {\r
return _prop.getProperty(key);\r
}\r
\r
- @Override\r
public String getProperty(String key, String defaultValue) {\r
return _prop.getProperty(key, defaultValue);\r
}\r
\r
+ public boolean getBoolean(String key) {\r
+ return "true".equalsIgnoreCase(getProperty(key, "false"));\r
+ }\r
}\r
--- /dev/null
+/*\r
+ * Copyright 2004-2008 the Seasar Foundation and the Others.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, \r
+ * either express or implied. See the License for the specific language\r
+ * governing permissions and limitations under the License.\r
+ */\r
+package org.seasar.extension.jdbc.gen.generator;\r
+\r
+import java.io.File;\r
+\r
+/**\r
+ * {@link Generator}のためのコンテキストを表すインタフェースです。\r
+ * \r
+ * @author taedium\r
+ */\r
+public interface GenerationContext {\r
+\r
+ /**\r
+ * エンコーディングを返します。\r
+ * \r
+ * @return エンコーディング\r
+ */\r
+ String getEncoding();\r
+\r
+ /**\r
+ * データモデルを返します。\r
+ * \r
+ * @return データモデル\r
+ */\r
+ Object getModel();\r
+\r
+ /**\r
+ * 生成するファイルを返します。\r
+ * \r
+ * @return 生成するファイル\r
+ */\r
+ public File getFile();\r
+\r
+ /**\r
+ * テンプレート名を返します。\r
+ * \r
+ * @return テンプレート名\r
+ */\r
+ public String getTemplateName();\r
+\r
+ /**\r
+ * 上書きする場合は{@code true}、しない場合は{@code false}を返します。\r
+ * \r
+ * @return 上書きする場合は{@code true}、しない場合は{@code false}\r
+ */\r
+ public boolean isOverwrite();\r
+}\r
--- /dev/null
+/*\r
+ * Copyright 2004-2008 the Seasar Foundation and the Others.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, \r
+ * either express or implied. See the License for the specific language\r
+ * governing permissions and limitations under the License.\r
+ */\r
+package org.seasar.extension.jdbc.gen.generator;\r
+\r
+/**\r
+ * ファイルを生成するインタフェースです。\r
+ * \r
+ * @author taedium\r
+ */\r
+public interface Generator {\r
+\r
+ /**\r
+ * 生成します。\r
+ * \r
+ * @param context\r
+ * コンテキスト\r
+ */\r
+ void generate(GenerationContext context);\r
+\r
+}\r
BeanDesc beanDesc = BeanDescFactory.getBeanDesc(getClass());\r
for (int i = 0; i < beanDesc.getPropertyDescSize(); i++) {\r
PropertyDesc propertyDesc = beanDesc.getPropertyDesc(i);\r
- if (propertyDesc.hasWriteMethod() && propertyDesc.hasReadMethod()) {\r
+ if (propertyDesc.hasWriteMethod()) {\r
getLogger().info(propertyDesc.getPropertyName());\r
getLogger().info(propertyDesc.getWriteMethod());\r
getLogger().log(\r
--- /dev/null
+/*\r
+ * Copyright 2004-2008 the Seasar Foundation and the Others.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, \r
+ * either express or implied. See the License for the specific language\r
+ * governing permissions and limitations under the License.\r
+ */\r
+package org.seasar.extension.jdbc.gen.internal.exception;\r
+\r
+import org.seasar.framework.exception.SRuntimeException;\r
+\r
+import freemarker.template.TemplateException;\r
+\r
+/**\r
+ * <code>TemplateException</code>をラップする例外です。\r
+ * \r
+ * @author taedium\r
+ */\r
+public class TemplateRuntimeException extends SRuntimeException {\r
+\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ /**\r
+ * {@link TemplateRuntimeException}を生成します。\r
+ * \r
+ * @param cause\r
+ */\r
+ public TemplateRuntimeException(TemplateException cause) {\r
+ super("ES2JDBCGen0002", new Object[] { cause }, cause);\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright 2004-2008 the Seasar Foundation and the Others.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, \r
+ * either express or implied. See the License for the specific language\r
+ * governing permissions and limitations under the License.\r
+ */\r
+package org.seasar.extension.jdbc.gen.internal.generator;\r
+\r
+import java.io.File;\r
+\r
+import org.seasar.extension.jdbc.gen.generator.GenerationContext;\r
+\r
+/**\r
+ * {@link GenerationContext}の実装クラスです。\r
+ * \r
+ * @author taedium\r
+ */\r
+public class GenerationContextImpl implements GenerationContext {\r
+\r
+ /** データモデル */\r
+ protected Object model;\r
+\r
+ /** 生成するファイルの出力先ディレクトリ */\r
+ protected File dir;\r
+\r
+ /** 生成するファイル */\r
+ protected File file;\r
+\r
+ /** テンプレート名 */\r
+ protected String templateName;\r
+\r
+ /** エンコーディング */\r
+ protected String encoding;\r
+\r
+ /** 上書きする場合{@code true} */\r
+ protected boolean overwrite;\r
+\r
+ /**\r
+ * インスタンスを構築します。\r
+ * \r
+ * @param model\r
+ * データモデル\r
+ * @param file\r
+ * 生成するファイル\r
+ * @param templateName\r
+ * テンプレート名\r
+ * @param encoding\r
+ * 生成するファイルのエンコーディング\r
+ * @param overwrite\r
+ * 上書きする場合{@code true}、しない場合{@code false}\r
+ */\r
+ public GenerationContextImpl(Object model, File file, String templateName,\r
+ String encoding, boolean overwrite) {\r
+ if (model == null) {\r
+ throw new NullPointerException("model");\r
+ }\r
+ if (file == null) {\r
+ throw new NullPointerException("file");\r
+ }\r
+ if (templateName == null) {\r
+ throw new NullPointerException("templateName");\r
+ }\r
+ if (encoding == null) {\r
+ throw new NullPointerException("dumpFileEncoding");\r
+ }\r
+ this.model = model;\r
+ this.file = file;\r
+ this.templateName = templateName;\r
+ this.encoding = encoding;\r
+ this.overwrite = overwrite;\r
+ }\r
+\r
+ public String getEncoding() {\r
+ return encoding;\r
+ }\r
+\r
+ public Object getModel() {\r
+ return model;\r
+ }\r
+\r
+ public File getFile() {\r
+ return file;\r
+ }\r
+\r
+ public String getTemplateName() {\r
+ return templateName;\r
+ }\r
+\r
+ public boolean isOverwrite() {\r
+ return overwrite;\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright 2004-2008 the Seasar Foundation and the Others.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, \r
+ * either express or implied. See the License for the specific language\r
+ * governing permissions and limitations under the License.\r
+ */\r
+package org.seasar.extension.jdbc.gen.internal.generator;\r
+\r
+import java.io.BufferedWriter;\r
+import java.io.File;\r
+import java.io.FileOutputStream;\r
+import java.io.IOException;\r
+import java.io.OutputStreamWriter;\r
+import java.io.Writer;\r
+import java.nio.charset.Charset;\r
+import java.util.Locale;\r
+\r
+import org.seasar.extension.jdbc.gen.generator.GenerationContext;\r
+import org.seasar.extension.jdbc.gen.generator.Generator;\r
+import org.seasar.extension.jdbc.gen.internal.exception.TemplateRuntimeException;\r
+import org.seasar.extension.jdbc.gen.internal.util.CloseableUtil;\r
+import org.seasar.framework.exception.IORuntimeException;\r
+import org.seasar.framework.log.Logger;\r
+import org.seasar.framework.util.FileOutputStreamUtil;\r
+\r
+import freemarker.cache.FileTemplateLoader;\r
+import freemarker.cache.MultiTemplateLoader;\r
+import freemarker.cache.TemplateLoader;\r
+import freemarker.template.Configuration;\r
+import freemarker.template.DefaultObjectWrapper;\r
+import freemarker.template.Template;\r
+import freemarker.template.TemplateException;\r
+\r
+/**\r
+ * {@link Generator}の実装クラスです。\r
+ * <p>\r
+ * テンプレートエンジンのFreeMarkerを利用します。\r
+ * <p>\r
+ * \r
+ * @author taedium\r
+ */\r
+public class GeneratorImpl implements Generator {\r
+\r
+ /** ロガー */\r
+ protected static Logger logger = Logger.getLogger(GeneratorImpl.class);\r
+\r
+ /** デフォルトのテンプレートディレクトリの名前 */\r
+ protected static String DEFAULT_TEMPLATE_DIR_NAME = "org/seasar/extension/jdbc/gen/internal/generator/tempaltes";\r
+\r
+ /** FreeMarkerの設定 */\r
+ protected Configuration configuration;\r
+\r
+ /**\r
+ * インスタンスを構築します。\r
+ * \r
+ * @param configuration\r
+ * FreeMarkerの設定\r
+ */\r
+ public GeneratorImpl(Configuration configuration) {\r
+ if (configuration == null) {\r
+ throw new NullPointerException("configuration");\r
+ }\r
+ this.configuration = configuration;\r
+ }\r
+\r
+ /**\r
+ * インスタンスを構築します。\r
+ * \r
+ * @param templateFileEncoding\r
+ * テンプレートファイルのエンコーディング\r
+ * @param templateFilePrimaryDir\r
+ * テンプレートファイルを格納したプライマリディレクトリ、プライマリディレクトリを使用しない場合{@code null}\r
+ */\r
+ public GeneratorImpl(String templateFileEncoding,\r
+ File templateFilePrimaryDir) {\r
+ if (templateFileEncoding == null) {\r
+ throw new NullPointerException("templateFileEncoding");\r
+ }\r
+ this.configuration = new Configuration();\r
+ configuration.setObjectWrapper(new DefaultObjectWrapper());\r
+ configuration.setSharedVariable("include", new IncludeDirective());\r
+ configuration.setEncoding(Locale.getDefault(), templateFileEncoding);\r
+ configuration.setNumberFormat("0.#####");\r
+ configuration\r
+ .setTemplateLoader(createTemplateLoader(templateFilePrimaryDir));\r
+ }\r
+\r
+ /**\r
+ * {@link TemplateLoader}を作成します。\r
+ * \r
+ * @param templateFilePrimaryDir\r
+ * テンプレートファイルを格納したプライマリディレクトリ、プライマリディレクトリを使用しない場合{@code null}\r
+ * @return {@link TemplateLoader}\r
+ */\r
+ protected TemplateLoader createTemplateLoader(File templateFilePrimaryDir) {\r
+ TemplateLoader primary = null;\r
+ if (templateFilePrimaryDir != null) {\r
+ try {\r
+ primary = new FileTemplateLoader(templateFilePrimaryDir);\r
+ } catch (IOException e) {\r
+ throw new IORuntimeException(e);\r
+ }\r
+ }\r
+ TemplateLoader secondary = new ResourceTemplateLoader(\r
+ DEFAULT_TEMPLATE_DIR_NAME);\r
+ if (primary == null) {\r
+ return secondary;\r
+ }\r
+ return new MultiTemplateLoader(new TemplateLoader[] { primary,\r
+ secondary });\r
+ }\r
+\r
+ public void generate(GenerationContext context) {\r
+ boolean exists = exists(context.getFile());\r
+ if (!context.isOverwrite() && exists) {\r
+ return;\r
+ }\r
+ File dir = context.getFile().getParentFile();\r
+ if (dir != null) {\r
+ mkdirs(dir);\r
+ }\r
+ Writer writer = openWriter(context);\r
+ try {\r
+ Template template = getTemplate(context.getTemplateName());\r
+ process(template, context.getModel(), writer);\r
+ if (exists) {\r
+ logger.log("DS2JDBCGen0009", new Object[] { context.getFile()\r
+ .getPath() });\r
+ } else {\r
+ logger.log("DS2JDBCGen0002", new Object[] { context.getFile()\r
+ .getPath() });\r
+ }\r
+ } finally {\r
+ CloseableUtil.close(writer);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * {@code file}が存在する場合に{@code true}を返します。\r
+ * \r
+ * @param file\r
+ * ファイル\r
+ * @return {@code file}が存在する場合は{@code true}、そうでない場合は{@code false}\r
+ */\r
+ protected boolean exists(File file) {\r
+ return file.exists();\r
+ }\r
+\r
+ /**\r
+ * ディレクトリを生成します。\r
+ * \r
+ * @param dir\r
+ * ディレクトリ\r
+ */\r
+ protected void mkdirs(File dir) {\r
+ dir.mkdirs();\r
+ }\r
+\r
+ /**\r
+ * {@link Writer}を開きます。\r
+ * \r
+ * @param context\r
+ * コンテキスト\r
+ * @return {@link Writer}\r
+ */\r
+ protected Writer openWriter(GenerationContext context) {\r
+ Charset charset = Charset.forName(context.getEncoding());\r
+ FileOutputStream fos = FileOutputStreamUtil.create(context.getFile());\r
+ OutputStreamWriter osw = new OutputStreamWriter(fos, charset);\r
+ return new BufferedWriter(osw);\r
+ }\r
+\r
+ /**\r
+ * テンプレートを取得します。\r
+ * \r
+ * @param name\r
+ * テンプレートの名前\r
+ * @return テンプレート\r
+ */\r
+ protected Template getTemplate(String name) {\r
+ try {\r
+ return configuration.getTemplate(name);\r
+ } catch (IOException e) {\r
+ throw new IORuntimeException(e);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * テンプレートを処理します。\r
+ * \r
+ * @param template\r
+ * テンプレート\r
+ * @param dataModel\r
+ * データモデル\r
+ * @param writer\r
+ * ライタ\r
+ */\r
+ protected void process(Template template, Object dataModel, Writer writer) {\r
+ try {\r
+ template.process(dataModel, writer);\r
+ } catch (IOException e) {\r
+ throw new IORuntimeException(e);\r
+ } catch (TemplateException e) {\r
+ throw new TemplateRuntimeException(e);\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright 2004-2008 the Seasar Foundation and the Others.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, \r
+ * either express or implied. See the License for the specific language\r
+ * governing permissions and limitations under the License.\r
+ */\r
+package org.seasar.extension.jdbc.gen.internal.generator;\r
+\r
+import java.io.IOException;\r
+import java.util.Map;\r
+\r
+import freemarker.core.Environment;\r
+import freemarker.template.SimpleScalar;\r
+import freemarker.template.Template;\r
+import freemarker.template.TemplateDirectiveBody;\r
+import freemarker.template.TemplateDirectiveModel;\r
+import freemarker.template.TemplateException;\r
+import freemarker.template.TemplateModel;\r
+\r
+/**\r
+ * インクルードのディレクティブです。\r
+ * <p>\r
+ * インクルード先のテンプレートで任意のオブジェクトをルートのデータモデルに指定できます。\r
+ * </p>\r
+ * \r
+ * @author taedium\r
+ */\r
+public class IncludeDirective implements TemplateDirectiveModel {\r
+\r
+ /** インクルードするテンプレート名のパラメータ名 */\r
+ protected static final String PARAM_NAME = "name";\r
+\r
+ /** ルートモデルのパラメータ名 */\r
+ protected static final String PARAM_ROOT_MODEL = "rootModel";\r
+\r
+ public void execute(Environment env,\r
+ @SuppressWarnings("unchecked") Map params,\r
+ TemplateModel[] loopVars, TemplateDirectiveBody body)\r
+ throws TemplateException, IOException {\r
+\r
+ Object name = params.get(PARAM_NAME);\r
+ if (name == null) {\r
+ throw new IllegalArgumentException("params[" + PARAM_NAME + "]");\r
+ }\r
+ if (!SimpleScalar.class.isInstance(name)) {\r
+ throw new IllegalArgumentException("params[" + PARAM_NAME + "]");\r
+ }\r
+\r
+ Object rootModel = params.get(PARAM_ROOT_MODEL);\r
+ if (rootModel == null) {\r
+ throw new IllegalArgumentException("params[" + PARAM_ROOT_MODEL\r
+ + "]");\r
+ }\r
+\r
+ Template template = env.getTemplateForInclusion(((SimpleScalar) name)\r
+ .getAsString(), null, true);\r
+ template.process(rootModel, env.getOut());\r
+ if (body != null) {\r
+ body.render(env.getOut());\r
+ }\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright 2004-2008 the Seasar Foundation and the Others.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, \r
+ * either express or implied. See the License for the specific language\r
+ * governing permissions and limitations under the License.\r
+ */\r
+package org.seasar.extension.jdbc.gen.internal.generator;\r
+\r
+import java.net.URL;\r
+\r
+import org.seasar.framework.util.ResourceUtil;\r
+\r
+import freemarker.cache.TemplateLoader;\r
+import freemarker.cache.URLTemplateLoader;\r
+\r
+/**\r
+ * リソースを扱う{@link TemplateLoader}の実装クラスです。\r
+ * <p>\r
+ * JARファイルに含まれたリソースを扱えます。\r
+ * </p>\r
+ * \r
+ * @author taedium\r
+ */\r
+public class ResourceTemplateLoader extends URLTemplateLoader {\r
+\r
+ /** ベースとなるパス */\r
+ protected String basePath;\r
+\r
+ /**\r
+ * インスタンスを構築します。\r
+ * \r
+ * @param basePath\r
+ * ベースとなるパス\r
+ */\r
+ public ResourceTemplateLoader(String basePath) {\r
+ if (basePath == null) {\r
+ throw new NullPointerException("basePath");\r
+ }\r
+ this.basePath = basePath;\r
+ }\r
+\r
+ @Override\r
+ protected URL getURL(String name) {\r
+ String path = basePath + "/" + name;\r
+ return ResourceUtil.getResourceNoException(path);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright 2004-2008 the Seasar Foundation and the Others.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, \r
+ * either express or implied. See the License for the specific language\r
+ * governing permissions and limitations under the License.\r
+ */\r
+package org.seasar.extension.jdbc.gen.internal.util;\r
+\r
+import java.io.Closeable;\r
+import java.io.IOException;\r
+\r
+import org.seasar.framework.log.Logger;\r
+\r
+/**\r
+ * {@link Closeable}のユーティリティクラスです。\r
+ * \r
+ * @author taedium\r
+ */\r
+public class CloseableUtil {\r
+\r
+ /** ロガー */\r
+ protected static Logger logger = Logger.getLogger(Closeable.class);\r
+\r
+ /**\r
+ * \r
+ */\r
+ protected CloseableUtil() {\r
+ }\r
+\r
+ /**\r
+ * クローズします。\r
+ * \r
+ * @param closeable\r
+ * {@link Closeable}\r
+ */\r
+ public static void close(Closeable closeable) {\r
+ try {\r
+ if (closeable != null) {\r
+ closeable.close();\r
+ }\r
+ } catch (IOException ignore) {\r
+ logger.log(ignore);\r
+ }\r
+ }\r
+}\r