svnno****@sourc*****
svnno****@sourc*****
2008年 11月 10日 (月) 21:38:07 JST
Revision: 2125 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=jiemamy&view=rev&rev=2125 Author: ykhr Date: 2008-11-10 21:38:07 +0900 (Mon, 10 Nov 2008) Log Message: ----------- 一時的コミット2 Added Paths: ----------- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/ForeignKeyCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/ForeignKeyMappingCommand.java -------------- next part -------------- Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/ForeignKeyCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/ForeignKeyCommand.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/ForeignKeyCommand.java 2008-11-10 12:38:07 UTC (rev 2125) @@ -0,0 +1,139 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/11/09 + * + * 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.serializer.sax; + +import org.xml.sax.Attributes; + +import org.jiemamy.creator.JiemamyModelFactory; +import org.jiemamy.spec.model.JiemamyModel; +import org.jiemamy.spec.model.connection.ForeignKeyModel; +import org.jiemamy.spec.model.connection.ForeignKeyModel.InitiallyCheckTime; +import org.jiemamy.spec.model.connection.ForeignKeyModel.ReferentialAction; +import org.jiemamy.spec.model.node.AbstractNodeModel; + +/** + * foreignKey要素のコマンドクラス。 + * @author ykhr + */ +public class ForeignKeyCommand extends JiemamyModelCommand { + + /** + * {@inheritDoc} + */ + @Override + public void end(ModelInfo model, XmlElement element, String text) { +// super.end(model, element, text); + } + + /** + * {@inheritDoc} + */ + @Override + public void endChild(XmlElement element, ModelInfo model, String text) { + ForeignKeyModel foreignKeyModel = model.getForeignKeyModel(); + String elementName = element.getName(); + + if (elementName.equals("name")) { + foreignKeyModel.setName(text); + } else if (elementName.equals("logicalName")) { + foreignKeyModel.setLogicalName(text); + } else if (elementName.equals("onDelete")) { + ReferentialAction value = getEnumValue(ReferentialAction.class, text); + if (value != null) { + foreignKeyModel.setOnDelete(value); + } + } else if (elementName.equals("onUpdate")) { + ReferentialAction value = getEnumValue(ReferentialAction.class, text); + if (value != null) { + foreignKeyModel.setOnUpdate(value); + } + } else if (elementName.equals("deferrable")) { + foreignKeyModel.setDeferrable(Boolean.valueOf(text)); + } else if (elementName.equals("initiallyCheckTime")) { + InitiallyCheckTime value = getEnumValue(InitiallyCheckTime.class, text); + if (value != null) { + foreignKeyModel.setInitiallyCheckTime(InitiallyCheckTime.valueOf(text)); + } + } else if (elementName.equals("description")) { + foreignKeyModel.setDescription(text); + } + + // TODO matchType?? + } + + /** + * {@inheritDoc} + */ + @Override + public void start(XmlElement element, ModelInfo model, Attributes attributes) { + ForeignKeyModel foreignKeyModel = JiemamyModelFactory.create(model.getRootModel(), ForeignKeyModel.class); + model.setForeignKeyModel(foreignKeyModel); + super.start(element, model, attributes); + } + + /** + * {@inheritDoc} + */ + @Override + public XmlElementCommand startChild(XmlElement element, ModelInfo model, Attributes attributes) { + ForeignKeyModel foreignKeyModel = model.getForeignKeyModel(); + String elementName = element.getName(); + + if (elementName.equals("mappings")) { + return new AbstractXmlElementCommand() { + + @Override + public XmlElementCommand startChild(XmlElement element, ModelInfo model, Attributes attributes) { + if (element.getName().equals("mapping")) { + return new ForeignKeyMappingCommand(); + } + return null; + } + }; + } + + if (elementName.equals("source")) { + AbstractNodeModel source = getReferenceModel(attributes); + foreignKeyModel.setSource(source); + } else if (elementName.equals("target")) { + AbstractNodeModel source = getReferenceModel(attributes); + foreignKeyModel.setTarget(source); + } + + return null; + } + + /** + * {@inheritDoc} + */ + @Override + protected JiemamyModel getTargetModel(ModelInfo model) { + return model.getForeignKeyModel(); + } + + private <T extends Enum<T>>T getEnumValue(Class<T> enumType, String name) { + try { + return Enum.valueOf(enumType, name); + } catch (IllegalArgumentException ignore) { + } + + return null; + } + +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/ForeignKeyCommand.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/ForeignKeyMappingCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/ForeignKeyMappingCommand.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/ForeignKeyMappingCommand.java 2008-11-10 12:38:07 UTC (rev 2125) @@ -0,0 +1,62 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/11/10 + * + * 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.serializer.sax; + +import org.xml.sax.Attributes; + +import org.jiemamy.creator.JiemamyModelFactory; +import org.jiemamy.spec.model.JiemamyModel; +import org.jiemamy.spec.model.connection.ForeignKeyMapping; + +/** + * foreignKey/mappings/mapping要素のコマンドクラス。 + * @author ykhr + */ +public class ForeignKeyMappingCommand extends JiemamyModelCommand { + + /** ForeignKeyMapping */ + private ForeignKeyMapping foreignKeyMapping; + + + /** + * {@inheritDoc} + */ + @Override + public void end(ModelInfo model, XmlElement element, String text) { + model.getForeignKeyModel().getMappings().add(foreignKeyMapping); + } + + /** + * {@inheritDoc} + */ + @Override + public void start(XmlElement element, ModelInfo model, Attributes attributes) { + foreignKeyMapping = JiemamyModelFactory.create(model.getRootModel(), ForeignKeyMapping.class); + super.start(element, model, attributes); + } + + /** + * {@inheritDoc} + */ + @Override + protected JiemamyModel getTargetModel(ModelInfo model) { + return foreignKeyMapping; + } + +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/sax/ForeignKeyMappingCommand.java ___________________________________________________________________ Name: svn:mime-type + text/plain