[Jiemamy-notify] commit [1967] [COM-3] 少しだけ書いたので一旦コミット。

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2008年 9月 28日 (日) 16:20:06 JST


Revision: 1967
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=jiemamy&view=rev&rev=1967
Author:   ewigkeit1204
Date:     2008-09-28 16:20:06 +0900 (Sun, 28 Sep 2008)

Log Message:
-----------
[COM-3] 少しだけ書いたので一旦コミット。

Added Paths:
-----------
    artemis/trunk/org.jiemamy.composer/src/main/java/org/jiemamy/composer/exporter/HtmlExporter.java


-------------- next part --------------
Added: artemis/trunk/org.jiemamy.composer/src/main/java/org/jiemamy/composer/exporter/HtmlExporter.java
===================================================================
--- artemis/trunk/org.jiemamy.composer/src/main/java/org/jiemamy/composer/exporter/HtmlExporter.java	                        (rev 0)
+++ artemis/trunk/org.jiemamy.composer/src/main/java/org/jiemamy/composer/exporter/HtmlExporter.java	2008-09-28 07:20:06 UTC (rev 1967)
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. Created on 2008/09/28
+ * 
+ * This file is part of Jiemamy.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
+ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+package org.jiemamy.composer.exporter;
+
+import java.io.File;
+
+import org.jiemamy.spec.exception.ExportException;
+import org.jiemamy.spec.extension.composer.ExportContext;
+import org.jiemamy.spec.extension.composer.Exporter;
+import org.jiemamy.spec.model.RootModel;
+
+/**
+ * モデルからHTML仕様書を生成するエクスポータ。
+ * 
+ * @author Keisuke.K
+ */
+public class HtmlExporter implements Exporter {
+	
+	/** ContextKey: オーバーライトするかどうか (Boolean) */
+	public static final String OVERWRITE = "overwrite";
+	
+	/** ContextKey: 出力先ディレクトリ (File) */
+	public static final String OUTPUT_DIR = "outputDir";
+	
+	/** ContextKey: SQL方言 (Dialect) */
+	public static final String DIALECT = "dialect";
+	
+
+	/**
+	 * {@inheritDoc}
+	 */
+	public boolean export(RootModel rootModel, ExportContext ctx) throws ExportException {
+		File outputDir = ctx.getValue(OUTPUT_DIR);
+		if (outputDir.exists()) {
+			if (Boolean.FALSE.equals(ctx.getValue(OVERWRITE))) {
+				return false;
+			}
+			
+			deleteDirectory(outputDir);
+		}
+		
+		if (!outputDir.mkdir()) {
+			throw new ExportException("Cannot create directory: " + outputDir.getAbsolutePath());
+		}
+		
+		// TODO
+		
+		return true;
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	public String getName() {
+		return "HTML Exporter";
+	}
+	
+	private void deleteDirectory(File directory) throws ExportException {
+		for (File file : directory.listFiles()) {
+			if (file.isDirectory()) {
+				deleteDirectory(file);
+			} else {
+				if (!file.delete()) {
+					throw new ExportException("Cannot delete file: " + file.getAbsolutePath());
+				}
+			}
+		}
+		
+		if (!directory.delete()) {
+			throw new ExportException("Cannot delete directory: " + directory.getAbsolutePath());
+		}
+	}
+	
+}


Property changes on: artemis/trunk/org.jiemamy.composer/src/main/java/org/jiemamy/composer/exporter/HtmlExporter.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain


Jiemamy-notify メーリングリストの案内
Back to archive index