svnno****@sourc*****
svnno****@sourc*****
2009年 2月 12日 (木) 02:34:17 JST
Revision: 2653 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2653 Author: daisuke_m Date: 2009-02-12 02:34:17 +0900 (Thu, 12 Feb 2009) Log Message: ----------- refactor / javadoc Modified Paths: -------------- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/formatter/DefaultSqlFormatter.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/RootModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/ColumnModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/ColumnRefImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/CheckConstraintModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/ForeignKeyModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/NotNullConstraintModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/PrimaryKeyModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/UniqueKeyModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/dataset/DataSetModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/dataset/RecordModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/DomainModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/TableModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/TableRefImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/ViewModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Identifier.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Keyword.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Literal.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Operator.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Separator.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/SqlStatementImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/DomBuilder.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DomUtil.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/sql/SqlStatement.java Added Paths: ----------- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/formatter/package-info.java Removed Paths: ------------- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/XmlUtil.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/xml/Xml.java -------------- next part -------------- Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/formatter/DefaultSqlFormatter.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/formatter/DefaultSqlFormatter.java 2009-02-11 17:13:40 UTC (rev 2652) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/formatter/DefaultSqlFormatter.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -23,25 +23,26 @@ import org.jiemamy.model.sql.Token; /** - * TODO for daisuke + * 最も基本的なのSQLフォーマッタ。 * * @author daisuke */ public class DefaultSqlFormatter implements SqlFormatter { + /** 空白文字 */ + private static final String WHITESPACE = " "; + + private static boolean isSeparator(Token token) { - return token instanceof Separator; + return token == null || token instanceof Separator; } - /** - * {@inheritDoc} - */ public String format(SqlStatement stmt) { StringBuilder sb = new StringBuilder(); - Token lastToken = Separator.INITIAL; + Token lastToken = null; for (Token token : stmt.toTokens()) { - if (lastToken.equals(Separator.COMMA) || (isSeparator(lastToken) == false && isSeparator(token) == false)) { - sb.append(" "); + if ((isSeparator(lastToken) == false && isSeparator(token) == false) || lastToken.equals(Separator.COMMA)) { + sb.append(WHITESPACE); } sb.append(token); lastToken = token; Added: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/formatter/package-info.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/formatter/package-info.java (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/formatter/package-info.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -0,0 +1,7 @@ +/** + * Jiemamyモデルの「SQL文」をStringにフォーマットする機能を提供するパッケージ。 + * + * @author daisuke + */ +package org.jiemamy.formatter; + Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/formatter/package-info.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/RootModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/RootModelImpl.java 2009-02-11 17:13:40 UTC (rev 2652) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/RootModelImpl.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -32,15 +32,12 @@ import org.jiemamy.model.datatype.DomainModel; import org.jiemamy.model.entity.EntityModel; import org.jiemamy.utils.ValidateUtil; -import org.jiemamy.xml.CoreQName; -import org.jiemamy.xml.Xml; /** * 1つのDBスキーマ・データ全体を表す。 * @author daisuke */ @SuppressWarnings("serial") - @ Xml(CoreQName.ROOT_MODEL) public class RootModelImpl extends AbstractJiemamyElement implements RootModel { /** SQL方言ID */ Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/ColumnModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/ColumnModelImpl.java 2009-02-11 17:13:40 UTC (rev 2652) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/ColumnModelImpl.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -26,8 +26,6 @@ import org.jiemamy.Jiemamy; import org.jiemamy.model.datatype.DataType; import org.jiemamy.model.datatype.DomainModel; -import org.jiemamy.xml.CoreQName; -import org.jiemamy.xml.Xml; /** * カラム定義モデル。Artemisにおける{@link ColumnModel}の実装クラス。 @@ -35,7 +33,6 @@ * @author daisuke */ @SuppressWarnings("serial") - @ Xml(CoreQName.COLUMN) public class ColumnModelImpl extends AbstractAttributeModel implements ColumnModel { /** 型記述子 */ Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/ColumnRefImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/ColumnRefImpl.java 2009-02-11 17:13:40 UTC (rev 2652) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/ColumnRefImpl.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -22,15 +22,12 @@ import org.jiemamy.Jiemamy; import org.jiemamy.model.ElementReferenceImpl; -import org.jiemamy.xml.CoreQName; -import org.jiemamy.xml.Xml; /** * {@link ColumnModel}に対する参照オブジェクトの実装。Artemisにおける{@link ColumnRef}の実装クラス。 * * @author daisuke */ - @ Xml(CoreQName.COLUMN_REF) public class ColumnRefImpl extends ElementReferenceImpl<ColumnModel> implements ColumnRef { /** Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/CheckConstraintModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/CheckConstraintModelImpl.java 2009-02-11 17:13:40 UTC (rev 2652) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/CheckConstraintModelImpl.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -21,8 +21,6 @@ import java.util.UUID; import org.jiemamy.Jiemamy; -import org.jiemamy.xml.CoreQName; -import org.jiemamy.xml.Xml; /** * チェック制約モデル。 @@ -30,7 +28,6 @@ * @author daisuke */ @SuppressWarnings("serial") - @ Xml(CoreQName.CHECK_CONSTRAINT) public class CheckConstraintModelImpl extends AbstractConstraintModel implements CheckConstraintModel { /** CHEKC制約定義式 */ Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/ForeignKeyModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/ForeignKeyModelImpl.java 2009-02-11 17:13:40 UTC (rev 2652) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/ForeignKeyModelImpl.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -23,8 +23,6 @@ import org.jiemamy.Jiemamy; import org.jiemamy.model.attribute.ColumnRef; -import org.jiemamy.xml.CoreQName; -import org.jiemamy.xml.Xml; /** * 外部キーモデル。 @@ -36,7 +34,6 @@ * @author daisuke */ @SuppressWarnings("serial") - @ Xml(CoreQName.FOREIGN_KEY) public class ForeignKeyModelImpl extends AbstractKeyConstraintModel implements ForeignKeyModel { /** マッチ型 */ Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/NotNullConstraintModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/NotNullConstraintModelImpl.java 2009-02-11 17:13:40 UTC (rev 2652) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/NotNullConstraintModelImpl.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -22,15 +22,12 @@ import org.jiemamy.Jiemamy; import org.jiemamy.model.attribute.ColumnRef; -import org.jiemamy.xml.CoreQName; -import org.jiemamy.xml.Xml; /** * NOT NULL制約モデル。 * * @author daisuke */ - @ Xml(CoreQName.NOT_NULL) public class NotNullConstraintModelImpl extends AbstractConstraintModel implements NotNullConstraintModel { private ColumnRef column; Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/PrimaryKeyModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/PrimaryKeyModelImpl.java 2009-02-11 17:13:40 UTC (rev 2652) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/PrimaryKeyModelImpl.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -21,15 +21,12 @@ import java.util.UUID; import org.jiemamy.Jiemamy; -import org.jiemamy.xml.CoreQName; -import org.jiemamy.xml.Xml; /** * PRIMARY KEY制約モデル。 * @author daisuke */ @SuppressWarnings("serial") - @ Xml(CoreQName.PRIMARY_KEY) public class PrimaryKeyModelImpl extends AbstractKeyConstraintModel implements PrimaryKeyModel { /** Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/UniqueKeyModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/UniqueKeyModelImpl.java 2009-02-11 17:13:40 UTC (rev 2652) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/UniqueKeyModelImpl.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -21,15 +21,12 @@ import java.util.UUID; import org.jiemamy.Jiemamy; -import org.jiemamy.xml.CoreQName; -import org.jiemamy.xml.Xml; /** * UNIQUE制約モデル。 * @author daisuke */ @SuppressWarnings("serial") - @ Xml(CoreQName.UNIQUE_KEY) public class UniqueKeyModelImpl extends AbstractKeyConstraintModel implements UniqueKeyModel { /** Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/dataset/DataSetModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/dataset/DataSetModelImpl.java 2009-02-11 17:13:40 UTC (rev 2652) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/dataset/DataSetModelImpl.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -28,15 +28,12 @@ import org.jiemamy.Jiemamy; import org.jiemamy.model.AbstractJiemamyElement; import org.jiemamy.model.entity.TableRef; -import org.jiemamy.xml.CoreQName; -import org.jiemamy.xml.Xml; /** * INSERT文用データセット。 * @author daisuke */ @SuppressWarnings("serial") - @ Xml(CoreQName.DATASETS) public class DataSetModelImpl extends AbstractJiemamyElement implements DataSetModel { /** データセット名 */ Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/dataset/RecordModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/dataset/RecordModelImpl.java 2009-02-11 17:13:40 UTC (rev 2652) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/dataset/RecordModelImpl.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -27,15 +27,12 @@ import org.jiemamy.Jiemamy; import org.jiemamy.model.AbstractJiemamyElement; import org.jiemamy.model.attribute.ColumnRef; -import org.jiemamy.xml.CoreQName; -import org.jiemamy.xml.Xml; /** * レコード(INSERT文1つ分)モデル。 * @author daisuke */ @SuppressWarnings("serial") - @ Xml(CoreQName.RECORD) public class RecordModelImpl extends AbstractJiemamyElement implements RecordModel { /** Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/DomainModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/DomainModelImpl.java 2009-02-11 17:13:40 UTC (rev 2652) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/DomainModelImpl.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -26,8 +26,6 @@ import org.jiemamy.Jiemamy; import org.jiemamy.model.AbstractJiemamyElement; import org.jiemamy.model.attribute.constraint.ValueConstraintModel; -import org.jiemamy.xml.CoreQName; -import org.jiemamy.xml.Xml; /** * ドメイン定義モデル。 @@ -35,7 +33,6 @@ * @author daisuke */ @SuppressWarnings("serial") - @ Xml(CoreQName.DOMAIN) public class DomainModelImpl extends AbstractJiemamyElement implements DomainModel { /** ドメイン名 */ Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/TableModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/TableModelImpl.java 2009-02-11 17:13:40 UTC (rev 2652) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/TableModelImpl.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -26,8 +26,6 @@ import org.jiemamy.Jiemamy; import org.jiemamy.model.attribute.AttributeModel; import org.jiemamy.model.index.IndexModel; -import org.jiemamy.xml.CoreQName; -import org.jiemamy.xml.Xml; /** * テーブルモデル。 @@ -35,7 +33,6 @@ * @author daisuke */ @SuppressWarnings("serial") - @ Xml(CoreQName.TABLE) public class TableModelImpl extends AbstractEntityModel implements TableModel { /** 属性のリスト */ Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/TableRefImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/TableRefImpl.java 2009-02-11 17:13:40 UTC (rev 2652) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/TableRefImpl.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -22,15 +22,12 @@ import org.jiemamy.Jiemamy; import org.jiemamy.model.ElementReferenceImpl; -import org.jiemamy.xml.CoreQName; -import org.jiemamy.xml.Xml; /** * {@link TableModel}に対する参照オブジェクトの実装。Artemisにおける{@link TableRef}の実装クラス。 * * @author daisuke */ - @ Xml(CoreQName.TABLE_REF) public class TableRefImpl extends ElementReferenceImpl<TableModel> implements TableRef { /** Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/ViewModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/ViewModelImpl.java 2009-02-11 17:13:40 UTC (rev 2652) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/ViewModelImpl.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -21,8 +21,6 @@ import java.util.UUID; import org.jiemamy.Jiemamy; -import org.jiemamy.xml.CoreQName; -import org.jiemamy.xml.Xml; /** * ビューモデル @@ -30,7 +28,6 @@ * @author daisuke */ @SuppressWarnings("serial") - @ Xml(CoreQName.VIEW) public class ViewModelImpl extends AbstractEntityModel implements ViewModel { /** VIEW定義SELECT文 */ Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Identifier.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Identifier.java 2009-02-11 17:13:40 UTC (rev 2652) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Identifier.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -19,7 +19,7 @@ package org.jiemamy.model.sql; /** - * TODO for daisuke + * 識別子クラス。 * * @author daisuke */ Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Keyword.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Keyword.java 2009-02-11 17:13:40 UTC (rev 2652) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Keyword.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -19,7 +19,7 @@ package org.jiemamy.model.sql; /** - * TODO for daisuke + * キーワードクラス。 * * @author daisuke */ Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Literal.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Literal.java 2009-02-11 17:13:40 UTC (rev 2652) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Literal.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -23,7 +23,7 @@ import org.jiemamy.model.datatype.LiteralType; /** - * TODO for daisuke + * リテラルクラス。 * * @author daisuke */ Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Operator.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Operator.java 2009-02-11 17:13:40 UTC (rev 2652) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Operator.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -21,14 +21,16 @@ import org.apache.commons.lang.Validate; /** - * TODO for daisuke + * 演算子クラス。 * * @author daisuke */ public class Operator implements Token { + /** IS 演算子 */ public static final Operator IS = new Operator("IS"); + /** NOT 演算子 */ public static final Operator NOT = new Operator("NOT"); private final String string; Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Separator.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Separator.java 2009-02-11 17:13:40 UTC (rev 2652) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Separator.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -19,7 +19,7 @@ package org.jiemamy.model.sql; /** - * TODO for daisuke + * 区切りトークンを表す列挙型。 * * @author daisuke */ @@ -35,10 +35,7 @@ LEFT_PAREN("("), /** 右括弧 */ - RIGHT_PAREN(")"), - - /** 初期状態 */ - INITIAL(""); + RIGHT_PAREN(")"); private final String string; Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/SqlStatementImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/SqlStatementImpl.java 2009-02-11 17:13:40 UTC (rev 2652) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/SqlStatementImpl.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -30,8 +30,7 @@ */ public class SqlStatementImpl implements SqlStatement { - // FIXME とりあえずStringでの意味無し実装。SQLを上手くモデル化できれば、という希望…。 - + /** トークンのリスト */ private List<Token> tokens = CollectionsUtil.newArrayList(); @@ -60,13 +59,6 @@ tokens.add(token); } - public List<Token> toTokens() { - return CollectionsUtil.newArrayList(tokens); - } - - /** - * {@inheritDoc} - */ @Override public String toString() { return toString(new DefaultSqlFormatter()); @@ -75,4 +67,8 @@ public String toString(SqlFormatter formatter) { return formatter.format(this); } + + public List<Token> toTokens() { + return CollectionsUtil.newArrayList(tokens); + } } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/DomBuilder.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/DomBuilder.java 2009-02-11 17:13:40 UTC (rev 2652) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/DomBuilder.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -18,7 +18,6 @@ */ package org.jiemamy.serializer; -import static org.jiemamy.utils.XmlUtil.getQName; import static org.jiemamy.xml.CoreQName.ADAPTER; import static org.jiemamy.xml.CoreQName.ATTRIBUTES; import static org.jiemamy.xml.CoreQName.BEGIN_SCRIPT; @@ -92,6 +91,8 @@ import org.jiemamy.model.attribute.constraint.ForeignKeyModel; import org.jiemamy.model.attribute.constraint.KeyConstraintModel; import org.jiemamy.model.attribute.constraint.NotNullConstraintModel; +import org.jiemamy.model.attribute.constraint.PrimaryKeyModel; +import org.jiemamy.model.attribute.constraint.UniqueKeyModel; import org.jiemamy.model.attribute.constraint.ValueConstraintModel; import org.jiemamy.model.dataset.DataSetModel; import org.jiemamy.model.dataset.RecordModel; @@ -109,6 +110,7 @@ import org.jiemamy.utils.model.TableUtil; import org.jiemamy.xml.CoreNamespace; import org.jiemamy.xml.CoreQName; +import org.jiemamy.xml.JiemamyQName; /** * {@link RootModel}からJiemamy XMLモデルのDOMを生成するクラス。 @@ -221,7 +223,7 @@ DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document document = documentBuilder.newDocument(); - Element rootElement = DomUtil.newElement(document, getQName(rootModel)); + Element rootElement = DomUtil.newElement(document, CoreQName.ROOT_MODEL); rootElement.setAttribute(CoreQName.ID.getQNameString(), rootModel.getId().toString()); rootElement.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); // FIXME locationを正式なURLに @@ -406,6 +408,24 @@ } } + private JiemamyQName getQName(AttributeModel attributeModel) { + if (attributeModel instanceof ColumnModel) { + return CoreQName.COLUMN; + } else if (attributeModel instanceof PrimaryKeyModel) { + return CoreQName.PRIMARY_KEY; + } else if (attributeModel instanceof UniqueKeyModel) { + return CoreQName.UNIQUE_KEY; + } else if (attributeModel instanceof ForeignKeyModel) { + return CoreQName.FOREIGN_KEY; + } else if (attributeModel instanceof NotNullConstraintModel) { + return CoreQName.NOT_NULL; + } else if (attributeModel instanceof CheckConstraintModel) { + return CoreQName.CHECK_CONSTRAINT; + } else { + return null; + } + } + /** * 出力レコードの並び順を、カラム定義順に合わせるコンパレータ。 Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DomUtil.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DomUtil.java 2009-02-11 17:13:40 UTC (rev 2652) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DomUtil.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -200,6 +200,17 @@ * @param qName 完全修飾要素名 * @return 生成された要素 */ + public static Element newElement(Document document, JiemamyQName qName) { + return newElement(document, qName.getQName()); + } + + /** + * 新しい要素を生成して返す。 + * + * @param document DOMドキュメント + * @param qName 完全修飾要素名 + * @return 生成された要素 + */ public static Element newElement(Document document, QName qName) { String prefix = StringUtils.isEmpty(qName.getPrefix()) ? "" : qName.getPrefix() + ":"; return document.createElementNS(qName.getNamespaceURI(), prefix + qName.getLocalPart()); Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/XmlUtil.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/XmlUtil.java 2009-02-11 17:13:40 UTC (rev 2652) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/XmlUtil.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -1,49 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/20 - * - * 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.utils; - -import javax.xml.namespace.QName; - -import org.jiemamy.xml.Xml; - -/** - * XMLを扱うユーティリティクラス。 - * - * @author daisuke - */ -public class XmlUtil { - - /** - * TODO for daisuke - * - * @param elem - * @return - */ - public static QName getQName(Object elem) { - Xml xmlAnnotation = elem.getClass().getAnnotation(Xml.class); - if (xmlAnnotation == null) { - // FIXME 適当にnull返してるw - return null; - } - return xmlAnnotation.value().getQName(); - } - - private XmlUtil() { - } -} Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/xml/Xml.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/xml/Xml.java 2009-02-11 17:13:40 UTC (rev 2652) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/xml/Xml.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -1,37 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/20 - * - * 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.xml; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * TODO for daisuke - * - * @author daisuke - */ - @ Retention(RetentionPolicy.RUNTIME) - @ Target(ElementType.TYPE) -public @interface Xml { - - CoreQName value(); - -} Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/sql/SqlStatement.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/sql/SqlStatement.java 2009-02-11 17:13:40 UTC (rev 2652) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/sql/SqlStatement.java 2009-02-11 17:34:17 UTC (rev 2653) @@ -31,13 +31,27 @@ */ public interface SqlStatement { - List<Token> toTokens(); - /** * SQL文に変換する。 + * + * <p>変換ロジックには、環境によって定められたデフォルトのロジックが用いられる。</p> + * * @return SQL文 */ String toString(); + /** + * 指定したフォーマッタを用いてSQL文に変換する。 + * + * @param formatter フォーマッタ + * @return SQL文 + */ String toString(SqlFormatter formatter); + + /** + * トークン列に変換する。 + * + * @return トークン列 + */ + List<Token> toTokens(); }