svnno****@sourc*****
svnno****@sourc*****
2008年 9月 11日 (木) 17:51:15 JST
Revision: 1912 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=jiemamy&view=rev&rev=1912 Author: daisuke_m Date: 2008-09-11 17:51:14 +0900 (Thu, 11 Sep 2008) Log Message: ----------- Dialectインスタンスの構成方法(インタフェイス)を整備。コンストラクタからprotectedのsetterに変更。 Modified Paths: -------------- artemis/trunk/org.jiemamy.dialect/src/main/java/org/jiemamy/dialect/AbstractDialect.java artemis/trunk/org.jiemamy.dialect.mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlDialect.java artemis/trunk/org.jiemamy.dialect.mysql/src/main/resources/jiemamy-dialect-mysql.dicon artemis/trunk/org.jiemamy.dialect.postgresql/src/main/java/org/jiemamy/dialect/postgresql/PostgresqlDialect.java artemis/trunk/org.jiemamy.dialect.sql99/src/main/java/org/jiemamy/dialect/sql99/Sql99Dialect.java Added Paths: ----------- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/extension/dialect/parser/DefaultModelParser.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/extension/dialect/validator/DefaultIdentifierValidator.java -------------- next part -------------- Added: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/extension/dialect/parser/DefaultModelParser.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/extension/dialect/parser/DefaultModelParser.java (rev 0) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/extension/dialect/parser/DefaultModelParser.java 2008-09-11 08:51:14 UTC (rev 1912) @@ -0,0 +1,37 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/09/11 + * + * 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.core.extension.dialect.parser; + +import org.jiemamy.core.model.RootModel; + +/** + * {@link ModelParser}のデフォルト実装。 + * @author daisuke + */ +public class DefaultModelParser implements ModelParser { + + /** + * {@inheritDoc} + */ + public String parse(RootModel rootModel) { + // TODO きちんとした実装をする。 + return "result of DefaultModelParser"; + } + +} Property changes on: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/extension/dialect/parser/DefaultModelParser.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/extension/dialect/validator/DefaultIdentifierValidator.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/extension/dialect/validator/DefaultIdentifierValidator.java (rev 0) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/extension/dialect/validator/DefaultIdentifierValidator.java 2008-09-11 08:51:14 UTC (rev 1912) @@ -0,0 +1,34 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/09/11 + * + * 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.core.extension.dialect.validator; + +/** + * {@link IdentifierValidator}のデフォルト実装。全て通す。 + * @author daisuke + */ +public class DefaultIdentifierValidator implements IdentifierValidator { + + /** + * {@inheritDoc} + */ + public boolean validate(String word) { + return true; + } + +} Property changes on: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/extension/dialect/validator/DefaultIdentifierValidator.java ___________________________________________________________________ Name: svn:mime-type + text/plain Modified: artemis/trunk/org.jiemamy.dialect/src/main/java/org/jiemamy/dialect/AbstractDialect.java =================================================================== --- artemis/trunk/org.jiemamy.dialect/src/main/java/org/jiemamy/dialect/AbstractDialect.java 2008-09-11 05:18:22 UTC (rev 1911) +++ artemis/trunk/org.jiemamy.dialect/src/main/java/org/jiemamy/dialect/AbstractDialect.java 2008-09-11 08:51:14 UTC (rev 1912) @@ -34,8 +34,10 @@ import org.jiemamy.core.extension.dialect.advisor.DefaultConnectionAdvisor; import org.jiemamy.core.extension.dialect.mapping.DataTypeMapping; import org.jiemamy.core.extension.dialect.mapping.SpecialDataTypeMapping; +import org.jiemamy.core.extension.dialect.parser.DefaultModelParser; import org.jiemamy.core.extension.dialect.parser.ModelParser; import org.jiemamy.core.extension.dialect.quoter.Quoter; +import org.jiemamy.core.extension.dialect.validator.DefaultIdentifierValidator; import org.jiemamy.core.extension.dialect.validator.IdentifierValidator; import org.jiemamy.core.model.RootModel; import org.jiemamy.core.model.node.AbstractEntityModel; @@ -60,44 +62,23 @@ */ public abstract class AbstractDialect implements Dialect { + /** {@link DataTypeMapping} */ private SpecialDataTypeMapping dataTypeMapping = new SpecialDataTypeMapping(this); - private Quoter quoter; + /** {@link ModelParser} */ + private ModelParser parser = new DefaultModelParser(); - private IdentifierValidator validator; + /** {@link Quoter} */ + private Quoter quoter = new DefaultQuoter(); + /** {@link IdentifierValidator} */ + private IdentifierValidator validator = new DefaultIdentifierValidator(); + + /** {@link ConnectionAdvisor} */ private ConnectionAdvisor advisor = new DefaultConnectionAdvisor(); /** - * コンストラクタ。 - * @param validator - * @category instance creation - */ - protected AbstractDialect(IdentifierValidator validator) { - this(validator, new DefaultQuoter()); - } - - /** - * コンストラクタ。 - * @param validator - * @param quoter - * @category instance creation - */ - protected AbstractDialect(IdentifierValidator validator, Quoter quoter) { - this.validator = validator; - this.quoter = quoter; - } - - /** - * コンストラクタ。 - * <p>for test</p> - * @category instance creation - */ - AbstractDialect() { - } - - /** * {@inheritDoc} */ public AbstractEntityModel createEntity(RootModel rootModel, ResultSet entity, Connection connection) @@ -113,36 +94,40 @@ } /** - * {@inheritDoc} + * {@link ConnectionAdvisor}を取得する。 + * @return {@link ConnectionAdvisor} */ public ConnectionAdvisor getAdvisor() { return advisor; } /** - * {@inheritDoc} + * {@link DataTypeMapping}を取得する。 + * @return {@link DataTypeMapping} */ public DataTypeMapping getDataTypeMapping() { return dataTypeMapping; } /** - * {@inheritDoc} + * {@link ModelParser}を取得する。 + * @return {@link ModelParser} */ public ModelParser getParser() { - // GenericDialectはSQLの出力に対応しない。 - throw new UnsupportedOperationException(); + return parser; } /** - * {@inheritDoc} + * {@link Quoter}を取得する。 + * @return {@link Quoter} */ public Quoter getQuoter() { return quoter; } /** - * {@inheritDoc} + * {@link IdentifierValidator}を取得する。 + * @return {@link IdentifierValidator} */ public IdentifierValidator getValidator() { return validator; @@ -157,6 +142,46 @@ } /** + * {@link ConnectionAdvisor}を設定する。 + * @param advisor {@link ConnectionAdvisor} + */ + protected void setAdvisor(ConnectionAdvisor advisor) { + this.advisor = advisor; + } + + /** + * {@link DataTypeMapping}を設定する。 + * @param dataTypeMapping {@link DataTypeMapping} + */ + protected void setDataTypeMapping(SpecialDataTypeMapping dataTypeMapping) { + this.dataTypeMapping = dataTypeMapping; + } + + /** + * {@link ModelParser}を設定する。 + * @param parser {@link ModelParser} + */ + protected void setParser(ModelParser parser) { + this.parser = parser; + } + + /** + * {@link Quoter}を設定する。 + * @param quoter {@link Quoter} + */ + protected void setQuoter(Quoter quoter) { + this.quoter = quoter; + } + + /** + * {@link IdentifierValidator}を設定する。 + * @param validator {@link IdentifierValidator} + */ + protected void setValidator(IdentifierValidator validator) { + this.validator = validator; + } + + /** * {@link DatabaseMetaData}から得られた結果を読み込み、{@link TableModel}を生成する。 * @param rootModel * @param tableName 読み込み対象テーブル名 Modified: artemis/trunk/org.jiemamy.dialect.mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlDialect.java =================================================================== --- artemis/trunk/org.jiemamy.dialect.mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlDialect.java 2008-09-11 05:18:22 UTC (rev 1911) +++ artemis/trunk/org.jiemamy.dialect.mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlDialect.java 2008-09-11 08:51:14 UTC (rev 1912) @@ -18,7 +18,6 @@ */ package org.jiemamy.dialect.mysql; -import org.jiemamy.core.extension.dialect.parser.ModelParser; import org.jiemamy.dialect.AbstractDialect; import org.jiemamy.dialect.mysql.datatype.IntegerDataType; import org.jiemamy.dialect.mysql.parser.MySqlModelParser; @@ -29,26 +28,14 @@ */ public class MySqlDialect extends AbstractDialect { - // FIXME DIしたい。 - /** モデルパーサ */ - public ModelParser parser = new MySqlModelParser(); - - /** * コンストラクタ。 * @category instance creation */ public MySqlDialect() { - super(new MySqlIdentifierValidator()); + setParser(new MySqlModelParser()); + setValidator(new MySqlIdentifierValidator()); registerDataType(IntegerDataType.class); } - - /** - * {@inheritDoc} - */ - @Override - public ModelParser getParser() { - return parser; - } } Modified: artemis/trunk/org.jiemamy.dialect.mysql/src/main/resources/jiemamy-dialect-mysql.dicon =================================================================== --- artemis/trunk/org.jiemamy.dialect.mysql/src/main/resources/jiemamy-dialect-mysql.dicon 2008-09-11 05:18:22 UTC (rev 1911) +++ artemis/trunk/org.jiemamy.dialect.mysql/src/main/resources/jiemamy-dialect-mysql.dicon 2008-09-11 08:51:14 UTC (rev 1912) @@ -4,9 +4,4 @@ <components> <include path="jiemamy-core.dicon"/> <include path="jiemamy-dialect.dicon"/> - <component class="org.jiemamy.dialect.mysql.MySqlDialect"> - <property name="parser"> - <component class="org.jiemamy.dialect.mysql.parser.MySqlModelParser"/> - </property> - </component> </components> Modified: artemis/trunk/org.jiemamy.dialect.postgresql/src/main/java/org/jiemamy/dialect/postgresql/PostgresqlDialect.java =================================================================== --- artemis/trunk/org.jiemamy.dialect.postgresql/src/main/java/org/jiemamy/dialect/postgresql/PostgresqlDialect.java 2008-09-11 05:18:22 UTC (rev 1911) +++ artemis/trunk/org.jiemamy.dialect.postgresql/src/main/java/org/jiemamy/dialect/postgresql/PostgresqlDialect.java 2008-09-11 08:51:14 UTC (rev 1912) @@ -55,7 +55,9 @@ * @category instance creation */ public PostgresqlDialect() { - super(new PostgresqlIdentifierValidator(), new PostgresqlQuoter()); + setValidator(new PostgresqlIdentifierValidator()); + setQuoter(new PostgresqlQuoter()); +// setParser(new PostgresqlParser()); registerDataType(IntegerDataType.class); registerDataType(SmallIntegerDataType.class); Modified: artemis/trunk/org.jiemamy.dialect.sql99/src/main/java/org/jiemamy/dialect/sql99/Sql99Dialect.java =================================================================== --- artemis/trunk/org.jiemamy.dialect.sql99/src/main/java/org/jiemamy/dialect/sql99/Sql99Dialect.java 2008-09-11 05:18:22 UTC (rev 1911) +++ artemis/trunk/org.jiemamy.dialect.sql99/src/main/java/org/jiemamy/dialect/sql99/Sql99Dialect.java 2008-09-11 08:51:14 UTC (rev 1912) @@ -39,7 +39,7 @@ * @category instance creation */ public Sql99Dialect() { - super(new Sql99IdentifierValidator()); + setValidator(new Sql99IdentifierValidator()); registerDataType(IntegerDataType.class); }