svnno****@sourc*****
svnno****@sourc*****
2008年 12月 15日 (月) 12:22:32 JST
Revision: 2265 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2265 Author: daisuke_m Date: 2008-12-15 12:22:31 +0900 (Mon, 15 Dec 2008) Log Message: ----------- パッケージ移動refactor Modified Paths: -------------- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/AdapterXmlElement.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/CheckConstraintXmlElement.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/CollectionXmlElement.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/ColumnXmlElement.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/ConstraintXmlElement.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/DataTypeXmlElement.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/DiagramPresentationXmlElement.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/DomainXmlElement.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/ForeignKeyMappingXmlElement.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/ForeignKeyXmlElement.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/InsertDataSetXmlElement.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/MapXmlElement.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/PropertyXmlElement.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/RecordXmlElement.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/RootXmlElement.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/StickyXmlElement.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/TableXmlElement.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/ViewXmlElement.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/XmlElement.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/EndElementEvent.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/JiemamyXmlConstants.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/NullEvent.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/StartElementEvent.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/JiemamySaxSerializer.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/JiemamyStaxSerializer.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/Namespaces.java zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/model/Jiemamy.java zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/serializer/JiemamySerializer.java Added Paths: ----------- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/ModelInputStream.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/ModelWriter.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/XmlElement.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ColumnCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ConnectionsCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ConstraintCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/DataSetCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/DomainCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/EntityModelCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ForeignKeyCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ForeignKeyMappingCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/JiemamyHandler.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/JiemamyModelCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ModelInfo.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/NodesCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/RootCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/StickyCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/TableCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ViewCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/XmlElementCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/XmlElementCommandAdapter.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/XmlElementStack.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyModelReadingEvent.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyWriter.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyWriterException.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyXmlWriter.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/RootModelReader.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/RootModelWriter.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/AbstractJiemamyModelReadingEvent.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/CloseEvent.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/ContentsEvent.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/OpenEvent.java artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/internal/ artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/internal/serializer/ artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/internal/serializer/sax/ artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/internal/serializer/sax/ModelInputStreamTest.java Removed Paths: ------------- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/AbstractJiemamyEvent.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/CharactersEvent.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/EndEvent.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/StartEvent.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/model/ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/ModelInputStream.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/ModelWriter.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/stax/ artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/serializer/ModelInputStreamTest.java -------------- next part -------------- Copied: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/ModelInputStream.java (from rev 2263, artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/ModelInputStream.java) =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/ModelInputStream.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/ModelInputStream.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,88 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/10/22 + * + * 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.internal.serializer.sax; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Queue; +import java.util.concurrent.LinkedBlockingQueue; + +import org.xml.sax.SAXException; + +import org.jiemamy.exception.UnexpectedConditionError; +import org.jiemamy.model.RootModel; +import org.jiemamy.serializer.Namespaces; + +/** + * モデルインプットストリーム。 + * + * @author j5ik2o + */ +public class ModelInputStream extends InputStream { + + /** 出力モデルキュー */ + private Queue<Byte> resourceQueue; + + private ModelWriter modelWriter; + + + /** + * コンストラクタ。 + * @param rootModel + * @category instance creation + */ + public ModelInputStream(RootModel rootModel) { + resourceQueue = new LinkedBlockingQueue<Byte>(); + try { + modelWriter = new ModelWriter(rootModel, resourceQueue, Namespaces.CORE + " jiemamy-core.xsd"); + } catch (SAXException e) { + throw new UnexpectedConditionError("something wrong...", e); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void close() throws IOException { + try { + modelWriter.dispose(); + } catch (SAXException e) { + throw new IOException(); + } + super.close(); + } + + /** + * {@inheritDoc} + */ + @Override + public int read() throws IOException { + if (resourceQueue.size() == 0) { + try { + if (modelWriter.write() == false) { + return -1; + } + } catch (SAXException e) { + throw new IOException(); + } + } + return resourceQueue.poll().intValue(); + } +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/ModelInputStream.java ___________________________________________________________________ Name: svn:mime-type + text/plain Copied: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/ModelWriter.java (from rev 2263, artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/ModelWriter.java) =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/ModelWriter.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/ModelWriter.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,205 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/10/25 + * + * 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.internal.serializer.sax; + +import java.io.StringWriter; +import java.util.Queue; +import java.util.Stack; + +import com.megginson.sax.DataWriter; + +import org.apache.commons.lang.Validate; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.AttributesImpl; + +import org.jiemamy.internal.serializer.sax.element.RootXmlElement; +import org.jiemamy.internal.serializer.sax.element.XmlElement; +import org.jiemamy.internal.serializer.sax.element.XmlElement.ElementState; +import org.jiemamy.model.DiagramPresentations; +import org.jiemamy.model.RootModel; +import org.jiemamy.serializer.Namespaces; + +/** + * モデルライター。 + * + * @author j5ik2o + */ +public class ModelWriter { + + /** + * 処理中のモデル構造スタック + * + * <pre> + * <foo> + * <bar/> + * <baz/> + * </foo> + * </pre> + * + * 上記のようなXML構造の場合、下記の順にスタック操作が行われる。 + * + * <ul> + * <li>push foo</li> + * <li>push bar</li> + * <li>pop bar</li> + * <li>push baz</li> + * <li>pop baz</li> + * <li>pop foo</li> + * </ul> + */ + private Stack<XmlElement> xmlStack = new Stack<XmlElement>(); + + private DataWriter dataWriter = new DataWriter(); + + private final Queue<Byte> resourceQueue; + + private String schemaLocation; + + + /** + * コンストラクタ。 + * @param rootModel + * @param resourceQueue + * @param schemaLocation + * @throws SAXException + * @throws IllegalArgumentException 引数rootModel, resourceQueueに{@code null}を与えた場合 + * @category instance creation + */ + public ModelWriter(RootModel rootModel, Queue<Byte> resourceQueue, String schemaLocation) throws SAXException { + assert xmlStack != null; + assert dataWriter != null; + Validate.notNull(rootModel); + Validate.notNull(resourceQueue); + + this.resourceQueue = resourceQueue; + dataWriter.forceNSDecleration(Namespaces.CORE, ""); + if (rootModel.hasAdapter(DiagramPresentations.class)) { + dataWriter.forceNSDecleration(Namespaces.VIEW, "view"); + } + dataWriter.forceNSDecleration(Namespaces.XSI, "xsi"); + + this.schemaLocation = schemaLocation; + + dataWriter.setIndentStep(2); + + StringWriter sw = new StringWriter(); + dataWriter.setOutput(sw); + dataWriter.startDocument(); + + addToQueue(sw.toString().getBytes()); + + xmlStack.push(new RootXmlElement(rootModel)); + } + + /** + * 破棄処理を行う。 + * @throws SAXException + */ + public void dispose() throws SAXException { + assert dataWriter != null; + dataWriter.endDocument(); + } + + /** + * 1行分をresourceQueueに出力する。 + * + * <p>1行というのは、 + * <ul> + * <li>タグのオープン</li> + * <li>それ以外のdataElementの出力</li> + * <li>タグのクローズ</li> + * </ul> + * と定義。</p> + * + * @return 出力する対象がもう残っていない場合は{@code false} + * @throws SAXException + */ + public boolean write() throws SAXException { + assert xmlStack != null; + assert dataWriter != null; + + if (xmlStack.isEmpty()) { + return false; + } + StringWriter sw = new StringWriter(); + dataWriter.setOutput(sw); // 毎回出力先を更新する + + write(xmlStack.peek()); + + addToQueue(sw.toString().getBytes()); + + return resourceQueue.size() > 0; + } + + /** + * 今回出力された内容をキューに突っ込む。 + * @param bytes + */ + private void addToQueue(byte[] bytes) { + assert resourceQueue != null; + Validate.notNull(bytes); + + for (byte b : bytes) { + if (b != 0) { + resourceQueue.add(b); + } + } + } + + /** + * TODO for daisuke + * @param attrs + */ + private void process(AttributesImpl attrs) { + if (schemaLocation != null) { + attrs.addAttribute(Namespaces.XSI, "schemaLocation", "xsi:schemaLocation", "CDATA", schemaLocation); + schemaLocation = null; + } + } + + private void write(XmlElement element) throws SAXException { + if (element.getState() == ElementState.INIT) { + if (element.hasNext()) { + AttributesImpl attrs = (AttributesImpl) element.getAttributes(); + process(attrs); + dataWriter.startElement(Namespaces.CORE, element.getName(), element.getName(), attrs); + element.setState(ElementState.PROGRESS); + xmlStack.push(element.next()); + } else { + if (element.isEmptyElement()) { + dataWriter.emptyElement(Namespaces.CORE, element.getName(), element.getName(), element + .getAttributes()); + } else { + dataWriter.dataElement(Namespaces.CORE, element.getName(), element.getName(), element + .getAttributes(), element.toString()); + } + element.setState(ElementState.FINISHED); + xmlStack.pop(); + } + } else if (element.getState() == ElementState.PROGRESS) { + if (element.hasNext()) { + xmlStack.push(element.next()); + } else { + dataWriter.endElement(Namespaces.CORE, element.getName(), element.getName()); + element.setState(ElementState.FINISHED); + xmlStack.pop(); + } + } + } +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/ModelWriter.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/XmlElement.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/XmlElement.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/XmlElement.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,125 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/11/06 + * + * 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.internal.serializer.sax; + +import java.util.LinkedList; +import java.util.Queue; + +import org.xml.sax.helpers.AttributesImpl; + +import org.jiemamy.internal.serializer.sax.element.XmlElement.ElementState; + +/** + * XMLのElement名を保持するクラス。 + * イミュータブル。 + * @author ykhr + */ +public class XmlElement { + + /** + * 未出力エレメントのキュー + * + * <pre> + * <foo> + * <bar/> + * <baz/> + * </foo> + * </pre> + * + * 上記のようなXML構造の場合、foo要素のXmlElementでは、コンストラクト時に bar, baz がenqueueされる。 + */ + protected Queue<XmlElement> queue = new LinkedList<XmlElement>(); + + /** hashcode */ + private int hashCode; + + /** 名前空間 */ + private String namespace; + + /** 要素名 */ + private String name; + + /** 属性 */ + private AttributesImpl attributes = new AttributesImpl(); + + private Object content; + + private ElementState state = ElementState.INIT; + + + /** + * コンストラクタ。 + * @param namespace + * @param name + * @category instance creation + */ + public XmlElement(String namespace, String name) { + this.namespace = namespace; + this.name = name; + hashCode = namespace.hashCode() * name.hashCode(); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) { + if ((obj instanceof XmlElement) == false) { + return false; + } + + XmlElement element = (XmlElement) obj; + return namespace.equals(element.namespace) && name.equals(element.name); + } + + /** + * Element名を取得する。 + * @return the name + * @category accessing + */ + public String getName() { + return name; + } + + /** + * URIを取得する。 + * @return the uri + * @category accessing + */ + public String getNamespace() { + return namespace; + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + return hashCode; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return namespace + ":" + name; + } + +} Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ColumnCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ColumnCommand.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ColumnCommand.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,145 @@ +/* + * 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.internal.serializer.sax.command; + +import java.util.UUID; + +import org.xml.sax.Attributes; + +import org.jiemamy.internal.serializer.sax.XmlElement; +import org.jiemamy.model.attribute.ColumnModel; +import org.jiemamy.model.constraint.Constraint; +import org.jiemamy.model.datatype.DataTypeDescriptor; + +/** + * column要素のコマンドクラス。 + * @author ykhr + */ +class ColumnCommand extends JiemamyModelCommand<ColumnModel> { + + /** + * {@inheritDoc} + */ + @Override + public void end(ModelInfo modelInfo, XmlElement element, String text) { + ColumnModel columnModel = modelInfo.getColumnModel(); + modelInfo.getTableModel().appendModel(columnModel); + } + + /** + * {@inheritDoc} + */ + @Override + public void endChild(XmlElement element, ModelInfo modelInfo, String text) { + ColumnModel columnModel = modelInfo.getColumnModel(); + String elementName = element.getName(); + + if (elementName.equals("name")) { + columnModel.setName(text); + } else if (elementName.equals("logicalName")) { + columnModel.setLogicalName(text); + } else if (elementName.equals("defaultValue")) { + columnModel.setDefaultValue(text); + } else if (elementName.equals("simpleIndex")) { + columnModel.setSimpleIndex(Boolean.valueOf(text)); + } else if (elementName.equals("freeString")) { + columnModel.setFreeString(text); + } else if (elementName.equals("description")) { + columnModel.setDescription(text); + } else if (elementName.equals("representation")) { + columnModel.setRepresentation(Boolean.valueOf(text)); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void start(XmlElement element, ModelInfo modelInfo, Attributes attributes) throws ClassNotFoundException { + UUID uuid = UUID.fromString(attributes.getValue("id")); + ColumnModel columnModel = modelInfo.getRootModel().newModel(ColumnModel.class, uuid); + modelInfo.setColumnModel(columnModel); + modelInfo.initConstraints(); + super.start(element, modelInfo, attributes); + } + + /** + * {@inheritDoc} + */ + @Override + public XmlElementCommand startChild(XmlElement element, ModelInfo modelInfo, Attributes attributes) + throws ClassNotFoundException { + String elementName = element.getName(); + + if (elementName.equals("constraints")) { + return new XmlElementCommandAdapter() { + + @Override + public void end(ModelInfo modelInfo, XmlElement element, String text) { + ColumnModel columnModel = modelInfo.getColumnModel(); + for (Constraint constraint : modelInfo.getConstraints()) { + columnModel.addConstraint(constraint); + } + } + + @Override + public XmlElementCommand startChild(XmlElement element, ModelInfo modelInfo, Attributes attributes) { + if (!element.getName().equals("constraint")) { + throw new IllegalStateException(); + } + return new ConstraintCommand(); + } + }; + + } + + if (elementName.equals("dataTypeDescriptor")) { + DataTypeDescriptor dataTypeDescriptor = null; + + if (hasAttribute(attributes, "ref")) { + dataTypeDescriptor = (DataTypeDescriptor) getReferenceModel(attributes); + + // TODO dataTypeが読み込めていない場合 +// if (dataType == null) { +// } + } else { + String className = attributes.getValue("class"); + try { + dataTypeDescriptor = (DataTypeDescriptor) Class.forName(className).newInstance(); + } catch (Exception e) { + // TODO しっかりしたエラー処理を + throw new RuntimeException(e); + } + } + + modelInfo.getColumnModel().setDataTypeDescriptor(dataTypeDescriptor); + } + + return super.startChild(element, modelInfo, attributes); + } + + /** + * {@inheritDoc} + */ + @Override + protected ColumnModel getTargetModel(ModelInfo modelInfo) { + return modelInfo.getColumnModel(); + } + +} Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ConnectionsCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ConnectionsCommand.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ConnectionsCommand.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,42 @@ +/* + * 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.internal.serializer.sax.command; + +import org.xml.sax.Attributes; + +import org.jiemamy.internal.serializer.sax.XmlElement; + +/** + * connection要素を読み込むクラス。 + * @author daisuke + */ +class ConnectionsCommand extends XmlElementCommandAdapter { + + /** + * {@inheritDoc} + */ + @Override + public XmlElementCommand startChild(XmlElement element, ModelInfo modelInfo, Attributes attributes) { + if (element.getName().equals("foreignKey")) { + return new ForeignKeyCommand(); + } + throw new IllegalStateException(); + } + +} Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ConstraintCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ConstraintCommand.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ConstraintCommand.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,80 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/11/08 + * + * 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.internal.serializer.sax.command; + +import org.xml.sax.Attributes; + +import org.jiemamy.exception.IllegalImplementationException; +import org.jiemamy.internal.serializer.sax.XmlElement; +import org.jiemamy.model.constraint.Constraint; + +/** + * Constraint要素のコマンドクラス。 + * @author ykhr + */ +class ConstraintCommand extends JiemamyModelCommand<Constraint> { + + /** 処理中のConstraint */ + private Constraint constraint = null; + + + /** + * {@inheritDoc} + */ + @Override + public void end(ModelInfo modelInfo, XmlElement element, String text) { + modelInfo.addConstraints(constraint); + } + + /** + * {@inheritDoc} + */ + @Override + public void endChild(XmlElement element, ModelInfo modelInfo, String text) { + if (element.getName().equals("name")) { + constraint.setName(text); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void start(XmlElement element, ModelInfo modelInfo, Attributes attributes) throws ClassNotFoundException { + String className = attributes.getValue("class"); + try { + constraint = Constraint.class.cast(Class.forName(className).newInstance()); + } catch (InstantiationException e) { + // XMLに表された実装クラスがおかしい or Constraintの実装がおかしい + throw new IllegalImplementationException(className, e); + } catch (IllegalAccessException e) { + throw new IllegalImplementationException(className, e); + } + super.start(element, modelInfo, attributes); + } + + /** + * {@inheritDoc} + */ + @Override + protected Constraint getTargetModel(ModelInfo modelInfo) { + return constraint; + } + +} Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/DataSetCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/DataSetCommand.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/DataSetCommand.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,38 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/11/13 + * + * 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.internal.serializer.sax.command; + +import org.jiemamy.model.node.AbstractEntityModel; + +/** + * dataSet要素を読み込むコマンドクラス。 + * @author ykhr + */ +public class DataSetCommand extends EntityModelCommand { + + /** + * {@inheritDoc} + */ + @Override + protected AbstractEntityModel getTargetEntityModel(ModelInfo modelInfo) { + // TODO Auto-generated method stub + return null; + } + +} Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/DomainCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/DomainCommand.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/DomainCommand.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,132 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/11/08 + * + * 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.internal.serializer.sax.command; + +import java.util.UUID; + +import org.xml.sax.Attributes; + +import org.jiemamy.exception.UnexpectedConditionError; +import org.jiemamy.internal.serializer.sax.XmlElement; +import org.jiemamy.model.constraint.Constraint; +import org.jiemamy.model.datatype.DataTypeDescriptor; +import org.jiemamy.model.datatype.DomainModel; + +/** + * Domain要素のコマンドクラス。 + * @author ykhr + */ +class DomainCommand extends JiemamyModelCommand<DomainModel> { + + /** + * {@inheritDoc} + */ + @Override + public void endChild(XmlElement element, ModelInfo modelInfo, String text) { + DomainModel domainModel = modelInfo.getDomainModel(); + String elementName = element.getName(); + + if (elementName.equals("name")) { + domainModel.setName(text); + } else if (elementName.equals("logicalName")) { + domainModel.setLogicalName(text); + } else if (elementName.equals("defaultValue")) { + domainModel.setDefaultValue(text); + } else if (elementName.equals("simpleIndex")) { + domainModel.setSimpleIndex(Boolean.valueOf(text)); + } else if (elementName.equals("freeString")) { + domainModel.setFreeString(text); + } else if (elementName.equals("description")) { + domainModel.setDescription(text); + } else { + super.endChild(element, modelInfo, text); + } + // TODO options?? + } + + /** + * {@inheritDoc} + */ + @Override + public void start(XmlElement element, ModelInfo modelInfo, Attributes attributes) throws ClassNotFoundException { + UUID uuid = UUID.fromString(attributes.getValue("id")); + DomainModel domainModel = modelInfo.getRootModel().newModel(DomainModel.class, uuid); + modelInfo.setDomainModel(domainModel); + modelInfo.initConstraints(); + super.start(element, modelInfo, attributes); + } + + /** + * {@inheritDoc} + */ + @Override + @SuppressWarnings("unchecked") + public XmlElementCommand startChild(XmlElement element, ModelInfo modelInfo, Attributes attributes) + throws ClassNotFoundException { + String elementName = element.getName(); + + if (elementName.equals("constraints")) { + return new XmlElementCommandAdapter() { + + @Override + public void end(ModelInfo modelInfo, XmlElement element, String text) { + DomainModel domainModel = modelInfo.getDomainModel(); + for (Constraint constraint : modelInfo.getConstraints()) { + domainModel.addConstraint(constraint); + } + } + + @Override + public XmlElementCommand startChild(XmlElement element, ModelInfo modelInfo, Attributes attributes) { + if (!element.getName().equals("constraint")) { + throw new IllegalStateException(); + } + return new ConstraintCommand(); + } + }; + } + + if (elementName.equals("dataTypeDescriptor")) { + String className = attributes.getValue("class"); + Class<? extends DataTypeDescriptor> clazz = null; + try { + clazz = (Class<? extends DataTypeDescriptor>) Class.forName(className); + DataTypeDescriptor dataType = DataTypeDescriptor.class.cast(clazz.newInstance()); + modelInfo.getDomainModel().setDataTypeDescriptor(DataTypeDescriptor.class.cast(dataType)); + } catch (InstantiationException e) { + throw new UnexpectedConditionError( + "Illegal DataTypeDescriptor implementation (need default constructor): " + clazz, e); + } catch (IllegalAccessException e) { + throw new UnexpectedConditionError( + "Illegal DataTypeDescriptor implementation (need public constructor): " + clazz, e); + } + } + + return null; + } + + /** + * {@inheritDoc} + */ + @Override + protected DomainModel getTargetModel(ModelInfo modelInfo) { + return modelInfo.getDomainModel(); + } + +} Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/EntityModelCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/EntityModelCommand.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/EntityModelCommand.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,65 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/11/06 + * + * 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.internal.serializer.sax.command; + +import org.jiemamy.internal.serializer.sax.XmlElement; +import org.jiemamy.model.node.AbstractEntityModel; + +/** + * AbstractEntityModel用XmlElementCommandクラス。 + * AbstractEntityModelが持つプロパティに値を設定する。 + * @author ykhr + */ +abstract class EntityModelCommand extends JiemamyModelCommand<AbstractEntityModel> { + + /** + * {@inheritDoc} + */ + @Override + public void endChild(XmlElement element, ModelInfo modelInfo, String text) { + String elementName = element.getName(); + if (elementName.equals("name")) { + getTargetEntityModel(modelInfo).setName(text); + } else if (elementName.equals("logicalName")) { + getTargetEntityModel(modelInfo).setLogicalName(text); + } else if (elementName.equals("beginScript")) { + getTargetEntityModel(modelInfo).setBeginScript(text); + } else if (elementName.equals("endScript")) { + getTargetEntityModel(modelInfo).setEndScript(text); + } else if (elementName.equals("description")) { + getTargetEntityModel(modelInfo).setDescription(text); + } + } + + /** + * 処理対象のモデルを取得する。 + * @param modelInfo ModelInfo + * @return AbstractEntityModel + */ + protected abstract AbstractEntityModel getTargetEntityModel(ModelInfo modelInfo); + + /** + * {@inheritDoc} + */ + @Override + protected AbstractEntityModel getTargetModel(ModelInfo modelInfo) { + return getTargetEntityModel(modelInfo); + } + +} Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ForeignKeyCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ForeignKeyCommand.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ForeignKeyCommand.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,125 @@ +/* + * 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.internal.serializer.sax.command; + +import java.util.UUID; + +import org.apache.commons.lang.StringUtils; +import org.xml.sax.Attributes; + +import org.jiemamy.internal.serializer.sax.XmlElement; +import org.jiemamy.model.connection.ForeignKeyModel; +import org.jiemamy.model.connection.ForeignKeyModel.InitiallyCheckTime; +import org.jiemamy.model.connection.ForeignKeyModel.ReferentialAction; +import org.jiemamy.model.node.AbstractNodeModel; + +/** + * foreignKey要素のコマンドクラス。 + * @author ykhr + */ +class ForeignKeyCommand extends JiemamyModelCommand<ForeignKeyModel> { + + /** + * {@inheritDoc} + */ + @Override + public void endChild(XmlElement element, ModelInfo modelInfo, String text) { + ForeignKeyModel foreignKeyModel = modelInfo.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")) { + if (StringUtils.isEmpty(text) == false) { + ReferentialAction value = ReferentialAction.valueOf(text); + foreignKeyModel.setOnDelete(value); + } + } else if (elementName.equals("onUpdate")) { + if (StringUtils.isEmpty(text) == false) { + ReferentialAction value = ReferentialAction.valueOf(text); + foreignKeyModel.setOnUpdate(value); + } + } else if (elementName.equals("deferrable")) { + foreignKeyModel.setDeferrable(Boolean.valueOf(text)); + } else if (elementName.equals("initiallyCheckTime")) { + if (StringUtils.isEmpty(text) == false) { + InitiallyCheckTime value = InitiallyCheckTime.valueOf(text); + foreignKeyModel.setInitiallyCheckTime(value); + } + } else if (elementName.equals("description")) { + foreignKeyModel.setDescription(text); + } + + // TODO matchType?? + } + + /** + * {@inheritDoc} + */ + @Override + public void start(XmlElement element, ModelInfo modelInfo, Attributes attributes) throws ClassNotFoundException { + UUID uuid = UUID.fromString(attributes.getValue("id")); + ForeignKeyModel foreignKeyModel = modelInfo.getRootModel().newModel(ForeignKeyModel.class, uuid); + modelInfo.setForeignKeyModel(foreignKeyModel); + super.start(element, modelInfo, attributes); + } + + /** + * {@inheritDoc} + */ + @Override + public XmlElementCommand startChild(XmlElement element, ModelInfo modelInfo, Attributes attributes) { + ForeignKeyModel foreignKeyModel = modelInfo.getForeignKeyModel(); + String elementName = element.getName(); + + if (elementName.equals("mappings")) { + return new XmlElementCommandAdapter() { + + @Override + public XmlElementCommand startChild(XmlElement element, ModelInfo modelInfo, Attributes attributes) { + if (element.getName().equals("mapping")) { + return new ForeignKeyMappingCommand(); + } + return null; + } + }; + } + + if (elementName.equals("source")) { + AbstractNodeModel source = (AbstractNodeModel) getReferenceModel(attributes); + foreignKeyModel.setSource(source); + } else if (elementName.equals("target")) { + AbstractNodeModel source = (AbstractNodeModel) getReferenceModel(attributes); + foreignKeyModel.setTarget(source); + } + + return null; + } + + /** + * {@inheritDoc} + */ + @Override + protected ForeignKeyModel getTargetModel(ModelInfo modelInfo) { + return modelInfo.getForeignKeyModel(); + } + +} Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ForeignKeyMappingCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ForeignKeyMappingCommand.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ForeignKeyMappingCommand.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,79 @@ +/* + * 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.internal.serializer.sax.command; + +import org.xml.sax.Attributes; + +import org.jiemamy.internal.serializer.sax.XmlElement; +import org.jiemamy.model.attribute.ColumnModel; +import org.jiemamy.model.connection.ForeignKeyMapping; + +/** + * foreignKey/mappings/mapping要素のコマンドクラス。 + * @author ykhr + */ +class ForeignKeyMappingCommand extends JiemamyModelCommand<ForeignKeyMapping> { + + /** ForeignKeyMapping */ + private ForeignKeyMapping foreignKeyMapping; + + + /** + * {@inheritDoc} + */ + @Override + public void end(ModelInfo modelInfo, XmlElement element, String text) { + modelInfo.getForeignKeyModel().getMappings().add(foreignKeyMapping); + } + + /** + * {@inheritDoc} + */ + @Override + public void start(XmlElement element, ModelInfo modelInfo, Attributes attributes) throws ClassNotFoundException { + foreignKeyMapping = modelInfo.getRootModel().newModel(ForeignKeyMapping.class); + super.start(element, modelInfo, attributes); + } + + /** + * {@inheritDoc} + */ + @Override + public XmlElementCommand startChild(XmlElement element, ModelInfo modelInfo, Attributes attributes) { + String elementName = element.getName(); + if (elementName.equals("constraintColumn")) { + ColumnModel referenceModel = (ColumnModel) getReferenceModel(attributes); + foreignKeyMapping.setConstraintColumn(referenceModel); + } else if (elementName.equals("referenceColumn")) { + ColumnModel referenceModel = (ColumnModel) getReferenceModel(attributes); + foreignKeyMapping.setReferenceColumn(referenceModel); + } + + return null; + } + + /** + * {@inheritDoc} + */ + @Override + protected ForeignKeyMapping getTargetModel(ModelInfo modelInfo) { + return foreignKeyMapping; + } + +} Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/JiemamyHandler.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/JiemamyHandler.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/JiemamyHandler.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,195 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/11/03 + * + * 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.internal.serializer.sax.command; + +import java.util.Stack; + +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +import org.jiemamy.internal.serializer.sax.XmlElement; +import org.jiemamy.model.RootModel; + +/** + * JiemamyXMLのSAX用DefaultHandler。 + * @author ykhr + */ +public class JiemamyHandler extends DefaultHandler { + + private static Logger logger = LoggerFactory.getLogger(JiemamyHandler.class); + + /** 要素の深さ(logging用) */ + private int depth = 0; + + /** 読み込んでいるタグの構成 */ + private XmlElementStack xmlElementStack = new XmlElementStack(); + + /** モデル */ + private ModelInfo modelInfo = null; + + /** コマンドのスタック */ + private Stack<CommandInfo> commandStack = new Stack<CommandInfo>(); + + /** buffer */ + private StringBuilder buffer = new StringBuilder(); + + + /** + * {@inheritDoc} + */ + @Override + public void characters(char[] ch, int offset, int length) { + buffer.append(ch, offset, length); + } + + /** + * {@inheritDoc} + */ + @Override + public void endElement(String uri, String localName, String qName) { + XmlElement element = xmlElementStack.peek(); + CommandInfo commandInfo = commandStack.peek(); + XmlElementCommand command = commandInfo.getCommand(); + + if (commandInfo.getStackAtCommandStarted().equals(xmlElementStack)) { + command.end(modelInfo, element, buffer.toString()); + commandStack.pop(); + logger.trace("***end command: " + command); + } else { + command.endChild(element, modelInfo, buffer.toString()); + } + + logger.trace(StringUtils.repeat(" ", --depth) + "end:" + xmlElementStack); + + xmlElementStack.pop(); + } + + /** + * XMLを読み込んだ結果を返す。 + * @return 読み込んだRootModel + */ + public RootModel getResult() { + return modelInfo.getRootModel(); + } + + /** + * {@inheritDoc} + */ + @Override + public void startDocument() { + modelInfo = new ModelInfo(); + commandStack.push(new CommandInfo(new FirstCommand(), xmlElementStack.snapshot())); + } + + /** + * {@inheritDoc} + */ + @Override + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { + XmlElement element = new XmlElement(uri, localName); + xmlElementStack.push(element); + + XmlElementCommand command = commandStack.peek().getCommand(); + XmlElementCommand nextCommand; + try { + nextCommand = command.startChild(element, modelInfo, attributes); + } catch (ClassNotFoundException e) { + throw new SAXException(e); + } + + if (nextCommand != null) { + commandStack.push(new CommandInfo(nextCommand, xmlElementStack.snapshot())); + try { + nextCommand.start(element, modelInfo, attributes); + } catch (ClassNotFoundException e) { + throw new SAXException(e); + } + } + + logger.trace(StringUtils.repeat(" ", depth++) + "start:" + xmlElementStack); + + buffer.setLength(0); + } + + + /** + * コマンド情報 + * @author ykhr + */ + private static class CommandInfo { + + /** コマンド */ + private XmlElementCommand command; + + /** このコマンドを開始した時点のタグの構成 */ + private XmlElementStack stackAtCommandStarted; + + + /** + * コンストラクタ。 + * @param command + * @param stackAtCommandStarted + * @category instance creation + */ + public CommandInfo(XmlElementCommand command, XmlElementStack stackAtCommandStarted) { + this.command = command; + this.stackAtCommandStarted = stackAtCommandStarted; + } + + /** + * コマンドを取得する。 + * @return the command + * @category accessing + */ + public XmlElementCommand getCommand() { + return command; + } + + /** + * コマンド開始時点のタグの構成を取得する。 + * @return the stackAtCommandStarted + * @category accessing + */ + public XmlElementStack getStackAtCommandStarted() { + return stackAtCommandStarted; + } + + } + + /** + * 最初のXmlElementCommandクラス。 + * @author ykhr + */ + private static class FirstCommand extends XmlElementCommandAdapter { + + /** + * {@inheritDoc} + */ + @Override + public XmlElementCommand startChild(XmlElement element, ModelInfo modelInfo, Attributes attributes) { + return new RootCommand(); + } + + } + +} Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/JiemamyModelCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/JiemamyModelCommand.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/JiemamyModelCommand.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,98 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/11/06 + * + * 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.internal.serializer.sax.command; + +import java.util.UUID; + +import org.xml.sax.Attributes; + +import org.jiemamy.internal.serializer.sax.XmlElement; +import org.jiemamy.model.DiagramPresentationModel; +import org.jiemamy.model.DiagramPresentations; +import org.jiemamy.model.RootModel; +import org.jiemamy.model.connection.AbstractConnectionModel; +import org.jiemamy.model.dataset.InsertDataSetModel; +import org.jiemamy.model.datatype.DomainModel; +import org.jiemamy.model.node.AbstractNodeModel; + +/** + * IDを持つモデルのXmlElementCommand。 + * @author ykhr + * @param <T> + */ +abstract class JiemamyModelCommand<T> extends XmlElementCommandAdapter { + + /** + * {@inheritDoc} + */ + @Override + public void end(ModelInfo modelInfo, XmlElement element, String text) { + Object child = getTargetModel(modelInfo); + RootModel rootModel = modelInfo.getRootModel(); + if (child instanceof DomainModel) { + rootModel.appendModel((DomainModel) child); + } else if (child instanceof AbstractConnectionModel) { + rootModel.appendModel((AbstractConnectionModel) child); + } else if (child instanceof AbstractNodeModel) { + rootModel.appendModel((AbstractNodeModel) child); + } else if (child instanceof InsertDataSetModel) { + rootModel.appendModel((InsertDataSetModel) child); + } else if (child instanceof DiagramPresentationModel) { + rootModel.getAdapter(DiagramPresentations.class).appendModel((DiagramPresentationModel) child); + } + } + + /** + * {@inheritDoc} + */ + @Override + @SuppressWarnings("unused") + public void start(XmlElement element, ModelInfo modelInfo, Attributes attributes) throws ClassNotFoundException { + } + + /** + * ref属性のIDから、モデルを取得する。 + * @param attributes + * @return モデル + */ + @SuppressWarnings("unchecked") + protected T getReferenceModel(Attributes attributes) { + String ref = attributes.getValue("ref"); + UUID refId = UUID.fromString(ref); + return (T) ModelInfo.map.get(refId); + } + + /** + * 処理対象のモデル。 + * @param modelInfo Model情報 + * @return モデル + */ + protected abstract T getTargetModel(ModelInfo modelInfo); + + /** + * 属性があるかどうか。 + * @param attributes + * @param name + * @return 属性がある場合、true + */ + protected boolean hasAttribute(Attributes attributes, String name) { + return attributes.getValue(name) != null; + } + +} Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ModelInfo.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ModelInfo.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ModelInfo.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,186 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/11/06 + * + * 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.internal.serializer.sax.command; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.jiemamy.model.Identifiable; +import org.jiemamy.model.RootModel; +import org.jiemamy.model.attribute.ColumnModel; +import org.jiemamy.model.connection.ForeignKeyModel; +import org.jiemamy.model.constraint.Constraint; +import org.jiemamy.model.datatype.DomainModel; +import org.jiemamy.model.node.TableModel; + +/** + * モデル情報。 + * + * <p>各Commandをまたがって必要となる情報をこのクラスに保持する。</p> + * + * @author ykhr + */ +class ModelInfo { + + /** FIXME ModelIdManagerの代わり。ダサいので要修正。 */ + public static Map<UUID, Identifiable> map = new HashMap<UUID, Identifiable>(); + + /** RootModel */ + private RootModel rootModel; + + /** 処理中のTableModel */ + private TableModel tableModel = null; + + /** 処理中のColumnModel */ + private ColumnModel columnModel = null; + + /** 処理中のDomainModel */ + private DomainModel domainModel = null; + + /** constraints */ + private List<Constraint> constraints = null; + + /** 処理中のForeignKeyModel */ + private ForeignKeyModel foreignKeyModel = null; + + + /** + * Constraintを追加する。 + * @param constraint + */ + public void addConstraints(Constraint constraint) { + constraints.add(constraint); + } + + /** + * ColumnModelを取得する。 + * @return the columnModel + * @category accessing + */ + public ColumnModel getColumnModel() { + return columnModel; + } + + /** + * Constraintを取得する。 + * @return the constraints + * @category accessing + */ + public List<Constraint> getConstraints() { + return constraints; + } + + /** + * DomainModelを取得する。 + * @return the domainModel + * @category accessing + */ + public DomainModel getDomainModel() { + return domainModel; + } + + /** + * ForeignKeyModelを取得する。 + * @return the foreignKeyModel + * @category accessing + */ + public ForeignKeyModel getForeignKeyModel() { + return foreignKeyModel; + } + + /** + * RootModelを取得する。 + * @return the rootModel + * @category accessing + */ + public RootModel getRootModel() { + return rootModel; + } + + /** + * TableModelを取得する。 + * @return the tableModel + * @category accessing + */ + public TableModel getTableModel() { + return tableModel; + } + + /** + * constratinsを初期化する。 + */ + public void initConstraints() { + constraints = new ArrayList<Constraint>(); + } + + /** + * ColumnModelを設定する。 + * @param columnModel the columnModel to set + * @category accessing + */ + public void setColumnModel(ColumnModel columnModel) { + this.columnModel = columnModel; + map.put(columnModel.getId(), columnModel); + } + + /** + * DomainModelを設定する。 + * @param domainModel the domainModel to set + * @category accessing + */ + public void setDomainModel(DomainModel domainModel) { + this.domainModel = domainModel; + map.put(domainModel.getId(), domainModel); + } + + /** + * ForeignKeyModelを設定する。 + * @param foreignKeyModel the foreignKeyModel to set + * @category accessing + */ + public void setForeignKeyModel(ForeignKeyModel foreignKeyModel) { + this.foreignKeyModel = foreignKeyModel; + map.put(foreignKeyModel.getId(), foreignKeyModel); + } + + /** + * RootModelを設定する。 + * @param rootModel the rootModel to set + * @category accessing + */ + public void setRootModel(RootModel rootModel) { + this.rootModel = rootModel; + map.clear(); + map.put(rootModel.getId(), rootModel); + } + + /** + * TableModelを設定する。 + * @param tableModel the tableModel to set + * @category accessing + */ + public void setTableModel(TableModel tableModel) { + this.tableModel = tableModel; + map.put(tableModel.getId(), tableModel); + } + +} Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/NodesCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/NodesCommand.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/NodesCommand.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,49 @@ +/* + * 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.internal.serializer.sax.command; + +import org.xml.sax.Attributes; + +import org.jiemamy.internal.serializer.sax.XmlElement; + +/** + * nodes要素を読み込むクラス。 + * @author ykhr + */ +class NodesCommand extends XmlElementCommandAdapter { + + /** + * {@inheritDoc} + */ + @Override + public XmlElementCommand startChild(XmlElement element, ModelInfo modelInfo, Attributes attributes) { + String elementName = element.getName(); + + if (elementName.equals("table")) { + return new TableCommand(); + } else if (elementName.equals("view")) { + return new ViewCommand(); + } else if (elementName.equals("sticky")) { + return new StickyCommand(); + } + + throw new IllegalStateException(); + } + +} Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/RootCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/RootCommand.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/RootCommand.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,136 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/11/06 + * + * 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.internal.serializer.sax.command; + +import java.util.UUID; + +import org.xml.sax.Attributes; + +import org.jiemamy.internal.serializer.sax.XmlElement; +import org.jiemamy.model.Jiemamy; +import org.jiemamy.model.RootModel; +import org.jiemamy.serializer.Namespaces; + +/** + * RootレベルのCommandクラス。 + * @author ykhr + */ +class RootCommand extends JiemamyModelCommand<RootModel> { + + /** + * {@inheritDoc} + */ + @Override + public void end(ModelInfo modelInfo, XmlElement element, String text) { + } + + /** + * {@inheritDoc} + */ + @Override + public void endChild(XmlElement element, ModelInfo modelInfo, String text) { + String elementName = element.getName(); + RootModel rootModel = modelInfo.getRootModel(); + + if (elementName.equals("beginScript")) { + rootModel.setBeginScript(text); + } else if (elementName.equals("endScript")) { + rootModel.setEndScript(text); + } else if (elementName.equals("description")) { + rootModel.setDescription(text); + } else if (elementName.equals("schemaName")) { + rootModel.setSchemaName(text); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void start(XmlElement element, ModelInfo modelInfo, Attributes attributes) throws ClassNotFoundException { + UUID uuid = UUID.fromString(attributes.getValue("id")); + RootModel rootModel = Jiemamy.newRootModel(uuid); + modelInfo.setRootModel(rootModel); + super.start(element, modelInfo, attributes); + } + + /** + * {@inheritDoc} + */ + @Override + public XmlElementCommand startChild(XmlElement element, ModelInfo modelInfo, Attributes attributes) { + String elementName = element.getName(); + if (elementName.equals("domains")) { + return new XmlElementCommandAdapter() { + + @Override + public XmlElementCommand startChild(XmlElement element, ModelInfo modelInfo, Attributes attributes) { + if (!element.getName().equals("domain")) { + throw new IllegalStateException(); + } + return new DomainCommand(); + } + }; + + } else if (elementName.equals("nodes")) { + return new NodesCommand(); + } else if (elementName.equals("connections")) { + return new ConnectionsCommand(); + } else if (elementName.equals("insertDataSetModels")) { + return new XmlElementCommandAdapter() { + + /** + * {@inheritDoc} + */ + @Override + public XmlElementCommand startChild(XmlElement element, ModelInfo modelInfo, Attributes attributes) { + if (!element.getName().equals("dataSet")) { + throw new IllegalStateException(); + } + // TODO +// return new DataSetCommand(); + return new NullCommand(); + } + }; + } else if (element.getNamespace().equals(Namespaces.VIEW) && elementName.equals("diagramPresentations")) { + // TODO + return new NullCommand(); + } + + if (elementName.equals("dialect")) { + modelInfo.getRootModel().setDialectId(attributes.getValue("class")); + } + + return null; + } + + /** + * {@inheritDoc} + */ + @Override + protected RootModel getTargetModel(ModelInfo modelInfo) { + return modelInfo.getRootModel(); + } + + + // TODO 仮実装Command + private static class NullCommand extends XmlElementCommandAdapter { + } + +} Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/StickyCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/StickyCommand.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/StickyCommand.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,63 @@ +/* + * 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.internal.serializer.sax.command; + +import org.xml.sax.Attributes; + +import org.jiemamy.internal.serializer.sax.XmlElement; +import org.jiemamy.model.node.StickyModel; + +/** + * sticky要素のコマンドクラス。 + * @author ykhr + */ +class StickyCommand extends JiemamyModelCommand<StickyModel> { + + /** StickyModel */ + private StickyModel stickyModel; + + + /** + * {@inheritDoc} + */ + @Override + public void endChild(XmlElement element, ModelInfo modelInfo, String text) { + if (element.getName().equals("contents")) { + stickyModel.setContents(text); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void start(XmlElement element, ModelInfo modelInfo, Attributes attributes) throws ClassNotFoundException { + stickyModel = modelInfo.getRootModel().newModel(StickyModel.class); + super.start(element, modelInfo, attributes); + } + + /** + * {@inheritDoc} + */ + @Override + protected StickyModel getTargetModel(ModelInfo modelInfo) { + return stickyModel; + } + +} Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/TableCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/TableCommand.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/TableCommand.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,82 @@ +/* + * 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.internal.serializer.sax.command; + +import java.util.UUID; + +import org.xml.sax.Attributes; + +import org.jiemamy.internal.serializer.sax.XmlElement; +import org.jiemamy.model.node.AbstractEntityModel; +import org.jiemamy.model.node.TableModel; + +/** + * table要素のコマンドクラス。 + * @author ykhr + */ +class TableCommand extends EntityModelCommand { + + /** + * {@inheritDoc} + */ + @Override + public void start(XmlElement element, ModelInfo modelInfo, Attributes attributes) throws ClassNotFoundException { + UUID uuid = UUID.fromString(attributes.getValue("id")); + TableModel tableModel = modelInfo.getRootModel().newModel(TableModel.class, uuid); + tableModel.autoDenominate(modelInfo.getRootModel()); + modelInfo.setTableModel(tableModel); + super.start(element, modelInfo, attributes); + } + + /** + * {@inheritDoc} + */ + @Override + public XmlElementCommand startChild(XmlElement element, ModelInfo modelInfo, Attributes attributes) { + String elementName = element.getName(); + + if (elementName.equals("columns")) { + return new XmlElementCommandAdapter() { + + @Override + public XmlElementCommand startChild(XmlElement element, ModelInfo modelInfo, Attributes attributes) { + if (!element.getName().equals("column")) { + throw new IllegalStateException(); + } + return new ColumnCommand(); + } + }; + } else if (elementName.equals("sourceConnections") || elementName.equals("targetConnections")) { + // 外部キー部分は、あとで読み込む + return new XmlElementCommandAdapter() { + }; + } + + return null; + } + + /** + * {@inheritDoc} + */ + @Override + protected AbstractEntityModel getTargetEntityModel(ModelInfo modelInfo) { + return modelInfo.getTableModel(); + } + +} Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ViewCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ViewCommand.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/ViewCommand.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,70 @@ +/* + * 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.internal.serializer.sax.command; + +import java.util.UUID; + +import org.xml.sax.Attributes; + +import org.jiemamy.internal.serializer.sax.XmlElement; +import org.jiemamy.model.node.AbstractEntityModel; +import org.jiemamy.model.node.ViewModel; + +/** + * view要素のコマンドクラス。 + * @author ykhr + */ +class ViewCommand extends EntityModelCommand { + + /** ViewModel */ + private ViewModel viewModel; + + + /** + * {@inheritDoc} + */ + @Override + public void endChild(XmlElement element, ModelInfo modelInfo, String text) { + if (element.getName().equals("definition")) { + viewModel.setDefinition(text); + } else { + super.endChild(element, modelInfo, text); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void start(XmlElement element, ModelInfo modelInfo, Attributes attributes) throws ClassNotFoundException { + UUID uuid = UUID.fromString(attributes.getValue("id")); + viewModel = modelInfo.getRootModel().newModel(ViewModel.class, uuid); + viewModel.autoDenominate(modelInfo.getRootModel()); + super.start(element, modelInfo, attributes); + } + + /** + * {@inheritDoc} + */ + @Override + protected AbstractEntityModel getTargetEntityModel(ModelInfo modelInfo) { + return viewModel; + } + +} Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/XmlElementCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/XmlElementCommand.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/XmlElementCommand.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,80 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/11/06 + * + * 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.internal.serializer.sax.command; + +import org.xml.sax.Attributes; + +import org.jiemamy.internal.serializer.sax.XmlElement; + +/** + * XMLの1要素に紐付くコマンドのインタフェース。 + * @author ykhr + */ +interface XmlElementCommand { + + /** + * 終了処理。 + * + * <p>このコマンドに関連付いた要素の終了時に呼ばれる。</p> + * + * @param modelInfo + * @param element + * @param text + */ + void end(ModelInfo modelInfo, XmlElement element, String text); + + /** + * 子要素の終了処理。 + * + * <p>配下の要素の終了時に呼ばれる。</p> + * + * @param element + * @param modelInfo + * @param text + */ + void endChild(XmlElement element, ModelInfo modelInfo, String text); + + /** + * 開始処理。 + * + * <p>このコマンドに関連付いた要素の最初に呼ばれる。</p> + * + * @param element + * @param modelInfo + * @param attributes + * @throws ClassCastException XMLに指定されたクラスが、必要なインターフェイスを実装していない場合 + * @throws ClassNotFoundException XMLに指定されたクラスが見つからない場合 + */ + void start(XmlElement element, ModelInfo modelInfo, Attributes attributes) throws ClassNotFoundException; + + /** + * 子要素の開始処理。 + * + * <p>配下の要素の開始時に呼ばれる。</p> + * + * @param element + * @param modelInfo + * @param attributes + * @return XmlElementCommand + * @throws ClassNotFoundException XMLに指定されたクラスが見つからない場合 + */ + XmlElementCommand startChild(XmlElement element, ModelInfo modelInfo, Attributes attributes) + throws ClassNotFoundException; + +} Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/XmlElementCommandAdapter.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/XmlElementCommandAdapter.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/XmlElementCommandAdapter.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,59 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/11/07 + * + * 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.internal.serializer.sax.command; + +import org.xml.sax.Attributes; + +import org.jiemamy.internal.serializer.sax.XmlElement; + +/** + * 空実装のXmlElementCommand。 + * @author ykhr + */ +class XmlElementCommandAdapter implements XmlElementCommand { + + /** + * {@inheritDoc} + */ + public void end(ModelInfo modelInfo, XmlElement element, String text) { + } + + /** + * {@inheritDoc} + */ + public void endChild(XmlElement element, ModelInfo modelInfo, String text) { + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unused") + public void start(XmlElement element, ModelInfo modelInfo, Attributes attributes) throws ClassNotFoundException { + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unused") + public XmlElementCommand startChild(XmlElement element, ModelInfo modelInfo, Attributes attributes) + throws ClassNotFoundException { + return null; + } + +} Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/XmlElementStack.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/XmlElementStack.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/command/XmlElementStack.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,109 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/11/06 + * + * 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.internal.serializer.sax.command; + +import java.util.Stack; + +import org.jiemamy.internal.serializer.sax.XmlElement; + + +/** + * XMLの構成を保持するクラス。 + * @author ykhr + */ +class XmlElementStack { + + /** XMLの要素のスタック */ + private Stack<XmlElement> stack = new Stack<XmlElement>(); + + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) { + if (!(obj instanceof XmlElementStack)) { + return false; + } + + XmlElementStack xmlElementStack = (XmlElementStack) obj; + return stack.equals(xmlElementStack.stack); + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + return stack.hashCode(); + } + + /** + * peek + * @return スタックの先頭のXmlElement + */ + public XmlElement peek() { + return stack.peek(); + } + + /** + * pop + * @return スタックの先頭のXmlElement + */ + public XmlElement pop() { + return stack.pop(); + } + + /** + * スタックの先頭にXmlElementを追加する。 + * @param element 追加するXmlElement + */ + public void push(XmlElement element) { + stack.push(element); + } + + /** + * 現時点のスタックのコピーを作成する。 + * @return XmlElementStackのコピー + */ + public XmlElementStack snapshot() { + XmlElementStack newStack = new XmlElementStack(); + for (XmlElement element : stack) { + // 新しいインスタンスを作る必要はなさそうだけど・・・ + newStack.stack.push(new XmlElement(element.getNamespace(), element.getName())); + } + + return newStack; + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + for (XmlElement element : stack) { + sb.append("/"); + sb.append(element.getName()); + } + + return sb.toString(); + } + +} Copied: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element (from rev 2263, artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element) Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/AdapterXmlElement.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/AdapterXmlElement.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/AdapterXmlElement.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -16,7 +16,7 @@ * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -package org.jiemamy.serializer.element; +package org.jiemamy.internal.serializer.sax.element; import java.lang.reflect.Field; Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/CheckConstraintXmlElement.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/CheckConstraintXmlElement.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/CheckConstraintXmlElement.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -16,7 +16,7 @@ * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -package org.jiemamy.serializer.element; +package org.jiemamy.internal.serializer.sax.element; import org.jiemamy.model.constraint.CheckConstraintModel; import org.jiemamy.serializer.Namespaces; Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/CollectionXmlElement.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/CollectionXmlElement.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/CollectionXmlElement.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -16,7 +16,7 @@ * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -package org.jiemamy.serializer.element; +package org.jiemamy.internal.serializer.sax.element; import java.util.Collection; import java.util.Iterator; Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/ColumnXmlElement.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/ColumnXmlElement.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/ColumnXmlElement.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -16,7 +16,7 @@ * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -package org.jiemamy.serializer.element; +package org.jiemamy.internal.serializer.sax.element; import org.apache.commons.lang.StringUtils; Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/ConstraintXmlElement.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/ConstraintXmlElement.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/ConstraintXmlElement.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -16,7 +16,7 @@ * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -package org.jiemamy.serializer.element; +package org.jiemamy.internal.serializer.sax.element; import org.jiemamy.model.constraint.Constraint; import org.jiemamy.serializer.Namespaces; Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/DataTypeXmlElement.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/DataTypeXmlElement.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/DataTypeXmlElement.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -16,7 +16,7 @@ * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -package org.jiemamy.serializer.element; +package org.jiemamy.internal.serializer.sax.element; import org.jiemamy.model.datatype.DataType; import org.jiemamy.model.datatype.DataTypeAdapter; Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/DiagramPresentationXmlElement.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/DiagramPresentationXmlElement.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/DiagramPresentationXmlElement.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -16,7 +16,7 @@ * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -package org.jiemamy.serializer.element; +package org.jiemamy.internal.serializer.sax.element; import org.jiemamy.serializer.Namespaces; import org.jiemamy.model.DiagramPresentationModel; Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/DomainXmlElement.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/DomainXmlElement.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/DomainXmlElement.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -16,7 +16,7 @@ * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -package org.jiemamy.serializer.element; +package org.jiemamy.internal.serializer.sax.element; import org.jiemamy.model.datatype.DomainModel; import org.jiemamy.serializer.Namespaces; Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/ForeignKeyMappingXmlElement.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/ForeignKeyMappingXmlElement.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/ForeignKeyMappingXmlElement.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -16,7 +16,7 @@ * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -package org.jiemamy.serializer.element; +package org.jiemamy.internal.serializer.sax.element; import org.jiemamy.model.connection.ForeignKeyMapping; import org.jiemamy.serializer.Namespaces; Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/ForeignKeyXmlElement.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/ForeignKeyXmlElement.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/ForeignKeyXmlElement.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -16,7 +16,7 @@ * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -package org.jiemamy.serializer.element; +package org.jiemamy.internal.serializer.sax.element; import org.jiemamy.model.connection.ForeignKeyModel; import org.jiemamy.model.node.TableModel; Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/InsertDataSetXmlElement.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/InsertDataSetXmlElement.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/InsertDataSetXmlElement.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -16,7 +16,7 @@ * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -package org.jiemamy.serializer.element; +package org.jiemamy.internal.serializer.sax.element; import org.jiemamy.model.dataset.InsertDataSetModel; import org.jiemamy.serializer.Namespaces; Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/MapXmlElement.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/MapXmlElement.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/MapXmlElement.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -16,7 +16,7 @@ * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -package org.jiemamy.serializer.element; +package org.jiemamy.internal.serializer.sax.element; import java.util.Collection; import java.util.Map; Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/PropertyXmlElement.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/PropertyXmlElement.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/PropertyXmlElement.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -16,7 +16,7 @@ * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -package org.jiemamy.serializer.element; +package org.jiemamy.internal.serializer.sax.element; import org.jiemamy.serializer.Namespaces; Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/RecordXmlElement.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/RecordXmlElement.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/RecordXmlElement.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -16,7 +16,7 @@ * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -package org.jiemamy.serializer.element; +package org.jiemamy.internal.serializer.sax.element; import org.jiemamy.model.dataset.RecordModel; import org.jiemamy.serializer.Namespaces; Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/RootXmlElement.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/RootXmlElement.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/RootXmlElement.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -16,7 +16,7 @@ * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -package org.jiemamy.serializer.element; +package org.jiemamy.internal.serializer.sax.element; import org.jiemamy.model.DiagramPresentations; import org.jiemamy.model.RootModel; Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/StickyXmlElement.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/StickyXmlElement.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/StickyXmlElement.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -16,7 +16,7 @@ * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -package org.jiemamy.serializer.element; +package org.jiemamy.internal.serializer.sax.element; import org.jiemamy.model.node.StickyModel; import org.jiemamy.serializer.Namespaces; Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/TableXmlElement.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/TableXmlElement.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/TableXmlElement.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -16,7 +16,7 @@ * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -package org.jiemamy.serializer.element; +package org.jiemamy.internal.serializer.sax.element; import org.jiemamy.model.node.TableModel; import org.jiemamy.serializer.Namespaces; Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/ViewXmlElement.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/ViewXmlElement.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/ViewXmlElement.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -16,7 +16,7 @@ * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -package org.jiemamy.serializer.element; +package org.jiemamy.internal.serializer.sax.element; import org.jiemamy.model.node.ViewModel; import org.jiemamy.serializer.Namespaces; Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/XmlElement.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/element/XmlElement.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/sax/element/XmlElement.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -16,7 +16,7 @@ * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -package org.jiemamy.serializer.element; +package org.jiemamy.internal.serializer.sax.element; import java.util.Collection; import java.util.Iterator; Copied: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyModelReadingEvent.java (from rev 2263, artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/stax/JiemamyEvent.java) =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyModelReadingEvent.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyModelReadingEvent.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,45 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/12/15 + * + * 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.internal.serializer.stax; + +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; + +import org.jiemamy.model.RootModel; + +/** + * Jiemamyのモデル(オブジェクトモデルや、XMLモデル)の逐次読み込み時に発生するイベント + * @author daisuke + */ +public interface JiemamyModelReadingEvent { + + /** + * TODO for daisuke + * @param rootModel + */ + void doWrite(RootModel rootModel); + + /** + * TODO for daisuke + * @param xmlWriter + * @throws XMLStreamException + */ + void doWrite(XMLStreamWriter xmlWriter) throws XMLStreamException; + +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyModelReadingEvent.java ___________________________________________________________________ Name: svn:mime-type + text/plain Copied: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyWriter.java (from rev 2263, artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/stax/JiemamyWriter.java) =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyWriter.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyWriter.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,34 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/12/15 + * + * 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.internal.serializer.stax; + +/** + * {@link JiemamyModelReadingEvent}の内容を書き出す、ライターインターフェイス。 + * @author daisuke + */ +public interface JiemamyWriter { + + /** + * イベントの内容を書き出す。 + * @param event + * @throws JiemamyWriterException + */ + void write(JiemamyModelReadingEvent event) throws JiemamyWriterException; + +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyWriter.java ___________________________________________________________________ Name: svn:mime-type + text/plain Copied: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyWriterException.java (from rev 2263, artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/stax/JiemamyWriterException.java) =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyWriterException.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyWriterException.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,64 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/12/15 + * + * 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.internal.serializer.stax; + +/** + * TODO for daisuke + * @author daisuke + */ + @ SuppressWarnings("serial") +public class JiemamyWriterException extends Exception { + + /** + * コンストラクタ。 + * @category instance creation + */ + public JiemamyWriterException() { + super(); + } + + /** + * コンストラクタ。 + * @param message + * @category instance creation + */ + public JiemamyWriterException(String message) { + super(message); + } + + /** + * コンストラクタ。 + * @param message + * @param cause + * @category instance creation + */ + public JiemamyWriterException(String message, Throwable cause) { + super(message, cause); + } + + /** + * コンストラクタ。 + * @param cause + * @category instance creation + */ + public JiemamyWriterException(Throwable cause) { + super(cause); + } + +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyWriterException.java ___________________________________________________________________ Name: svn:mime-type + text/plain Copied: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyXmlWriter.java (from rev 2263, artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/stax/JiemamyXmlWriter.java) =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyXmlWriter.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyXmlWriter.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,64 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/12/15 + * + * 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.internal.serializer.stax; + +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.commons.lang.Validate; + +/** + * TODO for daisuke + * @author daisuke + */ +public class JiemamyXmlWriter implements JiemamyWriter { + + private XMLStreamWriter xmlWriter; + + + /** + * コンストラクタ。 + * @param xmlWriter + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + * @category instance creation + */ + public JiemamyXmlWriter(XMLStreamWriter xmlWriter) { + Validate.notNull(xmlWriter); + this.xmlWriter = xmlWriter; + } + + /** + * {@inheritDoc} + */ + public void write(JiemamyModelReadingEvent event) throws JiemamyWriterException { + try { + event.doWrite(xmlWriter); + } catch (XMLStreamException e) { + throw new JiemamyWriterException(e); + } + +// xmlWriter.writeStartDocument(); +// xmlWriter.writeComment("comment"); +// xmlWriter.writeStartElement("hoge"); +// xmlWriter.writeEndElement(); +// xmlWriter.writeEmptyElement("fuga"); +// xmlWriter.writeEndDocument(); + } + +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyXmlWriter.java ___________________________________________________________________ Name: svn:mime-type + text/plain Copied: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/RootModelReader.java (from rev 2263, artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/stax/RootModelReader.java) =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/RootModelReader.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/RootModelReader.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,71 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/12/15 + * + * 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.internal.serializer.stax; + +import java.util.Stack; + +import org.jiemamy.internal.serializer.stax.event.OpenEvent; +import org.jiemamy.internal.serializer.stax.event.StartElementEvent; +import org.jiemamy.model.RootModel; + +/** + * {@link RootModel}の内容を{@link JiemamyModelReadingEvent}として読み出す、Reader実装。 + * @author daisuke + */ +public class RootModelReader { + + private RootModel rootModel; + + private Stack<Object> stack; + + + /** + * コンストラクタ。 + * @param rootModel + * @category instance creation + */ + public RootModelReader(RootModel rootModel) { + this.rootModel = rootModel; + } + + /** + * 次のイベントがあるかどうか調べる。 + * @return 次のイベントがある場合{@code true}、無い場合{@code false}を返す + */ + public boolean hasNext() { + return stack != null && stack.isEmpty(); + } + + /** + * TODO for daisuke + * @return + */ + public JiemamyModelReadingEvent nextEvent() { + JiemamyModelReadingEvent result = null; + if (stack == null) { + stack = new Stack<Object>(); + result = new OpenEvent(); + } else if (stack.size() == 0) { + stack.push(rootModel); + result = new StartElementEvent(rootModel); + } + return result; + } + +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/RootModelReader.java ___________________________________________________________________ Name: svn:mime-type + text/plain Copied: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/RootModelWriter.java (from rev 2263, artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/stax/RootModelWriter.java) =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/RootModelWriter.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/RootModelWriter.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,47 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/12/15 + * + * 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.internal.serializer.stax; + +import org.jiemamy.model.RootModel; + +/** + * {@link JiemamyModelReadingEvent}の内容を{@link RootModel}に書き出す、Writer実装。 + * @author daisuke + */ +public class RootModelWriter implements JiemamyWriter { + + private RootModel rootModel; + + + /** + * 書き出し結果の{@link RootModel}を取得する。 + * @return 書き出し結果 + */ + public RootModel getRootModel() { + return rootModel; + } + + /** + * {@inheritDoc} + */ + public void write(JiemamyModelReadingEvent event) { + event.doWrite(rootModel); + } + +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/RootModelWriter.java ___________________________________________________________________ Name: svn:mime-type + text/plain Copied: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event (from rev 2263, artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/stax/event) Deleted: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/AbstractJiemamyEvent.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/stax/event/AbstractJiemamyEvent.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/AbstractJiemamyEvent.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -1,69 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/12/15 - * - * 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.stax.event; - -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.events.XMLEvent; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.jiemamy.serializer.stax.JiemamyEvent; -import org.jiemamy.utils.StaxUtil; - -/** - * TODO for daisuke - * @author daisuke - */ -public abstract class AbstractJiemamyEvent implements JiemamyEvent { - - private static Logger logger = LoggerFactory.getLogger(AbstractJiemamyEvent.class); - - - /** - * TODO for daisuke - * @param xmlEvent - * @return - */ - public static JiemamyEvent newInstance(XMLEvent xmlEvent) { - logger.info("Type: " + StaxUtil.toEventTypeEnum(xmlEvent.getEventType()).toString()); - logger.info("String: " + xmlEvent.toString()); - - switch (xmlEvent.getEventType()) { - case XMLStreamConstants.START_DOCUMENT: - return new StartEvent(); - - case XMLStreamConstants.END_DOCUMENT: - return new EndEvent(); - - case XMLStreamConstants.START_ELEMENT: - return new StartElementEvent(xmlEvent.asStartElement()); - - case XMLStreamConstants.END_ELEMENT: - return new EndElementEvent(xmlEvent.asEndElement()); - - case XMLStreamConstants.CHARACTERS: - return new CharactersEvent(xmlEvent.asCharacters().getData()); - - default: - return new NullEvent(); - } - } - -} Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/AbstractJiemamyModelReadingEvent.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/AbstractJiemamyModelReadingEvent.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/AbstractJiemamyModelReadingEvent.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,71 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/12/15 + * + * 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.internal.serializer.stax.event; + +import javax.xml.stream.XMLEventReader; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.events.XMLEvent; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.jiemamy.internal.serializer.stax.JiemamyModelReadingEvent; +import org.jiemamy.utils.StaxUtil; + +/** + * TODO for daisuke + * @author daisuke + */ +public abstract class AbstractJiemamyModelReadingEvent implements JiemamyModelReadingEvent { + + private static Logger logger = LoggerFactory.getLogger(AbstractJiemamyModelReadingEvent.class); + + + /** + * TODO for daisuke + * @param source + * @param xmlEvent + * @return + */ + public static JiemamyModelReadingEvent newInstance(XMLEventReader source, XMLEvent xmlEvent) { + logger.info("Type: " + StaxUtil.toEventTypeEnum(xmlEvent.getEventType()).toString()); + logger.info("String: " + xmlEvent.toString()); + + switch (xmlEvent.getEventType()) { + case XMLStreamConstants.START_DOCUMENT: + return new OpenEvent(); + + case XMLStreamConstants.END_DOCUMENT: + return new CloseEvent(); + + case XMLStreamConstants.START_ELEMENT: + return new StartElementEvent(xmlEvent.asStartElement()); + + case XMLStreamConstants.END_ELEMENT: + return new EndElementEvent(xmlEvent.asEndElement()); + + case XMLStreamConstants.CHARACTERS: + return new ContentsEvent(xmlEvent.asCharacters().getData()); + + default: + return new NullEvent(); + } + } + +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/AbstractJiemamyModelReadingEvent.java ___________________________________________________________________ Name: svn:mime-type + text/plain Deleted: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/CharactersEvent.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/stax/event/CharactersEvent.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/CharactersEvent.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -1,61 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/12/15 - * - * 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.stax.event; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.commons.lang.Validate; - -import org.jiemamy.model.RootModel; - -/** - * TODO for daisuke - * @author daisuke - */ -public class CharactersEvent extends AbstractJiemamyEvent { - - private String text; - - - /** - * コンストラクタ。 - * @param text - * @category instance creation - */ - public CharactersEvent(String text) { - Validate.notNull(text); - this.text = text; - } - - /** - * {@inheritDoc} - */ - public void doWrite(RootModel rootModel) { - // TODO Auto-generated method stub - } - - /** - * {@inheritDoc} - */ - public void doWrite(XMLStreamWriter xmlWriter) throws XMLStreamException { - xmlWriter.writeCharacters(text); - } - -} Copied: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/CloseEvent.java (from rev 2263, artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/stax/event/EndEvent.java) =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/CloseEvent.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/CloseEvent.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,46 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/12/15 + * + * 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.internal.serializer.stax.event; + +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; + +import org.jiemamy.model.RootModel; + +/** + * TODO for daisuke + * @author daisuke + */ +public class CloseEvent extends AbstractJiemamyModelReadingEvent { + + /** + * {@inheritDoc} + */ + public void doWrite(RootModel rootModel) { + // TODO Auto-generated method stub + } + + /** + * {@inheritDoc} + */ + public void doWrite(XMLStreamWriter xmlWriter) throws XMLStreamException { + xmlWriter.writeEndDocument(); + } + +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/CloseEvent.java ___________________________________________________________________ Name: svn:mime-type + text/plain Copied: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/ContentsEvent.java (from rev 2263, artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/stax/event/CharactersEvent.java) =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/ContentsEvent.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/ContentsEvent.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,61 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/12/15 + * + * 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.internal.serializer.stax.event; + +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.commons.lang.Validate; + +import org.jiemamy.model.RootModel; + +/** + * TODO for daisuke + * @author daisuke + */ +public class ContentsEvent extends AbstractJiemamyModelReadingEvent { + + private String text; + + + /** + * コンストラクタ。 + * @param text + * @category instance creation + */ + public ContentsEvent(String text) { + Validate.notNull(text); + this.text = text; + } + + /** + * {@inheritDoc} + */ + public void doWrite(RootModel rootModel) { + // TODO Auto-generated method stub + } + + /** + * {@inheritDoc} + */ + public void doWrite(XMLStreamWriter xmlWriter) throws XMLStreamException { + xmlWriter.writeCharacters(text); + } + +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/ContentsEvent.java ___________________________________________________________________ Name: svn:mime-type + text/plain Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/EndElementEvent.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/stax/event/EndElementEvent.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/EndElementEvent.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -16,20 +16,19 @@ * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -package org.jiemamy.serializer.stax.event; +package org.jiemamy.internal.serializer.stax.event; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; import javax.xml.stream.events.EndElement; import org.jiemamy.model.RootModel; -import org.jiemamy.serializer.stax.JiemamyEvent; /** * TODO for daisuke * @author daisuke */ -public class EndElementEvent implements JiemamyEvent { +public class EndElementEvent extends AbstractJiemamyModelReadingEvent { /** * コンストラクタ。 Deleted: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/EndEvent.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/stax/event/EndEvent.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/EndEvent.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -1,46 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/12/15 - * - * 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.stax.event; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - -import org.jiemamy.model.RootModel; - -/** - * TODO for daisuke - * @author daisuke - */ -public class EndEvent extends AbstractJiemamyEvent { - - /** - * {@inheritDoc} - */ - public void doWrite(RootModel rootModel) { - // TODO Auto-generated method stub - } - - /** - * {@inheritDoc} - */ - public void doWrite(XMLStreamWriter xmlWriter) throws XMLStreamException { - xmlWriter.writeEndDocument(); - } - -} Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/JiemamyXmlConstants.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/stax/event/JiemamyXmlConstants.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/JiemamyXmlConstants.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -16,7 +16,7 @@ * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -package org.jiemamy.serializer.stax.event; +package org.jiemamy.internal.serializer.stax.event; import javax.xml.namespace.QName; Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/NullEvent.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/stax/event/NullEvent.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/NullEvent.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -16,7 +16,7 @@ * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -package org.jiemamy.serializer.stax.event; +package org.jiemamy.internal.serializer.stax.event; import javax.xml.stream.XMLStreamWriter; @@ -26,7 +26,7 @@ * TODO for daisuke * @author daisuke */ -public class NullEvent extends AbstractJiemamyEvent { +public class NullEvent extends AbstractJiemamyModelReadingEvent { /** * {@inheritDoc} Copied: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/OpenEvent.java (from rev 2263, artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/stax/event/StartEvent.java) =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/OpenEvent.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/OpenEvent.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,46 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/12/15 + * + * 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.internal.serializer.stax.event; + +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; + +import org.jiemamy.model.RootModel; + +/** + * TODO for daisuke + * @author daisuke + */ +public class OpenEvent extends AbstractJiemamyModelReadingEvent { + + /** + * {@inheritDoc} + */ + public void doWrite(RootModel rootModel) { + // TODO Auto-generated method stub + } + + /** + * {@inheritDoc} + */ + public void doWrite(XMLStreamWriter xmlWriter) throws XMLStreamException { + xmlWriter.writeStartDocument(); + } + +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/OpenEvent.java ___________________________________________________________________ Name: svn:mime-type + text/plain Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/StartElementEvent.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/stax/event/StartElementEvent.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/StartElementEvent.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -16,27 +16,26 @@ * either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ -package org.jiemamy.serializer.stax.event; +package org.jiemamy.internal.serializer.stax.event; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; import javax.xml.stream.events.StartElement; import org.jiemamy.model.RootModel; -import org.jiemamy.serializer.stax.JiemamyEvent; /** * TODO for daisuke * @author daisuke */ -public class StartElementEvent implements JiemamyEvent { +public class StartElementEvent extends AbstractJiemamyModelReadingEvent { /** * コンストラクタ。 - * @param model + * @param jiemamyModel * @category instance creation */ - public StartElementEvent(Object model) { + public StartElementEvent(Object jiemamyModel) { // TODO Auto-generated constructor stub } Deleted: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/StartEvent.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/stax/event/StartEvent.java 2008-12-14 23:26:59 UTC (rev 2263) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/event/StartEvent.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -1,46 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/12/15 - * - * 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.stax.event; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - -import org.jiemamy.model.RootModel; - -/** - * TODO for daisuke - * @author daisuke - */ -public class StartEvent extends AbstractJiemamyEvent { - - /** - * {@inheritDoc} - */ - public void doWrite(RootModel rootModel) { - // TODO Auto-generated method stub - } - - /** - * {@inheritDoc} - */ - public void doWrite(XMLStreamWriter xmlWriter) throws XMLStreamException { - xmlWriter.writeStartDocument(); - } - -} Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/JiemamySaxSerializer.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/JiemamySaxSerializer.java 2008-12-15 03:21:04 UTC (rev 2264) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/JiemamySaxSerializer.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -30,7 +30,8 @@ import org.apache.commons.lang.SerializationException; import org.xml.sax.SAXException; -import org.jiemamy.model.JiemamyHandler; +import org.jiemamy.internal.serializer.sax.ModelInputStream; +import org.jiemamy.internal.serializer.sax.command.JiemamyHandler; import org.jiemamy.model.RootModel; /** @@ -39,6 +40,11 @@ */ public class JiemamySaxSerializer implements JiemamySerializer { + private static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage"; + + private static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource"; + + /** * {@inheritDoc} */ @@ -49,7 +55,7 @@ factory.setValidating(true); SAXParser parser = factory.newSAXParser(); - parser.setProperty(SCHEMA_LANGUAGE, XML_SCHEMA); + parser.setProperty(SCHEMA_LANGUAGE, Namespaces.XSD); // parser.setProperty(SCHEMA_SOURCE, schema); // TODO XML Schemaによるバリデーションの実装。バリデーション失敗時には SerializationException をスロー。 JiemamyHandler handler = new JiemamyHandler(); Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/JiemamyStaxSerializer.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/JiemamyStaxSerializer.java 2008-12-15 03:21:04 UTC (rev 2264) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/JiemamyStaxSerializer.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -28,13 +28,13 @@ import javax.xml.stream.XMLStreamWriter; import org.jiemamy.exception.SerializationException; +import org.jiemamy.internal.serializer.stax.JiemamyWriter; +import org.jiemamy.internal.serializer.stax.JiemamyWriterException; +import org.jiemamy.internal.serializer.stax.JiemamyXmlWriter; +import org.jiemamy.internal.serializer.stax.RootModelReader; +import org.jiemamy.internal.serializer.stax.RootModelWriter; +import org.jiemamy.internal.serializer.stax.event.AbstractJiemamyModelReadingEvent; import org.jiemamy.model.RootModel; -import org.jiemamy.serializer.stax.JiemamyWriter; -import org.jiemamy.serializer.stax.JiemamyWriterException; -import org.jiemamy.serializer.stax.JiemamyXmlWriter; -import org.jiemamy.serializer.stax.RootModelReader; -import org.jiemamy.serializer.stax.RootModelWriter; -import org.jiemamy.serializer.stax.event.AbstractJiemamyEvent; /** * シリアライザのStAXによる実装。 @@ -57,7 +57,7 @@ writer = new RootModelWriter(); while (reader.hasNext()) { - writer.write(AbstractJiemamyEvent.newInstance(reader.nextEvent())); + writer.write(AbstractJiemamyModelReadingEvent.newInstance(reader, reader.nextEvent())); } } catch (XMLStreamException e) { throw new SerializationException(e); Deleted: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/ModelInputStream.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/ModelInputStream.java 2008-12-15 03:21:04 UTC (rev 2264) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/ModelInputStream.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -1,87 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/10/22 - * - * 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; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Queue; -import java.util.concurrent.LinkedBlockingQueue; - -import org.xml.sax.SAXException; - -import org.jiemamy.exception.UnexpectedConditionError; -import org.jiemamy.model.RootModel; - -/** - * モデルインプットストリーム。 - * - * @author j5ik2o - */ -public class ModelInputStream extends InputStream { - - /** 出力モデルキュー */ - private Queue<Byte> resourceQueue; - - private ModelWriter modelWriter; - - - /** - * コンストラクタ。 - * @param rootModel - * @category instance creation - */ - public ModelInputStream(RootModel rootModel) { - resourceQueue = new LinkedBlockingQueue<Byte>(); - try { - modelWriter = new ModelWriter(rootModel, resourceQueue, Namespaces.CORE + " jiemamy-core.xsd"); - } catch (SAXException e) { - throw new UnexpectedConditionError("something wrong...", e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void close() throws IOException { - try { - modelWriter.dispose(); - } catch (SAXException e) { - throw new IOException(); - } - super.close(); - } - - /** - * {@inheritDoc} - */ - @Override - public int read() throws IOException { - if (resourceQueue.size() == 0) { - try { - if (modelWriter.write() == false) { - return -1; - } - } catch (SAXException e) { - throw new IOException(); - } - } - return resourceQueue.poll().intValue(); - } -} Deleted: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/ModelWriter.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/ModelWriter.java 2008-12-15 03:21:04 UTC (rev 2264) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/ModelWriter.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -1,204 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/10/25 - * - * 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; - -import java.io.StringWriter; -import java.util.Queue; -import java.util.Stack; - -import com.megginson.sax.DataWriter; - -import org.apache.commons.lang.Validate; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.AttributesImpl; - -import org.jiemamy.model.DiagramPresentations; -import org.jiemamy.model.RootModel; -import org.jiemamy.serializer.element.RootXmlElement; -import org.jiemamy.serializer.element.XmlElement; -import org.jiemamy.serializer.element.XmlElement.ElementState; - -/** - * モデルライター。 - * - * @author j5ik2o - */ -public class ModelWriter { - - /** - * 処理中のモデル構造スタック - * - * <pre> - * <foo> - * <bar/> - * <baz/> - * </foo> - * </pre> - * - * 上記のようなXML構造の場合、下記の順にスタック操作が行われる。 - * - * <ul> - * <li>push foo</li> - * <li>push bar</li> - * <li>pop bar</li> - * <li>push baz</li> - * <li>pop baz</li> - * <li>pop foo</li> - * </ul> - */ - private Stack<XmlElement> xmlStack = new Stack<XmlElement>(); - - private DataWriter dataWriter = new DataWriter(); - - private final Queue<Byte> resourceQueue; - - private String schemaLocation; - - - /** - * コンストラクタ。 - * @param rootModel - * @param resourceQueue - * @param schemaLocation - * @throws SAXException - * @throws IllegalArgumentException 引数rootModel, resourceQueueに{@code null}を与えた場合 - * @category instance creation - */ - public ModelWriter(RootModel rootModel, Queue<Byte> resourceQueue, String schemaLocation) throws SAXException { - assert xmlStack != null; - assert dataWriter != null; - Validate.notNull(rootModel); - Validate.notNull(resourceQueue); - - this.resourceQueue = resourceQueue; - dataWriter.forceNSDecleration(Namespaces.CORE, ""); - if (rootModel.hasAdapter(DiagramPresentations.class)) { - dataWriter.forceNSDecleration(Namespaces.VIEW, "view"); - } - dataWriter.forceNSDecleration(Namespaces.XSI, "xsi"); - - this.schemaLocation = schemaLocation; - - dataWriter.setIndentStep(2); - - StringWriter sw = new StringWriter(); - dataWriter.setOutput(sw); - dataWriter.startDocument(); - - addToQueue(sw.toString().getBytes()); - - xmlStack.push(new RootXmlElement(rootModel)); - } - - /** - * 破棄処理を行う。 - * @throws SAXException - */ - public void dispose() throws SAXException { - assert dataWriter != null; - dataWriter.endDocument(); - } - - /** - * 1行分をresourceQueueに出力する。 - * - * <p>1行というのは、 - * <ul> - * <li>タグのオープン</li> - * <li>それ以外のdataElementの出力</li> - * <li>タグのクローズ</li> - * </ul> - * と定義。</p> - * - * @return 出力する対象がもう残っていない場合は{@code false} - * @throws SAXException - */ - public boolean write() throws SAXException { - assert xmlStack != null; - assert dataWriter != null; - - if (xmlStack.isEmpty()) { - return false; - } - StringWriter sw = new StringWriter(); - dataWriter.setOutput(sw); // 毎回出力先を更新する - - write(xmlStack.peek()); - - addToQueue(sw.toString().getBytes()); - - return resourceQueue.size() > 0; - } - - /** - * 今回出力された内容をキューに突っ込む。 - * @param bytes - */ - private void addToQueue(byte[] bytes) { - assert resourceQueue != null; - Validate.notNull(bytes); - - for (byte b : bytes) { - if (b != 0) { - resourceQueue.add(b); - } - } - } - - /** - * TODO for daisuke - * @param attrs - */ - private void process(AttributesImpl attrs) { - if (schemaLocation != null) { - attrs.addAttribute(Namespaces.XSI, "schemaLocation", "xsi:schemaLocation", "CDATA", schemaLocation); - schemaLocation = null; - } - } - - private void write(XmlElement element) throws SAXException { - if (element.getState() == ElementState.INIT) { - if (element.hasNext()) { - AttributesImpl attrs = (AttributesImpl) element.getAttributes(); - process(attrs); - dataWriter.startElement(Namespaces.CORE, element.getName(), element.getName(), attrs); - element.setState(ElementState.PROGRESS); - xmlStack.push(element.next()); - } else { - if (element.isEmptyElement()) { - dataWriter.emptyElement(Namespaces.CORE, element.getName(), element.getName(), element - .getAttributes()); - } else { - dataWriter.dataElement(Namespaces.CORE, element.getName(), element.getName(), element - .getAttributes(), element.toString()); - } - element.setState(ElementState.FINISHED); - xmlStack.pop(); - } - } else if (element.getState() == ElementState.PROGRESS) { - if (element.hasNext()) { - xmlStack.push(element.next()); - } else { - dataWriter.endElement(Namespaces.CORE, element.getName(), element.getName()); - element.setState(ElementState.FINISHED); - xmlStack.pop(); - } - } - } -} Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/Namespaces.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/Namespaces.java 2008-12-15 03:21:04 UTC (rev 2264) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/serializer/Namespaces.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -27,6 +27,9 @@ /** XML Namespace specifications */ public static final String XMLNS = "http://www.w3.org/2000/xmlns/"; + /** XML Schema */ + public static final String XSD = "http://www.w3.org/2001/XMLSchema"; + /** XML Schema instance */ public static final String XSI = "http://www.w3.org/2001/XMLSchema-instance"; Copied: artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/internal/serializer/sax/ModelInputStreamTest.java (from rev 2263, artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/serializer/ModelInputStreamTest.java) =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/internal/serializer/sax/ModelInputStreamTest.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/internal/serializer/sax/ModelInputStreamTest.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -0,0 +1,202 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/10/22 + * + * 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.internal.serializer.sax; + +import static org.junit.Assert.assertEquals; + +import java.io.BufferedReader; +import java.io.InputStreamReader; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.text.StrBuilder; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.jiemamy.ReflectionDialectAccessStrategy; +import org.jiemamy.internal.serializer.sax.ModelInputStream; +import org.jiemamy.model.Artemis; +import org.jiemamy.model.Jiemamy; +import org.jiemamy.model.RootModel; +import org.jiemamy.model.attribute.ColumnModel; +import org.jiemamy.model.datatype.IntegerDataTypeDescriptor; +import org.jiemamy.model.datatype.TimestampDataTypeDescriptor; +import org.jiemamy.model.datatype.VarcharDataTypeDescriptor; +import org.jiemamy.model.node.TableModel; + +/** + * {@link ModelInputStream}のテストクラス。 + * @author junichi + */ +public class ModelInputStreamTest { + + private static Logger logger = LoggerFactory.getLogger(ModelInputStreamTest.class); + + + /** + * setup + * @throws Exception + */ + @Before + public void setUp() throws Exception { + Jiemamy.init(Artemis.VIEW, new ReflectionDialectAccessStrategy()); + } + + /** + * teardown + * @throws Exception + */ + @After + public void tearDown() throws Exception { + Jiemamy.dispose(); + } + + /** + * モデルをInputStreamに変えるテスト + * @throws Exception + */ + @Test + public void testRead() throws Exception { + RootModel rootModel = Jiemamy.newRootModel(); + rootModel.setDialectId("org.jiemamy.dialect.mysql.MySqlDialect"); + rootModel.setBeginScript("BEGIN;"); + rootModel.setEndScript("COMMIT;"); + rootModel.setDescription("シリアライゼーションイメージ"); + rootModel.setSchemaName("FOO"); + + TableModel t = rootModel.newModel(TableModel.class); + t.setName("T_DEPT"); + t.setDescription("HOGEHOGE"); + + ColumnModel col1 = rootModel.newModel(ColumnModel.class); + ColumnModel col2 = rootModel.newModel(ColumnModel.class); + ColumnModel col3 = rootModel.newModel(ColumnModel.class); + + col1.setName("col1"); + col1.setDataTypeDescriptor(new IntegerDataTypeDescriptor()); + col2.setName("col2"); + col2.setDataTypeDescriptor(new VarcharDataTypeDescriptor(16)); + col3.setName("col3"); + col3.setDataTypeDescriptor(new TimestampDataTypeDescriptor()); + + t.appendModel(col1); + t.appendModel(col2); + t.appendModel(col3); + rootModel.appendModel(t); + + // もっと複雑なモデルを出したい時、コメント外す。 +// rootModel = new ApplicationModelCreator().createModel(); + + StrBuilder sbActual = new StrBuilder(); + BufferedReader reader = null; + try { + reader = new BufferedReader(new InputStreamReader(new ModelInputStream(rootModel))); + String buf; + while ((buf = reader.readLine()) != null) { + sbActual.appendln(buf); + } + } finally { + IOUtils.closeQuietly(reader); + } + + StrBuilder sbExpected = new StrBuilder(); + sbExpected.appendln("<?xml version=\"1.0\"?>"); + sbExpected.appendln("<rootModel id=\"" + rootModel.getId().toString() + "\" " + + "xsi:schemaLocation=\"http://jiemamy.org/xml/ns/core jiemamy-core.xsd\"" + + " xmlns=\"http://jiemamy.org/xml/ns/core\"" + + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + + " xmlns:view=\"http://jiemamy.org/xml/ns/view\">"); + sbExpected.appendln(" <dialect>org.jiemamy.dialect.mysql.MySqlDialect</dialect>"); + sbExpected.appendln(" <schemaName>FOO</schemaName>"); + sbExpected.appendln(" <beginScript>BEGIN;</beginScript>"); + sbExpected.appendln(" <endScript>COMMIT;</endScript>"); + sbExpected.appendln(" <description>シリアライゼーションイメージ</description>"); + sbExpected.appendln(" <domains/>"); + sbExpected.appendln(" <nodes>"); + sbExpected.appendln(" <table id=\"" + t.getId().toString() + "\">"); + sbExpected.appendln(" <name>T_DEPT</name>"); + sbExpected.appendln(" <logicalName/>"); + sbExpected.appendln(" <sourceConnections/>"); + sbExpected.appendln(" <targetConnections/>"); + sbExpected.appendln(" <beginScript/>"); + sbExpected.appendln(" <endScript/>"); + sbExpected.appendln(" <description>HOGEHOGE</description>"); + sbExpected.appendln(" <columns>"); + sbExpected.appendln(" <column id=\"" + t.getColumns().get(0).getId().toString() + "\">"); + sbExpected.appendln(" <name>col1</name>"); + sbExpected.appendln(" <logicalName/>"); + sbExpected.appendln(" <dataType class=\"org.jiemamy.model.datatype.IntegerDataTypeDescriptor\"/>"); + sbExpected.appendln(" <defaultValue/>"); + sbExpected.appendln(" <constraints/>"); + sbExpected.appendln(" <simpleIndex>false</simpleIndex>"); + sbExpected.appendln(" <freeString/>"); + sbExpected.appendln(" <description/>"); + sbExpected.appendln(" <options/>"); + sbExpected.appendln(" <representation>false</representation>"); + sbExpected.appendln(" </column>"); + sbExpected.appendln(" <column id=\"" + t.getColumns().get(1).getId().toString() + "\">"); + sbExpected.appendln(" <name>col2</name>"); + sbExpected.appendln(" <logicalName/>"); + sbExpected.appendln(" <dataType class=\"org.jiemamy.model.datatype.VarcharDataTypeDescriptor\">"); + sbExpected.appendln(" <adapter class=\"org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter\">"); + sbExpected.appendln(" <property name=\"size\">16</property>"); + sbExpected.appendln(" </adapter>"); + sbExpected.appendln(" </dataType>"); + sbExpected.appendln(" <defaultValue/>"); + sbExpected.appendln(" <constraints/>"); + sbExpected.appendln(" <simpleIndex>false</simpleIndex>"); + sbExpected.appendln(" <freeString/>"); + sbExpected.appendln(" <description/>"); + sbExpected.appendln(" <options/>"); + sbExpected.appendln(" <representation>false</representation>"); + sbExpected.appendln(" </column>"); + sbExpected.appendln(" <column id=\"" + t.getColumns().get(2).getId().toString() + "\">"); + sbExpected.appendln(" <name>col3</name>"); + sbExpected.appendln(" <logicalName/>"); + sbExpected.appendln(" <dataType class=\"org.jiemamy.model.datatype.TimestampDataTypeDescriptor\">"); + sbExpected + .appendln(" <adapter class=\"org.jiemamy.model.datatype.adapter.TimezonedDataTypeAdapter\">"); + sbExpected.appendln(" <property name=\"withTimezone\">false</property>"); + sbExpected.appendln(" </adapter>"); + sbExpected.appendln(" </dataType>"); + sbExpected.appendln(" <defaultValue/>"); + sbExpected.appendln(" <constraints/>"); + sbExpected.appendln(" <simpleIndex>false</simpleIndex>"); + sbExpected.appendln(" <freeString/>"); + sbExpected.appendln(" <description/>"); + sbExpected.appendln(" <options/>"); + sbExpected.appendln(" <representation>false</representation>"); + sbExpected.appendln(" </column>"); + sbExpected.appendln(" </columns>"); + sbExpected.appendln(" </table>"); + sbExpected.appendln(" </nodes>"); + sbExpected.appendln(" <connections/>"); + sbExpected.appendln(" <insertDataSetModels/>"); + sbExpected.appendln(" <view:diagramPresentations/>"); + sbExpected.appendln("</rootModel>"); + + logger.info("================ actual ================================================================"); + logger.info(sbActual.toString()); + logger.info("================ expected =============================================================="); + logger.info(sbExpected.toString()); + assertEquals(sbExpected.toString(), sbActual.toString()); + } +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/internal/serializer/sax/ModelInputStreamTest.java ___________________________________________________________________ Name: svn:mime-type + text/plain Deleted: artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/serializer/ModelInputStreamTest.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/serializer/ModelInputStreamTest.java 2008-12-15 03:21:04 UTC (rev 2264) +++ artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/serializer/ModelInputStreamTest.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -1,201 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/10/22 - * - * 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; - -import static org.junit.Assert.assertEquals; - -import java.io.BufferedReader; -import java.io.InputStreamReader; - -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.text.StrBuilder; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.jiemamy.ReflectionDialectAccessStrategy; -import org.jiemamy.model.Artemis; -import org.jiemamy.model.Jiemamy; -import org.jiemamy.model.RootModel; -import org.jiemamy.model.attribute.ColumnModel; -import org.jiemamy.model.datatype.IntegerDataTypeDescriptor; -import org.jiemamy.model.datatype.TimestampDataTypeDescriptor; -import org.jiemamy.model.datatype.VarcharDataTypeDescriptor; -import org.jiemamy.model.node.TableModel; - -/** - * {@link ModelInputStream}のテストクラス。 - * @author junichi - */ -public class ModelInputStreamTest { - - private static Logger logger = LoggerFactory.getLogger(ModelInputStreamTest.class); - - - /** - * setup - * @throws Exception - */ - @Before - public void setUp() throws Exception { - Jiemamy.init(Artemis.VIEW, new ReflectionDialectAccessStrategy()); - } - - /** - * teardown - * @throws Exception - */ - @After - public void tearDown() throws Exception { - Jiemamy.dispose(); - } - - /** - * モデルをInputStreamに変えるテスト - * @throws Exception - */ - @Test - public void testRead() throws Exception { - RootModel rootModel = Jiemamy.newRootModel(); - rootModel.setDialectId("org.jiemamy.dialect.mysql.MySqlDialect"); - rootModel.setBeginScript("BEGIN;"); - rootModel.setEndScript("COMMIT;"); - rootModel.setDescription("シリアライゼーションイメージ"); - rootModel.setSchemaName("FOO"); - - TableModel t = rootModel.newModel(TableModel.class); - t.setName("T_DEPT"); - t.setDescription("HOGEHOGE"); - - ColumnModel col1 = rootModel.newModel(ColumnModel.class); - ColumnModel col2 = rootModel.newModel(ColumnModel.class); - ColumnModel col3 = rootModel.newModel(ColumnModel.class); - - col1.setName("col1"); - col1.setDataTypeDescriptor(new IntegerDataTypeDescriptor()); - col2.setName("col2"); - col2.setDataTypeDescriptor(new VarcharDataTypeDescriptor(16)); - col3.setName("col3"); - col3.setDataTypeDescriptor(new TimestampDataTypeDescriptor()); - - t.appendModel(col1); - t.appendModel(col2); - t.appendModel(col3); - rootModel.appendModel(t); - - // もっと複雑なモデルを出したい時、コメント外す。 -// rootModel = new ApplicationModelCreator().createModel(); - - StrBuilder sbActual = new StrBuilder(); - BufferedReader reader = null; - try { - reader = new BufferedReader(new InputStreamReader(new ModelInputStream(rootModel))); - String buf; - while ((buf = reader.readLine()) != null) { - sbActual.appendln(buf); - } - } finally { - IOUtils.closeQuietly(reader); - } - - StrBuilder sbExpected = new StrBuilder(); - sbExpected.appendln("<?xml version=\"1.0\"?>"); - sbExpected.appendln("<rootModel id=\"" + rootModel.getId().toString() + "\" " - + "xsi:schemaLocation=\"http://jiemamy.org/xml/ns/core jiemamy-core.xsd\"" - + " xmlns=\"http://jiemamy.org/xml/ns/core\"" - + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" - + " xmlns:view=\"http://jiemamy.org/xml/ns/view\">"); - sbExpected.appendln(" <dialect>org.jiemamy.dialect.mysql.MySqlDialect</dialect>"); - sbExpected.appendln(" <schemaName>FOO</schemaName>"); - sbExpected.appendln(" <beginScript>BEGIN;</beginScript>"); - sbExpected.appendln(" <endScript>COMMIT;</endScript>"); - sbExpected.appendln(" <description>シリアライゼーションイメージ</description>"); - sbExpected.appendln(" <domains/>"); - sbExpected.appendln(" <nodes>"); - sbExpected.appendln(" <table id=\"" + t.getId().toString() + "\">"); - sbExpected.appendln(" <name>T_DEPT</name>"); - sbExpected.appendln(" <logicalName/>"); - sbExpected.appendln(" <sourceConnections/>"); - sbExpected.appendln(" <targetConnections/>"); - sbExpected.appendln(" <beginScript/>"); - sbExpected.appendln(" <endScript/>"); - sbExpected.appendln(" <description>HOGEHOGE</description>"); - sbExpected.appendln(" <columns>"); - sbExpected.appendln(" <column id=\"" + t.getColumns().get(0).getId().toString() + "\">"); - sbExpected.appendln(" <name>col1</name>"); - sbExpected.appendln(" <logicalName/>"); - sbExpected.appendln(" <dataType class=\"org.jiemamy.model.datatype.IntegerDataTypeDescriptor\"/>"); - sbExpected.appendln(" <defaultValue/>"); - sbExpected.appendln(" <constraints/>"); - sbExpected.appendln(" <simpleIndex>false</simpleIndex>"); - sbExpected.appendln(" <freeString/>"); - sbExpected.appendln(" <description/>"); - sbExpected.appendln(" <options/>"); - sbExpected.appendln(" <representation>false</representation>"); - sbExpected.appendln(" </column>"); - sbExpected.appendln(" <column id=\"" + t.getColumns().get(1).getId().toString() + "\">"); - sbExpected.appendln(" <name>col2</name>"); - sbExpected.appendln(" <logicalName/>"); - sbExpected.appendln(" <dataType class=\"org.jiemamy.model.datatype.VarcharDataTypeDescriptor\">"); - sbExpected.appendln(" <adapter class=\"org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter\">"); - sbExpected.appendln(" <property name=\"size\">16</property>"); - sbExpected.appendln(" </adapter>"); - sbExpected.appendln(" </dataType>"); - sbExpected.appendln(" <defaultValue/>"); - sbExpected.appendln(" <constraints/>"); - sbExpected.appendln(" <simpleIndex>false</simpleIndex>"); - sbExpected.appendln(" <freeString/>"); - sbExpected.appendln(" <description/>"); - sbExpected.appendln(" <options/>"); - sbExpected.appendln(" <representation>false</representation>"); - sbExpected.appendln(" </column>"); - sbExpected.appendln(" <column id=\"" + t.getColumns().get(2).getId().toString() + "\">"); - sbExpected.appendln(" <name>col3</name>"); - sbExpected.appendln(" <logicalName/>"); - sbExpected.appendln(" <dataType class=\"org.jiemamy.model.datatype.TimestampDataTypeDescriptor\">"); - sbExpected - .appendln(" <adapter class=\"org.jiemamy.model.datatype.adapter.TimezonedDataTypeAdapter\">"); - sbExpected.appendln(" <property name=\"withTimezone\">false</property>"); - sbExpected.appendln(" </adapter>"); - sbExpected.appendln(" </dataType>"); - sbExpected.appendln(" <defaultValue/>"); - sbExpected.appendln(" <constraints/>"); - sbExpected.appendln(" <simpleIndex>false</simpleIndex>"); - sbExpected.appendln(" <freeString/>"); - sbExpected.appendln(" <description/>"); - sbExpected.appendln(" <options/>"); - sbExpected.appendln(" <representation>false</representation>"); - sbExpected.appendln(" </column>"); - sbExpected.appendln(" </columns>"); - sbExpected.appendln(" </table>"); - sbExpected.appendln(" </nodes>"); - sbExpected.appendln(" <connections/>"); - sbExpected.appendln(" <insertDataSetModels/>"); - sbExpected.appendln(" <view:diagramPresentations/>"); - sbExpected.appendln("</rootModel>"); - - logger.info("================ actual ================================================================"); - logger.info(sbActual.toString()); - logger.info("================ expected =============================================================="); - logger.info(sbExpected.toString()); - assertEquals(sbExpected.toString(), sbActual.toString()); - } -} Modified: zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/model/Jiemamy.java =================================================================== --- zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/model/Jiemamy.java 2008-12-15 03:21:04 UTC (rev 2264) +++ zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/model/Jiemamy.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -129,6 +129,17 @@ } /** + * 指定したIDを持つ、新しい{@link RootModel}のインスタンスを取得する。 + * + * @param id 生成される{@link RootModel}が持つモデルID + * @return {@link RootModel}のインスタンス + * @throws IllegalStateException Jiemamyが初期化されていない場合 + */ + public static RootModel newRootModel(UUID id) { + return newModel(null, RootModel.class, id); + } + + /** * {@link Dialect}のインスタンスを取得する。 * @param fqcn 完全修飾クラス名 * @return {@link Dialect}のインスタンス @@ -179,17 +190,6 @@ return instance.jiemamyImpl.newInstance(clazz, id); } - /** - * 指定したIDを持つ、新しい{@link RootModel}のインスタンスを取得する。 - * - * @param id 生成される{@link RootModel}が持つモデルID - * @return {@link RootModel}のインスタンス - * @throws IllegalStateException Jiemamyが初期化されていない場合 - */ - static RootModel newRootModel(UUID id) { - return newModel(null, RootModel.class, id); - } - /** Jiemamy実装(モデルインスタンス生成戦略) */ private JiemamyImplementation jiemamyImpl; Modified: zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/serializer/JiemamySerializer.java =================================================================== --- zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/serializer/JiemamySerializer.java 2008-12-15 03:21:04 UTC (rev 2264) +++ zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/serializer/JiemamySerializer.java 2008-12-15 03:22:31 UTC (rev 2265) @@ -30,13 +30,6 @@ */ public interface JiemamySerializer { - public static final String SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage"; - - public static final String XML_SCHEMA = "http://www.w3.org/2001/XMLSchema"; - - public static final String SCHEMA_SOURCE = "http://java.sun.com/xml/jaxp/properties/schemaSource"; - - /** * InputStreamからRootModelにデシリアライズする。 * @param in デシリアライズするInputStream