svnno****@sourc*****
svnno****@sourc*****
2008年 12月 19日 (金) 02:11:51 JST
Revision: 2282 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2282 Author: daisuke_m Date: 2008-12-19 02:11:51 +0900 (Fri, 19 Dec 2008) Log Message: ----------- [SER-7] StAX serialzier 実装中。落ち着いてきた…かな? Modified Paths: -------------- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/model/connection/AbstractConnectionModelImpl.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/CommandContext.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyCommandInputStreamImpl.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/XmlEventReaderAdapter.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/NullEndCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/NullStartCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/utils/UUIDUtil.java artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/internal/serializer/sax/ModelInputStreamTest.java artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/internal/serializer/stax/JiemamyCommandInputStreamTest.java artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/internal/serializer/stax/JiemamyCommandOutputStreamTest.java artemis/trunk/org.jiemamy.view/src/test/java/org/jiemamy/internal/processor/ResetBendpointProcessorTest.java zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/exception/DriverNotFoundException.java zeus/trunk/org.jiemamy.spec.event/src/main/java/org/jiemamy/event/ModelChangeEvent.java zeus/trunk/org.jiemamy.spec.event/src/main/java/org/jiemamy/event/ObservableCollectionChangeEvent.java Added Paths: ----------- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/DataCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/EndElementCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/StartElementCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/CommandFactory.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/ResolvableDialectCommand.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/ResolvableRootModelCommand.java Removed Paths: ------------- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/end/ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/CommandFactory.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/CommandFactoryRule.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/CoreCommandFactoryRule.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/DialectCommandFactory.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/NullCommandFactory.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/RootModelCommandFactory.java artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/start/ -------------- next part -------------- Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/model/connection/AbstractConnectionModelImpl.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/model/connection/AbstractConnectionModelImpl.java 2008-12-18 16:02:38 UTC (rev 2281) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/model/connection/AbstractConnectionModelImpl.java 2008-12-18 17:11:51 UTC (rev 2282) @@ -34,10 +34,10 @@ public abstract class AbstractConnectionModelImpl implements AbstractConnectionModel, ConnectionModelAccessor { /** 接続元ノード */ - protected AbstractNodeModel source; + private AbstractNodeModel source; /** 接続先ノード */ - protected AbstractNodeModel target; + private AbstractNodeModel target; /** Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/CommandContext.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/CommandContext.java 2008-12-18 16:02:38 UTC (rev 2281) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/CommandContext.java 2008-12-18 17:11:51 UTC (rev 2282) @@ -19,11 +19,11 @@ package org.jiemamy.internal.serializer.stax; import org.jiemamy.internal.serializer.stax.command.CloseCommand; +import org.jiemamy.internal.serializer.stax.command.EndElementCommand; import org.jiemamy.internal.serializer.stax.command.OpenCommand; -import org.jiemamy.internal.serializer.stax.command.end.EndElementCommand; -import org.jiemamy.internal.serializer.stax.command.start.StartElementCommand; +import org.jiemamy.internal.serializer.stax.command.StartElementCommand; +import org.jiemamy.utils.ArrayEssentialStack; import org.jiemamy.utils.EssentialStack; -import org.jiemamy.utils.ArrayEssentialStack; /** * TODO for daisuke @@ -31,28 +31,28 @@ */ public class CommandContext { - private EssentialStack<JiemamyCommand> stack = new ArrayEssentialStack<JiemamyCommand>(); + private EssentialStack<JiemamyCommand> commandStack = new ArrayEssentialStack<JiemamyCommand>(); private Object content; public void begin(OpenCommand command) { - stack.push(command); + commandStack.push(command); } public void begin(StartElementCommand command) { - stack.push(command); + commandStack.push(command); } public void end(CloseCommand command) { - JiemamyCommand pop = stack.pop(); + JiemamyCommand pop = commandStack.pop(); if (pop instanceof OpenCommand == false) { throw new IllegalStateException(); } } public void end(EndElementCommand command) { - JiemamyCommand pop = stack.pop(); + JiemamyCommand pop = commandStack.pop(); if (pop instanceof StartElementCommand == false) { throw new IllegalStateException(); } Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyCommandInputStreamImpl.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyCommandInputStreamImpl.java 2008-12-18 16:02:38 UTC (rev 2281) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyCommandInputStreamImpl.java 2008-12-18 17:11:51 UTC (rev 2282) @@ -24,11 +24,11 @@ import org.apache.commons.lang.Validate; import org.jiemamy.internal.serializer.stax.command.CloseCommand; +import org.jiemamy.internal.serializer.stax.command.EndElementCommand; import org.jiemamy.internal.serializer.stax.command.OpenCommand; -import org.jiemamy.internal.serializer.stax.command.end.EndElementCommand; -import org.jiemamy.internal.serializer.stax.command.factory.DialectCommandFactory; -import org.jiemamy.internal.serializer.stax.command.factory.RootModelCommandFactory; -import org.jiemamy.internal.serializer.stax.command.start.StartElementCommand; +import org.jiemamy.internal.serializer.stax.command.StartElementCommand; +import org.jiemamy.internal.serializer.stax.command.factory.ResolvableDialectCommand; +import org.jiemamy.internal.serializer.stax.command.factory.ResolvableRootModelCommand; import org.jiemamy.model.RootModel; import org.jiemamy.utils.ResolvableQueue; @@ -41,7 +41,7 @@ * <li>{@link OpenCommand}</li> * <ul><li>{@link StartElementCommand} of {@link RootModel}</li> * <ul><li>{@link StartElementCommand} of {@link String} (dialect)</li> - * <ul><li>{@link DialectCommandFactory}</li></ul> + * <ul><li>{@link ResolvableDialectCommand}</li></ul> * <li>{@link EndElementCommand} of {@link String} (dialect)</li> * <li>...</li> * <li>{@link StartElementCommand} of {@link Collection} (domains)</li> @@ -122,7 +122,7 @@ checkClosed(); queue.clear(); queue.enqueue(new OpenCommand()); - queue.enqueue(new RootModelCommandFactory(rootModel)); + queue.enqueue(new ResolvableRootModelCommand(rootModel)); queue.enqueue(new CloseCommand()); } Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/XmlEventReaderAdapter.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/XmlEventReaderAdapter.java 2008-12-18 16:02:38 UTC (rev 2281) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/XmlEventReaderAdapter.java 2008-12-18 17:11:51 UTC (rev 2282) @@ -24,8 +24,7 @@ import org.apache.commons.lang.Validate; -import org.jiemamy.internal.serializer.stax.command.factory.CommandFactoryRule; -import org.jiemamy.internal.serializer.stax.command.factory.CoreCommandFactoryRule; +import org.jiemamy.internal.serializer.stax.command.factory.CommandFactory; /** * {@link XMLEventReader}を{@link JiemamyCommandInputStream}として扱うアダプタ。 @@ -35,7 +34,7 @@ private XMLEventReader xmlEventReader; - private CommandFactoryRule rule = new CoreCommandFactoryRule(); + private CommandFactory factory = new CommandFactory(); private CommandContext ctx = new CommandContext(); @@ -76,7 +75,7 @@ public JiemamyCommand nextCommand() throws JiemamyCommandException { try { XMLEvent xmlEvent = xmlEventReader.nextEvent(); - return rule.getCommand(xmlEvent, ctx); + return factory.newCommand(xmlEvent, ctx); } catch (XMLStreamException e) { throw new JiemamyCommandException(e); } Added: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/DataCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/DataCommand.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/DataCommand.java 2008-12-18 17:11:51 UTC (rev 2282) @@ -0,0 +1,63 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/12/19 + * + * 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.command; + +import javax.xml.stream.XMLEventWriter; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.events.Characters; + +import org.jiemamy.internal.serializer.stax.CommandContext; +import org.jiemamy.internal.serializer.stax.JiemamyCommand; +import org.jiemamy.model.RootModel; + +/** + * TODO for daisuke + * @author daisuke + */ +public class DataCommand implements JiemamyCommand { + + private String data; + + + /** + * コンストラクタ。 + * @param data + * @category instance creation + */ + public DataCommand(String data) { + this.data = data; + } + + /** + * {@inheritDoc} + */ + public RootModel applyTo(RootModel rootModel, CommandContext ctx) { + // FIXME Auto-generated method stub + return null; + } + + /** + * {@inheritDoc} + */ + public void applyTo(XMLEventWriter xmlWriter) throws XMLStreamException { + Characters characters = EVENT_FACTORY.createCharacters(data); + xmlWriter.add(characters); + } + +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/DataCommand.java ___________________________________________________________________ Name: svn:mime-type + text/plain Copied: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/EndElementCommand.java (from rev 2281, artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/end/EndElementCommand.java) =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/EndElementCommand.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/EndElementCommand.java 2008-12-18 17:11:51 UTC (rev 2282) @@ -0,0 +1,70 @@ +/* + * 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.command; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLEventWriter; +import javax.xml.stream.XMLStreamException; + +import org.jiemamy.internal.serializer.stax.CommandContext; +import org.jiemamy.internal.serializer.stax.JiemamyCommand; +import org.jiemamy.model.RootModel; + +/** + * TODO for daisuke + * @author daisuke + */ +public class EndElementCommand implements JiemamyCommand { + + private QName qName; + + + /** + * コンストラクタ。 + * @param qName + * @category instance creation + */ + public EndElementCommand(QName qName) { + this.qName = qName; + } + + /** + * {@inheritDoc} + */ + public RootModel applyTo(RootModel rootModel, CommandContext ctx) { + ctx.end(this); + return rootModel; + } + + /** + * {@inheritDoc} + */ + public void applyTo(XMLEventWriter xmlWriter) throws XMLStreamException { + xmlWriter.add(EVENT_FACTORY.createEndElement(qName, null)); + } + + /** + * TODO for daisuke + * @return + */ + public QName getQName() { + return qName; + } + +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/EndElementCommand.java ___________________________________________________________________ Name: svn:mime-type + text/plain Copied: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/StartElementCommand.java (from rev 2281, artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/start/StartElementCommand.java) =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/StartElementCommand.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/StartElementCommand.java 2008-12-18 17:11:51 UTC (rev 2282) @@ -0,0 +1,97 @@ +/* + * 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.command; + +import java.util.Map; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLEventWriter; +import javax.xml.stream.XMLStreamException; + +import org.apache.commons.collections15.MapUtils; +import org.apache.commons.lang.Validate; + +import org.jiemamy.internal.serializer.stax.CommandContext; +import org.jiemamy.internal.serializer.stax.JiemamyCommand; +import org.jiemamy.internal.serializer.stax.command.factory.ResolvableRootModelCommand; +import org.jiemamy.model.Jiemamy; +import org.jiemamy.model.RootModel; +import org.jiemamy.utils.UUIDUtil; + +/** + * TODO for daisuke + * @author daisuke + */ +public class StartElementCommand implements JiemamyCommand { + + private QName qName; + + private Map<String, String> attributes; + + + /** + * コンストラクタ。 + * @param qName + * @category instance creation + */ + @SuppressWarnings("unchecked") + public StartElementCommand(QName qName) { + this(qName, MapUtils.EMPTY_MAP); + } + + /** + * コンストラクタ。 + * @param qName + * @param attributes + * @category instance creation + */ + public StartElementCommand(QName qName, Map<String, String> attributes) { + Validate.notNull(qName); + Validate.notNull(attributes); + this.qName = qName; + this.attributes = attributes; + } + + /** + * {@inheritDoc} + */ + public RootModel applyTo(RootModel rootModel, CommandContext ctx) { + ctx.begin(this); + if (ResolvableRootModelCommand.QNAME.equals(qName)) { + rootModel = Jiemamy.newRootModel(UUIDUtil.valueOfOrRandom(attributes.get("id"))); + } + return rootModel; + } + + /** + * {@inheritDoc} + */ + public void applyTo(XMLEventWriter xmlWriter) throws XMLStreamException { + xmlWriter.add(EVENT_FACTORY.createStartElement(qName, null, null)); + } + + /** + * TODO for daisuke + * @return + */ + public QName getQName() { + return qName; + } + +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/StartElementCommand.java ___________________________________________________________________ Name: svn:mime-type + text/plain Deleted: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/CommandFactory.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/CommandFactory.java 2008-12-18 16:02:38 UTC (rev 2281) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/CommandFactory.java 2008-12-18 17:11:51 UTC (rev 2282) @@ -1,54 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/12/18 - * - * 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.command.factory; - -import javax.xml.namespace.QName; -import javax.xml.stream.events.EndElement; -import javax.xml.stream.events.StartElement; - -import org.jiemamy.internal.serializer.stax.JiemamyCommand; -import org.jiemamy.internal.serializer.stax.command.end.EndElementCommand; -import org.jiemamy.internal.serializer.stax.command.start.StartElementCommand; -import org.jiemamy.utils.Resolvable; - -/** - * TODO for daisuke - * @author daisuke - */ -public interface CommandFactory extends Resolvable<JiemamyCommand> { - - /** - * 要素の処理開始コマンドを生成する。 - * - * @param endElement - * @return 要素の処理開始コマンド - */ - EndElementCommand createEndCommand(EndElement endElement); - - /** - * 要素の処理終了コマンドを生成する。 - * - * @param startElement - * @return 要素の処理終了コマンド - */ - StartElementCommand createStartCommand(StartElement startElement); - - QName getQName(); - -} Copied: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/CommandFactory.java (from rev 2281, artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/CommandFactoryRule.java) =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/CommandFactory.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/CommandFactory.java 2008-12-18 17:11:51 UTC (rev 2282) @@ -0,0 +1,83 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/12/18 + * + * 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.command.factory; + +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.CommandContext; +import org.jiemamy.internal.serializer.stax.JiemamyCommand; +import org.jiemamy.internal.serializer.stax.command.CloseCommand; +import org.jiemamy.internal.serializer.stax.command.DataCommand; +import org.jiemamy.internal.serializer.stax.command.EndElementCommand; +import org.jiemamy.internal.serializer.stax.command.NullCommand; +import org.jiemamy.internal.serializer.stax.command.OpenCommand; +import org.jiemamy.internal.serializer.stax.command.StartElementCommand; +import org.jiemamy.utils.StaxUtil; + +/** + * TODO for daisuke + * @author daisuke + */ +public final class CommandFactory { + + private static Logger logger = LoggerFactory.getLogger(CommandFactory.class); + + + /** + * TODO for daisuke + * @param xmlEvent + * @param ctx + * @return + */ + public JiemamyCommand newCommand(XMLEvent xmlEvent, CommandContext ctx) { + logger.info("Type: " + StaxUtil.toEventTypeEnum(xmlEvent.getEventType()).toString()); + + switch (xmlEvent.getEventType()) { + case XMLStreamConstants.START_DOCUMENT: + OpenCommand openCommand = new OpenCommand(); + ctx.begin(openCommand); + return openCommand; + + case XMLStreamConstants.END_DOCUMENT: + CloseCommand closeCommand = new CloseCommand(); + ctx.end(closeCommand); + return closeCommand; + + case XMLStreamConstants.START_ELEMENT: + StartElementCommand startCommand = new StartElementCommand(xmlEvent.asStartElement().getName()); + ctx.begin(startCommand); + return startCommand; + + case XMLStreamConstants.END_ELEMENT: + EndElementCommand endCommand = new EndElementCommand(xmlEvent.asEndElement().getName()); + ctx.end(endCommand); + return endCommand; + + case XMLStreamConstants.CHARACTERS: + return new DataCommand(xmlEvent.asCharacters().getData()); + + default: + return new NullCommand(); + } + } +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/CommandFactory.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:mergeinfo + Deleted: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/CommandFactoryRule.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/CommandFactoryRule.java 2008-12-18 16:02:38 UTC (rev 2281) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/CommandFactoryRule.java 2008-12-18 17:11:51 UTC (rev 2282) @@ -1,139 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/12/18 - * - * 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.command.factory; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.events.EndElement; -import javax.xml.stream.events.StartElement; -import javax.xml.stream.events.XMLEvent; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.jiemamy.exception.IllegalImplementationException; -import org.jiemamy.internal.serializer.stax.CommandContext; -import org.jiemamy.internal.serializer.stax.JiemamyCommand; -import org.jiemamy.internal.serializer.stax.command.CloseCommand; -import org.jiemamy.internal.serializer.stax.command.NullCommand; -import org.jiemamy.internal.serializer.stax.command.OpenCommand; -import org.jiemamy.internal.serializer.stax.command.end.EndElementCommand; -import org.jiemamy.internal.serializer.stax.command.start.StartElementCommand; -import org.jiemamy.utils.StaxUtil; - -/** - * TODO for daisuke - * @author daisuke - */ -public abstract class CommandFactoryRule { - - private static Logger logger = LoggerFactory.getLogger(CommandFactoryRule.class); - - private List<Class<? extends CommandFactory>> commandFactories = new ArrayList<Class<? extends CommandFactory>>(); - - - /** - * {@link CommandFactoryRule}を作成する。 - */ - public CommandFactoryRule() { - } - - /** - * TODO for daisuke - * @param xmlEvent - * @param ctx - * @return - */ - public JiemamyCommand getCommand(XMLEvent xmlEvent, CommandContext ctx) { - logger.info("Type: " + StaxUtil.toEventTypeEnum(xmlEvent.getEventType()).toString()); - - switch (xmlEvent.getEventType()) { - case XMLStreamConstants.START_DOCUMENT: - OpenCommand openCommand = new OpenCommand(); - ctx.begin(openCommand); - return openCommand; - - case XMLStreamConstants.END_DOCUMENT: - CloseCommand closeCommand = new CloseCommand(); - ctx.end(closeCommand); - return closeCommand; - - case XMLStreamConstants.START_ELEMENT: - StartElement startElement = xmlEvent.asStartElement(); - CommandFactory commandFactory = getCommandFactory(startElement.getName()); - StartElementCommand startCommand = commandFactory.createStartCommand(startElement); - ctx.begin(startCommand); - return startCommand; - - case XMLStreamConstants.END_ELEMENT: - EndElement endElement = xmlEvent.asEndElement(); - CommandFactory commandFactory2 = getCommandFactory(endElement.getName()); - EndElementCommand endCommand = commandFactory2.createEndCommand(endElement); - ctx.end(endCommand); - return endCommand; - - case XMLStreamConstants.CHARACTERS: - // FIXME - return new NullCommand(); -// return new ContentsCommand(xmlEvent.asCharacters().getData()); - - default: - return new NullCommand(); - } - } - - /** - * {@link CommandFactory}を返す。 - * - * @param name - * @return {@link CommandFactory} - */ - public CommandFactory getCommandFactory(QName name) { - CommandFactory commandFactory = null; - for (Class<? extends CommandFactory> c : commandFactories) { - try { - commandFactory = c.newInstance(); - } catch (InstantiationException e) { - throw new IllegalImplementationException(c, e); - } catch (IllegalAccessException e) { - throw new IllegalImplementationException(c, e); - } - if (commandFactory.getQName().equals(name)) { - break; - } - commandFactory = null; - } - if (commandFactory == null) { - throw new RuntimeException("CommandFactory for " + name + " is not found."); - } - return commandFactory; - } - - /** - * {@link CommandFactory}を追加する。 - * - * @param commandFactoryClass - */ - protected void addCommandFactory(Class<? extends CommandFactory> commandFactoryClass) { - commandFactories.add(commandFactoryClass); - } -} Deleted: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/CoreCommandFactoryRule.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/CoreCommandFactoryRule.java 2008-12-18 16:02:38 UTC (rev 2281) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/CoreCommandFactoryRule.java 2008-12-18 17:11:51 UTC (rev 2282) @@ -1,36 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/12/18 - * - * 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.command.factory; - -/** - * TODO for daisuke - * @author daisuke - */ -public class CoreCommandFactoryRule extends CommandFactoryRule { - - /** - * コンストラクタ。 - * @category instance creation - */ - public CoreCommandFactoryRule() { - addCommandFactory(RootModelCommandFactory.class); - addCommandFactory(DialectCommandFactory.class); - } - -} Deleted: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/DialectCommandFactory.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/DialectCommandFactory.java 2008-12-18 16:02:38 UTC (rev 2281) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/DialectCommandFactory.java 2008-12-18 17:11:51 UTC (rev 2282) @@ -1,122 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/12/18 - * - * 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.command.factory; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLEventWriter; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.events.EndElement; -import javax.xml.stream.events.StartElement; - -import org.apache.commons.lang.StringUtils; - -import org.jiemamy.internal.serializer.stax.CommandContext; -import org.jiemamy.internal.serializer.stax.JiemamyCommand; -import org.jiemamy.internal.serializer.stax.command.end.DialectEndCommand; -import org.jiemamy.internal.serializer.stax.command.end.EndElementCommand; -import org.jiemamy.internal.serializer.stax.command.start.DialectStartCommand; -import org.jiemamy.internal.serializer.stax.command.start.StartElementCommand; -import org.jiemamy.model.RootModel; -import org.jiemamy.serializer.Namespaces; -import org.jiemamy.utils.EssentialQueue; -import org.jiemamy.utils.LinkedEssentialQueue; - -/** - * TODO for daisuke - * @author daisuke - */ -public class DialectCommandFactory implements CommandFactory { - - private String dialectId; - - - /** - * コンストラクタ。 - * @category instance creation - */ - public DialectCommandFactory() { - this(null); - } - - /** - * コンストラクタ。 - * @param dialectId - * @category instance creation - */ - public DialectCommandFactory(String dialectId) { - this.dialectId = dialectId; - } - - /** - * {@inheritDoc} - */ - public EndElementCommand createEndCommand(EndElement endElement) { - return new DialectEndCommand(getQName()); - } - - /** - * {@inheritDoc} - */ - public StartElementCommand createStartCommand(StartElement startElement) { - return new DialectStartCommand(getQName()); - } - - /** - * {@inheritDoc} - */ - public QName getQName() { - return new QName(Namespaces.CORE, "dialect"); - } - - /** - * {@inheritDoc} - */ - public EssentialQueue<JiemamyCommand> resolve() { - EssentialQueue<JiemamyCommand> queue = new LinkedEssentialQueue<JiemamyCommand>(); - queue.enqueue(new DialectStartCommand(getQName())); - queue.enqueue(new DialectCommand()); - queue.enqueue(new DialectEndCommand(getQName())); - return queue; - } - - - public class DialectCommand implements JiemamyCommand { - - /** - * {@inheritDoc} - */ - public RootModel applyTo(RootModel rootModel, CommandContext ctx) { - if (StringUtils.isBlank(dialectId)) { - return rootModel; - } - rootModel.setDialectId(dialectId); - // TODO Auto-generated method stub - return rootModel; - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unused") - public void applyTo(XMLEventWriter xmlWriter) throws XMLStreamException { - xmlWriter.add(EVENT_FACTORY.createCharacters(dialectId)); - } - - } -} Deleted: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/NullCommandFactory.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/NullCommandFactory.java 2008-12-18 16:02:38 UTC (rev 2281) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/NullCommandFactory.java 2008-12-18 17:11:51 UTC (rev 2282) @@ -1,66 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/12/18 - * - * 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.command.factory; - -import javax.xml.namespace.QName; -import javax.xml.stream.events.EndElement; -import javax.xml.stream.events.StartElement; - -import org.jiemamy.internal.serializer.stax.JiemamyCommand; -import org.jiemamy.internal.serializer.stax.command.end.EndElementCommand; -import org.jiemamy.internal.serializer.stax.command.start.StartElementCommand; -import org.jiemamy.utils.EssentialQueue; -import org.jiemamy.utils.LinkedEssentialQueue; - -/** - * TODO for daisuke - * @author daisuke - */ -public class NullCommandFactory implements CommandFactory { - - /** - * {@inheritDoc} - */ - public EndElementCommand createEndCommand(EndElement endElement) { - return new NullStartCommand(); - } - - /** - * {@inheritDoc} - */ - public StartElementCommand createStartCommand(StartElement startElement) { - return new NullEndCommand(); - } - - /** - * {@inheritDoc} - */ - public QName getQName() { - return null; - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public EssentialQueue<JiemamyCommand> resolve() { - return new LinkedEssentialQueue<JiemamyCommand>(); - } - -} Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/NullEndCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/NullEndCommand.java 2008-12-18 16:02:38 UTC (rev 2281) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/NullEndCommand.java 2008-12-18 17:11:51 UTC (rev 2282) @@ -20,7 +20,7 @@ import javax.xml.namespace.QName; -import org.jiemamy.internal.serializer.stax.command.start.StartElementCommand; +import org.jiemamy.internal.serializer.stax.command.StartElementCommand; /** * TODO for daisuke Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/NullStartCommand.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/NullStartCommand.java 2008-12-18 16:02:38 UTC (rev 2281) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/NullStartCommand.java 2008-12-18 17:11:51 UTC (rev 2282) @@ -20,7 +20,7 @@ import javax.xml.namespace.QName; -import org.jiemamy.internal.serializer.stax.command.end.EndElementCommand; +import org.jiemamy.internal.serializer.stax.command.EndElementCommand; /** * TODO for daisuke Copied: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/ResolvableDialectCommand.java (from rev 2281, artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/DialectCommandFactory.java) =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/ResolvableDialectCommand.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/ResolvableDialectCommand.java 2008-12-18 17:11:51 UTC (rev 2282) @@ -0,0 +1,95 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/12/18 + * + * 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.command.factory; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLEventWriter; +import javax.xml.stream.XMLStreamException; + +import org.apache.commons.lang.StringUtils; + +import org.jiemamy.internal.serializer.stax.CommandContext; +import org.jiemamy.internal.serializer.stax.JiemamyCommand; +import org.jiemamy.internal.serializer.stax.command.EndElementCommand; +import org.jiemamy.internal.serializer.stax.command.StartElementCommand; +import org.jiemamy.model.RootModel; +import org.jiemamy.serializer.Namespaces; +import org.jiemamy.utils.EssentialQueue; +import org.jiemamy.utils.Resolvable; +import org.jiemamy.utils.ResolvableQueue; + +/** + * TODO for daisuke + * @author daisuke + */ +public class ResolvableDialectCommand implements Resolvable<JiemamyCommand> { + + public static final QName QNAME = new QName(Namespaces.CORE, "dialect"); + + private String dialectId; + + + /** + * コンストラクタ。 + * @param dialectId + * @category instance creation + */ + public ResolvableDialectCommand(String dialectId) { + this.dialectId = dialectId; + } + + /** + * {@inheritDoc} + */ + public EssentialQueue<JiemamyCommand> resolve() { + EssentialQueue<JiemamyCommand> queue = new ResolvableQueue<JiemamyCommand>(); + queue.enqueue(new StartElementCommand(QNAME)); + queue.enqueue(new DialectCommand()); + queue.enqueue(new EndElementCommand(QNAME)); + return queue; + } + + + /** + * TODO for daisuke + * @author daisuke + */ + public class DialectCommand implements JiemamyCommand { + + /** + * {@inheritDoc} + */ + public RootModel applyTo(RootModel rootModel, CommandContext ctx) { + if (StringUtils.isBlank(dialectId)) { + return rootModel; + } + rootModel.setDialectId(dialectId); + return rootModel; + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unused") + public void applyTo(XMLEventWriter xmlWriter) throws XMLStreamException { + xmlWriter.add(EVENT_FACTORY.createCharacters(dialectId)); + } + + } +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/ResolvableDialectCommand.java ___________________________________________________________________ Name: svn:mime-type + text/plain Copied: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/ResolvableRootModelCommand.java (from rev 2281, artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/RootModelCommandFactory.java) =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/ResolvableRootModelCommand.java (rev 0) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/ResolvableRootModelCommand.java 2008-12-18 17:11:51 UTC (rev 2282) @@ -0,0 +1,90 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/12/18 + * + * 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.command.factory; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLEventWriter; +import javax.xml.stream.XMLStreamException; + +import org.jiemamy.internal.serializer.stax.CommandContext; +import org.jiemamy.internal.serializer.stax.JiemamyCommand; +import org.jiemamy.internal.serializer.stax.command.EndElementCommand; +import org.jiemamy.internal.serializer.stax.command.StartElementCommand; +import org.jiemamy.model.RootModel; +import org.jiemamy.serializer.Namespaces; +import org.jiemamy.utils.EssentialQueue; +import org.jiemamy.utils.Resolvable; +import org.jiemamy.utils.ResolvableQueue; + +/** + * TODO for daisuke + * @author daisuke + */ +public class ResolvableRootModelCommand implements Resolvable<JiemamyCommand> { + + public static final QName QNAME = new QName(Namespaces.CORE, "rootModel"); + + private RootModel rootModel; + + + /** + * コンストラクタ。 + * @param rootModel + * @category instance creation + */ + public ResolvableRootModelCommand(RootModel rootModel) { + this.rootModel = rootModel; + } + + /** + * {@inheritDoc} + */ + public EssentialQueue<JiemamyCommand> resolve() { + ResolvableQueue<JiemamyCommand> queue = new ResolvableQueue<JiemamyCommand>(); + queue.enqueue(new StartElementCommand(QNAME)); + queue.enqueue(new ResolvableDialectCommand(rootModel.getDialectId())); + queue.enqueue(new EndElementCommand(QNAME)); + return queue; + } + + + /** + * TODO for daisuke + * @author daisuke + */ + public class RootModelCommand implements JiemamyCommand { + + /** + * {@inheritDoc} + */ + public RootModel applyTo(RootModel rootModel, CommandContext ctx) { + if (rootModel != null) { + ResolvableRootModelCommand.this.rootModel = rootModel; + } + return ResolvableRootModelCommand.this.rootModel; + } + + /** + * {@inheritDoc} + */ + public void applyTo(XMLEventWriter xmlWriter) throws XMLStreamException { + throw new UnsupportedOperationException(); + } + } +} Property changes on: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/ResolvableRootModelCommand.java ___________________________________________________________________ Name: svn:mime-type + text/plain Deleted: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/RootModelCommandFactory.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/RootModelCommandFactory.java 2008-12-18 16:02:38 UTC (rev 2281) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/internal/serializer/stax/command/factory/RootModelCommandFactory.java 2008-12-18 17:11:51 UTC (rev 2282) @@ -1,126 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/12/18 - * - * 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.command.factory; - -import java.util.UUID; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLEventWriter; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.events.Attribute; -import javax.xml.stream.events.EndElement; -import javax.xml.stream.events.StartElement; - -import org.jiemamy.internal.serializer.stax.CommandContext; -import org.jiemamy.internal.serializer.stax.JiemamyCommand; -import org.jiemamy.internal.serializer.stax.command.end.EndElementCommand; -import org.jiemamy.internal.serializer.stax.command.end.RootModelEndCommand; -import org.jiemamy.internal.serializer.stax.command.start.RootModelStartCommand; -import org.jiemamy.internal.serializer.stax.command.start.StartElementCommand; -import org.jiemamy.model.Jiemamy; -import org.jiemamy.model.RootModel; -import org.jiemamy.serializer.Namespaces; -import org.jiemamy.utils.EssentialQueue; -import org.jiemamy.utils.ResolvableQueue; -import org.jiemamy.utils.UUIDUtil; - -/** - * TODO for daisuke - * @author daisuke - */ -public class RootModelCommandFactory implements CommandFactory { - - private RootModel rootModel; - - - /** - * コンストラクタ。 - * @category instance creation - */ - public RootModelCommandFactory() { - this(null); - } - - /** - * コンストラクタ。 - * @param rootModel - * @category instance creation - */ - public RootModelCommandFactory(RootModel rootModel) { - this.rootModel = rootModel; - } - - /** - * {@inheritDoc} - */ - public EndElementCommand createEndCommand(EndElement endElement) { - return new RootModelEndCommand(getQName()); - } - - /** - * {@inheritDoc} - */ - public StartElementCommand createStartCommand(StartElement startElement) { - Attribute idAttr = startElement.getAttributeByName(new QName("id")); - UUID id = UUIDUtil.valueOfOrRandom(idAttr.getValue()); - - rootModel = Jiemamy.newRootModel(id); - - return new RootModelStartCommand(getQName(), id); - } - - /** - * {@inheritDoc} - */ - public QName getQName() { - return new QName(Namespaces.CORE, "rootModel"); - } - - /** - * {@inheritDoc} - */ - public EssentialQueue<JiemamyCommand> resolve() { - ResolvableQueue<JiemamyCommand> queue = new ResolvableQueue<JiemamyCommand>(); - queue.enqueue(new RootModelStartCommand(getQName(), rootModel.getId())); - queue.enqueue(new DialectCommandFactory(rootModel.getDialectId())); - queue.enqueue(new RootModelEndCommand(getQName())); - return queue; - } - - - public class RootModelCommand implements JiemamyCommand { - - /** - * {@inheritDoc} - */ - public RootModel applyTo(RootModel rootModel, CommandContext ctx) { - if (rootModel != null) { - RootModelCommandFactory.this.rootModel = rootModel; - } - return RootModelCommandFactory.this.rootModel; - } - - /** - * {@inheritDoc} - */ - public void applyTo(XMLEventWriter xmlWriter) throws XMLStreamException { - throw new UnsupportedOperationException(); - } - } -} Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/utils/UUIDUtil.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/utils/UUIDUtil.java 2008-12-18 16:02:38 UTC (rev 2281) +++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/utils/UUIDUtil.java 2008-12-18 17:11:51 UTC (rev 2282) @@ -33,10 +33,14 @@ */ public static UUID valueOfOrRandom(String name) { UUID result; - try { - result = UUID.fromString(name); - } catch (IllegalArgumentException e) { + if (name == null) { result = UUID.randomUUID(); + } else { + try { + result = UUID.fromString(name); + } catch (IllegalArgumentException e) { + result = UUID.randomUUID(); + } } return result; } Modified: artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/internal/serializer/sax/ModelInputStreamTest.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/internal/serializer/sax/ModelInputStreamTest.java 2008-12-18 16:02:38 UTC (rev 2281) +++ artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/internal/serializer/sax/ModelInputStreamTest.java 2008-12-18 17:11:51 UTC (rev 2282) @@ -27,6 +27,7 @@ import org.apache.commons.lang.text.StrBuilder; import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -74,6 +75,7 @@ * @throws Exception */ @Test + @Ignore("SAX実装を使っていないので、テスト一時停止") public void testRead() throws Exception { RootModel rootModel = Jiemamy.newRootModel(); rootModel.setDialectId("org.jiemamy.dialect.mysql.MySqlDialect"); Modified: artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/internal/serializer/stax/JiemamyCommandInputStreamTest.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/internal/serializer/stax/JiemamyCommandInputStreamTest.java 2008-12-18 16:02:38 UTC (rev 2281) +++ artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/internal/serializer/stax/JiemamyCommandInputStreamTest.java 2008-12-18 17:11:51 UTC (rev 2282) @@ -20,13 +20,11 @@ import org.slf4j.LoggerFactory; import org.jiemamy.internal.serializer.stax.command.CloseCommand; +import org.jiemamy.internal.serializer.stax.command.EndElementCommand; import org.jiemamy.internal.serializer.stax.command.NullCommand; import org.jiemamy.internal.serializer.stax.command.OpenCommand; -import org.jiemamy.internal.serializer.stax.command.end.DialectEndCommand; -import org.jiemamy.internal.serializer.stax.command.end.RootModelEndCommand; -import org.jiemamy.internal.serializer.stax.command.factory.DialectCommandFactory; -import org.jiemamy.internal.serializer.stax.command.start.DialectStartCommand; -import org.jiemamy.internal.serializer.stax.command.start.RootModelStartCommand; +import org.jiemamy.internal.serializer.stax.command.StartElementCommand; +import org.jiemamy.internal.serializer.stax.command.factory.ResolvableDialectCommand.DialectCommand; import org.jiemamy.model.Artemis; import org.jiemamy.model.Jiemamy; import org.jiemamy.model.RootModel; @@ -70,11 +68,11 @@ List<Class<?>> expectedClasses = CollectionsUtil.newArrayList(); { expectedClasses.add(OpenCommand.class); - expectedClasses.add(RootModelStartCommand.class); - expectedClasses.add(DialectStartCommand.class); - expectedClasses.add(DialectCommandFactory.class); - expectedClasses.add(DialectEndCommand.class); - expectedClasses.add(RootModelEndCommand.class); + expectedClasses.add(StartElementCommand.class); + expectedClasses.add(StartElementCommand.class); + expectedClasses.add(DialectCommand.class); + expectedClasses.add(EndElementCommand.class); + expectedClasses.add(EndElementCommand.class); expectedClasses.add(CloseCommand.class); } @@ -120,10 +118,10 @@ expectedClasses.add(OpenCommand.class); // <rootModel xmlns="http://jiemamy.org/xml/ns/core" id="ffffffff-ffff-ffff-ffff-ffffffffffff"> - expectedClasses.add(RootModelStartCommand.class); + expectedClasses.add(StartElementCommand.class); // <dialect> - expectedClasses.add(DialectStartCommand.class); + expectedClasses.add(StartElementCommand.class); expectedClasses.add(NullCommand.class); @@ -131,10 +129,10 @@ // expectedClasses.add(DialectCommandFactory.class); // </dialect> - expectedClasses.add(DialectEndCommand.class); + expectedClasses.add(EndElementCommand.class); // </rootModel> - expectedClasses.add(RootModelEndCommand.class); + expectedClasses.add(EndElementCommand.class); expectedClasses.add(CloseCommand.class); } Modified: artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/internal/serializer/stax/JiemamyCommandOutputStreamTest.java =================================================================== --- artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/internal/serializer/stax/JiemamyCommandOutputStreamTest.java 2008-12-18 16:02:38 UTC (rev 2281) +++ artemis/trunk/org.jiemamy.serializer/src/test/java/org/jiemamy/internal/serializer/stax/JiemamyCommandOutputStreamTest.java 2008-12-18 17:11:51 UTC (rev 2282) @@ -39,17 +39,14 @@ import org.slf4j.LoggerFactory; import org.jiemamy.internal.serializer.stax.command.CloseCommand; +import org.jiemamy.internal.serializer.stax.command.EndElementCommand; import org.jiemamy.internal.serializer.stax.command.OpenCommand; -import org.jiemamy.internal.serializer.stax.command.end.DialectEndCommand; -import org.jiemamy.internal.serializer.stax.command.end.RootModelEndCommand; -import org.jiemamy.internal.serializer.stax.command.factory.DialectCommandFactory; -import org.jiemamy.internal.serializer.stax.command.start.DialectStartCommand; -import org.jiemamy.internal.serializer.stax.command.start.RootModelStartCommand; +import org.jiemamy.internal.serializer.stax.command.StartElementCommand; +import org.jiemamy.internal.serializer.stax.command.factory.ResolvableDialectCommand; import org.jiemamy.model.Artemis; import org.jiemamy.model.Jiemamy; import org.jiemamy.model.RootModel; import org.jiemamy.serializer.Namespaces; -import org.jiemamy.utils.UUIDUtil; /** * TODO for daisuke @@ -57,6 +54,8 @@ */ public class JiemamyCommandOutputStreamTest { + private static final String DIALECT_ID = "com.example.HogeDialect"; + private static Logger logger = LoggerFactory.getLogger(JiemamyCommandOutputStreamTest.class); @@ -93,6 +92,7 @@ RootModel rootModel = ((JiemamyCommandOutputStreamImpl) stream).getRootModel(); assertThat(rootModel, is(notNullValue())); logger.info(rootModel.toString()); + assertThat(rootModel.getDialectId(), is(DIALECT_ID)); } /** @@ -125,12 +125,11 @@ */ private void writeTestDataTo(JiemamyCommandOutputStream stream) throws JiemamyCommandException { stream.write(new OpenCommand()); - stream.write(new RootModelStartCommand(new QName(Namespaces.CORE, "rootModel"), UUIDUtil - .valueOfOrRandom("ffffffff-ffff-ffff-ffff-ffffffffffff"))); - stream.write(new DialectStartCommand(new QName(Namespaces.CORE, "dialect"))); - stream.write(new DialectCommandFactory("com.example.HogeDialect").new DialectCommand()); - stream.write(new DialectEndCommand(new QName(Namespaces.CORE, "dialect"))); - stream.write(new RootModelEndCommand(new QName(Namespaces.CORE, "rootModel"))); + stream.write(new StartElementCommand(new QName(Namespaces.CORE, "rootModel"))); + stream.write(new StartElementCommand(new QName(Namespaces.CORE, "dialect"))); + stream.write(new ResolvableDialectCommand(DIALECT_ID).new DialectCommand()); + stream.write(new EndElementCommand(new QName(Namespaces.CORE, "dialect"))); + stream.write(new EndElementCommand(new QName(Namespaces.CORE, "rootModel"))); stream.write(new CloseCommand()); } } Modified: artemis/trunk/org.jiemamy.view/src/test/java/org/jiemamy/internal/processor/ResetBendpointProcessorTest.java =================================================================== --- artemis/trunk/org.jiemamy.view/src/test/java/org/jiemamy/internal/processor/ResetBendpointProcessorTest.java 2008-12-18 16:02:38 UTC (rev 2281) +++ artemis/trunk/org.jiemamy.view/src/test/java/org/jiemamy/internal/processor/ResetBendpointProcessorTest.java 2008-12-18 17:11:51 UTC (rev 2282) @@ -44,15 +44,15 @@ */ public class ResetBendpointProcessorTest { - protected RootModel rootModel; + private RootModel rootModel; - protected TableModel empTableModel; + private TableModel empTableModel; - protected TableModel deptTableModel; + private TableModel deptTableModel; - protected ForeignKeyModel foreignKeyModel; + private ForeignKeyModel foreignKeyModel; - protected ForeignKeyModel selfRefFkModel; + private ForeignKeyModel selfRefFkModel; /** Modified: zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/exception/DriverNotFoundException.java =================================================================== --- zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/exception/DriverNotFoundException.java 2008-12-18 16:02:38 UTC (rev 2281) +++ zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/exception/DriverNotFoundException.java 2008-12-18 17:11:51 UTC (rev 2282) @@ -42,7 +42,7 @@ * 見つからなかったドライバクラス名を取得する。 * @return ドライバクラス名 */ - protected String getClassName() { + public String getClassName() { return className; } Modified: zeus/trunk/org.jiemamy.spec.event/src/main/java/org/jiemamy/event/ModelChangeEvent.java =================================================================== --- zeus/trunk/org.jiemamy.spec.event/src/main/java/org/jiemamy/event/ModelChangeEvent.java 2008-12-18 16:02:38 UTC (rev 2281) +++ zeus/trunk/org.jiemamy.spec.event/src/main/java/org/jiemamy/event/ModelChangeEvent.java 2008-12-18 17:11:51 UTC (rev 2282) @@ -28,7 +28,7 @@ public class ModelChangeEvent extends EventObject { /** 変更されたフィールド */ - protected transient Field field; + private transient Field field; /** Modified: zeus/trunk/org.jiemamy.spec.event/src/main/java/org/jiemamy/event/ObservableCollectionChangeEvent.java =================================================================== --- zeus/trunk/org.jiemamy.spec.event/src/main/java/org/jiemamy/event/ObservableCollectionChangeEvent.java 2008-12-18 16:02:38 UTC (rev 2281) +++ zeus/trunk/org.jiemamy.spec.event/src/main/java/org/jiemamy/event/ObservableCollectionChangeEvent.java 2008-12-18 17:11:51 UTC (rev 2282) @@ -127,7 +127,7 @@ @Override public String toString() { return getClass().getName() + "@" + Integer.toHexString(hashCode()) + "[ timing=" + timing.toString() - + ", source=" + source + ", field=" + field + "]"; + + ", source=" + source + ", field=" + getField() + "]"; }